Skip to content

Commit dbe0b5a

Browse files
author
Jonas Schievink
committed
Add a 1ms delay to force_reset
1 parent 6ede424 commit dbe0b5a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

nrf-hal-common/src/usbd/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,13 @@ impl UsbBus for Usbd<'_> {
707707
interrupt::free(|cs| {
708708
let regs = self.periph.borrow(cs);
709709
regs.usbpullup.write(|w| w.connect().disabled());
710-
// TODO delay needed?
710+
711+
// FIXME: it is unclear how much of a delay is needed here, so we use a conservative 1ms
712+
// Note that this is very bad for latency-sensitive apps since it happens in a critical
713+
// section. `force_reset` should be avoided if that is an issue.
714+
// We run at 64 MHz, so 64k cycles are 1ms.
715+
cortex_m::asm::delay(64_000);
716+
711717
regs.usbpullup.write(|w| w.connect().enabled());
712718
});
713719

0 commit comments

Comments
 (0)