Skip to content

Commit

Permalink
STM32: add support for LPTIM time driver
Browse files Browse the repository at this point in the history
  • Loading branch information
chrenderle committed Nov 8, 2024
1 parent 05d3623 commit 1ee12d5
Show file tree
Hide file tree
Showing 6 changed files with 509 additions and 38 deletions.
4 changes: 4 additions & 0 deletions embassy-stm32/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ time-driver-tim22 = ["_time-driver"]
time-driver-tim23 = ["_time-driver"]
## Use TIM24 as time driver
time-driver-tim24 = ["_time-driver"]
## Use LPTIM1 as time driver
time-driver-lptim1 = ["_time-driver"]
## Use LPTIM2 as time driver
time-driver-lptim2 = ["_time-driver"]


#! ## Analog Switch Pins (Pxy_C) on STM32H7 series
Expand Down
4 changes: 3 additions & 1 deletion embassy-stm32/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ fn main() {
Some("tim22") => "TIM22",
Some("tim23") => "TIM23",
Some("tim24") => "TIM24",
Some("lptim1") => "LPTIM1",
Some("lptim2") => "LPTIM2",
Some("any") => {
// Order of TIM candidators:
// 1. 2CH -> 2CH_CMP -> GP16 -> GP32 -> ADV
Expand All @@ -236,7 +238,7 @@ fn main() {
}
for tim in [
"tim1", "tim2", "tim3", "tim4", "tim5", "tim8", "tim9", "tim12", "tim15", "tim20", "tim21", "tim22", "tim23",
"tim24",
"tim24", "lptim1", "lptim2",
] {
cfgs.declare(format!("time_driver_{}", tim));
}
Expand Down
2 changes: 2 additions & 0 deletions embassy-stm32/src/lptim/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pin_trait!(Channel2Pin, BasicInstance);

pub(crate) trait SealedInstance: RccPeripheral {
fn regs() -> crate::pac::lptim::Lptim;
type Interrupt: crate::interrupt::typelevel::Interrupt;
}
pub(crate) trait SealedBasicInstance: RccPeripheral {}

Expand All @@ -34,6 +35,7 @@ foreach_interrupt! {
fn regs() -> crate::pac::lptim::Lptim {
crate::pac::$inst
}
type Interrupt = crate::interrupt::typelevel::$irq;
}
impl SealedBasicInstance for crate::peripherals::$inst {
}
Expand Down
Loading

0 comments on commit 1ee12d5

Please sign in to comment.