diff options
| author | hathach <[email protected]> | 2019-05-29 16:55:15 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2019-05-29 16:55:15 +0700 |
| commit | a0307bafdaa97628bb5e4d5e476db54cbc028d33 (patch) | |
| tree | bb2ff6a94e5229fffd1725c9e2e905ce333f110c /src/class/hid | |
| parent | dfdae7a4d28a7c45535e9d709eade45c1a88a9f2 (diff) | |
added usbd_edpt_xfer/usbd_edpt_busy to replace dcd_edpt_transfer/dcd_edpt_busy()
- improve fifo write/read_n with only one lock
- use usbd_edpt_xfer/usbd_edpt_busy for hid/cdc/msc class driver
- replace cdc read's pending_read_from_host by usbd_edpt_busy()
Diffstat (limited to 'src/class/hid')
| -rw-r--r-- | src/class/hid/hid_device.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/class/hid/hid_device.c b/src/class/hid/hid_device.c index aea16efc1..d3f59ed62 100644 --- a/src/class/hid/hid_device.c +++ b/src/class/hid/hid_device.c @@ -73,28 +73,31 @@ bool tud_hid_ready(void) {
uint8_t itf = 0;
uint8_t const ep_in = _hidd_itf[itf].ep_in;
- return tud_ready() && (ep_in != 0) && !dcd_edpt_busy(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() && (len <= CFG_TUD_HID_BUFSIZE) );
+ TU_VERIFY( tud_hid_ready() );
uint8_t itf = 0;
hidd_interface_t * p_hid = &_hidd_itf[itf];
- // If report id = 0, skip ID field
if (report_id)
{
+ len = tu_min8(len, CFG_TUD_HID_BUFSIZE-1);
+
p_hid->epin_buf[0] = report_id;
memcpy(p_hid->epin_buf+1, report, len);
len++;
}else
{
+ // If report id = 0, skip ID field
+ len = tu_min8(len, CFG_TUD_HID_BUFSIZE);
memcpy(p_hid->epin_buf, report, len);
}
- return dcd_edpt_xfer(TUD_OPT_RHPORT, p_hid->ep_in, p_hid->epin_buf, len);
+ return usbd_edpt_xfer(TUD_OPT_RHPORT, p_hid->ep_in, p_hid->epin_buf, len);
}
bool tud_hid_boot_mode(void)
@@ -180,7 +183,7 @@ bool hidd_open(uint8_t rhport, tusb_desc_interface_t const * desc_itf, uint16_t *p_len = sizeof(tusb_desc_interface_t) + sizeof(tusb_hid_descriptor_hid_t) + desc_itf->bNumEndpoints*sizeof(tusb_desc_endpoint_t);
// Prepare for output endpoint
- if (p_hid->ep_out) TU_ASSERT(dcd_edpt_xfer(rhport, p_hid->ep_out, p_hid->epout_buf, sizeof(p_hid->epout_buf)));
+ if (p_hid->ep_out) TU_ASSERT(usbd_edpt_xfer(rhport, p_hid->ep_out, p_hid->epout_buf, sizeof(p_hid->epout_buf)));
return true;
}
@@ -303,7 +306,7 @@ bool hidd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_ if (ep_addr == p_hid->ep_out)
{
tud_hid_set_report_cb(0, HID_REPORT_TYPE_INVALID, p_hid->epout_buf, xferred_bytes);
- TU_ASSERT(dcd_edpt_xfer(rhport, p_hid->ep_out, p_hid->epout_buf, sizeof(p_hid->epout_buf)));
+ TU_ASSERT(usbd_edpt_xfer(rhport, p_hid->ep_out, p_hid->epout_buf, sizeof(p_hid->epout_buf)));
}
return true;
|
