division by zero check to avoid panic #39

Merged
muellerr merged 1 commits from mohr/div_zero into main 2026-02-14 17:45:20 +01:00
2 changed files with 6 additions and 1 deletions
+1
View File
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## Changed
- Added division by zero check in gtc frequency_to_ticks to avoid runtime panic
- Increased UART type safety by providing dedicated MIO constructors for UART 0 and UART 1
respectively.
- Several bugfixes and improvements for GIC module. Some of the registers previously were
+5 -1
View File
@@ -18,7 +18,11 @@ unsafe impl Send for GlobalTimerCounter {}
/// Convert a frequency to GTC ticks given a clock frequency.
pub const fn frequency_to_ticks(clock: Hertz, frequency: Hertz) -> u32 {
clock.raw().div_ceil(frequency.raw())
if frequency.raw() != 0 {
clock.raw().div_ceil(frequency.raw())
} else {
0
}
}
impl GlobalTimerCounter {