Conversation
dpgeorge
left a comment
There was a problem hiding this comment.
Thanks!
I assume you tested the read-poll function?
There was a problem hiding this comment.
To make it robust, I think this function should initialise all the static variables (current_read_buffer, etc).
|
Added initialization of static variables to Init function. |
|
Added SNAK/CNAK mechanism for flow control. |
There was a problem hiding this comment.
Please add a short comment saying what this code does.
There was a problem hiding this comment.
Add short comment here as well.
There was a problem hiding this comment.
These shouldn't be exposed. Instead one should use the hid_out_ep variable defined in usbdev/class/src/usbd_cdc_msc_hid.c. Two options to make it work: 1) make a function in usbd_cdc_msc_hid.c to get the hid out EP (eg USBD_HID_GetOutEP); 2) add functions to usbd_cdc_msc_hid.c to set the SNAK/CNAK bits and call those functions from usbd_hid_interface.c. Probably the latter is cleaner.
There was a problem hiding this comment.
I used the approach used in usbd_cdc_interface (exposing defines via .h file), but apporach 2) makes much more sense. Will update the PR.
|
Reworked last commit according to comments |
|
Great, thank you! Rebased and merged, see 0883a7e |
I found a bug in the USB HID Receive code that resulted in first read packet always containing no data just zeroes. All subsequent reads were OK.
This patch fixes the issue by adding Init method to HID_fops, which sets the buffer correctly even for the first packet.
Also there is a SNAK/CNAK mechanism that implements flow control in case user does not call recv method often enough (it tells host side to stop sending more data).