summaryrefslogtreecommitdiff
path: root/src/device
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2025-11-20 14:17:13 +0700
committerGitHub <[email protected]>2025-11-20 14:17:13 +0700
commit409c19364b3be723b26b013efa5ab3ec1d17435a (patch)
treeec06dc2164823297b2be8eeb7276d054ed4cda62 /src/device
parent3af1bec1a9161ee8dec29487831f7ac7ade9e189 (diff)
parentcea86617f75804ad9347c0b9686c102db555d4b7 (diff)
Merge pull request #3313 from hathach/copilot/fix-dcd-edpt-xfer-issue
Add is_isr parameter to dcd_edpt_xfer, dcd_edpt_xfer_fifo, usbd_edpt_xfer, and usbd_edpt_xfer_fifo functions
Diffstat (limited to 'src/device')
-rw-r--r--src/device/dcd.h4
-rw-r--r--src/device/usbd.c12
-rw-r--r--src/device/usbd_control.c4
-rw-r--r--src/device/usbd_pvt.h4
4 files changed, 12 insertions, 12 deletions
diff --git a/src/device/dcd.h b/src/device/dcd.h
index 353f836ee..8a074ab47 100644
--- a/src/device/dcd.h
+++ b/src/device/dcd.h
@@ -158,11 +158,11 @@ bool dcd_edpt_open (uint8_t rhport, tusb_desc_endpoint_t const * desc
void dcd_edpt_close_all (uint8_t rhport);
// Submit a transfer, When complete dcd_event_xfer_complete() is invoked to notify the stack
-bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes);
+bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes, bool is_isr);
// Submit an transfer using fifo, When complete dcd_event_xfer_complete() is invoked to notify the stack
// This API is optional, may be useful for register-based for transferring data.
-bool dcd_edpt_xfer_fifo (uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes);
+bool dcd_edpt_xfer_fifo (uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes, bool is_isr);
// Stall endpoint, any queuing transfer should be removed from endpoint
void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr);
diff --git a/src/device/usbd.c b/src/device/usbd.c
index cf96f050d..d4dfae4b4 100644
--- a/src/device/usbd.c
+++ b/src/device/usbd.c
@@ -419,8 +419,8 @@ TU_ATTR_WEAK usbd_class_driver_t const* usbd_app_driver_get_cb(uint8_t* driver_c
return NULL;
}
-TU_ATTR_WEAK bool dcd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes) {
- (void) rhport; (void) ep_addr; (void) ff; (void) total_bytes;
+TU_ATTR_WEAK bool dcd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes, bool is_isr) {
+ (void) rhport; (void) ep_addr; (void) ff; (void) total_bytes; (void) is_isr;
return false;
}
@@ -1432,7 +1432,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);
@@ -1455,7 +1455,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)) {
+ 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
@@ -1471,7 +1471,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);
@@ -1486,7 +1486,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)) {
+ 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 996e7387f..47d58a1f9 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 6e220129a..72323ac80 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.