Exemple #1
0
int main(void)
{
    /* Setup the MMU and do necessary MMU configurations. */
    MMUConfigAndEnable();

    /* Enable all levels of CACHE. */
    CacheEnable(CACHE_ALL);

    /* Initialize the UART console */
    ConsoleUtilsInit();

    /* Select the console type based on compile time check */
    ConsoleUtilsSetType(CONSOLE_UART);

    ConsoleUtilsPrintf("McASP Example Application. ");
    ConsoleUtilsPrintf("Please connect headphone/speaker to the LINE OUT");
    ConsoleUtilsPrintf(" of the EVM to listen to the audio tone.");

    /* Enable the module clock for I2C0 Instance. */
    I2C0ModuleClkConfig();

    /* Set up the pin mux for I2C0 instance. */
    I2CPinMuxSetup(0);

    /* Enable the module clock for McASP1 Instance. */
    McASP1ModuleClkConfig();

    /* Enable pin-mux for McASP1 instance. */
    McASP1PinMuxSetup();

    /* Enable the EDMA module clocks. */
    EDMAModuleClkConfig();

    /* Initialize the ARM Interrupt Controller.*/
    IntAINTCInit();

    /* Enable EDMA Interrupt. */
    EDMA3IntSetup(); 

    /* Enable McASP Interrupt. */
    McASPIntSetup();
  
    /* Initialize the I2C interface for the codec AIC31 */
    I2CCodecIfInit(I2C_INST_BASE, I2C_SLAVE_CODEC_AIC31);

    /* Enable the interrupts generation at global level */ 
    IntMasterIRQEnable();

    /* Configure the Codec for I2S mode */
    AudioCodecInit();

    /* Initialize the looping of tone. */
    ToneLoopInit(); 

    /* Start playing tone. */
    AudioTxActivate();

    while(1);
}
Exemple #2
0
//*****************************************************************************
//
// The main code for the application.  It sets up the peripherals, displays the
// splash screens, and then manages the interaction between the game and the
// screen saver.
//
//*****************************************************************************
int
main(void)
{
	tRectangle sRect;
#ifndef _TMS320C6X
    unsigned int index;
#endif
	
    SetupIntc();

	
	/* Configuring UART2 instance for serial communication. */
    UARTStdioInit();

#ifdef _TMS320C6X
    CacheEnableMAR((unsigned int)0xC0000000, (unsigned int)0x20000000);
    CacheEnable(L1PCFG_L1PMODE_32K | L1DCFG_L1DMODE_32K | L2CFG_L2MODE_256K);
#else
    /* Sets up 'Level 1" page table entries. 
     * The page table entry consists of the base address of the page
     * and the attributes for the page. The following operation is to
     * setup one-to-one mapping page table for DDR memeory range and set
     * the atributes for the same. The DDR memory range is from 0xC0000000
     * to 0xDFFFFFFF. Thus the base of the page table ranges from 0xC00 to 
     * 0xDFF. Cache(C bit) and Write Buffer(B bit) are enabled  only for
     * those page table entries which maps to DDR RAM and internal RAM.
     * All the pages in the DDR range are provided with R/W permissions
     */
    for(index = 0; index < (4*1024); index++)
    {
         if((index >= 0xC00 && index < 0xE00)|| (index == 0x800))
         {             
              pageTable[index] = (index << 20) | 0x00000C1E;
         }
         else
         {
              pageTable[index] = (index << 20) | 0x00000C12;
         }
    }
     
    /* Configures translation table base register
     * with pagetable base address.
     */
    CP15TtbSet((unsigned int )pageTable);

    /* Enables MMU */
    CP15MMUEnable();
   
	/* Enable Instruction Cache */
    CP15ICacheEnable();

    /* Enable Data Cache */
    CP15DCacheEnable();
#endif

    SetUpLCD();
	
	ConfigureFrameBuffer();
		
	GrOffScreen16BPPInit(&g_sSHARP480x272x16Display0, (unsigned char *)g_pucBuffer0, LCD_WIDTH, LCD_HEIGHT);
	GrOffScreen16BPPInit(&g_sSHARP480x272x16Display1, (unsigned char *)g_pucBuffer1, LCD_WIDTH, LCD_HEIGHT);
	
	// Initialize a drawing context.
	GrContextInit(&sContext0, &g_sSHARP480x272x16Display0);
	GrContextInit(&sContext1, &g_sSHARP480x272x16Display1);

    /* enable End of frame interrupt */
    RasterEndOfFrameIntEnable(SOC_LCDC_0_REGS);

    /* enable raster */
    RasterEnable(SOC_LCDC_0_REGS);

	PeripheralsSetup();
	I2C0IntRegister(4);
    AIC31Init();
    ToneLoopInit();
	/* Start playing the tone */
    ToneLoopStart();
	
    // TS init	
	TouchInit();
	
	GrContextForegroundSet(&sContext0, ClrBlack);
	GrContextForegroundSet(&sContext1, ClrBlack);
    sRect.sXMin = GAME_X - 1;
    sRect.sYMin = GAME_Y - 1;
    sRect.sXMax = GAME_X + GAME_W;
    sRect.sYMax = GAME_Y + GAME_H;
    GrRectFill(&sContext0, &sRect);
    GrRectFill(&sContext1, &sRect);

    GrImageDraw(&sContext0, g_pucTILogo128x96, GAME_X, GAME_Y);
	GrImageDraw(&sContext1, g_pucTILogo128x96, GAME_X, GAME_Y);
	
	Delay(0x5FFFFF);
	
	// Confiure and start timer2
	Timer2Config();
	Timer2Start();

    // Loop forever.
    while(1)
    {
        // Display the main screen.
        if(MainScreen())
        {
            // The button was pressed, so start the game.
            PlayGame();
        }
        else
        {
            // The button was not pressed during the timeout period, so start
            // the screen saver.
            ScreenSaver();
        }
    }
}