Skip to content

Commit

Permalink
[nrf fromtree] drivers: usb: common: nrf_usbd_common: Handle USB SoF …
Browse files Browse the repository at this point in the history
…IRQ first

The processing order is relevant if the IRQ handler call is delayed and
multiple interrupts are pending. Handle USB SoF before other interrupts
to ensure that it would be reported before other USB events (e.g. before
completed USB data transfers).

Jira: NCSDK-28664

Signed-off-by: Marek Pieta <[email protected]>

(cherry picked from commit cd931fd)
  • Loading branch information
MarekPieta authored and nordicjm committed Sep 2, 2024
1 parent f8ab2bf commit a3247ac
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions drivers/usb/common/nrf_usbd_common/nrf_usbd_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,16 @@ void nrf_usbd_common_irq_handler(void)
volatile uint32_t *dma_endevent;
uint32_t epdatastatus = 0;

/* Always check and clear SOF but call handler only if SOF interrupt
* is actually enabled.
*/
if (NRF_USBD->EVENTS_SOF) {
NRF_USBD->EVENTS_SOF = 0;
if (NRF_USBD->INTENSET & USBD_INTEN_SOF_Msk) {
ev_sof_handler();
}
}

/* Clear EPDATA event and only then get and clear EPDATASTATUS to make
* sure we don't miss any event.
*/
Expand Down Expand Up @@ -1066,16 +1076,6 @@ void nrf_usbd_common_irq_handler(void)
ev_usbreset_handler();
}

/* Always check and clear SOF but call handler only if SOF interrupt
* is actually enabled.
*/
if (NRF_USBD->EVENTS_SOF) {
NRF_USBD->EVENTS_SOF = 0;
if (NRF_USBD->INTENSET & USBD_INTEN_SOF_Msk) {
ev_sof_handler();
}
}

if (NRF_USBD->EVENTS_USBEVENT) {
NRF_USBD->EVENTS_USBEVENT = 0;
ev_usbevent_handler();
Expand Down

0 comments on commit a3247ac

Please sign in to comment.