From 8290368c10a9ca54bd0ea5b5ffb8c63ce213371f Mon Sep 17 00:00:00 2001 From: Jennifer Wilcox Date: Sun, 25 Apr 2021 11:43:44 -0500 Subject: [PATCH] Pull pads out of reset and wait We're technically supposed to wait for these resets to finish before poking at registers. This seems to fix the instability I was seeing on the input example especially (TBH I have no idea how it ever worked) --- rp2040-hal/src/gpio.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/rp2040-hal/src/gpio.rs b/rp2040-hal/src/gpio.rs index 96dab87..03b7f9d 100644 --- a/rp2040-hal/src/gpio.rs +++ b/rp2040-hal/src/gpio.rs @@ -95,7 +95,13 @@ macro_rules! gpio { type Parts = Parts; fn split(self, pads: pac::$PADSX, sio: pac::SIO, resets: &mut pac::RESETS) -> Parts { - resets.reset.modify(|_, w| w.$gpiox().clear_bit()); + resets.reset.modify(|_, w| w.$gpiox().clear_bit().$padsx().clear_bit()); + while resets.reset_done.read().$gpiox().bit_is_clear() { + cortex_m::asm::delay(10); + } + while resets.reset_done.read().$padsx().bit_is_clear() { + cortex_m::asm::delay(10); + } Parts { _pads: pads, _sio: sio,