diff --git a/examples/rt685s-evk/src/bin/gpio-blinky.rs b/examples/rt685s-evk/src/bin/gpio-blinky.rs index 92ce607b..ee98849a 100644 --- a/examples/rt685s-evk/src/bin/gpio-blinky.rs +++ b/examples/rt685s-evk/src/bin/gpio-blinky.rs @@ -18,7 +18,10 @@ async fn main(_spawner: Spawner) { let cc1 = unsafe { pac::Clkctl1::steal() }; - assert!(cc1.pscctl1().read().hsgpio0_clk().is_disable_clock()); + assert!( + cc1.pscctl1().read().hsgpio0_clk().is_disable_clock(), + "GPIO port 0 clock was enabled before any GPIO pins were created!" + ); let mut led = gpio::Output::new( p.PIO0_26, @@ -28,7 +31,10 @@ async fn main(_spawner: Spawner) { gpio::SlewRate::Standard, ); - assert!(cc1.pscctl1().read().hsgpio0_clk().is_enable_clock()); + assert!( + cc1.pscctl1().read().hsgpio0_clk().is_enable_clock(), + "GPIO port 0 clock is still disabled even after a GPIO pin is created!" + ); loop { info!("Toggling LED"); diff --git a/examples/rt685s-evk/src/bin/gpio-flex.rs b/examples/rt685s-evk/src/bin/gpio-flex.rs index d2fde740..44c7074c 100644 --- a/examples/rt685s-evk/src/bin/gpio-flex.rs +++ b/examples/rt685s-evk/src/bin/gpio-flex.rs @@ -99,9 +99,6 @@ async fn main(_spawner: Spawner) { // check pin level is low assert!(flex.is_low()); - let mut flex = flex.disable_sensing(); - - let mut flex = flex.enable_sensing(); // toggle pin flex.toggle(); diff --git a/src/gpio.rs b/src/gpio.rs index 7496aa85..ef4d7221 100644 --- a/src/gpio.rs +++ b/src/gpio.rs @@ -258,7 +258,7 @@ impl Drop for Flex<'_, S> { let port = self.pin.port(); let is_last_drop = critical_section::with(|_| { - // Safe since we are using an atomic load and stores. + // SAFETY: Safe since we are using an atomic load and stores. let usecount = unsafe { PORT_USECOUNT[port].usecount.load(core::sync::atomic::Ordering::Acquire) }; assert!(usecount >= 1); unsafe { @@ -279,7 +279,7 @@ impl Drop for Flex<'_, S> { 5 => disable::(), 6 => disable::(), 7 => disable::(), - _ => panic!(), + _ => (), } } } @@ -296,7 +296,7 @@ impl<'d> Flex<'d, SenseEnabled> { let port = pin.port(); let is_first_construct = critical_section::with(|_| { - // Safe since we are using an atomic load and stores. + // SAFETY: Safe since we are using an atomic load and stores. let usecount = unsafe { PORT_USECOUNT[port].usecount.load(core::sync::atomic::Ordering::Acquire) }; unsafe { PORT_USECOUNT[port] @@ -315,7 +315,7 @@ impl<'d> Flex<'d, SenseEnabled> { 5 => enable_and_reset::(), 6 => enable_and_reset::(), 7 => enable_and_reset::(), - _ => panic!(), + _ => (), } } @@ -422,7 +422,7 @@ impl<'d> Flex<'d, SenseDisabled> { let port = pin.port(); let is_first_construct = critical_section::with(|_| { - // Safe since we are using an atomic load and stores. + // SAFETY: Safe since we are using an atomic load and stores. let usecount = unsafe { PORT_USECOUNT[port].usecount.load(core::sync::atomic::Ordering::Acquire) }; unsafe { PORT_USECOUNT[port] @@ -441,7 +441,7 @@ impl<'d> Flex<'d, SenseDisabled> { 5 => enable_and_reset::(), 6 => enable_and_reset::(), 7 => enable_and_reset::(), - _ => panic!(), + _ => (), } }