From 93780fa31d3c563e05fac6cd6ff8f15e43dc80fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Kr=C3=B6ger?= Date: Sun, 3 Jan 2021 13:56:13 +0100 Subject: [PATCH] uarte: Wait for the peripheral to be disabled Prevents a panic in the case of: 1. Abort a receive future 2. Free Uarte::free() 3. Uarte::new() -> panicked at 'assertion failed: uarte.enable.read().enable().is_disabled()' --- embassy-nrf/src/uarte.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/embassy-nrf/src/uarte.rs b/embassy-nrf/src/uarte.rs index aee91f80..dc2093c3 100644 --- a/embassy-nrf/src/uarte.rs +++ b/embassy-nrf/src/uarte.rs @@ -131,6 +131,8 @@ where } pub fn free(self) -> (T, T::Interrupt, Pins) { + // Wait for the peripheral to be disabled from the ISR. + while self.instance.enable.read().enable().is_enabled() {} (self.instance, self.irq, self.pins) }