stm32: Work around LPTIM4
This commit is contained in:
parent
652133bce4
commit
ac319970b8
@ -11,17 +11,23 @@ mod channel;
|
|||||||
#[cfg(any(lptim_v2a, lptim_v2b))]
|
#[cfg(any(lptim_v2a, lptim_v2b))]
|
||||||
pub use channel::Channel;
|
pub use channel::Channel;
|
||||||
|
|
||||||
pin_trait!(OutputPin, Instance);
|
pin_trait!(OutputPin, BasicInstance);
|
||||||
pin_trait!(Channel1Pin, Instance);
|
pin_trait!(Channel1Pin, BasicInstance);
|
||||||
pin_trait!(Channel2Pin, Instance);
|
pin_trait!(Channel2Pin, BasicInstance);
|
||||||
|
|
||||||
pub(crate) trait SealedInstance: RccPeripheral {
|
pub(crate) trait SealedInstance: RccPeripheral {
|
||||||
fn regs() -> crate::pac::lptim::Lptim;
|
fn regs() -> crate::pac::lptim::Lptim;
|
||||||
}
|
}
|
||||||
|
pub(crate) trait SealedBasicInstance: RccPeripheral {}
|
||||||
|
|
||||||
|
/// LPTIM basic instance trait.
|
||||||
|
#[allow(private_bounds)]
|
||||||
|
pub trait BasicInstance: SealedBasicInstance + 'static {}
|
||||||
|
|
||||||
/// LPTIM instance trait.
|
/// LPTIM instance trait.
|
||||||
#[allow(private_bounds)]
|
#[allow(private_bounds)]
|
||||||
pub trait Instance: SealedInstance + 'static {}
|
pub trait Instance: BasicInstance + SealedInstance + 'static {}
|
||||||
|
|
||||||
foreach_interrupt! {
|
foreach_interrupt! {
|
||||||
($inst:ident, lptim, LPTIM, UP, $irq:ident) => {
|
($inst:ident, lptim, LPTIM, UP, $irq:ident) => {
|
||||||
impl SealedInstance for crate::peripherals::$inst {
|
impl SealedInstance for crate::peripherals::$inst {
|
||||||
@ -29,9 +35,14 @@ foreach_interrupt! {
|
|||||||
crate::pac::$inst
|
crate::pac::$inst
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
impl SealedBasicInstance for crate::peripherals::$inst {
|
||||||
impl Instance for crate::peripherals::$inst {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
impl BasicInstance for crate::peripherals::$inst {}
|
||||||
|
impl Instance for crate::peripherals::$inst {}
|
||||||
|
};
|
||||||
|
($inst:ident, lptim, LPTIM_BASIC, UP, $irq:ident) => {
|
||||||
|
impl SealedBasicInstance for crate::peripherals::$inst {
|
||||||
|
}
|
||||||
|
impl BasicInstance for crate::peripherals::$inst {}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,11 +5,11 @@ use core::marker::PhantomData;
|
|||||||
use embassy_hal_internal::{into_ref, PeripheralRef};
|
use embassy_hal_internal::{into_ref, PeripheralRef};
|
||||||
|
|
||||||
use super::timer::Timer;
|
use super::timer::Timer;
|
||||||
use super::Instance;
|
|
||||||
#[cfg(not(any(lptim_v2a, lptim_v2b)))]
|
#[cfg(not(any(lptim_v2a, lptim_v2b)))]
|
||||||
use super::OutputPin;
|
use super::OutputPin;
|
||||||
#[cfg(any(lptim_v2a, lptim_v2b))]
|
#[cfg(any(lptim_v2a, lptim_v2b))]
|
||||||
use super::{channel::Channel, timer::ChannelDirection, Channel1Pin, Channel2Pin};
|
use super::{channel::Channel, timer::ChannelDirection, Channel1Pin, Channel2Pin};
|
||||||
|
use super::{BasicInstance, Instance};
|
||||||
use crate::gpio::{AfType, AnyPin, OutputType, Speed};
|
use crate::gpio::{AfType, AnyPin, OutputType, Speed};
|
||||||
use crate::time::Hertz;
|
use crate::time::Hertz;
|
||||||
use crate::Peripheral;
|
use crate::Peripheral;
|
||||||
@ -31,7 +31,7 @@ pub struct PwmPin<'d, T, C> {
|
|||||||
|
|
||||||
macro_rules! channel_impl {
|
macro_rules! channel_impl {
|
||||||
($new_chx:ident, $channel:ident, $pin_trait:ident) => {
|
($new_chx:ident, $channel:ident, $pin_trait:ident) => {
|
||||||
impl<'d, T: Instance> PwmPin<'d, T, $channel> {
|
impl<'d, T: BasicInstance> PwmPin<'d, T, $channel> {
|
||||||
#[doc = concat!("Create a new ", stringify!($channel), " PWM pin instance.")]
|
#[doc = concat!("Create a new ", stringify!($channel), " PWM pin instance.")]
|
||||||
pub fn $new_chx(pin: impl Peripheral<P = impl $pin_trait<T>> + 'd) -> Self {
|
pub fn $new_chx(pin: impl Peripheral<P = impl $pin_trait<T>> + 'd) -> Self {
|
||||||
into_ref!(pin);
|
into_ref!(pin);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user