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 /embassy-stm32/src/timer/qei.rs | |
| parent | a6562c4f033432e40970aafe82f33c5138adf84e (diff) | |
stm32/afio: use type inference for timer remaps as well.
Diffstat (limited to 'embassy-stm32/src/timer/qei.rs')
| -rw-r--r-- | embassy-stm32/src/timer/qei.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/embassy-stm32/src/timer/qei.rs b/embassy-stm32/src/timer/qei.rs index 4e5a309ac..39d051294 100644 --- a/embassy-stm32/src/timer/qei.rs +++ b/embassy-stm32/src/timer/qei.rs | |||
| @@ -20,18 +20,20 @@ pub enum Direction { | |||
| 20 | } | 20 | } |
| 21 | 21 | ||
| 22 | /// Wrapper for using a pin with QEI. | 22 | /// Wrapper for using a pin with QEI. |
| 23 | pub struct QeiPin<'d, T, Channel> { | 23 | pub struct QeiPin<'d, T, Channel, A> { |
| 24 | #[allow(unused)] | 24 | #[allow(unused)] |
| 25 | pin: Peri<'d, AnyPin>, | 25 | pin: Peri<'d, AnyPin>, |
| 26 | phantom: PhantomData<(T, Channel)>, | 26 | phantom: PhantomData<(T, Channel, A)>, |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | impl<'d, T: GeneralInstance4Channel, C: QeiChannel> QeiPin<'d, T, C> { | 29 | impl<'d, T: GeneralInstance4Channel, C: QeiChannel, A> QeiPin<'d, T, C, A> { |
| 30 | /// Create a new QEI pin instance. | 30 | /// Create a new QEI pin instance. |
| 31 | pub fn new(pin: Peri<'d, impl TimerPin<T, C>>) -> Self { | 31 | pub fn new(pin: Peri<'d, impl TimerPin<T, C, A>>) -> Self { |
| 32 | critical_section::with(|_| { | 32 | critical_section::with(|_| { |
| 33 | pin.set_low(); | 33 | pin.set_low(); |
| 34 | pin.set_as_af(pin.af_num(), AfType::input(Pull::None)); | 34 | pin.set_as_af(pin.af_num(), AfType::input(Pull::None)); |
| 35 | #[cfg(afio)] | ||
| 36 | pin.afio_remap(); | ||
| 35 | }); | 37 | }); |
| 36 | QeiPin { | 38 | QeiPin { |
| 37 | pin: pin.into(), | 39 | pin: pin.into(), |
| @@ -60,9 +62,7 @@ pub struct Qei<'d, T: GeneralInstance4Channel> { | |||
| 60 | impl<'d, T: GeneralInstance4Channel> Qei<'d, T> { | 62 | impl<'d, T: GeneralInstance4Channel> Qei<'d, T> { |
| 61 | /// Create a new quadrature decoder driver. | 63 | /// Create a new quadrature decoder driver. |
| 62 | #[allow(unused)] | 64 | #[allow(unused)] |
| 63 | pub fn new(tim: Peri<'d, T>, ch1: QeiPin<'d, T, Ch1>, ch2: QeiPin<'d, T, Ch2>) -> Self { | 65 | pub fn new<A>(tim: Peri<'d, T>, ch1: QeiPin<'d, T, Ch1, A>, ch2: QeiPin<'d, T, Ch2, A>) -> Self { |
| 64 | #[cfg(afio)] | ||
| 65 | super::set_afio::<T>(&[Some(ch1.pin), Some(ch2.pin)]); | ||
| 66 | Self::new_inner(tim) | 66 | Self::new_inner(tim) |
| 67 | } | 67 | } |
| 68 | 68 | ||
