From 495b8b739aaba3d1fe7e105559c830496fabb1d7 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Tue, 9 Jan 2024 23:58:26 +0100 Subject: Change GPIO inherent methods back to `&self`. With the embedded-hal rc3 update I changed them to require `&mut self`, but in retrospect I think `&self` is better, for extra flexibility. This PR reverts the changes from the rc3 update to inherent methods. --- tests/rp/src/bin/gpio.rs | 10 +++++----- tests/rp/src/bin/pwm.rs | 8 ++++---- tests/stm32/src/bin/gpio.rs | 12 ++++++------ 3 files changed, 15 insertions(+), 15 deletions(-) (limited to 'tests') diff --git a/tests/rp/src/bin/gpio.rs b/tests/rp/src/bin/gpio.rs index a57d5d9e8..e0c309887 100644 --- a/tests/rp/src/bin/gpio.rs +++ b/tests/rp/src/bin/gpio.rs @@ -16,10 +16,10 @@ async fn main(_spawner: Spawner) { // Test initial output { - let mut b = Input::new(&mut b, Pull::None); + let b = Input::new(&mut b, Pull::None); { - let mut a = Output::new(&mut a, Level::Low); + let a = Output::new(&mut a, Level::Low); delay(); assert!(b.is_low()); assert!(!b.is_high()); @@ -64,7 +64,7 @@ async fn main(_spawner: Spawner) { // Test input no pull { - let mut b = Input::new(&mut b, Pull::None); + let b = Input::new(&mut b, Pull::None); // no pull, the status is undefined let mut a = Output::new(&mut a, Level::Low); @@ -77,7 +77,7 @@ async fn main(_spawner: Spawner) { // Test input pulldown { - let mut b = Input::new(&mut b, Pull::Down); + let b = Input::new(&mut b, Pull::Down); delay(); assert!(b.is_low()); @@ -91,7 +91,7 @@ async fn main(_spawner: Spawner) { // Test input pullup { - let mut b = Input::new(&mut b, Pull::Up); + let b = Input::new(&mut b, Pull::Up); delay(); assert!(b.is_high()); diff --git a/tests/rp/src/bin/pwm.rs b/tests/rp/src/bin/pwm.rs index 3fc0bb2a0..e71d9e610 100644 --- a/tests/rp/src/bin/pwm.rs +++ b/tests/rp/src/bin/pwm.rs @@ -45,7 +45,7 @@ async fn main(_spawner: Spawner) { // Test output from A { - let mut pin1 = Input::new(&mut p9, Pull::None); + let pin1 = Input::new(&mut p9, Pull::None); let _pwm = Pwm::new_output_a(&mut p.PWM_CH3, &mut p6, cfg.clone()); Timer::after_millis(1).await; assert_eq!(pin1.is_low(), invert_a); @@ -59,7 +59,7 @@ async fn main(_spawner: Spawner) { // Test output from B { - let mut pin2 = Input::new(&mut p11, Pull::None); + let pin2 = Input::new(&mut p11, Pull::None); let _pwm = Pwm::new_output_b(&mut p.PWM_CH3, &mut p7, cfg.clone()); Timer::after_millis(1).await; assert_ne!(pin2.is_low(), invert_a); @@ -73,8 +73,8 @@ async fn main(_spawner: Spawner) { // Test output from A+B { - let mut pin1 = Input::new(&mut p9, Pull::None); - let mut pin2 = Input::new(&mut p11, Pull::None); + let pin1 = Input::new(&mut p9, Pull::None); + let pin2 = Input::new(&mut p11, Pull::None); let _pwm = Pwm::new_output_ab(&mut p.PWM_CH3, &mut p6, &mut p7, cfg.clone()); Timer::after_millis(1).await; assert_eq!(pin1.is_low(), invert_a); diff --git a/tests/stm32/src/bin/gpio.rs b/tests/stm32/src/bin/gpio.rs index 9f1993024..c4e2fe161 100644 --- a/tests/stm32/src/bin/gpio.rs +++ b/tests/stm32/src/bin/gpio.rs @@ -20,10 +20,10 @@ async fn main(_spawner: Spawner) { // Test initial output { - let mut b = Input::new(&mut b, Pull::None); + let b = Input::new(&mut b, Pull::None); { - let mut a = Output::new(&mut a, Level::Low, Speed::Low); + let a = Output::new(&mut a, Level::Low, Speed::Low); delay(); assert!(b.is_low()); assert!(!b.is_high()); @@ -68,7 +68,7 @@ async fn main(_spawner: Spawner) { // Test input no pull { - let mut b = Input::new(&mut b, Pull::None); + let b = Input::new(&mut b, Pull::None); // no pull, the status is undefined let mut a = Output::new(&mut a, Level::Low, Speed::Low); @@ -81,7 +81,7 @@ async fn main(_spawner: Spawner) { // Test input pulldown { - let mut b = Input::new(&mut b, Pull::Down); + let b = Input::new(&mut b, Pull::Down); delay(); assert!(b.is_low()); @@ -95,7 +95,7 @@ async fn main(_spawner: Spawner) { // Test input pullup { - let mut b = Input::new(&mut b, Pull::Up); + let b = Input::new(&mut b, Pull::Up); delay(); assert!(b.is_high()); @@ -109,7 +109,7 @@ async fn main(_spawner: Spawner) { // Test output open drain { - let mut b = Input::new(&mut b, Pull::Down); + let b = Input::new(&mut b, Pull::Down); // no pull, the status is undefined let mut a = OutputOpenDrain::new(&mut a, Level::Low, Speed::Low, Pull::None); -- cgit