Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FSDEV fix/cleanup. #2574

Merged
merged 14 commits into from
Apr 11, 2024
23 changes: 14 additions & 9 deletions src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
hathach marked this conversation as resolved.
Show resolved Hide resolved
} xfer_ctl_t;

// EP allocator
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}

Expand Down
Loading