mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-25 08:12:30 +00:00
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))]
|
||||
pub use channel::Channel;
|
||||
|
||||
pin_trait!(OutputPin, Instance);
|
||||
pin_trait!(Channel1Pin, Instance);
|
||||
pin_trait!(Channel2Pin, Instance);
|
||||
pin_trait!(OutputPin, BasicInstance);
|
||||
pin_trait!(Channel1Pin, BasicInstance);
|
||||
pin_trait!(Channel2Pin, BasicInstance);
|
||||
|
||||
pub(crate) trait SealedInstance: RccPeripheral {
|
||||
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.
|
||||
#[allow(private_bounds)]
|
||||
pub trait Instance: SealedInstance + 'static {}
|
||||
pub trait Instance: BasicInstance + SealedInstance + 'static {}
|
||||
|
||||
foreach_interrupt! {
|
||||
($inst:ident, lptim, LPTIM, UP, $irq:ident) => {
|
||||
impl SealedInstance for crate::peripherals::$inst {
|
||||
@ -29,9 +35,14 @@ foreach_interrupt! {
|
||||
crate::pac::$inst
|
||||
}
|
||||
}
|
||||
|
||||
impl Instance for crate::peripherals::$inst {
|
||||
|
||||
impl SealedBasicInstance 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 super::timer::Timer;
|
||||
use super::Instance;
|
||||
#[cfg(not(any(lptim_v2a, lptim_v2b)))]
|
||||
use super::OutputPin;
|
||||
#[cfg(any(lptim_v2a, lptim_v2b))]
|
||||
use super::{channel::Channel, timer::ChannelDirection, Channel1Pin, Channel2Pin};
|
||||
use super::{BasicInstance, Instance};
|
||||
use crate::gpio::{AfType, AnyPin, OutputType, Speed};
|
||||
use crate::time::Hertz;
|
||||
use crate::Peripheral;
|
||||
@ -31,7 +31,7 @@ pub struct PwmPin<'d, T, C> {
|
||||
|
||||
macro_rules! channel_impl {
|
||||
($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.")]
|
||||
pub fn $new_chx(pin: impl Peripheral<P = impl $pin_trait<T>> + 'd) -> Self {
|
||||
into_ref!(pin);
|
||||
|
Loading…
Reference in New Issue
Block a user