I've made all the necessary hardware modifications to allow host functionality on the DEVICE micro usb port of the Launchpad.
- R25 and R29 0-ohm resistors are populated
- H18 is shorted to H19, to supply +5v to VBUS.
I've been modifying the usb_host_msc example written for the dk-tm4c123g board. Since I do not have an LCD for displaying the file structure, I've muted all the calls to the graphics library. At this stage, I simply want the host to recognize the usb flash drive. The 4gb flash drive I'm using has been formatted to fat32 and it is connected via a USB-OTG cable. I know it's receiving enough power because I checked the voltage on VBUS and the flash drive has an LED that is glowing. However, there seems to be no information being exchanged which would've caused the LED to blink.
Upon stepping through the program, I can see that it is stuck STATE_NO_DEVICE of the state machine.
Code for the main routine is attached, I would've pasted it here but I though it might be a text file might improve readability.
//--------------------------------------------------------------------------- // main() //--------------------------------------------------------------------------- void main(void) { uint32_t ui32DriveTimeout, ui32SysClock, ui32PLLRate; // // Set the clocking to run from the PLL at 50MHz // SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); // // Configure the device pins. // // Enable rgb LED SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3); // Enable USB SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0); SysCtlUSBPLLEnable(); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); GPIOPinTypeUSBAnalog(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1); //id and vbus SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); GPIOPinTypeUSBAnalog(GPIO_PORTD_BASE, GPIO_PIN_4 | GPIO_PIN_5); //dp and dm // // Configure SysTick for a 100Hz interrupt. // SysTickPeriodSet(SysCtlClockGet() / TICKS_PER_SECOND); SysTickEnable(); SysTickIntEnable(); // // Enable the uDMA controller and set up the control table base. // The uDMA controller is used by the USB library. // SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA); uDMAEnable(); uDMAControlBaseSet(g_psDMAControlTable); // // Initially wait for device connection. // g_eState = STATE_NO_DEVICE; // // Initialize the USB stack for host mode only. // USBStackModeSet(0, eUSBModeHost, 0); // // Register the host class drivers. // USBHCDRegisterDrivers(0, g_ppHostClassDrivers, g_ui32NumHostClassDrivers); // // Open an instance of the mass storage class driver. // g_psMSCInstance = USBHMSCDriveOpen(0, MSCCallback); // // Initialize the drive timeout. // ui32DriveTimeout = USBMSC_DRIVE_RETRY; // // Initialize the USB stack for host mode. // USBStackModeSet(0, eUSBModeHost, 0); // // Register the host class drivers. // USBHCDRegisterDrivers(0, g_ppHostClassDrivers, g_ui32NumHostClassDrivers); // // Open an instance of the mass storage class driver. // g_psMSCInstance = USBHMSCDriveOpen(0, MSCCallback); // // Initialize the drive timeout. // ui32DriveTimeout = USBMSC_DRIVE_RETRY; // // 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 operation. // USBHCDInit(0, g_pHCDPool, HCD_MEMORY_SIZE); // // Initialize the file system. // FileInit(); // // Enter an (almost) infinite loop for reading and processing commands from // the user. // while(1) { // // Call the USB stack to keep it running. // USBHCDMain(); switch(g_eState) { case STATE_DEVICE_ENUM: { // // Take it easy on the Mass storage device if it is slow to // start up after connecting. // if(USBHMSCDriveReady(g_psMSCInstance) != 0) { // // Wait about 500ms before attempting to check if the // device is ready again. // SysCtlDelay(ui32SysClock / (3 * 2)); // // Decrement the retry count. // ui32DriveTimeout--; // // If the timeout is hit then go to the // STATE_TIMEOUT_DEVICE state. // if(ui32DriveTimeout == 0) { g_eState = STATE_TIMEOUT_DEVICE; } break; } // // Getting here means the device is ready. // Reset the CWD to the root directory. // g_cCwdBuf[0] = '/'; g_cCwdBuf[1] = 0; // // Set the Device Present flag. // g_ui32Flags = FLAGS_DEVICE_PRESENT; break; } // // If there is no device then just wait for one. // case STATE_NO_DEVICE: { if(g_ui32Flags == FLAGS_DEVICE_PRESENT) { // // Clear the Device Present flag. // g_ui32Flags &= ~FLAGS_DEVICE_PRESENT; } break; } // // An unknown device was connected. // case STATE_UNKNOWN_DEVICE: { // // If this is a new device then change the status. // if((g_ui32Flags & FLAGS_DEVICE_PRESENT) == 0) { //indicate unknown device is present } // // Set the Device Present flag. // g_ui32Flags = FLAGS_DEVICE_PRESENT; break; } // // The connected mass storage device is not reporting ready. // case STATE_TIMEOUT_DEVICE: { // // If this is the first time in this state then print a // message. // if((g_ui32Flags & FLAGS_DEVICE_PRESENT) == 0) { //indicate unknown device is present } // // Set the Device Present flag. // g_ui32Flags = FLAGS_DEVICE_PRESENT; break; } // // Something has caused a power fault. // case STATE_POWER_FAULT: { break; } default: { break; } } } }