aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32/src/timer/input_capture.rs
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2025-09-05 23:00:31 +0200
committerDario Nieuwenhuis <[email protected]>2025-09-05 23:00:31 +0200
commit7419b398bf7cc5c1ff164c504f4a4027cd6bcd3b (patch)
tree9ea26e1059b70502d0e5929a72a9f50c8c43838b /embassy-stm32/src/timer/input_capture.rs
parenta6562c4f033432e40970aafe82f33c5138adf84e (diff)
stm32/afio: use type inference for timer remaps as well.
Diffstat (limited to 'embassy-stm32/src/timer/input_capture.rs')
-rw-r--r--embassy-stm32/src/timer/input_capture.rs25
1 files changed, 9 insertions, 16 deletions
diff --git a/embassy-stm32/src/timer/input_capture.rs b/embassy-stm32/src/timer/input_capture.rs
index b717e6eac..262f9d067 100644
--- a/embassy-stm32/src/timer/input_capture.rs
+++ b/embassy-stm32/src/timer/input_capture.rs
@@ -17,14 +17,14 @@ use crate::Peri;
17/// Capture pin wrapper. 17/// Capture pin wrapper.
18/// 18///
19/// This wraps a pin to make it usable with capture. 19/// This wraps a pin to make it usable with capture.
20pub struct CapturePin<'d, T, C> { 20pub struct CapturePin<'d, T, C, A> {
21 #[allow(unused)] 21 #[allow(unused)]
22 pin: Peri<'d, AnyPin>, 22 pin: Peri<'d, AnyPin>,
23 phantom: PhantomData<(T, C)>, 23 phantom: PhantomData<(T, C, A)>,
24} 24}
25impl<'d, T: GeneralInstance4Channel, C: TimerChannel> CapturePin<'d, T, C> { 25impl<'d, T: GeneralInstance4Channel, C: TimerChannel, A> CapturePin<'d, T, C, A> {
26 /// Create a new capture pin instance. 26 /// Create a new capture pin instance.
27 pub fn new(pin: Peri<'d, impl TimerPin<T, C>>, pull: Pull) -> Self { 27 pub fn new(pin: Peri<'d, impl TimerPin<T, C, A>>, pull: Pull) -> Self {
28 pin.set_as_af(pin.af_num(), AfType::input(pull)); 28 pin.set_as_af(pin.af_num(), AfType::input(pull));
29 CapturePin { 29 CapturePin {
30 pin: pin.into(), 30 pin: pin.into(),
@@ -41,23 +41,16 @@ pub struct InputCapture<'d, T: GeneralInstance4Channel> {
41impl<'d, T: GeneralInstance4Channel> InputCapture<'d, T> { 41impl<'d, T: GeneralInstance4Channel> InputCapture<'d, T> {
42 /// Create a new input capture driver. 42 /// Create a new input capture driver.
43 #[allow(unused)] 43 #[allow(unused)]
44 pub fn new( 44 pub fn new<A>(
45 tim: Peri<'d, T>, 45 tim: Peri<'d, T>,
46 ch1: Option<CapturePin<'d, T, Ch1>>, 46 ch1: Option<CapturePin<'d, T, Ch1, A>>,
47 ch2: Option<CapturePin<'d, T, Ch2>>, 47 ch2: Option<CapturePin<'d, T, Ch2, A>>,
48 ch3: Option<CapturePin<'d, T, Ch3>>, 48 ch3: Option<CapturePin<'d, T, Ch3, A>>,
49 ch4: Option<CapturePin<'d, T, Ch4>>, 49 ch4: Option<CapturePin<'d, T, Ch4, A>>,
50 _irq: impl Binding<T::CaptureCompareInterrupt, CaptureCompareInterruptHandler<T>> + 'd, 50 _irq: impl Binding<T::CaptureCompareInterrupt, CaptureCompareInterruptHandler<T>> + 'd,
51 freq: Hertz, 51 freq: Hertz,
52 counting_mode: CountingMode, 52 counting_mode: CountingMode,
53 ) -> 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 ]);
61 Self::new_inner(tim, freq, counting_mode) 54 Self::new_inner(tim, freq, counting_mode)
62 } 55 }
63 56