diff options
| author | Dario Nieuwenhuis <[email protected]> | 2025-09-05 23:00:31 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2025-09-05 23:00:31 +0200 |
| commit | 7419b398bf7cc5c1ff164c504f4a4027cd6bcd3b (patch) | |
| tree | 9ea26e1059b70502d0e5929a72a9f50c8c43838b /tests/stm32 | |
| parent | a6562c4f033432e40970aafe82f33c5138adf84e (diff) | |
stm32/afio: use type inference for timer remaps as well.
Diffstat (limited to 'tests/stm32')
| -rw-r--r-- | tests/stm32/src/bin/afio.rs | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/tests/stm32/src/bin/afio.rs b/tests/stm32/src/bin/afio.rs index c684b7b3e..cc44dc59c 100644 --- a/tests/stm32/src/bin/afio.rs +++ b/tests/stm32/src/bin/afio.rs | |||
| @@ -6,7 +6,7 @@ mod common; | |||
| 6 | 6 | ||
| 7 | use common::*; | 7 | use common::*; |
| 8 | use embassy_executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_stm32::gpio::{OutputType, Pull}; | 9 | use embassy_stm32::gpio::{AfioRemap, OutputType, Pull}; |
| 10 | use embassy_stm32::pac::AFIO; | 10 | use embassy_stm32::pac::AFIO; |
| 11 | use embassy_stm32::time::khz; | 11 | use embassy_stm32::time::khz; |
| 12 | use embassy_stm32::timer::complementary_pwm::{ComplementaryPwm, ComplementaryPwmPin}; | 12 | use embassy_stm32::timer::complementary_pwm::{ComplementaryPwm, ComplementaryPwmPin}; |
| @@ -173,7 +173,7 @@ async fn main(_spawner: Spawner) { | |||
| 173 | { | 173 | { |
| 174 | // no remap | 174 | // no remap |
| 175 | afio_registers_set_remap(); | 175 | afio_registers_set_remap(); |
| 176 | SimplePwm::new( | 176 | SimplePwm::new::<AfioRemap<0>>( |
| 177 | p.TIM1.reborrow(), | 177 | p.TIM1.reborrow(), |
| 178 | Some(PwmPin::new(p.PA8.reborrow(), OutputType::PushPull)), | 178 | Some(PwmPin::new(p.PA8.reborrow(), OutputType::PushPull)), |
| 179 | Some(PwmPin::new(p.PA9.reborrow(), OutputType::PushPull)), | 179 | Some(PwmPin::new(p.PA9.reborrow(), OutputType::PushPull)), |
| @@ -187,7 +187,7 @@ async fn main(_spawner: Spawner) { | |||
| 187 | { | 187 | { |
| 188 | // no remap | 188 | // no remap |
| 189 | afio_registers_set_remap(); | 189 | afio_registers_set_remap(); |
| 190 | SimplePwm::new( | 190 | SimplePwm::new::<AfioRemap<0>>( |
| 191 | p.TIM1.reborrow(), | 191 | p.TIM1.reborrow(), |
| 192 | Some(PwmPin::new(p.PA8.reborrow(), OutputType::PushPull)), | 192 | Some(PwmPin::new(p.PA8.reborrow(), OutputType::PushPull)), |
| 193 | None, | 193 | None, |
| @@ -201,7 +201,7 @@ async fn main(_spawner: Spawner) { | |||
| 201 | { | 201 | { |
| 202 | // partial remap | 202 | // partial remap |
| 203 | reset_afio_registers(); | 203 | reset_afio_registers(); |
| 204 | ComplementaryPwm::new( | 204 | ComplementaryPwm::new::<AfioRemap<1>>( |
| 205 | p.TIM1.reborrow(), | 205 | p.TIM1.reborrow(), |
| 206 | Some(PwmPin::new(p.PA8.reborrow(), OutputType::PushPull)), | 206 | Some(PwmPin::new(p.PA8.reborrow(), OutputType::PushPull)), |
| 207 | None, | 207 | None, |
| @@ -219,7 +219,7 @@ async fn main(_spawner: Spawner) { | |||
| 219 | { | 219 | { |
| 220 | // partial remap | 220 | // partial remap |
| 221 | reset_afio_registers(); | 221 | reset_afio_registers(); |
| 222 | ComplementaryPwm::new( | 222 | ComplementaryPwm::new::<AfioRemap<1>>( |
| 223 | p.TIM1.reborrow(), | 223 | p.TIM1.reborrow(), |
| 224 | Some(PwmPin::new(p.PA8.reborrow(), OutputType::PushPull)), | 224 | Some(PwmPin::new(p.PA8.reborrow(), OutputType::PushPull)), |
| 225 | Some(ComplementaryPwmPin::new(p.PA7.reborrow(), OutputType::PushPull)), | 225 | Some(ComplementaryPwmPin::new(p.PA7.reborrow(), OutputType::PushPull)), |
| @@ -237,7 +237,7 @@ async fn main(_spawner: Spawner) { | |||
| 237 | { | 237 | { |
| 238 | // partial remap | 238 | // partial remap |
| 239 | reset_afio_registers(); | 239 | reset_afio_registers(); |
| 240 | InputCapture::new( | 240 | InputCapture::new::<AfioRemap<1>>( |
| 241 | p.TIM1.reborrow(), | 241 | p.TIM1.reborrow(), |
| 242 | Some(CapturePin::new(p.PA8.reborrow(), Pull::Down)), | 242 | Some(CapturePin::new(p.PA8.reborrow(), Pull::Down)), |
| 243 | None, | 243 | None, |
| @@ -252,13 +252,13 @@ async fn main(_spawner: Spawner) { | |||
| 252 | { | 252 | { |
| 253 | // partial remap | 253 | // partial remap |
| 254 | reset_afio_registers(); | 254 | reset_afio_registers(); |
| 255 | PwmInput::new_ch1(p.TIM1.reborrow(), p.PA8.reborrow(), Pull::Down, khz(10)); | 255 | PwmInput::new_ch1::<AfioRemap<1>>(p.TIM1.reborrow(), p.PA8.reborrow(), Pull::Down, khz(10)); |
| 256 | defmt::assert_eq!(AFIO.mapr().read().tim1_remap(), 1); | 256 | defmt::assert_eq!(AFIO.mapr().read().tim1_remap(), 1); |
| 257 | } | 257 | } |
| 258 | { | 258 | { |
| 259 | // partial remap | 259 | // partial remap |
| 260 | reset_afio_registers(); | 260 | reset_afio_registers(); |
| 261 | Qei::new( | 261 | Qei::new::<AfioRemap<1>>( |
| 262 | p.TIM1.reborrow(), | 262 | p.TIM1.reborrow(), |
| 263 | QeiPin::new(p.PA8.reborrow()), | 263 | QeiPin::new(p.PA8.reborrow()), |
| 264 | QeiPin::new(p.PA9.reborrow()), | 264 | QeiPin::new(p.PA9.reborrow()), |
| @@ -270,7 +270,7 @@ async fn main(_spawner: Spawner) { | |||
| 270 | { | 270 | { |
| 271 | // no remap | 271 | // no remap |
| 272 | afio_registers_set_remap(); | 272 | afio_registers_set_remap(); |
| 273 | SimplePwm::new( | 273 | SimplePwm::new::<AfioRemap<0>>( |
| 274 | p.TIM2.reborrow(), | 274 | p.TIM2.reborrow(), |
| 275 | Some(PwmPin::new(p.PA0.reborrow(), OutputType::PushPull)), | 275 | Some(PwmPin::new(p.PA0.reborrow(), OutputType::PushPull)), |
| 276 | Some(PwmPin::new(p.PA1.reborrow(), OutputType::PushPull)), | 276 | Some(PwmPin::new(p.PA1.reborrow(), OutputType::PushPull)), |
| @@ -284,7 +284,7 @@ async fn main(_spawner: Spawner) { | |||
| 284 | { | 284 | { |
| 285 | // partial remap 1 | 285 | // partial remap 1 |
| 286 | reset_afio_registers(); | 286 | reset_afio_registers(); |
| 287 | SimplePwm::new( | 287 | SimplePwm::new::<AfioRemap<1>>( |
| 288 | p.TIM2.reborrow(), | 288 | p.TIM2.reborrow(), |
| 289 | Some(PwmPin::new(p.PA15.reborrow(), OutputType::PushPull)), | 289 | Some(PwmPin::new(p.PA15.reborrow(), OutputType::PushPull)), |
| 290 | Some(PwmPin::new(p.PB3.reborrow(), OutputType::PushPull)), | 290 | Some(PwmPin::new(p.PB3.reborrow(), OutputType::PushPull)), |
| @@ -298,7 +298,7 @@ async fn main(_spawner: Spawner) { | |||
| 298 | { | 298 | { |
| 299 | // partial remap 2 | 299 | // partial remap 2 |
| 300 | reset_afio_registers(); | 300 | reset_afio_registers(); |
| 301 | SimplePwm::new( | 301 | SimplePwm::new::<AfioRemap<2>>( |
| 302 | p.TIM2.reborrow(), | 302 | p.TIM2.reborrow(), |
| 303 | Some(PwmPin::new(p.PA0.reborrow(), OutputType::PushPull)), | 303 | Some(PwmPin::new(p.PA0.reborrow(), OutputType::PushPull)), |
| 304 | Some(PwmPin::new(p.PA1.reborrow(), OutputType::PushPull)), | 304 | Some(PwmPin::new(p.PA1.reborrow(), OutputType::PushPull)), |
| @@ -312,7 +312,7 @@ async fn main(_spawner: Spawner) { | |||
| 312 | { | 312 | { |
| 313 | // full remap | 313 | // full remap |
| 314 | reset_afio_registers(); | 314 | reset_afio_registers(); |
| 315 | SimplePwm::new( | 315 | SimplePwm::new::<AfioRemap<3>>( |
| 316 | p.TIM2.reborrow(), | 316 | p.TIM2.reborrow(), |
| 317 | Some(PwmPin::new(p.PA15.reborrow(), OutputType::PushPull)), | 317 | Some(PwmPin::new(p.PA15.reborrow(), OutputType::PushPull)), |
| 318 | Some(PwmPin::new(p.PB3.reborrow(), OutputType::PushPull)), | 318 | Some(PwmPin::new(p.PB3.reborrow(), OutputType::PushPull)), |
