From 7e45c96a658be5c2c4287503e7a68d92e3eae65a Mon Sep 17 00:00:00 2001 From: Jennifer Wilcox Date: Sun, 25 Apr 2021 11:17:33 -0500 Subject: [PATCH] Do reset in a good way instead of a wacky way --- rp2040-hal/src/gpio.rs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/rp2040-hal/src/gpio.rs b/rp2040-hal/src/gpio.rs index fe0e8c7..96dab87 100644 --- a/rp2040-hal/src/gpio.rs +++ b/rp2040-hal/src/gpio.rs @@ -89,7 +89,6 @@ macro_rules! gpio { use core::convert::Infallible; use core::marker::PhantomData; use embedded_hal::digital::v2::{InputPin, OutputPin, StatefulOutputPin}; - use pac::generic::ResetValue; use super::*; impl GpioExt for pac::$GPIOX { @@ -120,12 +119,6 @@ macro_rules! gpio { )+ } - fn reset_pad(pads: &pac::$padsx::RegisterBlock, index: usize) { - let reset_value: u32 = pac::$padsx::GPIO::reset_value(); - // This is safe, we get the value we're setting directly from the PAC - pads.gpio[index].write(|w| unsafe { w.bits(reset_value) }); - } - fn set_gpio_function(gpios: &pac::$gpiox::RegisterBlock, index: usize, function: GpioFunction) { gpios.gpio[index] .gpio_ctrl @@ -152,7 +145,7 @@ macro_rules! gpio { self, ) -> $PXi { unsafe { - reset_pad(&*pac::$PADSX::ptr(), $i); + (*pac::$PADSX::ptr()).gpio[$i].reset(); } unsafe { set_gpio_function(&*pac::$GPIOX::ptr(), $i, GpioFunction::Sio); @@ -168,7 +161,7 @@ macro_rules! gpio { self, ) -> $PXi { unsafe { - reset_pad(&*pac::$PADSX::ptr(), $i); + (*pac::$PADSX::ptr()).gpio[$i].reset(); } unsafe { set_gpio_function(&*pac::$GPIOX::ptr(), $i, GpioFunction::Sio);