//***************************************************************************** // // main routine. // //***************************************************************************** int main(void) { tLPMFeature sLPMFeature; // // Run from the PLL at 120 MHz. // g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000); // // Configure the device pins. // PinoutSet(); // // Configure the UART. // UARTStdioConfig(0, 115200, g_ui32SysClock); // // Initialize the display driver. // Kentec320x240x16_SSD2119Init(g_ui32SysClock); // // Initialize the graphics context. // GrContextInit(&g_sContext, &g_sKentec320x240x16_SSD2119); // // Draw the application frame. // FrameDraw(&g_sContext, "usb-otg-mouse"); // // Configure USB for OTG operation. // USBOTGInit(g_ui32SysClock, ModeCallback); sLPMFeature.ui32HIRD = 500; sLPMFeature.ui32Features = USBLIB_FEATURE_LPM_EN | USBLIB_FEATURE_LPM_RMT_WAKE; USBHCDFeatureSet(0, USBLIB_FEATURE_LPM, &sLPMFeature); // // Initialize the host stack. // HostInit(); // // Initialize the device stack. // DeviceInit(); // // Initialize the USB controller for dual mode operation with a 2ms polling // rate. // USBOTGModeInit(0, 2000, g_pui8HCDPool, HCD_MEMORY_SIZE); // // Set the new state so that the screen updates on the first // pass. // g_ui32NewState = 1; // // Loop forever. // while(1) { // // Tell the OTG library code how much time has passed in milliseconds // since the last call. // USBOTGMain(GetTickms()); // // Handle deferred state change. // if(g_ui32NewState) { g_ui32NewState =0; // // Update the status area of the screen. // ClearMainWindow(); // // Update the status bar with the new mode. // switch(g_iCurrentMode) { case eUSBModeHost: { UpdateStatus("Host Mode", 0, true); break; } case eUSBModeDevice: { UpdateStatus("Device Mode", 0, true); break; } case eUSBModeNone: { UpdateStatus("Idle Mode\n", 0, true); break; } default: { break; } } } if(g_iCurrentMode == eUSBModeDevice) { DeviceMain(); } else if(g_iCurrentMode == eUSBModeHost) { HostMain(); } } }
//***************************************************************************** // // Capture one sequence of DEVCTL register values during a session request. // //***************************************************************************** int main(void) { tRectangle sRect; // // Set the clocking to run directly from the crystal. // ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); // // Set the pinout appropriately for this board. // PinoutSet(); // // Initialize the display driver. // Kitronix320x240x16_SSD2119Init(); // // Initialize the graphics context. // GrContextInit(&g_sContext, &g_sKitronix320x240x16_SSD2119); // // 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 = 14; 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_pFontFixed6x8); GrStringDrawCentered(&g_sContext, "OTG Example", -1, GrContextDpyWidthGet(&g_sContext) / 2, 7, 0); #ifdef DEBUG // // Configure the relevant pins such that UART0 owns them. // ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); // // Open the UART for I/O // UARTStdioInit(0); #endif // // Determine the number of SysCtlDelay loops required to delay 1mS. // g_ulClockMS = ROM_SysCtlClockGet() / (3 * 1000); // // Configure the required pins for USB operation. // ROM_GPIOPinTypeUSBDigital(GPIO_PORTA_BASE, GPIO_PIN_6 | GPIO_PIN_7); ROM_GPIOPinTypeUSBDigital(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1); // // Initialize the USB stack mode and pass in a mode callback. // USBStackModeSet(0, USB_MODE_OTG, ModeCallback); // // Initialize the host stack. // HostInit(); // // Initialize the device stack. // DeviceInit(); // // Initialize the USB controller for dual mode operation with a 2ms polling // rate. // USBOTGModeInit(0, 2000, g_pHCDPool, HCD_MEMORY_SIZE); // // Set the new state so that the screen updates on the first // pass. // g_ulNewState = 1; // // Loop forever. // while(1) { // // Tell the OTG library code how much time has passed in milliseconds // since the last call. // USBOTGMain(GetTickms()); // // Handle deferred state change. // if(g_ulNewState) { g_ulNewState =0; // // Update the status area of the screen. // ClearMainWindow(); // // Update the status bar with the new mode. // switch(g_eCurrentUSBMode) { case USB_MODE_HOST: { UpdateStatus("Host Mode", 0, true); break; } case USB_MODE_DEVICE: { UpdateStatus("Device Mode", 0, true); break; } case USB_MODE_NONE: { UpdateStatus("Idle Mode", 0, true); break; } default: { break; } } } if(g_eCurrentUSBMode == USB_MODE_DEVICE) { DeviceMain(); } else if(g_eCurrentUSBMode == USB_MODE_HOST) { HostMain(); } } }