diff options
| author | Reinhard Panhuber <[email protected]> | 2021-01-04 12:02:08 +0100 |
|---|---|---|
| committer | Reinhard Panhuber <[email protected]> | 2021-01-04 12:02:08 +0100 |
| commit | 09d8ead4b86049260dd6ee7e61d137b6bdccaa28 (patch) | |
| tree | 8eee435fe5fcbd0cbe236fd4d1f31ee16366f35e /src/device | |
| parent | e79a7b91526dfb19bfa764f505c87740488849dc (diff) | |
Start changes - not yet finished
Diffstat (limited to 'src/device')
| -rw-r--r-- | src/device/usbd.c | 29 | ||||
| -rw-r--r-- | src/device/usbd_pvt.h | 3 |
2 files changed, 32 insertions, 0 deletions
diff --git a/src/device/usbd.c b/src/device/usbd.c index 791d533ae..55e76bb66 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -1188,6 +1188,35 @@ bool usbd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t } } +bool usbd_edpt_ISO_xfer(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes) +{ + uint8_t const epnum = tu_edpt_number(ep_addr); + uint8_t const dir = tu_edpt_dir(ep_addr); + + TU_LOG2(" Queue ISO EP %02X with %u bytes ... ", ep_addr, total_bytes); + + // Attempt to transfer on a busy endpoint, sound like an race condition ! + TU_ASSERT(_usbd_dev.ep_status[epnum][dir].busy == 0); + + // Set busy first since the actual transfer can be complete before dcd_edpt_xfer() could return + // and usbd task can preempt and clear the busy + _usbd_dev.ep_status[epnum][dir].busy = true; + + if ( dcd_edpt_ISO_xfer(rhport, ep_addr, ff, total_bytes) ) + { + TU_LOG2("OK\r\n"); + return true; + }else + { + // DCD error, mark endpoint as ready to allow next transfer + _usbd_dev.ep_status[epnum][dir].busy = false; + _usbd_dev.ep_status[epnum][dir].claimed = 0; + TU_LOG2("failed\r\n"); + TU_BREAKPOINT(); + return false; + } +} + bool usbd_edpt_busy(uint8_t rhport, uint8_t ep_addr) { (void) rhport; diff --git a/src/device/usbd_pvt.h b/src/device/usbd_pvt.h index 212c3a202..de2f37281 100644 --- a/src/device/usbd_pvt.h +++ b/src/device/usbd_pvt.h @@ -72,6 +72,9 @@ void usbd_edpt_close(uint8_t rhport, uint8_t ep_addr); // Submit a usb transfer bool usbd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes); +// Submit a usb ISO transfer by use of a FIFO (ring buffer) +bool usbd_edpt_ISO_xfer(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes); + // Claim an endpoint before submitting a transfer. // If caller does not make any transfer, it must release endpoint for others. bool usbd_edpt_claim(uint8_t rhport, uint8_t ep_addr); |
