diff options
| author | Dario Nieuwenhuis <[email protected]> | 2023-07-11 12:38:53 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2023-07-11 12:40:07 +0200 |
| commit | 91c1d17f166541c5dafc765e952486f21841e120 (patch) | |
| tree | 3adb656e8c461023f16f58d0d11cc652d53cb96f /tests/rp/src | |
| parent | 8a811cfcf75b25fe81168134bf0cf8a8d387c391 (diff) | |
rp/gpio: fix is_set_high/is_set_low, expand tests.
Diffstat (limited to 'tests/rp/src')
| -rw-r--r-- | tests/rp/src/bin/gpio.rs | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/tests/rp/src/bin/gpio.rs b/tests/rp/src/bin/gpio.rs index 51112d319..946b7dc88 100644 --- a/tests/rp/src/bin/gpio.rs +++ b/tests/rp/src/bin/gpio.rs | |||
| @@ -21,14 +21,46 @@ async fn main(_spawner: Spawner) { | |||
| 21 | let b = Input::new(&mut b, Pull::None); | 21 | let b = Input::new(&mut b, Pull::None); |
| 22 | 22 | ||
| 23 | { | 23 | { |
| 24 | let _a = Output::new(&mut a, Level::Low); | 24 | let a = Output::new(&mut a, Level::Low); |
| 25 | delay(); | 25 | delay(); |
| 26 | assert!(b.is_low()); | 26 | assert!(b.is_low()); |
| 27 | assert!(!b.is_high()); | ||
| 28 | assert!(a.is_set_low()); | ||
| 29 | assert!(!a.is_set_high()); | ||
| 27 | } | 30 | } |
| 28 | { | 31 | { |
| 29 | let _a = Output::new(&mut a, Level::High); | 32 | let mut a = Output::new(&mut a, Level::High); |
| 30 | delay(); | 33 | delay(); |
| 34 | assert!(!b.is_low()); | ||
| 31 | assert!(b.is_high()); | 35 | assert!(b.is_high()); |
| 36 | assert!(!a.is_set_low()); | ||
| 37 | assert!(a.is_set_high()); | ||
| 38 | |||
| 39 | // Test is_set_low / is_set_high | ||
| 40 | a.set_low(); | ||
| 41 | delay(); | ||
| 42 | assert!(b.is_low()); | ||
| 43 | assert!(a.is_set_low()); | ||
| 44 | assert!(!a.is_set_high()); | ||
| 45 | |||
| 46 | a.set_high(); | ||
| 47 | delay(); | ||
| 48 | assert!(b.is_high()); | ||
| 49 | assert!(!a.is_set_low()); | ||
| 50 | assert!(a.is_set_high()); | ||
| 51 | |||
| 52 | // Test toggle | ||
| 53 | a.toggle(); | ||
| 54 | delay(); | ||
| 55 | assert!(b.is_low()); | ||
| 56 | assert!(a.is_set_low()); | ||
| 57 | assert!(!a.is_set_high()); | ||
| 58 | |||
| 59 | a.toggle(); | ||
| 60 | delay(); | ||
| 61 | assert!(b.is_high()); | ||
| 62 | assert!(!a.is_set_low()); | ||
| 63 | assert!(a.is_set_high()); | ||
| 32 | } | 64 | } |
| 33 | } | 65 | } |
| 34 | 66 | ||
