Skip to content

Commit cd931fd

Browse files
MarekPietanashif
authored andcommitted
drivers: usb: common: nrf_usbd_common: Handle USB SoF 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). Signed-off-by: Marek Pieta <[email protected]>
1 parent 1dbfa7f commit cd931fd

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

drivers/usb/common/nrf_usbd_common/nrf_usbd_common.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,16 @@ void nrf_usbd_common_irq_handler(void)
10291029
volatile uint32_t *dma_endevent;
10301030
uint32_t epdatastatus = 0;
10311031

1032+
/* Always check and clear SOF but call handler only if SOF interrupt
1033+
* is actually enabled.
1034+
*/
1035+
if (NRF_USBD->EVENTS_SOF) {
1036+
NRF_USBD->EVENTS_SOF = 0;
1037+
if (NRF_USBD->INTENSET & USBD_INTEN_SOF_Msk) {
1038+
ev_sof_handler();
1039+
}
1040+
}
1041+
10321042
/* Clear EPDATA event and only then get and clear EPDATASTATUS to make
10331043
* sure we don't miss any event.
10341044
*/
@@ -1066,16 +1076,6 @@ void nrf_usbd_common_irq_handler(void)
10661076
ev_usbreset_handler();
10671077
}
10681078

1069-
/* Always check and clear SOF but call handler only if SOF interrupt
1070-
* is actually enabled.
1071-
*/
1072-
if (NRF_USBD->EVENTS_SOF) {
1073-
NRF_USBD->EVENTS_SOF = 0;
1074-
if (NRF_USBD->INTENSET & USBD_INTEN_SOF_Msk) {
1075-
ev_sof_handler();
1076-
}
1077-
}
1078-
10791079
if (NRF_USBD->EVENTS_USBEVENT) {
10801080
NRF_USBD->EVENTS_USBEVENT = 0;
10811081
ev_usbevent_handler();

0 commit comments

Comments
 (0)