Merge pull request #4237 from felipebalbi/rp-invert-gpio

embassy-rp: implement input/output inversion
This commit is contained in:
Dario Nieuwenhuis
2025-06-01 12:17:40 +00:00
committed by GitHub
2 changed files with 72 additions and 0 deletions

View File

@@ -67,6 +67,40 @@ async fn main(_spawner: Spawner) {
}
}
// Test input inversion
{
let mut b = Input::new(b.reborrow(), Pull::None);
b.set_inversion(true);
// no pull, the status is undefined
let mut a = Output::new(a.reborrow(), Level::Low);
delay();
assert!(b.is_high());
a.set_high();
delay();
assert!(b.is_low());
b.set_inversion(false);
a.set_inversion(true);
a.set_low();
delay();
assert!(b.is_high());
a.set_high();
delay();
assert!(b.is_low());
b.set_inversion(true);
a.set_high();
delay();
assert!(b.is_high());
a.set_high();
delay();
assert!(b.is_high());
}
// Test input no pull
{
let b = Input::new(b.reborrow(), Pull::None);