mirror of
https://github.com/rtic-rs/rtic.git
synced 2025-12-16 21:05:35 +01:00
panic if STM32 clock prescaler value overflows
This commit is contained in:
parent
1104a12ca3
commit
b4a0c9057d
2 changed files with 7 additions and 2 deletions
|
|
@ -7,6 +7,9 @@ For each category, *Added*, *Changed*, *Fixed* add new entries at the top!
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Panic if STM32 prescaler value would overflow
|
||||||
|
|
||||||
## v2.1.0 - 2025-06-22
|
## v2.1.0 - 2025-06-22
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
|
||||||
|
|
@ -238,8 +238,10 @@ macro_rules! make_timer {
|
||||||
$timer.cr1().modify(|r| r.set_cen(false));
|
$timer.cr1().modify(|r| r.set_cen(false));
|
||||||
|
|
||||||
assert!((tim_clock_hz % timer_hz) == 0, "Unable to find suitable timer prescaler value!");
|
assert!((tim_clock_hz % timer_hz) == 0, "Unable to find suitable timer prescaler value!");
|
||||||
let psc = tim_clock_hz / timer_hz - 1;
|
let Ok(psc) = u16::try_from(tim_clock_hz / timer_hz - 1) else {
|
||||||
$timer.psc().write(|r| r.set_psc(psc as u16));
|
panic!("Clock prescaler overflowed!");
|
||||||
|
};
|
||||||
|
$timer.psc().write(|r| r.set_psc(psc));
|
||||||
|
|
||||||
// Enable full-period interrupt.
|
// Enable full-period interrupt.
|
||||||
$timer.dier().modify(|r| r.set_uie(true));
|
$timer.dier().modify(|r| r.set_uie(true));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue