1 | //! Low-power timer (LPTIM) |
2 | |
3 | pub mod pwm; |
4 | pub mod timer; |
5 | |
6 | use crate::rcc::RccPeripheral; |
7 | |
8 | /// Timer channel. |
9 | #[cfg (any(lptim_v2a, lptim_v2b))] |
10 | mod channel; |
11 | #[cfg (any(lptim_v2a, lptim_v2b))] |
12 | pub use channel::Channel; |
13 | |
14 | pin_trait!(OutputPin, BasicInstance); |
15 | pin_trait!(Channel1Pin, BasicInstance); |
16 | pin_trait!(Channel2Pin, BasicInstance); |
17 | |
18 | pub(crate) trait SealedInstance: RccPeripheral { |
19 | fn regs() -> crate::pac::lptim::Lptim; |
20 | } |
21 | pub(crate) trait SealedBasicInstance: RccPeripheral {} |
22 | |
23 | /// LPTIM basic instance trait. |
24 | #[allow (private_bounds)] |
25 | pub trait BasicInstance: SealedBasicInstance + 'static {} |
26 | |
27 | /// LPTIM instance trait. |
28 | #[allow (private_bounds)] |
29 | pub trait Instance: BasicInstance + SealedInstance + 'static {} |
30 | |
31 | foreach_interrupt! { |
32 | ($inst:ident, lptim, LPTIM, GLOBAL, $irq:ident) => { |
33 | impl SealedInstance for crate::peripherals::$inst { |
34 | fn regs() -> crate::pac::lptim::Lptim { |
35 | crate::pac::$inst |
36 | } |
37 | } |
38 | impl SealedBasicInstance for crate::peripherals::$inst { |
39 | } |
40 | impl BasicInstance for crate::peripherals::$inst {} |
41 | impl Instance for crate::peripherals::$inst {} |
42 | }; |
43 | ($inst:ident, lptim, LPTIM_BASIC, GLOBAL, $irq:ident) => { |
44 | impl SealedBasicInstance for crate::peripherals::$inst { |
45 | } |
46 | impl BasicInstance for crate::peripherals::$inst {} |
47 | }; |
48 | } |
49 | |