diff options
Diffstat (limited to 'embassy-stm32/src/timer/input_capture.rs')
| -rw-r--r-- | embassy-stm32/src/timer/input_capture.rs | 15 |
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; | |||
| 5 | use core::pin::Pin; | 5 | use core::pin::Pin; |
| 6 | use core::task::{Context, Poll}; | 6 | use core::task::{Context, Poll}; |
| 7 | 7 | ||
| 8 | use embassy_hal_internal::{into_ref, PeripheralRef}; | ||
| 9 | |||
| 10 | use super::low_level::{CountingMode, FilterValue, InputCaptureMode, InputTISelection, Timer}; | 8 | use super::low_level::{CountingMode, FilterValue, InputCaptureMode, InputTISelection, Timer}; |
| 11 | use super::{ | 9 | use super::{ |
| 12 | CaptureCompareInterruptHandler, Channel, Channel1Pin, Channel2Pin, Channel3Pin, Channel4Pin, | 10 | CaptureCompareInterruptHandler, Channel, Channel1Pin, Channel2Pin, Channel3Pin, Channel4Pin, |
| @@ -15,7 +13,7 @@ use super::{ | |||
| 15 | use crate::gpio::{AfType, AnyPin, Pull}; | 13 | use crate::gpio::{AfType, AnyPin, Pull}; |
| 16 | use crate::interrupt::typelevel::{Binding, Interrupt}; | 14 | use crate::interrupt::typelevel::{Binding, Interrupt}; |
| 17 | use crate::time::Hertz; | 15 | use crate::time::Hertz; |
| 18 | use crate::Peripheral; | 16 | use crate::Peri; |
| 19 | 17 | ||
| 20 | /// Channel 1 marker type. | 18 | /// Channel 1 marker type. |
| 21 | pub enum Ch1 {} | 19 | pub 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. |
| 32 | pub struct CapturePin<'d, T, C> { | 30 | pub 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> { | |||
| 63 | impl<'d, T: GeneralInstance4Channel> InputCapture<'d, T> { | 60 | impl<'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); |
