diff options
| author | copilot-swe-agent[bot] <[email protected]> | 2025-10-22 06:12:08 +0000 |
|---|---|---|
| committer | copilot-swe-agent[bot] <[email protected]> | 2025-10-22 06:12:08 +0000 |
| commit | 27415e6114cb6e23ca085b21161eb79278f6b97b (patch) | |
| tree | 43d1d403c57a40dccc0cb4b3b3cb134a100e7ac1 /src/device | |
| parent | 16cfe6895a4ee6d6b196e99a033a7326908f8d8a (diff) | |
Add is_isr parameter to usbd_edpt_xfer and usbd_edpt_xfer_fifo
- Added bool is_isr parameter to usbd_edpt_xfer() and usbd_edpt_xfer_fifo() wrapper functions
- These are called by class drivers to queue USB transfers
- Updated all callers to pass false by default (non-ISR context)
- Updated audiod_rx_xfer_isr() and audiod_tx_xfer_isr() to pass true (ISR context)
- All 21 unit tests pass
Co-authored-by: HiFiPhile <[email protected]>
Diffstat (limited to 'src/device')
| -rw-r--r-- | src/device/usbd.c | 8 | ||||
| -rw-r--r-- | src/device/usbd_control.c | 4 | ||||
| -rw-r--r-- | src/device/usbd_pvt.h | 4 |
3 files changed, 8 insertions, 8 deletions
diff --git a/src/device/usbd.c b/src/device/usbd.c index d5ebcc66b..a664c2186 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -1410,7 +1410,7 @@ bool usbd_edpt_release(uint8_t rhport, uint8_t ep_addr) { return tu_edpt_release(ep_state, _usbd_mutex); } -bool usbd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t* buffer, uint16_t total_bytes) { +bool usbd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t* buffer, uint16_t total_bytes, bool is_isr) { rhport = _usbd_rhport; uint8_t const epnum = tu_edpt_number(ep_addr); @@ -1433,7 +1433,7 @@ bool usbd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t* buffer, uint16_t t // could return and USBD task can preempt and clear the busy _usbd_dev.ep_status[epnum][dir].busy = 1; - if (dcd_edpt_xfer(rhport, ep_addr, buffer, total_bytes, false)) { + if (dcd_edpt_xfer(rhport, ep_addr, buffer, total_bytes, is_isr)) { return true; } else { // DCD error, mark endpoint as ready to allow next transfer @@ -1449,7 +1449,7 @@ bool usbd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t* buffer, uint16_t t // bytes should be written and second to keep the return value free to give back a boolean // success message. If total_bytes is too big, the FIFO will copy only what is available // into the USB buffer! -bool usbd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t* ff, uint16_t total_bytes) { +bool usbd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t* ff, uint16_t total_bytes, bool is_isr) { rhport = _usbd_rhport; uint8_t const epnum = tu_edpt_number(ep_addr); @@ -1464,7 +1464,7 @@ bool usbd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t* ff, uint16_ // and usbd task can preempt and clear the busy _usbd_dev.ep_status[epnum][dir].busy = 1; - if (dcd_edpt_xfer_fifo(rhport, ep_addr, ff, total_bytes, false)) { + if (dcd_edpt_xfer_fifo(rhport, ep_addr, ff, total_bytes, is_isr)) { TU_LOG_USBD("OK\r\n"); return true; } else { diff --git a/src/device/usbd_control.c b/src/device/usbd_control.c index c9700fd9d..b75362425 100644 --- a/src/device/usbd_control.c +++ b/src/device/usbd_control.c @@ -71,7 +71,7 @@ CFG_TUD_MEM_SECTION static struct { static inline bool status_stage_xact(uint8_t rhport, const tusb_control_request_t* request) { // Opposite to endpoint in Data Phase const uint8_t ep_addr = request->bmRequestType_bit.direction ? EDPT_CTRL_OUT : EDPT_CTRL_IN; - return usbd_edpt_xfer(rhport, ep_addr, NULL, 0); + return usbd_edpt_xfer(rhport, ep_addr, NULL, 0, false); } // Status phase @@ -98,7 +98,7 @@ static bool data_stage_xact(uint8_t rhport) { } } - return usbd_edpt_xfer(rhport, ep_addr, xact_len ? _ctrl_epbuf.buf : NULL, xact_len); + return usbd_edpt_xfer(rhport, ep_addr, xact_len ? _ctrl_epbuf.buf : NULL, xact_len, false); } // Transmit data to/from the control endpoint. diff --git a/src/device/usbd_pvt.h b/src/device/usbd_pvt.h index a688cf497..a1c884f12 100644 --- a/src/device/usbd_pvt.h +++ b/src/device/usbd_pvt.h @@ -84,10 +84,10 @@ bool usbd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const * desc_ep); 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); +bool usbd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes, bool is_isr); // Submit a usb ISO transfer by use of a FIFO (ring buffer) - all bytes in FIFO get transmitted -bool usbd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes); +bool usbd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes, bool is_isr); // Claim an endpoint before submitting a transfer. // If caller does not make any transfer, it must release endpoint for others. |
