diff options
Diffstat (limited to 'embassy-stm32/src/timer/input_capture.rs')
| -rw-r--r-- | embassy-stm32/src/timer/input_capture.rs | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/embassy-stm32/src/timer/input_capture.rs b/embassy-stm32/src/timer/input_capture.rs index dda33e7f1..b717e6eac 100644 --- a/embassy-stm32/src/timer/input_capture.rs +++ b/embassy-stm32/src/timer/input_capture.rs | |||
| @@ -18,7 +18,8 @@ use crate::Peri; | |||
| 18 | /// | 18 | /// |
| 19 | /// This wraps a pin to make it usable with capture. | 19 | /// This wraps a pin to make it usable with capture. |
| 20 | pub struct CapturePin<'d, T, C> { | 20 | pub struct CapturePin<'d, T, C> { |
| 21 | _pin: Peri<'d, AnyPin>, | 21 | #[allow(unused)] |
| 22 | pin: Peri<'d, AnyPin>, | ||
| 22 | phantom: PhantomData<(T, C)>, | 23 | phantom: PhantomData<(T, C)>, |
| 23 | } | 24 | } |
| 24 | impl<'d, T: GeneralInstance4Channel, C: TimerChannel> CapturePin<'d, T, C> { | 25 | impl<'d, T: GeneralInstance4Channel, C: TimerChannel> CapturePin<'d, T, C> { |
| @@ -26,7 +27,7 @@ impl<'d, T: GeneralInstance4Channel, C: TimerChannel> CapturePin<'d, T, C> { | |||
| 26 | pub fn new(pin: Peri<'d, impl TimerPin<T, C>>, pull: Pull) -> Self { | 27 | pub fn new(pin: Peri<'d, impl TimerPin<T, C>>, pull: Pull) -> Self { |
| 27 | pin.set_as_af(pin.af_num(), AfType::input(pull)); | 28 | pin.set_as_af(pin.af_num(), AfType::input(pull)); |
| 28 | CapturePin { | 29 | CapturePin { |
| 29 | _pin: pin.into(), | 30 | pin: pin.into(), |
| 30 | phantom: PhantomData, | 31 | phantom: PhantomData, |
| 31 | } | 32 | } |
| 32 | } | 33 | } |
| @@ -39,16 +40,24 @@ pub struct InputCapture<'d, T: GeneralInstance4Channel> { | |||
| 39 | 40 | ||
| 40 | impl<'d, T: GeneralInstance4Channel> InputCapture<'d, T> { | 41 | impl<'d, T: GeneralInstance4Channel> InputCapture<'d, T> { |
| 41 | /// Create a new input capture driver. | 42 | /// Create a new input capture driver. |
| 43 | #[allow(unused)] | ||
| 42 | pub fn new( | 44 | pub fn new( |
| 43 | tim: Peri<'d, T>, | 45 | tim: Peri<'d, T>, |
| 44 | _ch1: Option<CapturePin<'d, T, Ch1>>, | 46 | ch1: Option<CapturePin<'d, T, Ch1>>, |
| 45 | _ch2: Option<CapturePin<'d, T, Ch2>>, | 47 | ch2: Option<CapturePin<'d, T, Ch2>>, |
| 46 | _ch3: Option<CapturePin<'d, T, Ch3>>, | 48 | ch3: Option<CapturePin<'d, T, Ch3>>, |
| 47 | _ch4: Option<CapturePin<'d, T, Ch4>>, | 49 | ch4: Option<CapturePin<'d, T, Ch4>>, |
| 48 | _irq: impl Binding<T::CaptureCompareInterrupt, CaptureCompareInterruptHandler<T>> + 'd, | 50 | _irq: impl Binding<T::CaptureCompareInterrupt, CaptureCompareInterruptHandler<T>> + 'd, |
| 49 | freq: Hertz, | 51 | freq: Hertz, |
| 50 | counting_mode: CountingMode, | 52 | counting_mode: CountingMode, |
| 51 | ) -> Self { | 53 | ) -> Self { |
| 54 | #[cfg(afio)] | ||
| 55 | super::set_afio::<T>(&[ | ||
| 56 | ch1.map(|p| p.pin), | ||
| 57 | ch2.map(|p| p.pin), | ||
| 58 | ch3.map(|p| p.pin), | ||
| 59 | ch4.map(|p| p.pin), | ||
| 60 | ]); | ||
| 52 | Self::new_inner(tim, freq, counting_mode) | 61 | Self::new_inner(tim, freq, counting_mode) |
| 53 | } | 62 | } |
| 54 | 63 | ||
