summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2021-12-09 00:44:44 +0700
committerGitHub <[email protected]>2021-12-09 00:44:44 +0700
commit6bf7fba2a41a1c2f7b4d33b15fa09ec073c64651 (patch)
treea085046a9718c592714264fb6074ed0bb5492608 /src
parentcde824f17f73b5ce4fcec8c176827297854a76c2 (diff)
parent21db2351fdd3edd560e14d2949b9b0d217a51f93 (diff)
Merge pull request #1221 from kasjer/kasjer/fix-nrf5x-vbus-race-condition
nrf5x: Fix race condition during startup
Diffstat (limited to 'src')
-rw-r--r--src/portable/nordic/nrf5x/dcd_nrf5x.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/portable/nordic/nrf5x/dcd_nrf5x.c b/src/portable/nordic/nrf5x/dcd_nrf5x.c
index 2bcd56b8a..ed597a34f 100644
--- a/src/portable/nordic/nrf5x/dcd_nrf5x.c
+++ b/src/portable/nordic/nrf5x/dcd_nrf5x.c
@@ -1059,7 +1059,13 @@ void tusb_hal_nrf_power_event (uint32_t event)
// Enable interrupt, priorities should be set by application
NVIC_ClearPendingIRQ(USBD_IRQn);
- NVIC_EnableIRQ(USBD_IRQn);
+ // Don't enable USBD interrupt yet, if dcd_init() did not finish yet
+ // Interrupt will be enabled by tud_init(), when USB stack is ready
+ // to handle interrupts.
+ if (tud_inited())
+ {
+ NVIC_EnableIRQ(USBD_IRQn);
+ }
// Wait for HFCLK
while ( !hfclk_running() ) { }