This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

lpc1768 no USB Host component?

Somewhat related to:

https://community.arm.com/developer/tools-software/tools/f/keil-forum/34159/cmsis-driver-usb-host-is-missing-error

I've managed to successfully connect to a PC USB host when running the lpc as a USB device. Now I need it to be a USB host (CDC/VirtualCOM) for another mcu (dspic30f6013a). I've looked at the samples that come with (are downloadable through) keil and it seems there isn't a CDC USB host component.

Mass storage USB host sample components:

My current project is missing the USB host component:

Do you see any conflicting components that might prevent the host component from being used? 

The lpc can be used as both a usb host and a device, right?

https://community.arm.com/developer/tools-software/tools/f/keil-forum/39003/usb-host-and-device-at-the-same-time-lpc2478

so that shouldn't be the reason. 

Given that the project is somewhat old (2013) is it possible for the components list not to have been updated and as such is missing the USB host? I remember reading that the host component was not always available. It seems uinlikely ... 

The lpc needs to connect to the dspic30f601a and read a byte stream similar to:

__NO_RETURN void app_main (void *arg);

/*------------------------------------------------------------------------------
 *        Application
 *----------------------------------------------------------------------------*/

__NO_RETURN void app_main (void *arg) {
  usbStatus usb_status;                 // USB status
  usbStatus hid_status;                 // HID status
  int       status;
  int       ch;                         // Character
  uint8_t   con = 0U;                   // Connection status of keyboard

  (void)arg;

  status = stdout_init ();              // Initialize retargeted stdout
  if (status != 0) {
    for (;;) {}                         // Handle stdout init failure
  }

  usb_status = USBH_Initialize (0U);    // Initialize USB Host 0
  if (usb_status != usbOK) {
    for (;;) {}                         // Handle USB Host 0 init failure
  }

  for (;;) {
    hid_status = USBH_HID_GetDeviceStatus (0U); // Get HID device status
    if (hid_status == usbOK) {
      if (con == 0U) {                  // If keyboard was not connected previously
        con = 1U;                       // Keyboard got connected
        printf ("Keyboard connected!\n");
      }
    } else {
      if (con == 1U) {                  // If keyboard was connected previously
        con = 0U;                       // Keyboard got disconnected
        printf ("\nKeyboard disconnected!\n");
      }
    }
    if (con != 0U) {                    // If keyboard is active
      ch = USBH_HID_GetKeyboardKey (0U); // Get pressed key
      if (ch != -1) {                   // If valid key value
        if ((ch & 0x10000) != 0) {      // Handle non-ASCII translated keys (Keypad 0 .. 9)
                                        // Bit  16:    non-ASCII bit (0 = ASCII, 1 = not ASCII)
                                        // Bits 15..8: modifiers (SHIFT, ALT, CTRL, GUI)
                                        // Bits  7..0: ASCII or HID key Usage ID if not ASCII
                                        // HID Usage ID values can be found in following link:
                                        // http://www.usb.org/developers/hidpage/Hut1_12v2.pdf
          ch &= 0xFF;                   // Remove non-ASCII bit and modifiers
          if ((ch>=0x59)&&(ch<=0x61)) { // Keypad 1 .. 9 key convert to
            ch = (ch - 0x59) + '1';     // ASCII  1 .. 9
          } else if (ch == 0x62) {      // Keypad 0 key convert to
            ch = '0';                   // ASCII  0
          } else {                      // If not Keypad 0 .. 9
            ch = -1;                    // invalidate the key
          }
        }
        if ((ch > 0) && (ch < 128)) {   // Output ASCII 0 .. 127 range
          putchar (ch);
          fflush (stdout);
        }
      }
    }
    osDelay(10U);
  }
}