diff options
| author | Dario Nieuwenhuis <[email protected]> | 2025-06-01 12:17:40 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-06-01 12:17:40 +0000 |
| commit | a636ec439eda06a140ddf4c2cbb17b2fc245a7d1 (patch) | |
| tree | eeab374baa22b4c50f019f59fa45e70bfe8115ae /tests | |
| parent | ad5a14fe850190b3052487f87a579eaf7ea65ec5 (diff) | |
| parent | ea36d121db8dc71ebd205040cdd4b99fe5c2086c (diff) | |
Merge pull request #4237 from felipebalbi/rp-invert-gpio
embassy-rp: implement input/output inversion
Diffstat (limited to 'tests')
| -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); |
