use crate::gpio::OptionalPin; #[cfg(feature = "unstable-pac")] pub mod low_level { pub use super::sealed::*; } pub(crate) mod sealed { use crate::gpio::sealed::OptionalPin; pub trait Channel1Pin: OptionalPin { unsafe fn configure(&mut self); } pub trait Channel1ComplementaryPin: OptionalPin { unsafe fn configure(&mut self); } pub trait Channel2Pin: OptionalPin { unsafe fn configure(&mut self); } pub trait Channel2ComplementaryPin: OptionalPin { unsafe fn configure(&mut self); } pub trait Channel3Pin: OptionalPin { unsafe fn configure(&mut self); } pub trait Channel3ComplementaryPin: OptionalPin { unsafe fn configure(&mut self); } pub trait Channel4Pin: OptionalPin { unsafe fn configure(&mut self); } pub trait Channel4ComplementaryPin: OptionalPin { unsafe fn configure(&mut self); } pub trait ExternalTriggerPin: OptionalPin { unsafe fn configure(&mut self); } pub trait BreakInputPin: OptionalPin { unsafe fn configure(&mut self); } pub trait BreakInputComparator1Pin: OptionalPin { unsafe fn configure(&mut self); } pub trait BreakInputComparator2Pin: OptionalPin { unsafe fn configure(&mut self); } pub trait BreakInput2Pin: OptionalPin { unsafe fn configure(&mut self); } pub trait BreakInput2Comparator1Pin: OptionalPin { unsafe fn configure(&mut self); } pub trait BreakInput2Comparator2Pin: OptionalPin { unsafe fn configure(&mut self); } } pub trait Channel1Pin: sealed::Channel1Pin + OptionalPin + 'static {} pub trait Channel1ComplementaryPin: sealed::Channel1ComplementaryPin + OptionalPin + 'static { } pub trait Channel2Pin: sealed::Channel2Pin + 'static {} pub trait Channel2ComplementaryPin: sealed::Channel2ComplementaryPin + OptionalPin + 'static { } pub trait Channel3Pin: sealed::Channel3Pin + 'static {} pub trait Channel3ComplementaryPin: sealed::Channel3ComplementaryPin + OptionalPin + 'static { } pub trait Channel4Pin: sealed::Channel4Pin + 'static {} pub trait Channel4ComplementaryPin: sealed::Channel4ComplementaryPin + OptionalPin + 'static { } pub trait ExternalTriggerPin: sealed::ExternalTriggerPin + OptionalPin + 'static { } pub trait BreakInputPin: sealed::BreakInputPin + OptionalPin + 'static {} pub trait BreakInputComparator1Pin: sealed::BreakInputComparator1Pin + OptionalPin + 'static { } pub trait BreakInputComparator2Pin: sealed::BreakInputComparator2Pin + OptionalPin + 'static { } pub trait BreakInput2Pin: sealed::BreakInput2Pin + OptionalPin + 'static {} pub trait BreakInput2Comparator1Pin: sealed::BreakInput2Comparator1Pin + OptionalPin + 'static { } pub trait BreakInput2Comparator2Pin: sealed::BreakInput2Comparator2Pin + OptionalPin + 'static { } macro_rules! impl_no_pin { ($timer:ident, $signal:ident) => { impl crate::pwm::pins::sealed::$signal for crate::gpio::NoPin { unsafe fn configure(&mut self) {} } impl crate::pwm::pins::$signal for crate::gpio::NoPin {} }; } #[allow(unused)] macro_rules! impl_pin { ($timer:ident, $signal:ident, $pin:ident, $af:expr) => { impl crate::pwm::pins::sealed::$signal for crate::peripherals::$pin { unsafe fn configure(&mut self) { use crate::gpio::sealed::{AFType, Pin}; use crate::gpio::Speed; self.set_low(); self.set_speed(Speed::VeryHigh); self.set_as_af($af, AFType::OutputPushPull); } } impl crate::pwm::pins::$signal for crate::peripherals::$pin {} }; }