コード例 #1
0
ファイル: main.c プロジェクト: wangjianghua/gas-flow-meter
/*
*********************************************************************************************************
*                                          App_TaskStart()
*
* Description : This is an example of a startup task.  As mentioned in the book's text, you MUST
*               initialize the ticker only once multitasking has started.
*
* Argument(s) : p_arg   is the argument passed to 'App_TaskStart()' by 'OSTaskCreateExt()'.
*
* Return(s)   : none.
*
* Caller(s)   : This is a task.
*
* Notes       : (1) The first line of code is used to prevent a compiler warning because 'p_arg' is not
*                   used.  The compiler should not generate any code for this statement.
*********************************************************************************************************
*/
static  void  App_TaskStart (void *p_arg)
{   
    (void)p_arg;                                                /* See Note #1                                              */

    BSP_Init();                                                 /* Initialize BSP functions                                 */

    OS_CPU_SysTickInit();                                       /* Initialize the SysTick                                   */

#if (OS_TASK_STAT_EN > 0)
    OSStatInit();                                               /* Determine CPU capacity                                   */
#endif

    MEM_Init();

    End_Init();

    GUI_Init(); 

    TIME_Init();

    MENU_Init();

    App_EventCreate();                                          /* Create application events                                */

    App_TaskCreate();                                           /* Create application tasks                                 */
        
    while (DEF_TRUE) {                                          /* Task body, always written as an infinite loop            */
        beep();

        OSTimeDlyHMSM(0, 0, 0, 50);
    }
}
コード例 #2
0
ファイル: dEngine.c プロジェクト: slarti88/Shmup
void dEngine_Init(void) 
{
	FS_InitFilesystem();
    Log_Printf("dEngine Initialization...\n");
    
	ENT_InitCacheSystem();
	TEXT_InitCacheSystem();
	MAT_InitCacheSystem();

#ifdef GENERATE_VIDEO	
	dEngine_INIT_ScreenshotBuffer();
#endif
	
	engine.sceneId = -1;
	dEngine_RequireSceneId(0);
	
	//engine.recordVideo = 0;
	
	engine.musicFilename[0] = '\0';
	engine.musicStartAt = 0;
	engine.playback.filename[0] = '\0';
	
	// Enable/disable sounds here
	engine.soundEnabled = 0;
	engine.musicEnabled = 0;

	engine.gameCenterEnabled = 0;
	
	ENPAR_Init();
	
	

	dEngine_ReadConfig();

	SCR_Init();
	
	
	
	
	MATLIB_LoadLibraries();
	

	
	COLL_InitUnitCube();
	
	
	ENE_Mem_Init();
	
	//SND_Init();
	
	
	MENU_Init();
	
	
}
コード例 #3
0
ファイル: LineMaze.c プロジェクト: balajianbu/projects
int main( void )
{
    int         i;
    int         led = 0;
    uint16_t    prevSwitches = 0;

    InitHardware();
    InitADC();
    InitMotors();

    eeprom_read_block( &gMemParam, &gEEParam, sizeof( gMemParam ));

    if ( gMemParam.thresh_hi == 0xFF )
    {
        gMemParam.thresh_hi = 0x80;
    }
    if ( gMemParam.thresh_lo == 0xFF )
    {
        gMemParam.thresh_lo = 0x10;
    }

#if CFG_LOG_USE_STDIO
    fdevopen( UART0_PutCharStdio, UART0_GetCharStdio );

    LogInit( stdout );
#endif

    // The first handle opened for read goes to stdin, and the first handle
    // opened for write goes to stdout. So u0 is stdin, stdout, and stderr

    Log( "*****\n" );
    Log( "***** Line Maze program\n" );
    Log( "*****\n" );

    LCD_Init( 2, 16 );
    LCD_Printf( " SRS Sample Bot " );
    LCD_MoveTo( 0, 1 );
    LCD_Printf( "Second line" );

    Log( "\n" );

    MENU_Init( gTopMenu );

    LED_OFF( GREEN );

    while( 1 )
    {
        uint16_t    switches;
        uint8_t     pinc;
        uint8_t     pind;
        int8_t      error;

        LED_TOGGLE( GREEN );

        led++;
        if ( led >= 6 )
        {
            led = 0;
        }

        error = GetLineError();

        if ( MENU_IsActive() )
        {
            MENU_Event( MENU_EVENT_TIMER );
        }
        else
        {
            if ( MENU_IsModified() )
            {
                eeprom_write_block( &gMemParam, &gEEParam, sizeof( gMemParam ));
                MENU_ClearModified();

                LCD_Clear();
                LCD_Printf( "EEPROM Updated\n" );
                Log( "EEPROM Updated\n" );
                ms_spin( 1000 );
            }

            //switches = EXP_TransferWord( ~( 1 << ( led + 2 )), EXP_OUT_LED_MASK );
            switches = EXP_TransferWord( 0, 0 );
            Log( "SW:%04x ", switches );

            if ( switches != prevSwitches )
            {
                LCD_Clear();
                prevSwitches = switches;
            }
            for ( i = 0; i < 8; i++ )
            {
                Log( "%02x ", gLineADC[ i ]);
            }

            //Log( "C: %02x\n", PINC );

            switch (( switches & 0xF0 ) >> 4 )
            {
            case 0:
            {
                LCD_MoveTo( 0, 0 );
                LCD_Printf( " SRS Sample Bot " );
                LCD_MoveTo( 0, 1 );
                LCD_Printf( "Second line" );
                break;
            }

            case 1:
            {
                LCD_MoveTo( 0, 0 );
                LCD_Printf( "Joy: %c%c%c%c%c",
                            (( switches & 0x4000 ) == 0 ) ? 'L' : ' ',
                            (( switches & 0x2000 ) == 0 ) ? 'R' : ' ',
                            (( switches & 0x0800 ) == 0 ) ? 'U' : ' ',
                            (( switches & 0x0400 ) == 0 ) ? 'D' : ' ',
                            (( switches & 0x1000 ) == 0 ) ? 'X' : ' ' );
                LCD_MoveTo( 0, 1 );
                LCD_Printf( "S1:%d S2:%d S3:%d",
                            ( switches & 0x0200 ) == 0,
                            ( switches & 0x0100 ) == 0,
                            ( PIND & ( 1 << 6 ))  == 0 );
                break;
            }

            case 2:
            {
                LCD_MoveTo( 0, 0 );
                LCD_Printf( "L %02x %02x %02x %02x %02x",
                            gLineADC[ 0 ],
                            gLineADC[ 1 ],
                            gLineADC[ 2 ],
                            gLineADC[ 3 ],
                            gLineADC[ 4 ] );

                LCD_MoveTo( 0, 1 );
                LCD_Printf( "E %02x %02x %3d B %02x", gADC[ 0 ], gADC[ 7 ], error, gADC[ 6 ] );
                break;
            }

            default:
            {
                LCD_MoveTo( 0, 0 );
                LCD_Printf( "Setting: %d", ( switches & 0xF0 ) >> 4 );
                break;
            }
            }

            pinc = PINC;
            pind = PIND;

            Log( " QL:%d%d QR:%d%d EC-L:%d EC-R:%d Err:%2d L:%5b H:%5b\n",
                 ( ENCODER_L_A_PIN & ENCODER_L_A_MASK ) != 0,
                 ( ENCODER_L_B_PIN & ENCODER_L_B_MASK ) != 0,
                 ( ENCODER_R_A_PIN & ENCODER_R_A_MASK ) != 0,
                 ( ENCODER_R_B_PIN & ENCODER_R_B_MASK ) != 0,
                 gEncoderCountL,
                 gEncoderCountR,
                 error, gLowMask, gHighMask );
        }

        // Tick rate is 100/sec so waiting for 50 waits for 1/2 sec

        for ( i = 0; i < 50; i++ )
        {
            WaitForTimer0Rollover();
            CheckSwitches();

#if 1
            if ( UART0_IsCharAvailable() )
            {
                char    ch = UART0_GetChar();

                if ( ch == ' ' )
                {
                    DebugKey();
                }
                else
                {
                    Log( "Read: '%c'\n", ch );
                }
            }
#endif
        }
    }

    return 0;
}
コード例 #4
0
void dEngine_Init()
{
	ENT_InitCacheSystem();
	TEXT_InitCacheSystem();
	MAT_InitCacheSystem();

#ifdef GENERATE_VIDEO	
	dEngine_INIT_ScreenshotBuffer();
#endif
	
	engine.sceneId = -1;
	dEngine_RequireSceneId(0);
	
	//engine.recordVideo = 0;
	
	engine.musicFilename[0] = '\0';
	engine.musicStartAt = 0;
	engine.playback.filename[0] = '\0';
	
	engine.soundEnabled = 1;
	engine.musicEnabled = 1;
	engine.gameCenterEnabled = 0;
	
	ENPAR_Init();
	
	
	FS_InitFilesystem();

	dEngine_ReadConfig();

	SCR_Init();
	
	
	
	
	MATLIB_LoadLibraries();
	

	
	COLL_InitUnitCube();
	
	
	ENE_Mem_Init();
	
	SND_Init();
	
	
	MENU_Init();
	
	
	
	//TESTS
	/*
	char c = CHAR_MAX;
	unsigned char uc = UCHAR_MAX;
	short s = SHRT_MAX;
	unsigned short us = USHRT_MAX;
	int i = INT_MAX;
	unsigned int ui = UINT_MAX;
	long l = LONG_MAX;
	unsigned long ul = ULONG_MAX;
	
	printf("\n");
	printf("LIMITS: c:%d, uc:%u, s:%d, us:%u\n"
		   "LIMITS: i:%d, ui:%u, l:%ld, ul:%lu\n",
		   c, uc, s, us, i, ui, l, ul);
	
	// promotion 
	printf("\n");
	printf("i = s: %d, \n", i = s);
	printf("i = us: %d, \n", i = us);
	printf("ui = s: %u, \n", ui = s);
	printf("ui = us: %u\n", ui = us);
	
	// narrowing 
	printf("\n");
	printf("c = s: %d, \n", c = s);
	printf("c = us: %d, \n", c = us);
	printf("uc = s: %d, \n", uc = s); //Ln:31
	printf("uc = us: %d\n", uc = us);
	
	printf("\n");
	printf("uc = UCHAR_MAX (%u) + 1: %u, \n",
		   UCHAR_MAX, uc = UCHAR_MAX + 1); // Ln:36 
	printf("uc = -1: %d\n", uc = -1);
	*/
	
}