//***************************************************************************** // //! This function sets one of the \b USBLIB_FEATURE_ requests. //! //! \param ui32Index is the index of the USB controller to access. //! \param ui32Feature is one of the \b USBLIB_FEATURE_ defines. //! \param pvFeature is a pointer to the data for the \b USBLIB_FEATURE //! request. //! //! This function sends the requested feature request to the USB library. //! Not all features are supported by all devices so see the documentation //! for the \b USBLIB_FEATURE_ to determine if the feature is supported. //! //! \return Returns \b true if the feature was set and \b false if the feature //! is not supported or could not be changed to the requested value. // //***************************************************************************** bool USBOTGFeatureSet(uint32_t ui32Index, uint32_t ui32Feature, void *pvFeature) { bool bRetCode; bRetCode = true; // // Pass this on to the host and device and indicate false if // either fails. // if(USBDCDFeatureSet(ui32Index, ui32Feature, pvFeature) == false) { bRetCode = false; } if(USBHCDFeatureSet(ui32Index, ui32Feature, pvFeature) == false) { bRetCode = false; } return(bRetCode); }
//***************************************************************************** // // The main application loop. // //***************************************************************************** int main(void) { uint32_t ui32SysClock, ui32PLLRate; #ifdef USE_ULPI uint32_t ui32Setting; #endif // // Set the application to run at 120 MHz with a PLL frequency of 480 MHz. // ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000); // // Set the part pin out appropriately for this device. // PinoutSet(); #ifdef USE_ULPI // // Switch the USB ULPI Pins over. // USBULPIPinoutSet(); // // Enable USB ULPI with high speed support. // ui32Setting = USBLIB_FEATURE_ULPI_HS; USBOTGFeatureSet(0, USBLIB_FEATURE_USBULPI, &ui32Setting); // // Setting the PLL frequency to zero tells the USB library to use the // external USB clock. // ui32PLLRate = 0; #else // // Save the PLL rate used by this application. // ui32PLLRate = 480000000; #endif // // Initialize the connection status. // g_sStatus.bConnected = false; // // Initially there are no modifiers set. // g_sStatus.ui32Modifiers = 0; // // Enable Clocking to the USB controller. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0); // // Enable Interrupts // ROM_IntMasterEnable(); // // Initialize the USB stack mode and pass in a mode callback. // USBStackModeSet(0, eUSBModeHost, 0); // // Register the host class drivers. // USBHCDRegisterDrivers(0, g_ppHostClassDrivers, g_ui32NumHostClassDrivers); // // Open an instance of the keyboard driver. The keyboard does not need // to be present at this time, this just save a place for it and allows // the applications to be notified when a keyboard is present. // g_psKeyboard = USBHKeyboardOpen(KeyboardCallback, 0, 0); // // Initialize the power configuration. This sets the power enable signal // to be active high and does not enable the power fault. // USBHCDPowerConfigInit(0, USBHCD_VBUS_AUTO_HIGH | USBHCD_VBUS_FILTER); // // Tell the USB library the CPU clock and the PLL frequency. This is a // new requirement for TM4C129 devices. // USBHCDFeatureSet(0, USBLIB_FEATURE_CPUCLK, &ui32SysClock); USBHCDFeatureSet(0, USBLIB_FEATURE_USBPLL, &ui32PLLRate); // // Initialize the USB controller for Host mode. // USBHCDInit(0, g_pui8HCDPool, sizeof(g_pui8HCDPool)); // // Initialize the GUI elements. // UIInit(ui32SysClock); // // The main loop for the application. // while(1) { // // Call the USB library to let non-interrupt code run. // USBHCDMain(); // // Call the keyboard and mass storage main routines. // KeyboardMain(); } }
//***************************************************************************** // // 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(); } } }