diff options
| author | Ha Thach <[email protected]> | 2020-09-14 23:56:21 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-09-14 23:56:21 +0700 |
| commit | 745c15d5b5b7fed5fd8e89cc95b76a56af673a60 (patch) | |
| tree | 80b9a73196c938cdab922849ae835774dce8802d /src/class/hid | |
| parent | 3d393df2d0647a4482f81253574446186c9d99e0 (diff) | |
| parent | 9c0d15fc43818282b6a92432e675dd214e51735e (diff) | |
Merge pull request #508 from hathach/fix-edpt-race
Fix edpt xfer race condition
Diffstat (limited to 'src/class/hid')
| -rw-r--r-- | src/class/hid/hid_device.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/class/hid/hid_device.c b/src/class/hid/hid_device.c index c46fc591a..10267d734 100644 --- a/src/class/hid/hid_device.c +++ b/src/class/hid/hid_device.c @@ -72,18 +72,21 @@ static inline hidd_interface_t* get_interface_by_itfnum(uint8_t itf_num) //--------------------------------------------------------------------+ bool tud_hid_ready(void) { - uint8_t itf = 0; + uint8_t const itf = 0; uint8_t const ep_in = _hidd_itf[itf].ep_in; - return tud_ready() && (ep_in != 0) && usbd_edpt_ready(TUD_OPT_RHPORT, ep_in); + return tud_ready() && (ep_in != 0) && !usbd_edpt_busy(TUD_OPT_RHPORT, ep_in); } bool tud_hid_report(uint8_t report_id, void const* report, uint8_t len) { - TU_VERIFY( tud_hid_ready() ); - - uint8_t itf = 0; + uint8_t const rhport = 0; + uint8_t const itf = 0; hidd_interface_t * p_hid = &_hidd_itf[itf]; + // claim endpoint + TU_VERIFY( usbd_edpt_claim(rhport, p_hid->ep_in) ); + + // prepare data if (report_id) { len = tu_min8(len, CFG_TUD_HID_EP_BUFSIZE-1); |
