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); } }
Don't NXP provide anything?
https://www.nxp.com/products/processors-and-microcontrollers/arm-microcontrollers/general-purpose-mcus/lpc1700-cortex-m3/512kb-flash-64kb-sram-ethernet-usb-lqfp100-package:LPC1768FBD100?tab=Design_Tools_Tab
They do. The problem is that keil cannot see the USB component when I try to add it to an existing project. The samples that make use of it compile. I'll also try to create a new project and see if it can be added to it.
Ok! Figured it out. Pick MDK-Pro instead of plus from the component manager! That sucked.