Merge pull request #2450 from shufps/feat/timer-driver-tim22-tim23

adds timer-driver for tim21 and tim22 (on L0)
This commit is contained in:
Dario Nieuwenhuis 2024-01-15 12:01:22 +01:00 committed by GitHub
commit 9cd0beaee3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 2 deletions

View File

@ -139,6 +139,10 @@ time-driver-tim11 = ["_time-driver"]
time-driver-tim12 = ["_time-driver"]
## Use TIM15 as time driver
time-driver-tim15 = ["_time-driver"]
## Use TIM21 as time driver
time-driver-tim21 = ["_time-driver"]
## Use TIM22 as time driver
time-driver-tim22 = ["_time-driver"]
#! ## Analog Switch Pins (Pxy_C) on STM32H7 series

View File

@ -191,6 +191,8 @@ fn main() {
Some("tim11") => "TIM11",
Some("tim12") => "TIM12",
Some("tim15") => "TIM15",
Some("tim21") => "TIM21",
Some("tim22") => "TIM22",
Some("any") => {
if singletons.contains(&"TIM2".to_string()) {
"TIM2"
@ -208,6 +210,10 @@ fn main() {
"TIM12"
} else if singletons.contains(&"TIM15".to_string()) {
"TIM15"
} else if singletons.contains(&"TIM21".to_string()) {
"TIM21"
} else if singletons.contains(&"TIM22".to_string()) {
"TIM22"
} else {
panic!("time-driver-any requested, but the chip doesn't have TIM2, TIM3, TIM4, TIM5, TIM9, TIM11, TIM12 or TIM15.")
}

View File

@ -28,10 +28,10 @@ use crate::{interrupt, peripherals};
// available after reserving CC1 for regular time keeping. For example, TIM2 has four CC registers:
// CC1, CC2, CC3, and CC4, so it can provide ALARM_COUNT = 3.
#[cfg(not(any(time_driver_tim12, time_driver_tim15)))]
#[cfg(not(any(time_driver_tim12, time_driver_tim15, time_driver_tim21, time_driver_tim22)))]
const ALARM_COUNT: usize = 3;
#[cfg(any(time_driver_tim12, time_driver_tim15))]
#[cfg(any(time_driver_tim12, time_driver_tim15, time_driver_tim21, time_driver_tim22))]
const ALARM_COUNT: usize = 1;
#[cfg(time_driver_tim2)]
@ -50,6 +50,10 @@ type T = peripherals::TIM11;
type T = peripherals::TIM12;
#[cfg(time_driver_tim15)]
type T = peripherals::TIM15;
#[cfg(time_driver_tim21)]
type T = peripherals::TIM21;
#[cfg(time_driver_tim22)]
type T = peripherals::TIM22;
foreach_interrupt! {
(TIM2, timer, $block:ident, UP, $irq:ident) => {
@ -116,6 +120,22 @@ foreach_interrupt! {
DRIVER.on_interrupt()
}
};
(TIM21, timer, $block:ident, UP, $irq:ident) => {
#[cfg(time_driver_tim21)]
#[cfg(feature = "rt")]
#[interrupt]
fn $irq() {
DRIVER.on_interrupt()
}
};
(TIM22, timer, $block:ident, UP, $irq:ident) => {
#[cfg(time_driver_tim22)]
#[cfg(feature = "rt")]
#[interrupt]
fn $irq() {
DRIVER.on_interrupt()
}
};
}
// Clock timekeeping works with something we call "periods", which are time intervals