/* * ======== EK_TM4C123GXL_initUSB ======== * This function just turns on the USB */ void EK_TM4C123GXL_initUSB(EK_TM4C123GXL_USBMode usbMode) { /* Enable the USB peripheral and PLL */ MAP_SysCtlPeripheralEnable(INEEDMD_USB_SYSCTL_PERIPH); MAP_SysCtlUSBPLLEnable(); EK_TM4C123GXL_initDMA(); /* Setup pins for USB operation */ GPIOPinTypeUSBAnalog(INEEDMD_USB_GPIO_PORT, INEEDMD_USBDP_PIN | INEEDMD_USBDM_PIN); if (usbMode == EK_TM4C123GXL_USBHOST) { System_abort("USB host not supported\n"); } }
//***************************************************************************** // //! Initializes the USB controller for OTG mode operation. //! //! \param ui32Index specifies the USB controller that is to be initialized for //! OTG mode operation. //! \param ui32PollingRate is the rate in milliseconds to poll the controller //! for changes in mode. //! \param pvPool is a pointer to the data to use as a memory pool for this //! controller. //! \param ui32PoolSize is the size in bytes of the buffer passed in as //! \e pvPool. //! //! This function initializes the USB controller hardware into a state //! suitable for OTG mode operation. Applications must use this function to //! ensure that the controller is in a neutral state and able to receive //! appropriate interrupts before host or device mode is chosen by OTG //! negotiation. The \e ui32PollingRate parameter is used to set the rate at //! which the USB library will poll the controller to determine the mode. This //! has the most effect on how quickly the USB library will detect changes when //! going to host mode. The parameters \e pvPool and \e ui32PoolSize are //! passed on to the USB host library functions to provide memory for the USB //! library when it is acting as a host. Any device and host initialization //! should have been called before calling this function to prevent the USB //! library from attempting to run in device or host mode before the USB //! library is fully configured. //! //! \return None. // //***************************************************************************** void USBOTGModeInit(uint32_t ui32Index, uint32_t ui32PollingRate, void *pvPool, uint32_t ui32PoolSize) { // // We only support a single USB controller. // ASSERT(ui32Index == 0); // // This should never be called if not in OTG mode. // ASSERT(g_iUSBMode == eUSBModeOTG); // // Force OTG mode in all cases since anything else is invalid, but a DEBUG // build will still ASSERT above if this value is incorrect. // g_iUSBMode = eUSBModeOTG; // // Remember that we have not yet determined whether we are device or // host. // g_iDualMode = eUSBModeNone; // // Set the default polling rate. // g_ui32PollRate = ui32PollingRate; // // Enable the USB controller. // MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0); // // Turn on USB Phy clock. // MAP_SysCtlUSBPLLEnable(); // // Initialize the host controller stack. // USBHCDInit(ui32Index, pvPool, ui32PoolSize); // // Configure the End point 0. // USBHostEndpointConfig(USB0_BASE, USB_EP_0, 64, 0, 0, (USB_EP_MODE_CTRL | USB_EP_SPEED_FULL | USB_EP_HOST_OUT)); // // Enable control interrupts. // MAP_USBIntEnableControl(USB0_BASE, USB_INTCTRL_RESET | USB_INTCTRL_DISCONNECT | USB_INTCTRL_SESSION | USB_INTCTRL_BABBLE | USB_INTCTRL_CONNECT | USB_INTCTRL_RESUME | USB_INTCTRL_SUSPEND | USB_INTCTRL_VBUS_ERR | USB_INTCTRL_MODE_DETECT | USB_INTCTRL_SOF); // // Make sure the mode OTG mode and not forced device or host. // USBOTGMode(USB0_BASE); // // Enable all endpoint interrupts. // MAP_USBIntEnableEndpoint(USB0_BASE, USB_INTEP_ALL); // // Initialize the power configuration. // USBHCDPowerConfigSet(ui32Index, USBHCDPowerConfigGet(ui32Index)); // // If power enable is automatic then then USBHostPwrEnable() has to be // called to allow the USB controller to control the power enable pin. // if(USBHCDPowerAutomatic(ui32Index)) { // // This will not turn on power but instead will allow the USB // controller to turn on power when needed. // USBHostPwrEnable(USB0_BASE); } // // Enable the USB interrupt. // if(CLASS_IS_TM4C129) { OS_INT_ENABLE(INT_USB0_TM4C129); } else { OS_INT_ENABLE(INT_USB0_TM4C123); } }