aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorpawel00100 <[email protected]>2024-01-24 23:24:26 +0100
committerDario Nieuwenhuis <[email protected]>2024-04-05 01:20:34 +0200
commit143b288333a96c3caf6a0f372edca13ebea10af1 (patch)
treeaa42e870f85dda1ce5a4d0e055e0feb6f6696e60 /tests
parent9d0b682b2d11cc4c194fc4cff8c3edfd459e1ef8 (diff)
Add parameter for enabling pull-up and pull-down in RP PWM input mode
Diffstat (limited to 'tests')
-rw-r--r--tests/rp/src/bin/pwm.rs46
1 files changed, 43 insertions, 3 deletions
diff --git a/tests/rp/src/bin/pwm.rs b/tests/rp/src/bin/pwm.rs
index 4b02e5bab..c05197000 100644
--- a/tests/rp/src/bin/pwm.rs
+++ b/tests/rp/src/bin/pwm.rs
@@ -94,7 +94,7 @@ async fn main(_spawner: Spawner) {
94 // Test level-gated 94 // Test level-gated
95 { 95 {
96 let mut pin2 = Output::new(&mut p11, Level::Low); 96 let mut pin2 = Output::new(&mut p11, Level::Low);
97 let pwm = Pwm::new_input(&mut p.PWM_SLICE3, &mut p7, InputMode::Level, cfg.clone()); 97 let pwm = Pwm::new_input(&mut p.PWM_SLICE3, &mut p7, Pull::None, InputMode::Level, cfg.clone());
98 assert_eq!(pwm.counter(), 0); 98 assert_eq!(pwm.counter(), 0);
99 Timer::after_millis(5).await; 99 Timer::after_millis(5).await;
100 assert_eq!(pwm.counter(), 0); 100 assert_eq!(pwm.counter(), 0);
@@ -110,7 +110,13 @@ async fn main(_spawner: Spawner) {
110 // Test rising-gated 110 // Test rising-gated
111 { 111 {
112 let mut pin2 = Output::new(&mut p11, Level::Low); 112 let mut pin2 = Output::new(&mut p11, Level::Low);
113 let pwm = Pwm::new_input(&mut p.PWM_SLICE3, &mut p7, InputMode::RisingEdge, cfg.clone()); 113 let pwm = Pwm::new_input(
114 &mut p.PWM_SLICE3,
115 &mut p7,
116 Pull::None,
117 InputMode::RisingEdge,
118 cfg.clone(),
119 );
114 assert_eq!(pwm.counter(), 0); 120 assert_eq!(pwm.counter(), 0);
115 Timer::after_millis(5).await; 121 Timer::after_millis(5).await;
116 assert_eq!(pwm.counter(), 0); 122 assert_eq!(pwm.counter(), 0);
@@ -125,7 +131,13 @@ async fn main(_spawner: Spawner) {
125 // Test falling-gated 131 // Test falling-gated
126 { 132 {
127 let mut pin2 = Output::new(&mut p11, Level::High); 133 let mut pin2 = Output::new(&mut p11, Level::High);
128 let pwm = Pwm::new_input(&mut p.PWM_SLICE3, &mut p7, InputMode::FallingEdge, cfg.clone()); 134 let pwm = Pwm::new_input(
135 &mut p.PWM_SLICE3,
136 &mut p7,
137 Pull::None,
138 InputMode::FallingEdge,
139 cfg.clone(),
140 );
129 assert_eq!(pwm.counter(), 0); 141 assert_eq!(pwm.counter(), 0);
130 Timer::after_millis(5).await; 142 Timer::after_millis(5).await;
131 assert_eq!(pwm.counter(), 0); 143 assert_eq!(pwm.counter(), 0);
@@ -137,6 +149,34 @@ async fn main(_spawner: Spawner) {
137 assert_eq!(pwm.counter(), 1); 149 assert_eq!(pwm.counter(), 1);
138 } 150 }
139 151
152 // pull-down
153 {
154 let pin2 = Input::new(&mut p11, Pull::None);
155 Pwm::new_input(
156 &mut p.PWM_SLICE3,
157 &mut p7,
158 Pull::Down,
159 InputMode::FallingEdge,
160 cfg.clone(),
161 );
162 Timer::after_millis(1).await;
163 assert!(pin2.is_low());
164 }
165
166 // pull-up
167 {
168 let pin2 = Input::new(&mut p11, Pull::None);
169 Pwm::new_input(
170 &mut p.PWM_SLICE3,
171 &mut p7,
172 Pull::Up,
173 InputMode::FallingEdge,
174 cfg.clone(),
175 );
176 Timer::after_millis(1).await;
177 assert!(pin2.is_high());
178 }
179
140 info!("Test OK"); 180 info!("Test OK");
141 cortex_m::asm::bkpt(); 181 cortex_m::asm::bkpt();
142} 182}