diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/rp/src/bin/gpio.rs | 36 | ||||
| -rw-r--r-- | tests/stm32/src/bin/gpio.rs | 36 |
2 files changed, 68 insertions, 4 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 | ||
diff --git a/tests/stm32/src/bin/gpio.rs b/tests/stm32/src/bin/gpio.rs index 67f44317e..aad174431 100644 --- a/tests/stm32/src/bin/gpio.rs +++ b/tests/stm32/src/bin/gpio.rs | |||
| @@ -40,14 +40,46 @@ async fn main(_spawner: Spawner) { | |||
| 40 | let b = Input::new(&mut b, Pull::None); | 40 | let b = Input::new(&mut b, Pull::None); |
| 41 | 41 | ||
| 42 | { | 42 | { |
| 43 | let _a = Output::new(&mut a, Level::Low, Speed::Low); | 43 | let a = Output::new(&mut a, Level::Low, Speed::Low); |
| 44 | delay(); | 44 | delay(); |
| 45 | assert!(b.is_low()); | 45 | assert!(b.is_low()); |
| 46 | assert!(!b.is_high()); | ||
| 47 | assert!(a.is_set_low()); | ||
| 48 | assert!(!a.is_set_high()); | ||
| 46 | } | 49 | } |
| 47 | { | 50 | { |
| 48 | let _a = Output::new(&mut a, Level::High, Speed::Low); | 51 | let mut a = Output::new(&mut a, Level::High, Speed::Low); |
| 49 | delay(); | 52 | delay(); |
| 53 | assert!(!b.is_low()); | ||
| 50 | assert!(b.is_high()); | 54 | assert!(b.is_high()); |
| 55 | assert!(!a.is_set_low()); | ||
| 56 | assert!(a.is_set_high()); | ||
| 57 | |||
| 58 | // Test is_set_low / is_set_high | ||
| 59 | a.set_low(); | ||
| 60 | delay(); | ||
| 61 | assert!(b.is_low()); | ||
| 62 | assert!(a.is_set_low()); | ||
| 63 | assert!(!a.is_set_high()); | ||
| 64 | |||
| 65 | a.set_high(); | ||
| 66 | delay(); | ||
| 67 | assert!(b.is_high()); | ||
| 68 | assert!(!a.is_set_low()); | ||
| 69 | assert!(a.is_set_high()); | ||
| 70 | |||
| 71 | // Test toggle | ||
| 72 | a.toggle(); | ||
| 73 | delay(); | ||
| 74 | assert!(b.is_low()); | ||
| 75 | assert!(a.is_set_low()); | ||
| 76 | assert!(!a.is_set_high()); | ||
| 77 | |||
| 78 | a.toggle(); | ||
| 79 | delay(); | ||
| 80 | assert!(b.is_high()); | ||
| 81 | assert!(!a.is_set_low()); | ||
| 82 | assert!(a.is_set_high()); | ||
| 51 | } | 83 | } |
| 52 | } | 84 | } |
| 53 | 85 | ||
