Hello, I am new to RL and am trying to implement a USB custom class for device operation. Now I have a question about how to implement Bulk-OUT handling codes.
My project is Cortex-M4 (STM32F407) using USB FS device function. I have added usbd_cls.c to my project as well as adding USB_CM3.lib and other device specific drivers and configs. I can now override device descriptor and config descriptor, and any other class request impl. But I can't see how to implement Bulk-Out handler that hooks for any in-coming Bulk-Out packets. The template usbd_cls.c looks like having only request handler's template but not such skeleton for Bulk-Out handling.
Is thre any good example code regarding this? My KEIL version is 4.7 PRO using RTX and RL for USB.
Thanks, Makoto
Tsuneo-san,
Thank you for the advice! Adding an EP1's handler task did solve the issue, I much appreciate your advice!
I added the task handler for EP address 0x01 (BULK-OUT) like this, and now Bulk-OUT handling works perfectly:
__task void USBD_RTX_EndPoint1 (void) { OS_RESULT result; static uint8_t bulkout_data[256]; uint32_t cnt; for(;;) { result = os_evt_wait_or( USBD_EVT_OUT, 0xffff); if( result == OS_R_EVT) { cnt = USBD_ReadEP( 0x01, bulkout_data); if( cnt > 0) { ... } }
// never comes here os_tsk_delete_self (); }
By the way, to make work USB_ReadEP(), I had to modify #define USBD_EP_NUM to a specific value for the USB device of class. Actually my device is USBTMC (Test & Measurement class) so I needed to manually define USBD_EP_NUM to 3 in the usb_config_FS.c (otherwise left as 0.) However the Wizard UI for this config does not provide a chance to set USBD_EP_NUM when selecting custom class. I dont know why...
Thanks Makoto