diff options
| author | Dario Nieuwenhuis <[email protected]> | 2025-03-26 16:01:37 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2025-03-27 15:18:06 +0100 |
| commit | d41eeeae79388f219bf6a84e2f7bde9f6b532516 (patch) | |
| tree | 678b6fc732216e529dc38e6f65b72a309917ac32 /embassy-stm32/src/timer/complementary_pwm.rs | |
| parent | 9edf5b7f049f95742b60b041e4443967d8a6b708 (diff) | |
Remove Peripheral trait, rename PeripheralRef->Peri.
Diffstat (limited to 'embassy-stm32/src/timer/complementary_pwm.rs')
| -rw-r--r-- | embassy-stm32/src/timer/complementary_pwm.rs | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/embassy-stm32/src/timer/complementary_pwm.rs b/embassy-stm32/src/timer/complementary_pwm.rs index 02c01e900..f543bafab 100644 --- a/embassy-stm32/src/timer/complementary_pwm.rs +++ b/embassy-stm32/src/timer/complementary_pwm.rs | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | 2 | ||
| 3 | use core::marker::PhantomData; | 3 | use core::marker::PhantomData; |
| 4 | 4 | ||
| 5 | use embassy_hal_internal::{into_ref, PeripheralRef}; | ||
| 6 | use stm32_metapac::timer::vals::Ckd; | 5 | use stm32_metapac::timer::vals::Ckd; |
| 7 | 6 | ||
| 8 | use super::low_level::{CountingMode, OutputPolarity, Timer}; | 7 | use super::low_level::{CountingMode, OutputPolarity, Timer}; |
| @@ -14,13 +13,13 @@ use super::{ | |||
| 14 | use crate::gpio::{AnyPin, OutputType}; | 13 | use crate::gpio::{AnyPin, OutputType}; |
| 15 | use crate::time::Hertz; | 14 | use crate::time::Hertz; |
| 16 | use crate::timer::low_level::OutputCompareMode; | 15 | use crate::timer::low_level::OutputCompareMode; |
| 17 | use crate::Peripheral; | 16 | use crate::Peri; |
| 18 | 17 | ||
| 19 | /// Complementary PWM pin wrapper. | 18 | /// Complementary PWM pin wrapper. |
| 20 | /// | 19 | /// |
| 21 | /// This wraps a pin to make it usable with PWM. | 20 | /// This wraps a pin to make it usable with PWM. |
| 22 | pub struct ComplementaryPwmPin<'d, T, C> { | 21 | pub struct ComplementaryPwmPin<'d, T, C> { |
| 23 | _pin: PeripheralRef<'d, AnyPin>, | 22 | _pin: Peri<'d, AnyPin>, |
| 24 | phantom: PhantomData<(T, C)>, | 23 | phantom: PhantomData<(T, C)>, |
| 25 | } | 24 | } |
| 26 | 25 | ||
| @@ -28,8 +27,7 @@ macro_rules! complementary_channel_impl { | |||
| 28 | ($new_chx:ident, $channel:ident, $pin_trait:ident) => { | 27 | ($new_chx:ident, $channel:ident, $pin_trait:ident) => { |
| 29 | impl<'d, T: AdvancedInstance4Channel> ComplementaryPwmPin<'d, T, $channel> { | 28 | impl<'d, T: AdvancedInstance4Channel> ComplementaryPwmPin<'d, T, $channel> { |
| 30 | #[doc = concat!("Create a new ", stringify!($channel), " complementary PWM pin instance.")] | 29 | #[doc = concat!("Create a new ", stringify!($channel), " complementary PWM pin instance.")] |
| 31 | pub fn $new_chx(pin: impl Peripheral<P = impl $pin_trait<T>> + 'd, output_type: OutputType) -> Self { | 30 | pub fn $new_chx(pin: Peri<'d, impl $pin_trait<T>>, output_type: OutputType) -> Self { |
| 32 | into_ref!(pin); | ||
| 33 | critical_section::with(|_| { | 31 | critical_section::with(|_| { |
| 34 | pin.set_low(); | 32 | pin.set_low(); |
| 35 | pin.set_as_af( | 33 | pin.set_as_af( |
| @@ -38,7 +36,7 @@ macro_rules! complementary_channel_impl { | |||
| 38 | ); | 36 | ); |
| 39 | }); | 37 | }); |
| 40 | ComplementaryPwmPin { | 38 | ComplementaryPwmPin { |
| 41 | _pin: pin.map_into(), | 39 | _pin: pin.into(), |
| 42 | phantom: PhantomData, | 40 | phantom: PhantomData, |
| 43 | } | 41 | } |
| 44 | } | 42 | } |
| @@ -60,7 +58,7 @@ impl<'d, T: AdvancedInstance4Channel> ComplementaryPwm<'d, T> { | |||
| 60 | /// Create a new complementary PWM driver. | 58 | /// Create a new complementary PWM driver. |
| 61 | #[allow(clippy::too_many_arguments)] | 59 | #[allow(clippy::too_many_arguments)] |
| 62 | pub fn new( | 60 | pub fn new( |
| 63 | tim: impl Peripheral<P = T> + 'd, | 61 | tim: Peri<'d, T>, |
| 64 | _ch1: Option<PwmPin<'d, T, Ch1>>, | 62 | _ch1: Option<PwmPin<'d, T, Ch1>>, |
| 65 | _ch1n: Option<ComplementaryPwmPin<'d, T, Ch1>>, | 63 | _ch1n: Option<ComplementaryPwmPin<'d, T, Ch1>>, |
| 66 | _ch2: Option<PwmPin<'d, T, Ch2>>, | 64 | _ch2: Option<PwmPin<'d, T, Ch2>>, |
| @@ -75,7 +73,7 @@ impl<'d, T: AdvancedInstance4Channel> ComplementaryPwm<'d, T> { | |||
| 75 | Self::new_inner(tim, freq, counting_mode) | 73 | Self::new_inner(tim, freq, counting_mode) |
| 76 | } | 74 | } |
| 77 | 75 | ||
| 78 | fn new_inner(tim: impl Peripheral<P = T> + 'd, freq: Hertz, counting_mode: CountingMode) -> Self { | 76 | fn new_inner(tim: Peri<'d, T>, freq: Hertz, counting_mode: CountingMode) -> Self { |
| 79 | let mut this = Self { inner: Timer::new(tim) }; | 77 | let mut this = Self { inner: Timer::new(tim) }; |
| 80 | 78 | ||
| 81 | this.inner.set_counting_mode(counting_mode); | 79 | this.inner.set_counting_mode(counting_mode); |
