diff options
| author | Romain Goyet <[email protected]> | 2024-09-05 16:30:45 -0400 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2024-09-11 01:18:52 +0200 |
| commit | ac319970b82e3e613c35d45a11f31423204115e0 (patch) | |
| tree | 8e5ad9fc98c78c9aee926d90decb9e64d64d7ffa | |
| parent | 652133bce48f39ea5f379d056ca46a7f2ca3a99a (diff) | |
stm32: Work around LPTIM4
| -rw-r--r-- | embassy-stm32/src/lptim/mod.rs | 25 | ||||
| -rw-r--r-- | embassy-stm32/src/lptim/pwm.rs | 4 |
2 files changed, 20 insertions, 9 deletions
diff --git a/embassy-stm32/src/lptim/mod.rs b/embassy-stm32/src/lptim/mod.rs index 9c10efa43..05ed4de44 100644 --- a/embassy-stm32/src/lptim/mod.rs +++ b/embassy-stm32/src/lptim/mod.rs | |||
| @@ -11,17 +11,23 @@ mod channel; | |||
| 11 | #[cfg(any(lptim_v2a, lptim_v2b))] | 11 | #[cfg(any(lptim_v2a, lptim_v2b))] |
| 12 | pub use channel::Channel; | 12 | pub use channel::Channel; |
| 13 | 13 | ||
| 14 | pin_trait!(OutputPin, Instance); | 14 | pin_trait!(OutputPin, BasicInstance); |
| 15 | pin_trait!(Channel1Pin, Instance); | 15 | pin_trait!(Channel1Pin, BasicInstance); |
| 16 | pin_trait!(Channel2Pin, Instance); | 16 | pin_trait!(Channel2Pin, BasicInstance); |
| 17 | 17 | ||
| 18 | pub(crate) trait SealedInstance: RccPeripheral { | 18 | pub(crate) trait SealedInstance: RccPeripheral { |
| 19 | fn regs() -> crate::pac::lptim::Lptim; | 19 | fn regs() -> crate::pac::lptim::Lptim; |
| 20 | } | 20 | } |
| 21 | pub(crate) trait SealedBasicInstance: RccPeripheral {} | ||
| 22 | |||
| 23 | /// LPTIM basic instance trait. | ||
| 24 | #[allow(private_bounds)] | ||
| 25 | pub trait BasicInstance: SealedBasicInstance + 'static {} | ||
| 21 | 26 | ||
| 22 | /// LPTIM instance trait. | 27 | /// LPTIM instance trait. |
| 23 | #[allow(private_bounds)] | 28 | #[allow(private_bounds)] |
| 24 | pub trait Instance: SealedInstance + 'static {} | 29 | pub trait Instance: BasicInstance + SealedInstance + 'static {} |
| 30 | |||
| 25 | foreach_interrupt! { | 31 | foreach_interrupt! { |
| 26 | ($inst:ident, lptim, LPTIM, UP, $irq:ident) => { | 32 | ($inst:ident, lptim, LPTIM, UP, $irq:ident) => { |
| 27 | impl SealedInstance for crate::peripherals::$inst { | 33 | impl SealedInstance for crate::peripherals::$inst { |
| @@ -29,9 +35,14 @@ foreach_interrupt! { | |||
| 29 | crate::pac::$inst | 35 | crate::pac::$inst |
| 30 | } | 36 | } |
| 31 | } | 37 | } |
| 32 | 38 | impl SealedBasicInstance for crate::peripherals::$inst { | |
| 33 | impl Instance for crate::peripherals::$inst { | 39 | } |
| 34 | 40 | impl BasicInstance for crate::peripherals::$inst {} | |
| 41 | impl Instance for crate::peripherals::$inst {} | ||
| 42 | }; | ||
| 43 | ($inst:ident, lptim, LPTIM_BASIC, UP, $irq:ident) => { | ||
| 44 | impl SealedBasicInstance for crate::peripherals::$inst { | ||
| 35 | } | 45 | } |
| 46 | impl BasicInstance for crate::peripherals::$inst {} | ||
| 36 | }; | 47 | }; |
| 37 | } | 48 | } |
diff --git a/embassy-stm32/src/lptim/pwm.rs b/embassy-stm32/src/lptim/pwm.rs index 586148848..1f43eb6ee 100644 --- a/embassy-stm32/src/lptim/pwm.rs +++ b/embassy-stm32/src/lptim/pwm.rs | |||
| @@ -5,11 +5,11 @@ use core::marker::PhantomData; | |||
| 5 | use embassy_hal_internal::{into_ref, PeripheralRef}; | 5 | use embassy_hal_internal::{into_ref, PeripheralRef}; |
| 6 | 6 | ||
| 7 | use super::timer::Timer; | 7 | use super::timer::Timer; |
| 8 | use super::Instance; | ||
| 9 | #[cfg(not(any(lptim_v2a, lptim_v2b)))] | 8 | #[cfg(not(any(lptim_v2a, lptim_v2b)))] |
| 10 | use super::OutputPin; | 9 | use super::OutputPin; |
| 11 | #[cfg(any(lptim_v2a, lptim_v2b))] | 10 | #[cfg(any(lptim_v2a, lptim_v2b))] |
| 12 | use super::{channel::Channel, timer::ChannelDirection, Channel1Pin, Channel2Pin}; | 11 | use super::{channel::Channel, timer::ChannelDirection, Channel1Pin, Channel2Pin}; |
| 12 | use super::{BasicInstance, Instance}; | ||
| 13 | use crate::gpio::{AfType, AnyPin, OutputType, Speed}; | 13 | use crate::gpio::{AfType, AnyPin, OutputType, Speed}; |
| 14 | use crate::time::Hertz; | 14 | use crate::time::Hertz; |
| 15 | use crate::Peripheral; | 15 | use crate::Peripheral; |
| @@ -31,7 +31,7 @@ pub struct PwmPin<'d, T, C> { | |||
| 31 | 31 | ||
| 32 | macro_rules! channel_impl { | 32 | macro_rules! channel_impl { |
| 33 | ($new_chx:ident, $channel:ident, $pin_trait:ident) => { | 33 | ($new_chx:ident, $channel:ident, $pin_trait:ident) => { |
| 34 | impl<'d, T: Instance> PwmPin<'d, T, $channel> { | 34 | impl<'d, T: BasicInstance> PwmPin<'d, T, $channel> { |
| 35 | #[doc = concat!("Create a new ", stringify!($channel), " PWM pin instance.")] | 35 | #[doc = concat!("Create a new ", stringify!($channel), " PWM pin instance.")] |
| 36 | pub fn $new_chx(pin: impl Peripheral<P = impl $pin_trait<T>> + 'd) -> Self { | 36 | pub fn $new_chx(pin: impl Peripheral<P = impl $pin_trait<T>> + 'd) -> Self { |
| 37 | into_ref!(pin); | 37 | into_ref!(pin); |
