gfroerli / firmware

Firmware for the water temperature sensor project
GNU General Public License v3.0
6 stars 1 forks source link

monotonic impl: Fix panic due to timer rollover #96

Closed rnestler closed 3 years ago

rnestler commented 3 years ago

After the timer value rolls over the newer more recent value will be negative. Calculating the duration_since with an older still positive Instant results in a panic due to subtracting with overflow:

panicked at 'attempt to subtract with overflow', src/monotonic_stm32l0.rs:149:20

Fixes #96

See also https://github.com/rtic-rs/rtic-examples/commit/beabbe39d5c4bb37c8c453de704aeba0b8c118b0