//***************************************************************************** // // This is the main loop that runs the application. // //***************************************************************************** int main(void) { #ifdef DMA_MODE MMUConfigAndEnable(); /* Enable Data Cache */ CacheEnable(CACHE_DCACHE); #endif // //USB module clock enable // USB0ModuleClkConfig(); // //USB Interrupt enable // USBInterruptEnable(); // //Delay timer setup // DelayTimerSetup(); // // Initialize the idle timeout and reset all flags. // //g_ulIdleTimeout = 0; g_ulFlags = 0; // // Initialize the state to idle. // g_eMSCState = MSC_DEV_IDLE; USBDMSCInit(0, (tUSBDMSCDevice *)&g_sMSCDevice); #ifdef DMA_MODE Cppi41DmaInit(USB_INSTANCE, epInfo, NUMBER_OF_ENDPOINTS); for(;g_bufferIndex < NUM_OF_RX_BDs; g_bufferIndex++) { dataBuffer = (unsigned char *)cppiDmaAllocBuffer(); doDmaRxTransfer(USB_INSTANCE, USB_MSC_BUFER_SIZE, dataBuffer, g_sMSCDevice.psPrivateData->ucOUTEndpoint); } #endif // // Drop into the main loop. // while(1); }
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); }
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); } }
int main(void) { unsigned int triggerValue = 0; /* Setup the MMU and do necessary MMU configurations. */ MMUConfigAndEnable(); /* Enable all levels of CACHE. */ CacheEnable(CACHE_ALL); /* Set up the UART2 peripheral */ UARTStdioInit(); /* 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 */ UARTPuts("Program Reset!", -1); UARTPuts("Input any key at least once in every 4 seconds to avoid a further reset.\n\r", -1); /* Enable the Watchdog Timer */ WatchdogTimerEnable(SOC_WDT_1_REGS); while(1) { /* Wait for an input through UART. If no input is given, ** the WDT will timeout and reset will occur. */ if(UARTGetc()) { 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); } } }
//***************************************************************************** // // This is the main loop that runs the application. // //***************************************************************************** int main(void) { unsigned int i; unsigned char *src, *dest; /* MMU needs to be turned on to provide HW support unaligned access to USB structures */ MMUConfigAndEnable(); /* Enable Data Cache */ CacheEnable(CACHE_ALL); // //USB module clock enable // USB0ModuleClkConfig(); // //USB Interrupt enable // USBInterruptEnable(); // //Delay timer setup // DelayTimerSetup(); CacheDataCleanInvalidateAll(); USBDMSCInit(0, (tUSBDMSCDevice *)&g_sMSCDevice); #ifdef DMA_MODE Cppi41DmaInit(USB_INSTANCE, epInfo, NUMBER_OF_ENDPOINTS); for(;g_bufferIndex < NUM_OF_RX_BDs; g_bufferIndex++) { dataBuffer = (unsigned char *)cppiDmaAllocBuffer(); doDmaRxTransfer(USB_INSTANCE, USB_MSC_BUFER_SIZE, dataBuffer, g_sMSCDevice.psPrivateData->ucOUTEndpoint); } #endif while(1) { } }
int main(void) { MMUConfigAndEnable(); CacheEnable(CACHE_ALL); SetupIntc(); UARTStdioInit(); /* This function will enable clocks for the DMTimer2 instance */ DMTimer2ModuleClkConfig(); TouchScreenInit(); return 0; }
/* ** 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 */ } }
//***************************************************************************** // // This is the main application entry function. // //***************************************************************************** int main(void) { unsigned int ulTxCount; unsigned int ulRxCount; tRectangle sRect; char pcBuffer[16]; unsigned int ulFullness; unsigned int intFlags = 0; unsigned char Intstatus; unsigned int i; unsigned char *src, *dest; MMUConfigAndEnable(); // // Not configured initially. // g_bUSBConfigured = false; // //configures arm interrupt controller to generate raster interrupt // USBInterruptEnable(); // //LCD Back light setup // LCDBackLightEnable(); // //UPD Pin setup // UPDNPinControl(); // //Delay timer setup // DelayTimerSetup(); // //Configures raster to display image // SetUpLCD(); RasterDMAFBConfig(SOC_LCDC_0_REGS, (unsigned int)(g_pucBuffer+PALETTE_OFFSET), (unsigned int)(g_pucBuffer+PALETTE_OFFSET) + sizeof(g_pucBuffer) - 2 - PALETTE_OFFSET, FRAME_BUFFER_0); RasterDMAFBConfig(SOC_LCDC_0_REGS, (unsigned int)(g_pucBuffer+PALETTE_OFFSET), (unsigned int)(g_pucBuffer+PALETTE_OFFSET) + sizeof(g_pucBuffer) - 2 - PALETTE_OFFSET, FRAME_BUFFER_1); src = (unsigned char *) palette_32b; dest = (unsigned char *) (g_pucBuffer+PALETTE_OFFSET); // Copy palette info into buffer for( i = PALETTE_OFFSET; i < (PALETTE_SIZE+PALETTE_OFFSET); i++) { *dest++ = *src++; } GrOffScreen24BPPInit(&g_s35_480x272x24Display, g_pucBuffer, LCD_WIDTH, LCD_HEIGHT); // Initialize a drawing context. GrContextInit(&g_sContext, &g_s35_480x272x24Display); /* enable End of frame interrupt */ RasterEndOfFrameIntEnable(SOC_LCDC_0_REGS); /* enable raster */ RasterEnable(SOC_LCDC_0_REGS); // // Fill the top 24 rows of the screen with blue to create the banner. // sRect.sXMin = 0; sRect.sYMin = 0; sRect.sXMax = GrContextDpyWidthGet(&g_sContext) - 1; sRect.sYMax = 23; GrContextForegroundSet(&g_sContext, ClrDarkBlue); GrRectFill(&g_sContext, &sRect); // // Put a white box around the banner. // GrContextForegroundSet(&g_sContext, ClrWhite); GrRectDraw(&g_sContext, &sRect); // // Put the application name in the middle of the banner. // GrContextFontSet(&g_sContext, &g_sFontCm20); GrStringDrawCentered(&g_sContext, "usb-dev-serial", -1, GrContextDpyWidthGet(&g_sContext) / 2, 10, 0); // // Show the various static text elements on the color STN display. // GrContextFontSet(&g_sContext, TEXT_FONT); GrStringDraw(&g_sContext, "Tx bytes:", -1, 8, 80, false); GrStringDraw(&g_sContext, "Tx buffer:", -1, 8, 105, false); GrStringDraw(&g_sContext, "Rx bytes:", -1, 8, 160, false); GrStringDraw(&g_sContext, "Rx buffer:", -1, 8, 185, false); DrawBufferMeter(&g_sContext, 150, 105); DrawBufferMeter(&g_sContext, 150, 185); // // Tell the user what we are up to. // DisplayStatus(&g_sContext, " Configuring USB... "); // //Initialize the Rx and TX Buffers // USBBufferInit((tUSBBuffer *)&g_sTxBuffer); USBBufferInit((tUSBBuffer *)&g_sRxBuffer); // // Pass our device information to the USB library and place the device // on the bus. // USBDCDCInit(0, (tUSBDCDCDevice *)&g_sCDCDevice); // // Wait for initial configuration to complete. // DisplayStatus(&g_sContext, " Waiting for host... "); // // Clear our local byte counters. // ulRxCount = 0; ulTxCount = 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 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); /* Performing FIFO configurations. */ UartFIFOConfigure(); /* Preparing the 'intFlags' variable to be passed as an argument.*/ intFlags |= (UART_INT_LINE_STAT | UART_INT_RHR_CTI); /* Enable the Interrupts in UART.*/ UARTIntEnable(SOC_UART_0_REGS, intFlags); // // Main application loop. // while(1) { // // Have we been asked to update the status display? // if(g_ulFlags & COMMAND_STATUS_UPDATE) { // // Clear the command flag // Intstatus = IntDisable(); g_ulFlags &= ~COMMAND_STATUS_UPDATE; IntEnable(Intstatus); DisplayStatus(&g_sContext, g_pcStatus); } // // Has there been any transmit traffic since we last checked? // if(ulTxCount != g_ulUARTTxCount) { // // Take a snapshot of the latest transmit count. // ulTxCount = g_ulUARTTxCount; // // Update the display of bytes transmitted by the UART. // usnprintf(pcBuffer, 16, "%d ", ulTxCount); GrStringDraw(&g_sContext, pcBuffer, -1, 150, 80, true); // // Update the RX buffer fullness. Remember that the buffers are // named relative to the USB whereas the status display is from // the UART's perspective. The USB's receive buffer is the UART's // transmit buffer. // ulFullness = ((USBBufferDataAvailable(&g_sRxBuffer) * 100) / UART_BUFFER_SIZE); UpdateBufferMeter(&g_sContext, ulFullness, 150, 105); } // // Has there been any receive traffic since we last checked? // if(ulRxCount != g_ulUARTRxCount) { // // Take a snapshot of the latest receive count. // ulRxCount = g_ulUARTRxCount; // // Update the display of bytes received by the UART. // usnprintf(pcBuffer, 16, "%d ", ulRxCount); GrStringDraw(&g_sContext, pcBuffer, -1, 150, 160, true); // // Update the TX buffer fullness. Remember that the buffers are // named relative to the USB whereas the status display is from // the UART's perspective. The USB's transmit buffer is the UART's // receive buffer. // ulFullness = ((USBBufferDataAvailable(&g_sTxBuffer) * 100) / UART_BUFFER_SIZE); UpdateBufferMeter(&g_sContext, ulFullness, 150, 185); } } }
//***************************************************************************** // // This is the main loop that runs the application. // //***************************************************************************** int main(void) { tRectangle sRect; unsigned int i; unsigned char *src, *dest; MMUConfigAndEnable(); // //configures arm interrupt controller to generate raster interrupt // USBInterruptEnable(USB_INSTANCE); // //LCD back light setup // LCDBackLightEnable(); // //UPD Pin setup // UPDNPinControl(); // //Delay timer setup // DelayTimerSetup(); // //Configures raster to display image // SetUpLCD(); /* configuring the base ceiling */ RasterDMAFBConfig(SOC_LCDC_0_REGS, (unsigned int)(g_pucBuffer+PALETTE_OFFSET), (unsigned int)(g_pucBuffer+PALETTE_OFFSET) + sizeof(g_pucBuffer) - 2 - PALETTE_OFFSET, FRAME_BUFFER_0); RasterDMAFBConfig(SOC_LCDC_0_REGS, (unsigned int)(g_pucBuffer+PALETTE_OFFSET), (unsigned int)(g_pucBuffer+PALETTE_OFFSET) + sizeof(g_pucBuffer) - 2 - PALETTE_OFFSET, FRAME_BUFFER_1); src = (unsigned char *) palette_32b; dest = (unsigned char *) (g_pucBuffer+PALETTE_OFFSET); // Copy palette info into buffer for( i = PALETTE_OFFSET; i < (PALETTE_SIZE+PALETTE_OFFSET); i++) { *dest++ = *src++; } GrOffScreen24BPPInit(&g_s35_800x480x24Display, g_pucBuffer, LCD_WIDTH, LCD_HEIGHT); // Initialize a drawing context. GrContextInit(&g_sContext, &g_s35_800x480x24Display); /* enable End of frame interrupt */ RasterEndOfFrameIntEnable(SOC_LCDC_0_REGS); /* enable raster */ RasterEnable(SOC_LCDC_0_REGS); // // Fill the top 15 rows of the screen with blue to create the banner. // sRect.sXMin = 0; sRect.sYMin = 0; sRect.sXMax = GrContextDpyWidthGet(&g_sContext) - 1; sRect.sYMax = DISPLAY_BANNER_HEIGHT; // // Set the banner background. // GrContextForegroundSet(&g_sContext, DISPLAY_BANNER_BG); GrRectFill(&g_sContext, &sRect); // // Put a white box around the banner. // GrContextForegroundSet(&g_sContext, DISPLAY_BANNER_FG); GrRectDraw(&g_sContext, &sRect); // // Put the application name in the middle of the banner. // GrContextFontSet(&g_sContext, &g_sFontCm20); GrStringDrawCentered(&g_sContext, "usb_host_mouse", -1, GrContextDpyWidthGet(&g_sContext) / 2, 10, 0); // // Register the host class drivers. // USBHCDRegisterDrivers(USB_INSTANCE, g_ppHostClassDrivers, g_ulNumHostClassDrivers); // // Initialized the cursor. // g_ulButtons = 0; g_sCursor.sXMin = GrContextDpyWidthGet(&g_sContext) / 2; g_sCursor.sXMax = g_sCursor.sXMin + DISPLAY_MOUSE_SIZE; g_sCursor.sYMin = GrContextDpyHeightGet(&g_sContext) / 2; g_sCursor.sYMax = g_sCursor.sYMin + DISPLAY_MOUSE_SIZE; // // Update the status on the screen. // UpdateStatus(); // // Update the cursor once to display it. // UpdateCursor(0, 0); // // Open an instance of the mouse driver. The mouse does not need // to be present at this time, this just saves a place for it and allows // the applications to be notified when a mouse is present. // g_ulMouseInstance = USBHMouseOpen(USB_INSTANCE, MouseCallback, g_pucMouseBuffer, MOUSE_MEMORY_SIZE); // // Initialize the power configuration. This sets the power enable signal // to be active high and does not enable the power fault. // USBHCDPowerConfigInit(USB_INSTANCE, USBHCD_VBUS_AUTO_HIGH); // // Initialize the host controller stack. // USBHCDInit(USB_INSTANCE, g_pHCDPool, HCD_MEMORY_SIZE); // // Call the main loop for the Host controller driver. // USBHCDMain(USB_INSTANCE, g_ulMouseInstance); // // The main loop for the application. // while(1) { switch(eUSBState) { // // This state is entered when the mouse is first detected. // case STATE_MOUSE_INIT: { // // Initialize the newly connected mouse. // USBHMouseInit(g_ulMouseInstance); // // Proceed to the mouse connected state. // eUSBState = STATE_MOUSE_CONNECTED; // // Update the status on the screen. // UpdateStatus(); break; } case STATE_MOUSE_CONNECTED: { // // Nothing is currently done in the main loop when the mouse // is connected. // break; } case STATE_NO_DEVICE: { // // The mouse is not connected so nothing needs to be done here. // break; } default: { break; } } // // Periodically call the main loop for the Host controller driver. // USBHCDMain(USB_INSTANCE, g_ulMouseInstance); } }
/***************************************************************************** * * This is the main loop that runs the application. * *****************************************************************************/ int main(void) { tRectangle sRect; MMUConfigAndEnable(); /* Enable USB module clock */ USB0ModuleClkConfig(); /* Enable DM timer 3 module clock */ DMTimer3ModuleClkConfig(); /* Enbale touch screen module colock */ TSCADCModuleClkConfig(); /* Enable touch screen ADC pinmux */ TSCADCPinMuxSetUp(); /* configures arm interrupt controller to generate raster interrupt */ USBInterruptEnable(); /* LCD Back light setup */ LCDBackLightEnable(); /* UPD Pin setup */ UPDNPinControl(); /* Delay timer setup */ DelayTimerSetup(); /* Configures raster to display image */ SetUpLCD(); /* Register touch scren interrupt */ TouchIntRegister(); IntSystemEnable(SYS_INT_TINT3); IntPrioritySet(SYS_INT_TINT3, 0, AINTC_HOSTINT_ROUTE_IRQ); IntSystemEnable(SYS_INT_ADC_TSC_GENINT); IntPrioritySet(SYS_INT_ADC_TSC_GENINT, 0, AINTC_HOSTINT_ROUTE_IRQ); /* Configures raster to display image and Copy palette info into buffer */ LCDInit(); GrOffScreen24BPPInit(&g_s35_480x272x24Display, g_pucBuffer, LCD_WIDTH, LCD_HEIGHT); /* Initialize a drawing context. */ GrContextInit(&g_sContext, &g_s35_480x272x24Display); /* enable End of frame interrupt */ RasterEndOfFrameIntEnable(SOC_LCDC_0_REGS); /* enable raster */ RasterEnable(SOC_LCDC_0_REGS); /* Fill the top 24 rows of the screen with blue to create the banner. */ sRect.sXMin = 0; sRect.sYMin = 0; sRect.sXMax = GrContextDpyWidthGet(&g_sContext) - 1; sRect.sYMax = (MAX_ROW_NUM - 1); GrContextForegroundSet(&g_sContext, ClrDarkBlue); GrRectFill(&g_sContext, &sRect); /* Put a white box around the banner. */ GrContextForegroundSet(&g_sContext, ClrWhite); GrRectDraw(&g_sContext, &sRect); /* Put the application name in the middle of the banner. */ GrContextFontSet(&g_sContext, &g_sFontCm20); GrStringDrawCentered(&g_sContext, "usb-dev-composite", -1, GrContextDpyWidthGet(&g_sContext) / 2, 10, 0); sRect.sXMin = 0; sRect.sYMin = (MAX_ROW_NUM + 1); sRect.sXMax = GrContextDpyWidthGet(&g_sContext) - 1; sRect.sYMax = GrContextDpyHeightGet(&g_sContext) - BUTTON_HEIGHT - 2; GrContextForegroundSet(&g_sContext, ClrBlack); GrRectFill(&g_sContext, &sRect); /* Put a white box around the banner. */ GrContextForegroundSet(&g_sContext, ClrRed); GrRectDraw(&g_sContext, &sRect); /* Draw the buttons in their initial (unpressed)state. */ UpdateDisplay(g_ucButtons, true); /* Show the various static text elements on the color STN display. */ GrContextFontSet(&g_sContext, TEXT_FONT); GrStringDraw(&g_sContext, "Tx bytes:", -1, CDC_STR_X_POSITION, CDC_STR_Y_POSITION, false); GrStringDraw(&g_sContext, "Tx buffer:", -1, CDC_STR_X_POSITION, (CDC_STR_Y_POSITION + CDC_STR_Y_DIFF), false); GrStringDraw(&g_sContext, "Rx bytes:", -1, CDC_STR_X_POSITION, (CDC_STR_Y_POSITION + (CDC_STR_Y_DIFF * 3)), false); GrStringDraw(&g_sContext, "Rx buffer:", -1, CDC_STR_X_POSITION, (CDC_STR_Y_POSITION + (CDC_STR_Y_DIFF * 4)), false); DrawBufferMeter(&g_sContext, BUFFER_METER_X_POS, BUFFER_METER_Y_POS); DrawBufferMeter(&g_sContext, BUFFER_METER_X_POS, (BUFFER_METER_Y_POS + CDC_BUF_METER_Y_DIFF)); /* Tell the user what we are up to. */ DisplayStatus(&g_sContext, " Waiting for host... "); /* Initialize touch screen */ TouchInit(); /* Touch screen Interrupt enbale */ TouchIntEnable(); /* Touch Screen Enable */ TouchEnable(); /* Pass the USB library our device information, initialize the USB controller and connect the device to the bus. */ g_psCompDevices[0].pvInstance = USBDHIDMouseCompositeInit(0, (tUSBDHIDMouseDevice *)&g_sMouseDevice); g_psCompDevices[1].pvInstance = USBDCDCCompositeInit(0, (tUSBDCDCDevice *)&g_sCDCDevice); /* Pass the device information to the USB library and place the device on the bus. */ USBDCompositeInit(0, &g_sCompDevice, DESCRIPTOR_DATA_SIZE, g_pucDescriptorData); /* Initialize the mouse and serial devices. */ SerialInit(); /* Drop into the main loop. */ while(1) { /* Allow the main serial routine to run. */ SerialMain(); /* Allow the main mouse routine to run. */ MouseMain(); } }
/* ** 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); }
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; } } }
int main(void) { tRectangle sRect; unsigned int i = 0; unsigned char *src = (unsigned char *) palette_32b; unsigned char *dest = (unsigned char *) (g_pucBuffer+4); MMUConfigAndEnable(); // //Enable USB module clock // USB0ModuleClkConfig(); // //Enable DM timer 3 module clock // DMTimer3ModuleClkConfig(); // //Enbale touch screen module colock // TSCADCModuleClkConfig(); // //Enable touch screen ADC pinmux // TSCADCPinMuxSetUp(); // //Enbale USB interrupts // USBInterruptEnable(); // //Switch ON LCD back light // LCDBackLightEnable(); // //UDP Pin control // UPDNPinControl(); // //Delay timer setup // DelayTimerSetup(); // //Configures raster to display image // SetUpLCD(); // //Register touch scren interrupt // TouchIntRegister(); IntSystemEnable(SYS_INT_TINT3); IntPrioritySet(SYS_INT_TINT3, 0, AINTC_HOSTINT_ROUTE_IRQ); IntSystemEnable(SYS_INT_ADC_TSC_GENINT); IntPrioritySet(SYS_INT_ADC_TSC_GENINT, 0, AINTC_HOSTINT_ROUTE_IRQ); RasterDMAFBConfig(SOC_LCDC_0_REGS, (unsigned int)(g_pucBuffer+PALETTE_OFFSET), (unsigned int)(g_pucBuffer+PALETTE_OFFSET) + sizeof(g_pucBuffer) - 2 - PALETTE_OFFSET, FRAME_BUFFER_0); RasterDMAFBConfig(SOC_LCDC_0_REGS, (unsigned int)(g_pucBuffer+PALETTE_OFFSET), (unsigned int)(g_pucBuffer+PALETTE_OFFSET) + sizeof(g_pucBuffer) - 2 - PALETTE_OFFSET, FRAME_BUFFER_1); src = (unsigned char *) palette_32b; dest = (unsigned char *) (g_pucBuffer+PALETTE_OFFSET); // Copy palette info into buffer for( i = PALETTE_OFFSET; i < (PALETTE_SIZE+PALETTE_OFFSET); i++) { *dest++ = *src++; } GrOffScreen24BPPInit(&g_s35_480x272x24Display, g_pucBuffer, LCD_WIDTH, LCD_HEIGHT); // Initialize a drawing context. GrContextInit(&g_sContext, &g_s35_480x272x24Display); /* enable End of frame interrupt */ RasterEndOfFrameIntEnable(SOC_LCDC_0_REGS); /* enable raster */ RasterEnable(SOC_LCDC_0_REGS); // // Fill the top 24 rows of the screen with blue to create the banner. // sRect.sXMin = 0; sRect.sYMin = 0; sRect.sXMax = GrContextDpyWidthGet(&g_sContext) - 1; sRect.sYMax = 23; GrContextForegroundSet(&g_sContext, ClrDarkBlue); GrRectFill(&g_sContext, &sRect); // // Put a white box around the banner. // GrContextForegroundSet(&g_sContext, ClrWhite); GrRectDraw(&g_sContext, &sRect); // // Put the application name in the middle of the banner. // GrContextFontSet(&g_sContext, &g_sFontCm20); GrStringDrawCentered(&g_sContext, "usb-dev-mouse", -1, GrContextDpyWidthGet(&g_sContext) / 2, 10, 0); // // Fill the top 24 rows of the screen with blue to create the banner. // sRect.sXMin = 0; sRect.sYMin = 25; sRect.sXMax = GrContextDpyWidthGet(&g_sContext) - 1; sRect.sYMax = GrContextDpyHeightGet(&g_sContext) - BUTTON_HEIGHT - 2; GrContextForegroundSet(&g_sContext, ClrDarkGray); GrRectFill(&g_sContext, &sRect); // // Put a white box around the banner. // GrContextForegroundSet(&g_sContext, ClrRed); GrRectDraw(&g_sContext, &sRect); // // Draw the buttons in their initial (unpressed)state. // UpdateDisplay(g_ucButtons, true); // //Initialize touch screen // TouchInit(); // //Touch screen Interrupt enbale // TouchIntEnable(); // //Touch Screen Enable // TouchEnable(); // // Initialize the mouse // USBDHIDMouseInit(0, (tUSBDHIDMouseDevice *)&g_sMouseDevice); // // Drop into the main loop. // while(1) { // // Wait for USB configuration to complete. // while(!bConnected) { } // //Wait till someone touches the screen // while(!g_iTouch) { g_iTouch = TouchDetect(); } // //Loop here as long as someone moving the finger/stylus on the touch screen // do { // //If so, read the x and Y vlaue and give it to touch handler // TouchCoOrdGet(&g_lScreenX, &g_lScreenY); // //Call touch handler // TouchHandler(); }while(TouchDetect()); // //Touch is released // g_released = 1; // //Reset the button status // g_ucButtons = 0; // //Call the touch handler to update the release status // TouchHandler(); // //Reset the touch flag // g_iTouch = 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 UART. */ UARTStdioInit(); /* 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(); /* Basic controller initializations */ HSMMCSDControllerSetup(); 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) { UARTPuts("Please insert the card \n\r", -1); } 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; } } }
/***************************************************************************** * * This is the main loop that runs the application. * *****************************************************************************/ int main(void) { tRectangle sRect; MMUConfigAndEnable(); /* Enable USB module clock */ USB0ModuleClkConfig(); /* configures arm interrupt controller to generate raster interrupt */ USBInterruptEnable(); /* LCD Back light setup */ LCDBackLightEnable(); /* UPD Pin setup */ UPDNPinControl(); /* Delay timer setup */ DelayTimerSetup(); /* Configures raster to display image */ SetUpLCD(); /* Configures raster to display image and Copy palette info into buffer */ LCDInit(); GrOffScreen24BPPInit(&g_s35_800x480x24Display, g_pucBuffer, LCD_WIDTH, LCD_HEIGHT); /* Initialize a drawing context. */ GrContextInit(&g_sContext, &g_s35_800x480x24Display); /* enable End of frame interrupt */ RasterEndOfFrameIntEnable(SOC_LCDC_0_REGS); /* enable raster */ RasterEnable(SOC_LCDC_0_REGS); /* Fill the top 24 rows of the screen with blue to create the banner. */ sRect.sXMin = 0; sRect.sYMin = 0; sRect.sXMax = GrContextDpyWidthGet(&g_sContext) - 1; sRect.sYMax = (MAX_ROW_NUM - 1); GrContextForegroundSet(&g_sContext, ClrDarkBlue); GrRectFill(&g_sContext, &sRect); /* Put a white box around the banner. */ GrContextForegroundSet(&g_sContext, ClrWhite); GrRectDraw(&g_sContext, &sRect); /* Put the application name in the middle of the banner. */ GrContextFontSet(&g_sContext, &g_sFontCm20); GrStringDrawCentered(&g_sContext, "usb-dev-composite", -1, GrContextDpyWidthGet(&g_sContext) / 2, 10, 0); /* Show the various static text elements on the color STN display. */ GrContextFontSet(&g_sContext, TEXT_FONT); GrContextForegroundSet(&g_sContext, ClrViolet); GrStringDraw(&g_sContext, "CDC Serial 1 :-", -1, CDC1_STR_X_POSITION, CDC1_STR_Y_POSITION, false); GrStringDraw(&g_sContext, "CDC Serial 2 :-", -1, CDC2_STR_X_POSITION, CDC1_STR_Y_POSITION, false); GrContextForegroundSet(&g_sContext, ClrWhite); GrStringDraw(&g_sContext, "Tx bytes:", -1, CDC1_STR_X_POSITION, (CDC1_STR_Y_POSITION + CDC_STR_Y_DIFF), false); GrStringDraw(&g_sContext, "Tx buffer:", -1, CDC1_STR_X_POSITION, (CDC1_STR_Y_POSITION + (CDC_STR_Y_DIFF * 2)), false); GrStringDraw(&g_sContext, "Rx bytes:", -1, CDC1_STR_X_POSITION, (CDC1_STR_Y_POSITION + (CDC_STR_Y_DIFF * 4)), false); GrStringDraw(&g_sContext, "Rx buffer:", -1, CDC1_STR_X_POSITION, (CDC1_STR_Y_POSITION + (CDC_STR_Y_DIFF * 5)), false); DrawBufferMeter(&g_sContext, CDC1_BUF_METER_X_POS, CDC1_BUF_METER_Y_POS); DrawBufferMeter(&g_sContext, CDC1_BUF_METER_X_POS, (CDC1_BUF_METER_Y_POS + CDC_BUF_METER_Y_DIFF)); GrStringDraw(&g_sContext, "Tx bytes:", -1, CDC2_STR_X_POSITION, (CDC2_STR_Y_POSITION + CDC_STR_Y_DIFF), false); GrStringDraw(&g_sContext, "Tx buffer:", -1, CDC2_STR_X_POSITION, (CDC2_STR_Y_POSITION + (CDC_STR_Y_DIFF * 2)), false); GrStringDraw(&g_sContext, "Rx bytes:", -1, CDC2_STR_X_POSITION, (CDC2_STR_Y_POSITION + (CDC_STR_Y_DIFF * 4)), false); GrStringDraw(&g_sContext, "Rx buffer:", -1, CDC2_STR_X_POSITION, (CDC2_STR_Y_POSITION + (CDC_STR_Y_DIFF * 5)), false); DrawBufferMeter(&g_sContext, CDC2_BUF_METER_X_POS, CDC2_BUF_METER_Y_POS); DrawBufferMeter(&g_sContext, CDC2_BUF_METER_X_POS, (CDC2_BUF_METER_Y_POS + CDC_BUF_METER_Y_DIFF)); DisplayStatus(&g_sContext, " Waiting for host... "); /* Pass the USB library our device information, initialize the USB controller and connect the device to the bus. */ g_psCompDevices[0].pvInstance = USBDCDCCompositeInit(0, (tUSBDCDCDevice *)&g_sCDCDevice1); g_psCompDevices[1].pvInstance = USBDCDCCompositeInit(0, (tUSBDCDCDevice *)&g_sCDCDevice2); /* Pass the device information to the USB library and place the device on the bus. */ USBDCompositeInit(0, &g_sCompDevice, DESCRIPTOR_DATA_SIZE, g_pucDescriptorData); /* Initialize the serial devices. */ SerialInit(); /* Drop into the main loop. */ while(1) { /* Allow the main serial routine to run. */ SerialMain(); } }
/* ** 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(); } } }
//***************************************************************************** // // This is the main application entry function. // //***************************************************************************** int main(void) { unsigned int ulTxCount; unsigned int ulRxCount; tRectangle sRect; char pcBuffer[16]; unsigned int i; unsigned char *src, *dest; MMUConfigAndEnable(); // // USB module clock enable // USB0ModuleClkConfig(); // //USB interrupt enable // USBInterruptEnable(); // //LCD back light enable // LCDBackLightEnable(); // UPD Pin setup // // UPDNPinControl(); // //Delay timer setup // DelayTimerSetup(); // //Configures raster to display image // SetUpLCD(); RasterDMAFBConfig(SOC_LCDC_0_REGS, (unsigned int)(g_pucBuffer+PALETTE_OFFSET), (unsigned int)(g_pucBuffer+PALETTE_OFFSET) + sizeof(g_pucBuffer) - 2 - PALETTE_OFFSET, FRAME_BUFFER_0); RasterDMAFBConfig(SOC_LCDC_0_REGS, (unsigned int)(g_pucBuffer+PALETTE_OFFSET), (unsigned int)(g_pucBuffer+PALETTE_OFFSET) + sizeof(g_pucBuffer) - 2 - PALETTE_OFFSET, FRAME_BUFFER_1); src = (unsigned char *) palette_32b; dest = (unsigned char *) (g_pucBuffer+PALETTE_OFFSET); // Copy palette info into buffer for( i = PALETTE_OFFSET; i < (PALETTE_SIZE+PALETTE_OFFSET); i++) { *dest++ = *src++; } GrOffScreen24BPPInit(&g_s35_800x480x24Display, g_pucBuffer, LCD_WIDTH, LCD_HEIGHT); // Initialize a drawing context. GrContextInit(&g_sContext, &g_s35_800x480x24Display); /* enable End of frame interrupt */ RasterEndOfFrameIntEnable(SOC_LCDC_0_REGS); /* enable raster */ RasterEnable(SOC_LCDC_0_REGS); // // Fill the top 15 rows of the screen with blue to create the banner. // sRect.sXMin = 0; sRect.sYMin = 0; sRect.sXMax = GrContextDpyWidthGet(&g_sContext) - 1; sRect.sYMax = 23; GrContextForegroundSet(&g_sContext, ClrDarkBlue); GrRectFill(&g_sContext, &sRect); // // Put a white box around the banner. // GrContextForegroundSet(&g_sContext, ClrWhite); GrRectDraw(&g_sContext, &sRect); // // Put the application name in the middle of the banner. // GrContextFontSet(&g_sContext, &g_sFontCm20); GrStringDrawCentered(&g_sContext, "usb-dev-bulk", -1, GrContextDpyWidthGet(&g_sContext) / 2, 10, 0); // // Show the various static text elements on the color STN display. // GrContextFontSet(&g_sContext, TEXT_FONT); GrStringDraw(&g_sContext, "Tx bytes:", -1, 8, 100, false); GrStringDraw(&g_sContext, "Rx bytes:", -1, 8, 130, false); // // Tell the user what we are up to. // DisplayStatus(&g_sContext, " Configuring USB... "); // // Initialize the transmit and receive buffers. // USBBufferInit((tUSBBuffer *)&g_sTxBuffer); USBBufferInit((tUSBBuffer *)&g_sRxBuffer); // // Pass our device information to the USB library and place the device // on the bus. // USBDBulkInit(0, (tUSBDBulkDevice *)&g_sBulkDevice); // // Wait for initial configuration to complete. // DisplayStatus(&g_sContext, "Waiting for host..."); // // Clear our local byte counters. // ulRxCount = 0; ulTxCount = 0; // // Main application loop. // while(1) { // // Have we been asked to update the status display? // if(g_ulFlags & COMMAND_STATUS_UPDATE) { // // Clear the command flag // g_ulFlags &= ~COMMAND_STATUS_UPDATE; DisplayStatus(&g_sContext, g_pcStatus); } // // Has there been any transmit traffic since we last checked? // if(ulTxCount != g_ulTxCount) { // // Take a snapshot of the latest transmit count. // ulTxCount = g_ulTxCount; // // Update the display of bytes transmitted by the UART. // usnprintf(pcBuffer, 16, " %d ", ulTxCount); GrStringDraw(&g_sContext, pcBuffer, -1, 120, 100, true); } // // Has there been any receive traffic since we last checked? // if(ulRxCount != g_ulRxCount) { // // Take a snapshot of the latest receive count. // ulRxCount = g_ulRxCount; // // Update the display of bytes received by the UART. // usnprintf(pcBuffer, 16, " %d ", ulRxCount); GrStringDraw(&g_sContext, pcBuffer, -1, 120, 130, true); } } }
int main(void) { volatile unsigned int i = 0; volatile unsigned int initFlg = 1; #ifdef ARM_SUPPORTED /* Setup the MMU and do necessary MMU configurations. */ MMUConfigAndEnable(); #endif #ifdef CACHE_SUPPORTED /* Enable all levels of CACHE. */ CacheEnable(CACHE_ALL); #endif /* Initialize UART. */ UARTStdioInit(); /* Configure the EDMA clocks. */ EDMAModuleClkConfig(); /* Configure EDMA to service the MMCSD events. */ MMCSDEdmaInit(); /* Perform pin-mux for MMCSD pins. */ MMCSDPinMuxSetup(); /* Enable module clock for MMCSD. */ MMCSDModuleClkConfig(); DelayTimerSetup(); #ifdef MMCSD_PERF PerfTimerSetup(); #endif /* Basic controller initializations */ MMCSDControllerSetup(); /* Initialize the MMCSD controller */ MMCSDCtrlInit(&ctrlInfo); MMCSDIntEnable(&ctrlInfo); #if 0 UARTPuts("Test timer:wait 5s\r\n", -1); delay(5000); UARTPuts("Test timer:Done\r\n", -1); #endif for(;;) { if((MMCSDCardPresent(&ctrlInfo)) == 1) { #if DEBUG_PRINT UARTPuts("Card is present\r\n", -1); #endif if(initFlg) { UARTPuts("Call MMCSDFsMount\r\n", -1); MMCSDFsMount(0, &sdCard); UARTPuts("Back MMCSDFsMount\r\n", -1); initFlg = 0; UARTPuts("Call Cmd_help\r\n", -1); Cmd_help(0, NULL); } MMCSDFsProcessCmdLine(); } else { UARTPuts("Card is not present\r\n", -1); delay(1000); // delay(1); i = (i + 1) & 0xFFF; if(i == 1) { UARTPuts("Please insert the card \r\n", -1); } if(initFlg != 1) { /* Reinitialize all the state variables */ dmaIsRunning = 0; xferCompFlag = 0; dataTimeout = 0; dataCRCError = 0; cmdCompFlag = 0; cmdTimeout = 0; /* Initialize the MMCSD controller */ MMCSDCtrlInit(&ctrlInfo); MMCSDIntEnable(&ctrlInfo); } initFlg = 1; } } }