Skip to content

Commit

Permalink
addressed review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Matteo Tullo committed Nov 8, 2024
1 parent 0167142 commit 20fa507
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
10 changes: 8 additions & 2 deletions examples/rt685s-evk/src/bin/gpio-blinky.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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");
Expand Down
3 changes: 0 additions & 3 deletions examples/rt685s-evk/src/bin/gpio-flex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
12 changes: 6 additions & 6 deletions src/gpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ impl<S: Sense> 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 {
Expand All @@ -279,7 +279,7 @@ impl<S: Sense> Drop for Flex<'_, S> {
5 => disable::<peripherals::HSGPIO5>(),
6 => disable::<peripherals::HSGPIO6>(),
7 => disable::<peripherals::HSGPIO7>(),
_ => panic!(),
_ => (),
}
}
}
Expand All @@ -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]
Expand All @@ -315,7 +315,7 @@ impl<'d> Flex<'d, SenseEnabled> {
5 => enable_and_reset::<peripherals::HSGPIO5>(),
6 => enable_and_reset::<peripherals::HSGPIO6>(),
7 => enable_and_reset::<peripherals::HSGPIO7>(),
_ => panic!(),
_ => (),
}
}

Expand Down Expand Up @@ -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]
Expand All @@ -441,7 +441,7 @@ impl<'d> Flex<'d, SenseDisabled> {
5 => enable_and_reset::<peripherals::HSGPIO5>(),
6 => enable_and_reset::<peripherals::HSGPIO6>(),
7 => enable_and_reset::<peripherals::HSGPIO7>(),
_ => panic!(),
_ => (),
}
}

Expand Down

0 comments on commit 20fa507

Please sign in to comment.