aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32/src/timer/qei.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/qei.rs
parent9edf5b7f049f95742b60b041e4443967d8a6b708 (diff)
Remove Peripheral trait, rename PeripheralRef->Peri.
Diffstat (limited to 'embassy-stm32/src/timer/qei.rs')
-rw-r--r--embassy-stm32/src/timer/qei.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/embassy-stm32/src/timer/qei.rs b/embassy-stm32/src/timer/qei.rs
index fc5835414..bac290f28 100644
--- a/embassy-stm32/src/timer/qei.rs
+++ b/embassy-stm32/src/timer/qei.rs
@@ -2,13 +2,12 @@
2 2
3use core::marker::PhantomData; 3use core::marker::PhantomData;
4 4
5use embassy_hal_internal::{into_ref, PeripheralRef};
6use stm32_metapac::timer::vals; 5use stm32_metapac::timer::vals;
7 6
8use super::low_level::Timer; 7use super::low_level::Timer;
9use super::{Channel1Pin, Channel2Pin, GeneralInstance4Channel}; 8use super::{Channel1Pin, Channel2Pin, GeneralInstance4Channel};
10use crate::gpio::{AfType, AnyPin, Pull}; 9use crate::gpio::{AfType, AnyPin, Pull};
11use crate::Peripheral; 10use crate::Peri;
12 11
13/// Counting direction 12/// Counting direction
14pub enum Direction { 13pub enum Direction {
@@ -25,7 +24,7 @@ pub enum Ch2 {}
25 24
26/// Wrapper for using a pin with QEI. 25/// Wrapper for using a pin with QEI.
27pub struct QeiPin<'d, T, Channel> { 26pub struct QeiPin<'d, T, Channel> {
28 _pin: PeripheralRef<'d, AnyPin>, 27 _pin: Peri<'d, AnyPin>,
29 phantom: PhantomData<(T, Channel)>, 28 phantom: PhantomData<(T, Channel)>,
30} 29}
31 30
@@ -33,14 +32,13 @@ macro_rules! channel_impl {
33 ($new_chx:ident, $channel:ident, $pin_trait:ident) => { 32 ($new_chx:ident, $channel:ident, $pin_trait:ident) => {
34 impl<'d, T: GeneralInstance4Channel> QeiPin<'d, T, $channel> { 33 impl<'d, T: GeneralInstance4Channel> QeiPin<'d, T, $channel> {
35 #[doc = concat!("Create a new ", stringify!($channel), " QEI pin instance.")] 34 #[doc = concat!("Create a new ", stringify!($channel), " QEI pin instance.")]
36 pub fn $new_chx(pin: impl Peripheral<P = impl $pin_trait<T>> + 'd) -> Self { 35 pub fn $new_chx(pin: Peri<'d, impl $pin_trait<T>>) -> Self {
37 into_ref!(pin);
38 critical_section::with(|_| { 36 critical_section::with(|_| {
39 pin.set_low(); 37 pin.set_low();
40 pin.set_as_af(pin.af_num(), AfType::input(Pull::None)); 38 pin.set_as_af(pin.af_num(), AfType::input(Pull::None));
41 }); 39 });
42 QeiPin { 40 QeiPin {
43 _pin: pin.map_into(), 41 _pin: pin.into(),
44 phantom: PhantomData, 42 phantom: PhantomData,
45 } 43 }
46 } 44 }
@@ -58,11 +56,11 @@ pub struct Qei<'d, T: GeneralInstance4Channel> {
58 56
59impl<'d, T: GeneralInstance4Channel> Qei<'d, T> { 57impl<'d, T: GeneralInstance4Channel> Qei<'d, T> {
60 /// Create a new quadrature decoder driver. 58 /// Create a new quadrature decoder driver.
61 pub fn new(tim: impl Peripheral<P = T> + 'd, _ch1: QeiPin<'d, T, Ch1>, _ch2: QeiPin<'d, T, Ch2>) -> Self { 59 pub fn new(tim: Peri<'d, T>, _ch1: QeiPin<'d, T, Ch1>, _ch2: QeiPin<'d, T, Ch2>) -> Self {
62 Self::new_inner(tim) 60 Self::new_inner(tim)
63 } 61 }
64 62
65 fn new_inner(tim: impl Peripheral<P = T> + 'd) -> Self { 63 fn new_inner(tim: Peri<'d, T>) -> Self {
66 let inner = Timer::new(tim); 64 let inner = Timer::new(tim);
67 let r = inner.regs_gp16(); 65 let r = inner.regs_gp16();
68 66