From d0d352b03f81f73d8adf93f474f717b8478cb002 Mon Sep 17 00:00:00 2001 From: Rene van der Meer Date: Fri, 13 Oct 2023 00:44:40 +0200 Subject: [PATCH] Set direction before changing mode --- src/gpio/gpiomem/rp1.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gpio/gpiomem/rp1.rs b/src/gpio/gpiomem/rp1.rs index d4ebd4c8..3eee24b4 100644 --- a/src/gpio/gpiomem/rp1.rs +++ b/src/gpio/gpiomem/rp1.rs @@ -249,16 +249,16 @@ impl GpioRegisters for GpioMem { Mode::Alt8 => FSEL_ALT8, }; + // Set the actual direction here, since this isn't set in the FSEL register. + if mode == Mode::Input || mode == Mode::Output { + self.set_direction(pin, mode); + } + reg_value = (reg_value & !CTRL_OUTOVER_MASK) | (OUTOVER_PERI << CTRL_OUTOVER_LSB); reg_value = (reg_value & !CTRL_OEOVER_MASK) | (OEOVER_PERI << CTRL_OEOVER_LSB); reg_value = (reg_value & !CTRL_FUNCSEL_MASK) | ((fsel_mode as u32) << CTRL_FUNCSEL_LSB); self.write(offset, reg_value); - - // Set the actual direction here, since this isn't set in the FSEL register. - if mode == Mode::Input || mode == Mode::Output { - self.set_direction(pin, mode); - } } fn set_bias(&self, pin: u8, bias: Bias) {