I am looking for an example or documentation on creating a custom USB device class with the MDK Pro Pack Middleware v6.1.0 for the NXP LPC43xx series processor. When I look at the documentation accessible by double clicking on the USB component class icon and navigate to "USB Device->USB Device Examples->Custom USB Device" I am greeted with a helpful "More information coming soon" page.
Furthermore the documentation on the Device Class Functions is not very helpful or thorough in providing any help in designing a custom device using the MDK-Pro Middleware's USB library.
At the moment the device will show up in windows but a USB Device Not Recognized balloon pops up. On sniffing the bus traffic I see that the device never responds to a GET_DESCRIPTOR Setup packet request. Where does this need to get implemented? I thought that using the wizards associated with USBD_Config_CustomClass.h and USBD_Config.c would configure the proper information and then let the library handle descriptor requests. Unfortunately there is NO Documentation to tell me if that is correct or not.
Any documentation or example code would be much appreciated!
How about trying with latest Middleware 6.2.0 ?
I am unaware of how to do that, my packs and ARM-MDK are all up to the latest version available. The following two links show the ARM-MDK version and the PACK versions.
puu.sh/.../f208d1a6e6.jpg puu.sh/.../31d3f5ce41.png
Scratch that, my Pack installer was having some issues updating. That said the USBD_CustomClass0_Endpoint1_Event is never called during execution and none of the functions in the USBD_User_Custom_Class_0.c file get called again after initial enumeration.
Hi,
here is example of two functions needed to implement for Endpoint 1 Bulk IN and Endpoint 1 Bulk OUT communication on Custom Class.
void USBD_CustomClass0_EventEndpointStart (uint8_t ep_addr) { // Start communication on Endpoint if (!(ep_addr & 0x80)) { // If Endpoint type is OUT switch (ep_addr & 0x0F) { case 1: USBD_EndpointRead(0, USB_ENDPOINT_OUT(1), class0_bulk_out_buf, 64); break; default: break; } } }
so when start is called, reception on Bulk OUT is started with USBD_EndpointRead
void USBD_CustomClass0_Endpoint1_Event (uint32_t event) { // Handle Endpoint 1 events uint32_t i; switch (event) { case ARM_USBD_EVENT_OUT: class0_bulk_len = USBD_EndpointReadGetResult(0, USB_ENDPOINT_OUT(1)); USBD_EndpointRead(0, USB_ENDPOINT_OUT(1), class0_bulk_out_buf, 64); switch (class0_bulk_out_buf[0]) { case 0: for (i = 1; i < class0_bulk_len; i++) class0_bulk_in_buf[i] = (class0_bulk_out_buf[i] << 4); USBD_EndpointWrite(0, USB_ENDPOINT_IN(1), class0_bulk_in_buf, class0_bulk_len); break; } break; case ARM_USBD_EVENT_IN: break; default: break; } };
in this function case ARM_USBD_EVENT_OUT is entered when data was received on Bulk OUT Endpoint, number of received bytes is read with USBD_EndpointReadGetResult then new reception is started on Bulk OUT Endpoint with USBD_EndpointRead and response is returned on Bulk IN Endpoint with USBD_EndpointWrite function
Wild,
Starting from a basic project and adding the USB class with the stuff written in your reply I was still unable to get the USBD_CustomClass0_Endpoint1_Event call back. I have uploaded a simple project for the MCB4357 board which exhibits the problem. When I build a similar project for the LPC1549 chip I do receive callbacks. Is there something different that I need to be doing with the LPC4357? The USB stack does operate and the device does enumerate with the LPC4357, but as I have said when the data is transferred to the chip I never get a callback.
www.filedropper.com/blinkyulp (sorry the link looks very questionable but it is legitimate)
Can you first try the original HID and Mass Storage example to see that they work and then build on one of those.
Can you please share what was the problem/solution to help people in future having similar problems?
The problem it seemed boiled down to the third parameter of the USBD_EndpointRead call matching the endpoint size so:
// High Speed Devices USBD_EndpointRead(0, USB_ENDPOINT_OUT(1), class0_bulk_out_buf, 512); // Full Speed Device USBD_EndpointRead(0, USB_ENDPOINT_OUT(1), class0_bulk_out_buf, 64);
Thanks for sharing.