aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32/src/timer/input_capture.rs
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2025-03-26 16:01:37 +0100
committerDario Nieuwenhuis <[email protected]>2025-03-27 15:18:06 +0100
commitd41eeeae79388f219bf6a84e2f7bde9f6b532516 (patch)
tree678b6fc732216e529dc38e6f65b72a309917ac32 /embassy-stm32/src/timer/input_capture.rs
parent9edf5b7f049f95742b60b041e4443967d8a6b708 (diff)
Remove Peripheral trait, rename PeripheralRef->Peri.
Diffstat (limited to 'embassy-stm32/src/timer/input_capture.rs')
-rw-r--r--embassy-stm32/src/timer/input_capture.rs15
1 files changed, 6 insertions, 9 deletions
diff --git a/embassy-stm32/src/timer/input_capture.rs b/embassy-stm32/src/timer/input_capture.rs
index b7c13343c..0450f14fa 100644
--- a/embassy-stm32/src/timer/input_capture.rs
+++ b/embassy-stm32/src/timer/input_capture.rs
@@ -5,8 +5,6 @@ use core::marker::PhantomData;
5use core::pin::Pin; 5use core::pin::Pin;
6use core::task::{Context, Poll}; 6use core::task::{Context, Poll};
7 7
8use embassy_hal_internal::{into_ref, PeripheralRef};
9
10use super::low_level::{CountingMode, FilterValue, InputCaptureMode, InputTISelection, Timer}; 8use super::low_level::{CountingMode, FilterValue, InputCaptureMode, InputTISelection, Timer};
11use super::{ 9use super::{
12 CaptureCompareInterruptHandler, Channel, Channel1Pin, Channel2Pin, Channel3Pin, Channel4Pin, 10 CaptureCompareInterruptHandler, Channel, Channel1Pin, Channel2Pin, Channel3Pin, Channel4Pin,
@@ -15,7 +13,7 @@ use super::{
15use crate::gpio::{AfType, AnyPin, Pull}; 13use crate::gpio::{AfType, AnyPin, Pull};
16use crate::interrupt::typelevel::{Binding, Interrupt}; 14use crate::interrupt::typelevel::{Binding, Interrupt};
17use crate::time::Hertz; 15use crate::time::Hertz;
18use crate::Peripheral; 16use crate::Peri;
19 17
20/// Channel 1 marker type. 18/// Channel 1 marker type.
21pub enum Ch1 {} 19pub enum Ch1 {}
@@ -30,7 +28,7 @@ pub enum Ch4 {}
30/// 28///
31/// This wraps a pin to make it usable with capture. 29/// This wraps a pin to make it usable with capture.
32pub struct CapturePin<'d, T, C> { 30pub struct CapturePin<'d, T, C> {
33 _pin: PeripheralRef<'d, AnyPin>, 31 _pin: Peri<'d, AnyPin>,
34 phantom: PhantomData<(T, C)>, 32 phantom: PhantomData<(T, C)>,
35} 33}
36 34
@@ -38,11 +36,10 @@ macro_rules! channel_impl {
38 ($new_chx:ident, $channel:ident, $pin_trait:ident) => { 36 ($new_chx:ident, $channel:ident, $pin_trait:ident) => {
39 impl<'d, T: GeneralInstance4Channel> CapturePin<'d, T, $channel> { 37 impl<'d, T: GeneralInstance4Channel> CapturePin<'d, T, $channel> {
40 #[doc = concat!("Create a new ", stringify!($channel), " capture pin instance.")] 38 #[doc = concat!("Create a new ", stringify!($channel), " capture pin instance.")]
41 pub fn $new_chx(pin: impl Peripheral<P = impl $pin_trait<T>> + 'd, pull: Pull) -> Self { 39 pub fn $new_chx(pin: Peri<'d, impl $pin_trait<T>>, pull: Pull) -> Self {
42 into_ref!(pin);
43 pin.set_as_af(pin.af_num(), AfType::input(pull)); 40 pin.set_as_af(pin.af_num(), AfType::input(pull));
44 CapturePin { 41 CapturePin {
45 _pin: pin.map_into(), 42 _pin: pin.into(),
46 phantom: PhantomData, 43 phantom: PhantomData,
47 } 44 }
48 } 45 }
@@ -63,7 +60,7 @@ pub struct InputCapture<'d, T: GeneralInstance4Channel> {
63impl<'d, T: GeneralInstance4Channel> InputCapture<'d, T> { 60impl<'d, T: GeneralInstance4Channel> InputCapture<'d, T> {
64 /// Create a new input capture driver. 61 /// Create a new input capture driver.
65 pub fn new( 62 pub fn new(
66 tim: impl Peripheral<P = T> + 'd, 63 tim: Peri<'d, T>,
67 _ch1: Option<CapturePin<'d, T, Ch1>>, 64 _ch1: Option<CapturePin<'d, T, Ch1>>,
68 _ch2: Option<CapturePin<'d, T, Ch2>>, 65 _ch2: Option<CapturePin<'d, T, Ch2>>,
69 _ch3: Option<CapturePin<'d, T, Ch3>>, 66 _ch3: Option<CapturePin<'d, T, Ch3>>,
@@ -75,7 +72,7 @@ impl<'d, T: GeneralInstance4Channel> InputCapture<'d, T> {
75 Self::new_inner(tim, freq, counting_mode) 72 Self::new_inner(tim, freq, counting_mode)
76 } 73 }
77 74
78 fn new_inner(tim: impl Peripheral<P = T> + 'd, freq: Hertz, counting_mode: CountingMode) -> Self { 75 fn new_inner(tim: Peri<'d, T>, freq: Hertz, counting_mode: CountingMode) -> Self {
79 let mut this = Self { inner: Timer::new(tim) }; 76 let mut this = Self { inner: Timer::new(tim) };
80 77
81 this.inner.set_counting_mode(counting_mode); 78 this.inner.set_counting_mode(counting_mode);