Esempio n. 1
0
int main(void)
{
    SetupIntc();

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

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

    ADCConfigure();

    while(flag);

    val1 = (sample1 * RESOL_X_MILLION) / 1000;

    ConsoleUtilsPrintf("Voltage sensed on the AN0 line : ");

    ConsoleUtilsPrintf("%d", val1);

    ConsoleUtilsPrintf("mV\r\n");

    val2 = (sample2 * RESOL_X_MILLION) / 1000;

    ConsoleUtilsPrintf("Voltage sensed on the AN1 line : ");

    ConsoleUtilsPrintf("%d", val2);

    ConsoleUtilsPrintf("mV\r\n");

    while(1);

}
int main(void)
{
    /* Initialize console for communication with the Host Machine */
    ConsoleUtilsInit();

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

    /* Configure EDMA module clock */
    EDMAModuleClkConfig();

    /* Initialize EDMA */
    EDMA3Init(EDMAAPP_EDMACC_BASE_ADDRESS, EDMAAPP_DMA_EVTQ);

    _EDMAAppRegisterEdma3Interrupts();

#ifdef CH_TYPE_DMA
    EDMAAppEDMA3Test();
#else
    EDMAAppQDMA3Test();
#endif

    EDMA3Deinit(EDMAAPP_EDMACC_BASE_ADDRESS, EDMAAPP_DMA_EVTQ);

    return 0;
}
Esempio n. 3
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);
}
Esempio n. 4
0
int main(void)
{
    unsigned int triggerValue = 0;
    unsigned char inputVal = 0u;

    /* 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);

    /* Enable the WDT clocks */
    WatchdogTimer1ModuleClkConfig();

    /* Reset the Watchdog Timer */
    WatchdogTimerReset(SOC_WDT_1_REGS);

    /* Disable the Watchdog timer */
    WatchdogTimerDisable(SOC_WDT_1_REGS);
                                               
    /* Perform the initial settings for the Watchdog Timer */
    WatchdogTimerSetUp();

    /* Send the message to UART console */
    ConsoleUtilsPrintf("Program Reset!");
    ConsoleUtilsPrintf("Input any key at least once in every 4 seconds");
    ConsoleUtilsPrintf(" to avoid a further reset.\n\r");

    /* Enable the Watchdog Timer */
    WatchdogTimerEnable(SOC_WDT_1_REGS);

    while(1)
    {
        /* Wait for an input through console. If no input is given,
        ** the WDT will timeout and reset will occur.
        */
        if(ConsoleUtilsScanf("%c", &inputVal))
        {

            triggerValue += 1;

            /* Write into the trigger register. This will load the value from the 
            ** load register into the counter register and hence timer will start 
            ** from the initial count.
            */
            WatchdogTimerTriggerSet(SOC_WDT_1_REGS, triggerValue);
        }
    }
}
int main(void)
{
    MMUConfigAndEnable();

    CacheEnable(CACHE_ALL);

    IntMasterIRQEnable();

    IntAINTCInit();

    /* Initialize console for communication with the Host Machine */
    ConsoleUtilsInit();
    //
    //Delay timer setup
    //
    DelayTimerSetup();

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

    ConsoleUtilsPrintf("LCDC Controller\r\n");

    LCDAINTCConfigure();
    
    LCDBackLightEnable();
    
    SetUpLCD();
    
    /* Configuring the base ceiling */
    RasterDMAFBConfig(LCDC_INSTANCE, 
                      (unsigned int)curr_image,
                      (unsigned int)curr_image + sizeof(image1) - 2,
                      0);
    
    RasterDMAFBConfig(LCDC_INSTANCE, 
                      (unsigned int)curr_image,
                      (unsigned int)curr_image + sizeof(image1) - 2,
                      1);

    /* Enable End of frame0/frame1 interrupt */
    RasterIntEnable(LCDC_INSTANCE, RASTER_END_OF_FRAME0_INT |
                                     RASTER_END_OF_FRAME1_INT);
    /* Enable raster */
    RasterEnable(LCDC_INSTANCE);

    while(1) {
	if (curr_image == image1) {
	    curr_image = image2;
	} else {
	    curr_image = image1;
	}
        delay(5000);
    }
}
Esempio n. 6
0
/******************************************************************************
**                          FUNCTION DEFINITIONS
*******************************************************************************/
int main(void)
{
    /* This function will enable clocks for the DMTimer2 instance */
    DMTimer2ModuleClkConfig();

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

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

    /* Enable IRQ in CPSR */
    IntMasterIRQEnable();

    /* Register DMTimer2 interrupts on to AINTC */
    DMTimerAintcConfigure();

    /* Perform the necessary configurations for DMTimer */
    DMTimerSetUp();

    /* Enable the DMTimer interrupts */
    DMTimerIntEnable(SOC_DMTIMER_2_REGS, DMTIMER_INT_OVF_EN_FLAG);

    ConsoleUtilsPrintf("Tencounter: ");

    /* Start the DMTimer */
    DMTimerEnable(SOC_DMTIMER_2_REGS);  

    while(cntValue)
    {
        if(flagIsr == 1)
        {
            ConsoleUtilsPrintf("\b%d",(cntValue - 1));
            cntValue--;
            flagIsr = 0;
        }
    }

    /* Stop the DMTimer */
    DMTimerDisable(SOC_DMTIMER_2_REGS); 

    PRINT_STATUS(S_PASS);

    /* Halt the program */
    while(1);
}
Esempio n. 7
0
/*
** Main function.
*/
int main(void)
{
    unsigned int numByteChunks = 0;
    unsigned char *pBuffer = NULL;
    unsigned int remainBytes = 0;

    /* Configure and enable the MMU. */
    MMUConfigAndEnable();

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

    /* Configuring the system clocks for EDMA. */
    EDMAModuleClkConfig();

    /* Configuring the system clocks for UART0 instance. */
    UART0ModuleClkConfig();

    /* Performing Pin Multiplexing for UART0 instance. */
    UARTPinMuxSetup(0);

    /* Enabling IRQ in CPSR of ARM processor. */
    IntMasterIRQEnable();

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

    /* Initializing the EDMA. */
    EDMA3Initialize();

    /* Initializing the UART0 instance for use. */
    UARTInitialize();

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

    /*
    ** Configuring the EDMA.
    */

    /* Request DMA Channel and TCC for UART Transmit*/
    EDMA3RequestChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA,
                        EDMA3_UART_TX_CHA_NUM, EDMA3_UART_TX_CHA_NUM,
                        EVT_QUEUE_NUM);

    /* Registering Callback Function for TX*/
    cb_Fxn[EDMA3_UART_TX_CHA_NUM] = &callback;

    /* Request DMA Channel and TCC for UART Receive */
    EDMA3RequestChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA,
                        EDMA3_UART_RX_CHA_NUM, EDMA3_UART_RX_CHA_NUM,
                        EVT_QUEUE_NUM);

    /* Registering Callback Function for RX*/
    cb_Fxn[EDMA3_UART_RX_CHA_NUM] = &callback;

    /******************** Transmission of a string **************************/

    numByteChunks = (sizeof(welcome) - 1) / txBytesPerEvent;
    remainBytes = (sizeof(welcome) - 1) % txBytesPerEvent;

    /* Configuring EDMA PaRAM sets to transmit data. */
    UARTTxEDMAPaRAMSetConfig(welcome,
                             numByteChunks * txBytesPerEvent,
                             EDMA3_UART_TX_CHA_NUM,
                             EDMA3CC_OPT(DUMMY_CH_NUM),
                             EDMA3_UART_TX_CHA_NUM);

    /* Configuring the PaRAM set for Dummy Transfer. */
    TxDummyPaRAMConfEnable();

    /* Enable EDMA Transfer */
    EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, EDMA3_UART_TX_CHA_NUM,
                        EDMA3_TRIG_MODE_EVENT);

    /* Wait for return from callback */
    while(0 == clBackFlag);
    clBackFlag = 0;

    /* Remaining bytes are transferred through polling method. */
    if(0 != remainBytes)
    {
        pBuffer = welcome + (sizeof(welcome) - 1) - remainBytes;
        UARTPuts((char*)pBuffer, remainBytes);
    }

    /******************** Transmission of a string **************************/

    numByteChunks = (sizeof(intent) - 1) / txBytesPerEvent;
    remainBytes = (sizeof(intent) - 1) % txBytesPerEvent;

    /* Enabling DMA Mode 1. */
    UARTDMAEnable(UART_INSTANCE_BASE_ADD, UART_DMA_MODE_1_ENABLE);

    /* Configuring EDMA PaRAM sets to transmit data. */
    UARTTxEDMAPaRAMSetConfig(intent,
                             numByteChunks * txBytesPerEvent,
                             EDMA3_UART_TX_CHA_NUM,
                             EDMA3CC_OPT(DUMMY_CH_NUM),
                             EDMA3_UART_TX_CHA_NUM);

    /* Configuring the PaRAM set for Dummy Transfer. */
    TxDummyPaRAMConfEnable();

    /* Enable EDMA Transfer */
    EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, EDMA3_UART_TX_CHA_NUM,
                        EDMA3_TRIG_MODE_EVENT);

    /* Wait for return from callback */
    while(0 == clBackFlag);
    clBackFlag = 0;

    /* Remaining bytes are transferred through polling method. */
    if(0 != remainBytes)
    {
        pBuffer = intent + (sizeof(intent) - 1) - remainBytes;
        UARTPuts((char*)pBuffer, remainBytes);
    }

    /******************** Transmission of a string **************************/

    numByteChunks = (sizeof(enter) - 1) / txBytesPerEvent;
    remainBytes = (sizeof(enter) - 1) % txBytesPerEvent;

    /* Enabling DMA Mode 1. */
    UARTDMAEnable(UART_INSTANCE_BASE_ADD, UART_DMA_MODE_1_ENABLE);

    /* Configuring EDMA PaRAM sets to transmit data. */
    UARTTxEDMAPaRAMSetConfig(enter,
                             numByteChunks * txBytesPerEvent,
                             EDMA3_UART_TX_CHA_NUM,
                             EDMA3CC_OPT(DUMMY_CH_NUM),
                             EDMA3_UART_TX_CHA_NUM);

    /* Configuring the PaRAM set for Dummy Transfer. */
    TxDummyPaRAMConfEnable();

    /* Enable EDMA Transfer */
    EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, EDMA3_UART_TX_CHA_NUM,
                        EDMA3_TRIG_MODE_EVENT);

    /* Wait for return from callback */
    while(0 == clBackFlag);
    clBackFlag = 0;

    /* Remaining bytes are transferred through polling method. */
    if(0 != remainBytes)
    {
        pBuffer = enter + (sizeof(enter) - 1) - remainBytes;
        UARTPuts((char*)pBuffer, remainBytes);
    }

    /********************* Receiving Data from User *************************/

    /* Enabling DMA Mode 1. */
    UARTDMAEnable(UART_INSTANCE_BASE_ADD, UART_DMA_MODE_1_ENABLE);

    /* Configuring the PaRAM set for reception. */
    UARTRxEDMAPaRAMSetConfig(rxBuffer,
                             NUM_RX_BYTES,
                             EDMA3_UART_RX_CHA_NUM,
                             0xFFFF,
                             EDMA3_UART_RX_CHA_NUM);

    /* Enable EDMA Transfer */
    EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, EDMA3_UART_RX_CHA_NUM,
                        EDMA3_TRIG_MODE_EVENT);

    /* Wait for return from callback */
    while(0 == clBackFlag);
    clBackFlag = 0;

    /******************* Echoing received bytes *****************************/

    numByteChunks = (NUM_RX_BYTES) / txBytesPerEvent;
    remainBytes = (NUM_RX_BYTES) % txBytesPerEvent;

    /* Enabling DMA Mode 1. */
    UARTDMAEnable(UART_INSTANCE_BASE_ADD, UART_DMA_MODE_1_ENABLE);

    /* Configuring EDMA PaRAM sets to transmit data. */
    UARTTxEDMAPaRAMSetConfig(rxBuffer,
                             numByteChunks * txBytesPerEvent,
                             EDMA3_UART_TX_CHA_NUM,
                             EDMA3CC_OPT(DUMMY_CH_NUM),
                             EDMA3_UART_TX_CHA_NUM);

    /* Configuring the PaRAM set for Dummy Transfer. */
    TxDummyPaRAMConfEnable();

    /* Enable EDMA Transfer */
    EDMA3EnableTransfer(SOC_EDMA30CC_0_REGS, EDMA3_UART_TX_CHA_NUM,
                        EDMA3_TRIG_MODE_EVENT);

    /* Wait for return from callback */
    while(0 == clBackFlag);
    clBackFlag = 0;

    /* Remaining bytes are transferred through polling method. */
    if(0 != remainBytes)
    {
        pBuffer = rxBuffer + NUM_RX_BYTES - remainBytes;
        UARTPuts((char*)pBuffer, remainBytes);
    }

    /******************* Freeing of allocated channels **********************/

    /* Free EDMA3 Channels for TX and RX */
    EDMA3FreeChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA,
                     EDMA3_UART_TX_CHA_NUM, EDMA3_TRIG_MODE_EVENT,
                     EDMA3_UART_TX_CHA_NUM, EVT_QUEUE_NUM);

    EDMA3FreeChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA,
                     EDMA3_UART_RX_CHA_NUM, EDMA3_TRIG_MODE_EVENT,
                     EDMA3_UART_RX_CHA_NUM, EVT_QUEUE_NUM);

    /* Support for Automation Testing. */
    PRINT_STATUS(S_PASS);

    while(1);
}
/*
** The main function
*/
int main(void)
{
    unsigned int ipAddr;
    LWIP_IF lwipIfPort1, lwipIfPort2;

    MMUConfigAndEnable();

#ifdef LWIP_CACHE_ENABLED
    CacheEnable(CACHE_ALL);
#endif

    CPSWPinMuxSetup();
    CPSWClkEnable();

    /* Initialize console for communication with the Host Machine */
    ConsoleUtilsInit();

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

    /* Chip configuration RGMII selection */
    EVMPortMIIModeSelect();

    /* Get the MAC address */
    EVMMACAddrGet(0, lwipIfPort1.macArray); 
    EVMMACAddrGet(1, lwipIfPort2.macArray); 

    AintcCPSWIntrSetUp();
    //DelayTimerSetup();

    ConsoleUtilsPrintf("\n\rStarterWare Ethernet Echo Application. \n\r\n\r" );
   
    ConsoleUtilsPrintf("Acquiring IP Address for Port 1... \n\r" );

#if STATIC_IP_ADDRESS_PORT1

    lwipIfPort1.instNum = 0;
    lwipIfPort1.slvPortNum = 1; 
    lwipIfPort1.ipAddr = STATIC_IP_ADDRESS_PORT1; 
    lwipIfPort1.netMask = 0; 
    lwipIfPort1.gwAddr = 0; 
    lwipIfPort1.ipMode = IPADDR_USE_STATIC; 

    ipAddr = lwIPInit(&lwipIfPort1);

#else

    lwipIfPort1.instNum = 0;
    lwipIfPort1.slvPortNum = 1; 
    lwipIfPort1.ipAddr = 0; 
    lwipIfPort1.netMask = 0; 
    lwipIfPort1.gwAddr = 0; 
    lwipIfPort1.ipMode = IPADDR_USE_DHCP; 

    ipAddr = lwIPInit(&lwipIfPort1);

#endif
    if(ipAddr)
    {
        ConsoleUtilsPrintf("\n\r\n\rPort 1 IP Address Assigned: ");
        IpAddrDisplay(ipAddr);
    }
    else
    {
        ConsoleUtilsPrintf("\n\r\n\rPort 1 IP Address Acquisition Failed.");
    }

    /* Initialize the sample httpd server. */
    echo_init();
   
    /* Loop forever.  All the work is done in interrupt handlers. */
    while(1)
    {
        ; /* Perform nothing */
    }
}
/******************************************************************************
**              FUNCTION DEFINITIONS
******************************************************************************/
int main()
{
    unsigned int numByteChunks = 0;
    unsigned int remainBytes = 0;
    unsigned int bIndex = 0;

    /* Configuring the system clocks for UART0 instance. */
    UART0ModuleClkConfig();

    /* Performing the Pin Multiplexing for UART0 instance. */
    UARTPinMuxSetup(0);

    /* Performing a module reset. */
    UARTModuleReset(SOC_UART_0_REGS);

    /* Performing FIFO configurations. */
    UartFIFOConfigure();

    /* Performing Baud Rate settings. */
    UartBaudRateSet();

    /* Switching to Configuration Mode B. */
    UARTRegConfigModeEnable(SOC_UART_0_REGS, UART_REG_CONFIG_MODE_B);

    /* Programming the Line Characteristics. */
    UARTLineCharacConfig(SOC_UART_0_REGS, (UART_FRAME_WORD_LENGTH_8 | UART_FRAME_NUM_STB_1), UART_PARITY_NONE);

    /* Disabling write access to Divisor Latches. */
    UARTDivisorLatchDisable(SOC_UART_0_REGS);

    /* Disabling Break Control. */
    UARTBreakCtl(SOC_UART_0_REGS, UART_BREAK_COND_DISABLE);

    /* Switching to UART16x operating mode. */
    UARTOperatingModeSelect(SOC_UART_0_REGS, UART16x_OPER_MODE);

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

    /* Performing Interrupt configurations. */
    UartInterruptEnable();

    numByteChunks = (sizeof(txArray) - 1) / NUM_TX_BYTES_PER_TRANS;
    remainBytes = (sizeof(txArray) - 1) % NUM_TX_BYTES_PER_TRANS;

    while(1)
    {
        /* This branch is entered if the transmission is not yet complete. */
        if(TRUE == txEmptyFlag)
        {
            if(bIndex < numByteChunks)
            {
                /* Transmitting bytes in chunks of NUM_TX_BYTES_PER_TRANS. */
                currNumTxBytes += UARTFIFOWrite(SOC_UART_0_REGS,&txArray[currNumTxBytes],NUM_TX_BYTES_PER_TRANS);
                bIndex++;
            }

            else
            {
                /* Transmitting remaining data from the data block. */
                currNumTxBytes += UARTFIFOWrite(SOC_UART_0_REGS,&txArray[currNumTxBytes],remainBytes);
            }

            txEmptyFlag = FALSE;

            /*
            ** Re-enables the Transmit Interrupt. This interrupt
            ** was disabled in the Transmit section of the UART ISR.
            */
            UARTIntEnable(SOC_UART_0_REGS, UART_INT_THR);
        }
    }



}
Esempio n. 10
0
int main(void)
{
    volatile unsigned int i = 0;
    volatile unsigned int initFlg = 1;

    /* Setup the MMU and do necessary MMU configurations. */
//    MMUConfigAndEnable();

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

    /* Initialize console for communication with the Host Machine */
    ConsoleUtilsInit();

    /*
    ** Select the console type based on compile time check
    ** Note: This example is not fully complaint to semihosting. It is
    **       recommended to use Uart console interface only.
    */
    ConsoleUtilsSetType(CONSOLE_UART);

    /* Enabling functional clocks for GPIO1 instance. */
//    GPIO1ModuleClkConfig();
    /* Enabling the GPIO module. */
//    GPIOModuleEnable(GPIO_INSTANCE_ADDRESS);
    /* Resetting the GPIO module. */
//    GPIOModuleReset(GPIO_INSTANCE_ADDRESS);
    /* Setting the GPIO pin as an output pin. */
//    GPIODirModeSet(GPIO_INSTANCE_ADDRESS,GPIO_INSTANCE_PIN_NUMBER,GPIO_DIR_OUTPUT);

//	GPIOPinWrite(GPIO_INSTANCE_ADDRESS,GPIO_INSTANCE_PIN_NUMBER,GPIO_PIN_HIGH);
//	GPIOPinWrite(GPIO_INSTANCE_ADDRESS,GPIO_INSTANCE_PIN_NUMBER,GPIO_PIN_LOW);

    /* Configure the EDMA clocks. */
    EDMAModuleClkConfig();

    /* Configure EDMA to service the HSMMCSD events. */
    HSMMCSDEdmaInit();

    /* Perform pin-mux for HSMMCSD pins. */
    HSMMCSDPinMuxSetup();

    /* Enable module clock for HSMMCSD. */
    HSMMCSDModuleClkConfig();

    DelayTimerSetup();

#ifdef MMCSD_PERF
    PerfTimerSetup();
#endif

    /* Basic controller initializations */
    HSMMCSDControllerSetup();

    /* Initialize the MMCSD controller */
    HSMMCSDControllerInit(&ctrlInfo);

    ctrlInfo.intrEnable(&ctrlInfo);


    while(1)
    {
        if(HSMMCSDIsCardInserted(ctrlInfo.memBase) == 1)
        {
            if(initFlg)
            {
                HSMMCSDFsMount(0, &sdCard);
                initFlg = 0;
                Cmd_help(0, NULL);
            }
            HSMMCSDFsProcessCmdLine();
        }
        else
        {
            delay(1);

            i = (i + 1) & 0xFFF;

            if(i == 1)
            {
                ConsoleUtilsPrintf("Please insert the card \n\r");
            }

            if(initFlg != 1)
            {
                /* Reinitialize all the state variables */
                callbackOccured = 0;
                xferCompFlag = 0;
                dataTimeout = 0;
                cmdCompFlag = 0;
                cmdTimeout = 0;

                /* Initialize the MMCSD controller */
                HSMMCSDControllerInit(&ctrlInfo);

                ctrlInfo.intrEnable(&ctrlInfo);
            }

            initFlg = 1;
        }
    }
}
Esempio n. 11
0
/*
** Main function. The application starts here.
*/
int main(void)
{
    unsigned char rxByte;
    unsigned int value = (unsigned int)E_FAIL;

    #ifdef __TMS470__
    /* Relocate the required section to internal RAM */
    memcpy((void *)(&relocstart), (const void *)(&iram_start),
           (unsigned int)(&iram_size));
    #elif defined(__IAR_SYSTEMS_ICC__)
    #pragma section = "CodeRelocOverlay"
    #pragma section = "DataRelocOverlay"
    #pragma section = "DataOverlayBlk"
    #pragma section = "CodeOverlayBlk"
    char* srcAddr = (__section_begin("CodeRelocOverlay"));
    char* endAddr = (__section_end("DataRelocOverlay"));

    memcpy((void *)(__section_begin("CodeRelocOverlay")),
           (const void *)(__section_begin("CodeOverlayBlk")),
           endAddr - srcAddr);

    #else
    memcpy((void *)&(relocstart), (const void *)&(iram_start),
           (unsigned int)(((&(relocend)) -
            (&(relocstart))) * (sizeof(unsigned int))));
    #endif

    MMUConfigAndEnable();    

    /* Enable Instruction Cache */
    CacheEnable(CACHE_ALL);

    PeripheralsSetUp();

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

    /* Register the ISRs */  
    Timer2IntRegister();
    Timer4IntRegister();
    EnetIntRegister();
    RtcIntRegister();
    CM3IntRegister();
    HSMMCSDIntRegister();
    IntRegister(127, dummyIsr);

    IntMasterIRQEnable();

    pageIndex = 0;
    prevAction = 0;

    /* Enable system interrupts */
    IntSystemEnable(SYS_INT_RTCINT);
    IntPrioritySet(SYS_INT_RTCINT, 0, AINTC_HOSTINT_ROUTE_IRQ);
    IntSystemEnable(SYS_INT_3PGSWTXINT0);
    IntPrioritySet(SYS_INT_3PGSWTXINT0, 0, AINTC_HOSTINT_ROUTE_IRQ);
    IntSystemEnable(SYS_INT_3PGSWRXINT0);
    IntPrioritySet(SYS_INT_3PGSWRXINT0, 0, AINTC_HOSTINT_ROUTE_IRQ);
    IntSystemEnable(SYS_INT_TINT2);
    IntPrioritySet(SYS_INT_TINT2, 0, AINTC_HOSTINT_ROUTE_IRQ);
    IntSystemEnable(SYS_INT_TINT4);
    IntPrioritySet(SYS_INT_TINT4, 0, AINTC_HOSTINT_ROUTE_IRQ);	
    IntSystemEnable(SYS_INT_MMCSD0INT);
    IntPrioritySet(SYS_INT_MMCSD0INT, 0, AINTC_HOSTINT_ROUTE_IRQ);
    IntSystemEnable(SYS_INT_EDMACOMPINT);
    IntPrioritySet(SYS_INT_EDMACOMPINT, 0, AINTC_HOSTINT_ROUTE_IRQ);
    IntPrioritySet(SYS_INT_M3_TXEV, 0, AINTC_HOSTINT_ROUTE_IRQ );
    IntSystemEnable(SYS_INT_M3_TXEV);
    IntSystemEnable(127);
    IntPrioritySet(127, 0, AINTC_HOSTINT_ROUTE_IRQ);

    IntSystemEnable(SYS_INT_UART0INT);
    IntPrioritySet(SYS_INT_UART0INT, 0, AINTC_HOSTINT_ROUTE_IRQ);
    IntRegister(SYS_INT_UART0INT, uartIsr);

     /*	GPIO interrupts	*/
    IntSystemEnable(SYS_INT_GPIOINT0A);
    IntPrioritySet(SYS_INT_GPIOINT0A, 0, AINTC_HOSTINT_ROUTE_IRQ);
    IntRegister(SYS_INT_GPIOINT0A, gpioIsr);
    IntSystemEnable(SYS_INT_GPIOINT0B);
    IntPrioritySet(SYS_INT_GPIOINT0B, 0, AINTC_HOSTINT_ROUTE_IRQ);
    IntRegister(SYS_INT_GPIOINT0B, gpioIsr);

    BoardInfoInit();
    deviceVersion = DeviceVersionGet();

    CM3EventsClear();
    CM3LoadAndRun();
    waitForM3Txevent();

    /* Initialize console for communication with the Host Machine */
    ConsoleUtilsInit();

    /*
    ** Select the console type based on compile time check
    ** Note: This example is not fully complaint to semihosting. It is
    **       recommended to use Uart console interface only.
    */
    ConsoleUtilsSetType(CONSOLE_UART);

    /* Print Board and SoC information on console */
    ConsoleUtilsPrintf("\n\r Board Name          : %s", BoardNameGet());
    ConsoleUtilsPrintf("\n\r Board Version       : %s", BoardVersionGet());
    ConsoleUtilsPrintf("\n\r SoC Version         : %d", deviceVersion);

    /* On CM3 init firmware version is loaded onto the IPC Message Reg */
    ConsoleUtilsPrintf("\n CM3 Firmware Version: %d", readCM3FWVersion());

    I2CIntRegister(I2C_0);
    IntPrioritySet(SYS_INT_I2C0INT, 0, AINTC_HOSTINT_ROUTE_IRQ);
    IntSystemEnable(SYS_INT_I2C0INT);
    I2CInit(I2C_0);

    IntSystemEnable(SYS_INT_TINT1_1MS);
    IntPrioritySet(SYS_INT_TINT1_1MS, 0, AINTC_HOSTINT_ROUTE_IRQ);
    IntRegister(SYS_INT_TINT1_1MS,clearTimerInt);

    configVddOpVoltage();
    RtcInit();
    HSMMCSDContolInit();
    DelayTimerSetup();

    initializeTimer1();
    ConsoleUtilsPrintf("\r\n After intializing timer");
    Timer2Config();
    Timer4Config();
    LedIfConfig();
    MailBoxInit();

    Timer2IntEnable();
    Timer4IntEnable();
    RtcSecIntEnable();
    	
    Timer4Start(); 
    while(FALSE == tmr4Flag);
    tmr4Flag = FALSE;
    Timer4Stop();

    ConsoleUtilsPrintf("\n\r Configuring for maximum OPP");
    mpuOpp = ConfigMaximumOPP();

    mpuFreq = FrequencyGet(mpuOpp);
    mpuVdd1 = VddVoltageGet(mpuOpp);
    PrintConfigDVFS();

    /*  Create menu page */
    pageIndex = MENU_IDX_MAIN;

    ActionEnetInit();

    /*
    ** Loop for ever. Necessary actions shall be taken
    ** after detecting the click.
    */
    while(1)
    {
        /*
        ** Check for any any activity on Uart Console and process it.
        */
        if (true == UARTCharsAvail(SOC_UART_0_REGS))
        {

            /* Receiving bytes from the host machine through serial console. */
            rxByte = UARTGetc();

            /*
            ** Checking if the entered character is a carriage return.
            ** Pressing the 'Enter' key on the keyboard executes a
            ** carriage return on the serial console.
            */
            if('\r' == rxByte)
            {
                ConsoleUtilsPrintf("\n");
                UartAction(value);
                value = (unsigned int)E_FAIL;
                rxByte = 0;
            }

            /*
            ** Checking if the character entered is one among the decimal
            ** number set 0,1,2,3,....9
            */
            if(('0' <= rxByte) && (rxByte <= '9'))
            {
                ConsoleUtilsPrintf("%c", rxByte);

                if((unsigned int)E_FAIL == value)
                {
                    value = 0;
                }

                value = value*10 + (rxByte - 0x30);
            }

        }

         /*
         ** Check if click is detected
         */
         if(clickIdx != 0)
         {
             /*
             ** Take the Action for click
             */
             ClickAction();

             clickIdx = 0;
         }
       
         /*
         ** Check if the Timer Expired
         */ 
         if(TRUE == tmrFlag)
         {
             /* Toggle the LED state */
             LedToggle();
             tmrFlag = FALSE;
         }
 
         /*
         ** Check if RTC Time is set
         */
         if(TRUE == rtcSetFlag)
         {
             if(TRUE == rtcSecUpdate)
             { 
                 rtcSecUpdate = FALSE;
                 RtcTimeCalDisplay();
                 ConsoleUtilsPrintf(" --- Selected:  ");
             }
         } 
   
         if(TRUE == tmr4Flag)
         {
            tmr4Flag = FALSE;
             /* Make sure that interrupts are disabled and no lwIP functions
                are executed while calling an lwIP exported API */
             IntMasterIRQDisable();
             etharp_tmr();
             IntMasterIRQEnable();
         }
    }
}
Esempio n. 12
0
int main(void)
{
    volatile unsigned int i = 0;
    volatile unsigned int initFlg = 1;

    /* Setup the MMU and do necessary MMU configurations. */
    MMUConfigAndEnable();

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

    /* Initialize console for communication with the Host Machine */
    ConsoleUtilsInit();

    /*
    ** Select the console type based on compile time check
    ** Note: This example is not fully complaint to semihosting. It is
    **       recommended to use Uart console interface only.
    */
    ConsoleUtilsSetType(CONSOLE_UART);

    /* Configure the EDMA clocks. */
    EDMAModuleClkConfig();

    /* Configure EDMA to service the HSMMCSD events. */
    HSMMCSDEdmaInit();

    /* Perform pin-mux for HSMMCSD pins. */
    HSMMCSDPinMuxSetup();

    /* Enable module clock for HSMMCSD. */
    HSMMCSDModuleClkConfig();

    DelayTimerSetup();

#ifdef MMCSD_PERF
    PerfTimerSetup();
#endif

    /* Basic controller initializations */
    HSMMCSDControllerSetup();

    /* Initialize the MMCSD controller */
    MMCSDCtrlInit(&ctrlInfo);

    MMCSDIntEnable(&ctrlInfo);

    while(1)
    {
        if((HSMMCSDCardPresent(&ctrlInfo)) == 1)
        {
            if(initFlg)
            {
                HSMMCSDFsMount(0, &sdCard);
                initFlg = 0;
                Cmd_help(0, NULL);
            }
            HSMMCSDFsProcessCmdLine();
        }
        else
        {
            delay(1);

            i = (i + 1) & 0xFFF;

            if(i == 1)
            {
                 ConsoleUtilsPrintf("Please insert the card \n\r");
            }

            if(initFlg != 1)
            {
                 /* Reinitialize all the state variables */
                 callbackOccured = 0;
                 xferCompFlag = 0;
                 dataTimeout = 0;
                 cmdCompFlag = 0;
                 cmdTimeout = 0;

                 /* Initialize the MMCSD controller */
                 MMCSDCtrlInit(&ctrlInfo);

                 MMCSDIntEnable(&ctrlInfo);
            }

            initFlg = 1;
        }
    }
}