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.
This commit is contained in:
Dario Nieuwenhuis
2024-01-09 23:58:26 +01:00
parent 67ed134479
commit 495b8b739a
23 changed files with 157 additions and 192 deletions

View File

@@ -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());

View File

@@ -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);

View File

@@ -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);