diff options
| author | Felipe Balbi <[email protected]> | 2025-05-22 14:01:40 -0700 |
|---|---|---|
| committer | Felipe Balbi <[email protected]> | 2025-05-22 14:07:06 -0700 |
| commit | ea36d121db8dc71ebd205040cdd4b99fe5c2086c (patch) | |
| tree | baeee3f343c72f38bcacf0c085f6b7650d5c2562 /tests/rp/src | |
| parent | edceb0dc7da32848fd31b525b4c247671a14eb2d (diff) | |
embassy-rp: implement input/output inversion
RP2040/RP23xx support inversion in HW of the inputs and
outputs. Implement minimal support for that.
Diffstat (limited to 'tests/rp/src')
| -rw-r--r-- | tests/rp/src/bin/gpio.rs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/rp/src/bin/gpio.rs b/tests/rp/src/bin/gpio.rs index 614b6317a..8bd0df8d8 100644 --- a/tests/rp/src/bin/gpio.rs +++ b/tests/rp/src/bin/gpio.rs | |||
| @@ -67,6 +67,40 @@ async fn main(_spawner: Spawner) { | |||
| 67 | } | 67 | } |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | // Test input inversion | ||
| 71 | { | ||
| 72 | let mut b = Input::new(b.reborrow(), Pull::None); | ||
| 73 | b.set_inversion(true); | ||
| 74 | // no pull, the status is undefined | ||
| 75 | |||
| 76 | let mut a = Output::new(a.reborrow(), Level::Low); | ||
| 77 | delay(); | ||
| 78 | assert!(b.is_high()); | ||
| 79 | a.set_high(); | ||
| 80 | delay(); | ||
| 81 | assert!(b.is_low()); | ||
| 82 | |||
| 83 | b.set_inversion(false); | ||
| 84 | a.set_inversion(true); | ||
| 85 | |||
| 86 | a.set_low(); | ||
| 87 | delay(); | ||
| 88 | assert!(b.is_high()); | ||
| 89 | |||
| 90 | a.set_high(); | ||
| 91 | delay(); | ||
| 92 | assert!(b.is_low()); | ||
| 93 | |||
| 94 | b.set_inversion(true); | ||
| 95 | a.set_high(); | ||
| 96 | delay(); | ||
| 97 | assert!(b.is_high()); | ||
| 98 | |||
| 99 | a.set_high(); | ||
| 100 | delay(); | ||
| 101 | assert!(b.is_high()); | ||
| 102 | } | ||
| 103 | |||
| 70 | // Test input no pull | 104 | // Test input no pull |
| 71 | { | 105 | { |
| 72 | let b = Input::new(b.reborrow(), Pull::None); | 106 | let b = Input::new(b.reborrow(), Pull::None); |
