Skip to content

Commit 68bb858

Browse files
committed
nrf5x: Handle ISOOUT CRC errors
NRF5x USB controller can detect ISO OUT CRC errors. In such case USBEVENT is signaled with EVENTCAUSE_ISOOUTCRC set. Even if controller detects corrupted ISO OUT packet it allows to data transfer from ednpoint to RAM however packet is corrupted and code could just as well drop packet altogether. With current implementation incoming ISO OUT packets were put in FIFO and exact information how much data already in FIFO is correct was hard to keep track of. If was observed that on certain configurations HS hub when FS device was connected occasionally sent invalid (short) packet. In such case if packet length was reported odd audio stream was not recognizable any more. With this change corrupted packets are not passed to upper layers and are silently dropped.
1 parent b60d0ff commit 68bb858

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/portable/nordic/nrf5x/dcd_nrf5x.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,11 @@ void dcd_int_handler(uint8_t rhport)
653653
if (NRF_USBD->EPOUTEN & USBD_EPOUTEN_ISOOUT_Msk)
654654
{
655655
iso_enabled = true;
656-
xact_out_dma(EP_ISO_NUM);
656+
// Transfer from endpoint to RAM only if data is not corrupted
657+
if ((int_status & USBD_INTEN_USBEVENT_Msk) == 0 ||
658+
(NRF_USBD->EVENTCAUSE & USBD_EVENTCAUSE_ISOOUTCRC_Msk) == 0) {
659+
xact_out_dma(EP_ISO_NUM);
660+
}
657661
}
658662

659663
// ISOIN: Notify client that data was transferred
@@ -683,7 +687,7 @@ void dcd_int_handler(uint8_t rhport)
683687
{
684688
TU_LOG(2, "EVENTCAUSE = 0x%04lX\r\n", NRF_USBD->EVENTCAUSE);
685689

686-
enum { EVT_CAUSE_MASK = USBD_EVENTCAUSE_SUSPEND_Msk | USBD_EVENTCAUSE_RESUME_Msk | USBD_EVENTCAUSE_USBWUALLOWED_Msk };
690+
enum { EVT_CAUSE_MASK = USBD_EVENTCAUSE_SUSPEND_Msk | USBD_EVENTCAUSE_RESUME_Msk | USBD_EVENTCAUSE_USBWUALLOWED_Msk | USBD_EVENTCAUSE_ISOOUTCRC_Msk };
687691
uint32_t const evt_cause = NRF_USBD->EVENTCAUSE & EVT_CAUSE_MASK;
688692
NRF_USBD->EVENTCAUSE = evt_cause; // clear interrupt
689693

0 commit comments

Comments
 (0)