From 422772b98805829f914e68d3861feff6592809da Mon Sep 17 00:00:00 2001 From: Andrey Zgarbul Date: Tue, 7 Jan 2025 14:06:05 +0300 Subject: [PATCH] remove Lines --- src/timer.rs | 1 + src/timer/capture.rs | 38 +++++--------------------------------- 2 files changed, 6 insertions(+), 33 deletions(-) diff --git a/src/timer.rs b/src/timer.rs index 97bc9d28..30bce86c 100644 --- a/src/timer.rs +++ b/src/timer.rs @@ -498,6 +498,7 @@ macro_rules! split { ($(PwmChannelDisabled::<_, $C>::new(),)+) } } + #[cfg(not(feature = "gpio-f410"))] impl SplitCapture for $TIM { type CaptureChannels = ($(CaptureChannelDisabled<$TIM, $C>,)+); fn split_capture() -> Self::CaptureChannels { diff --git a/src/timer/capture.rs b/src/timer/capture.rs index 02bfdbf2..4576a40b 100644 --- a/src/timer/capture.rs +++ b/src/timer/capture.rs @@ -5,7 +5,7 @@ //! Timer::new(dp.TIM5, &clocks).capture_hz(24.MHz()); //! ``` //! In the `capture_hz` method, the desired timer counter frequency is specified. -//! For high accuracy, it is recommended to use 32-bit timers (TIM2, TIM5) and to select the highest possible frequency, ideally the maximum frequency equal to the timer's clock frequency. +//! For high accuracy, it is recommended to use 32-bit timers (TIM2, TIM5) and to select the highest possible frequency, ideally the maximum frequency equal to the timer's clock frequency. //! This returns a `CaptureHzManager` and a tuple of all `CaptureChannel`s supported by the timer. Additionally, the [`CaptureExt`] trait is implemented for `pac::TIMx` to simplify the creation of a new structure. //! //! ```rust,ignore @@ -102,32 +102,14 @@ where self.tim.preload_capture(C, CaptureMode::InputCapture); CaptureChannel { tim: self.tim, - lines: CaptureLines::One(pin.into()), - } - } -} - -#[derive(Debug)] -pub enum CaptureLines

{ - One(P), - Two(P, P), - Three(P, P, P), - Four(P, P, P, P), -} -impl

CaptureLines

{ - pub fn and(self, pin: P) -> Self { - match self { - Self::One(p) => Self::Two(p, pin), - Self::Two(p1, p2) => Self::Three(p1, p2, pin), - Self::Three(p1, p2, p3) => Self::Four(p1, p2, p3, pin), - Self::Four(_, _, _, _) => unreachable!(), + pin: pin.into(), } } } pub struct CaptureChannel, const C: u8, const COMP: bool = false, Otype = PushPull> { pub(super) tim: TIM, - lines: CaptureLines>, + pin: TIM::Ch, // TODO: add complementary pins } @@ -137,9 +119,9 @@ impl, const C: u8, const COMP: bool, Otype pub const fn channel(&self) -> u8 { C } - pub fn release(mut self) -> (CaptureChannelDisabled, CaptureLines>) { + pub fn release(mut self) -> (CaptureChannelDisabled, TIM::Ch) { self.disable(); - (CaptureChannelDisabled { tim: self.tim }, self.lines) + (CaptureChannelDisabled { tim: self.tim }, self.pin) } pub fn erase(self) -> CaptureErasedChannel { CaptureErasedChannel { @@ -156,16 +138,6 @@ impl, const C: u8, const COMP: bool, Otype self.tim.filter_capture(C, filter); } } -impl, const C: u8, const COMP: bool, Otype> - CaptureChannel -{ - pub fn with(self, pin: impl Into>) -> Self { - Self { - tim: self.tim, - lines: self.lines.and(pin.into()), - } - } -} pub struct CaptureErasedChannel { _tim: TIM,