summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhathach <[email protected]>2024-04-11 20:53:44 +0700
committerhathach <[email protected]>2024-04-11 20:53:44 +0700
commit0f775630c7468b804fad7e3350b37430b6fb0a2d (patch)
tree00ffee8f88cc3838bfc93646b69ae69fe0d01d82 /src
parent535571c3d278efbbeebdc531c36ce1f492ea4d05 (diff)
rename, invert logic for iso_in_sending. Also limit its usage to ISO endpoint
Diffstat (limited to 'src')
-rw-r--r--src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
index 56c9bc84b..493e634c7 100644
--- a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
+++ b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
@@ -152,7 +152,7 @@ typedef struct {
uint16_t queued_len;
uint16_t max_packet_size;
uint8_t ep_idx; // index for USB_EPnR register
- bool in_complete; // Workaround for ISO IN EP doesn't have interrupt mask
+ bool iso_in_sending; // Workaround for ISO IN EP doesn't have interrupt mask
} xfer_ctl_t;
// EP allocator
@@ -502,13 +502,15 @@ static void dcd_ep_ctr_tx_handler(uint32_t wIstr)
xfer_ctl_t *xfer = xfer_ctl_ptr(ep_addr);
- /* Ignore spurious int */
- if (xfer->in_complete) {
- return;
- }
- xfer->in_complete = true;
-
if ((wEPRegVal & USB_EP_TYPE_MASK) == USB_EP_ISOCHRONOUS) {
+ // Ignore spurious interrupts that we don't schedule
+ // host can send IN token while there is no data to send, since ISO does not have NAK
+ // this will result to zero length packet --> trigger interrupt (which cannot be masked)
+ if (!xfer->iso_in_sending) {
+ return;
+ }
+ xfer->iso_in_sending = false;
+
if (wEPRegVal & USB_EP_DTOG_TX) {
pcd_set_ep_tx_dbuf0_cnt(USB, EPindex, 0);
} else {
@@ -955,9 +957,10 @@ static void dcd_transmit_packet(xfer_ctl_t *xfer, uint16_t ep_ix)
}
uint16_t ep_reg = pcd_get_endpoint(USB, ep_ix);
+ bool const is_iso = (ep_reg & USB_EP_TYPE_MASK) == USB_EP_ISOCHRONOUS;
uint16_t addr_ptr;
- if ((ep_reg & USB_EP_TYPE_MASK) == USB_EP_ISOCHRONOUS) {
+ if (is_iso) {
if (ep_reg & USB_EP_DTOG_TX) {
addr_ptr = pcd_get_ep_dbuf1_address(USB, ep_ix);
pcd_set_ep_tx_dbuf1_cnt(USB, ep_ix, len);
@@ -979,7 +982,9 @@ static void dcd_transmit_packet(xfer_ctl_t *xfer, uint16_t ep_ix)
dcd_int_disable(0);
pcd_set_ep_tx_status(USB, ep_ix, USB_EP_TX_VALID);
- xfer->in_complete = false;
+ if (is_iso) {
+ xfer->iso_in_sending = true;
+ }
dcd_int_enable(0);
}