2022-05-25 04:02 AM
I have a custom board with STM32F302C8T6. I generated a custom HID project by CubeMX(STM32Cube_FW_F3_V1.11.3), and found that only two packets could be received if "USBD_CUSTOM_HID_SendReport" is used to send data back to host.
Here are some more details:
1. 0.zip is the original code generated by CubeMX. 305dea60e57af8b78b4e49039b6e2bd1fcf512cc.zip is the modified version. You can compare to see the difference. Also, you could see diff.diff to difference.
2. In windows10 x64, I use a modified version of hid_test to test custom HID read/write. Please see "test.c" for details.
3. In CUSTOM_HID_OutEvent_FS, if "USBD_CUSTOM_HID_SendReport" is called, the first two hid_write and hid_read_timeout will succeed. The following hid_write will fail. Also CUSTOM_HID_OutEvent_FS will be called only twice.
4. If "USBD_CUSTOM_HID_SendReport" is not called, hid_write from host will always succeed (and CUSTOM_HID_OutEvent_FS will be called successfully also).
5. So it looks that if USBD_CUSTOM_HID_SendReport is called, USB will be stuck.
6. I generated a similar project for STM32F103C8T6, everything will be fine, regardless of whether "USBD_CUSTOM_HID_SendReport" is called.
Please help to figure out the issue. Thanks.
2022-05-25 04:17 AM
I can see USTS c0000004 when two packets are sent and received.
2022-05-25 10:58 PM
Currently "USBD_LL_PrepareReceive" is called in "USBD_CUSTOM_HID_DataOut". I think it should be called in "USBD_CUSTOM_HID_DataIn" if data needs to be sent "USBD_CUSTOM_HID_SendReport" called in "CUSTOM_HID_OutEvent_FS".