Skip to content

Commit b2111b9

Browse files
david-sawatzketherealprof
authored andcommitted
Fix overflow in delay (#40)
Gets checked in debug builds
1 parent 6b2ffaa commit b2111b9

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1212
- Support for STM32F091 - @jessebraham
1313
- Support for HSE as a system clocksource (#25 - breaking change) - @zklapow
1414

15+
### Fixed
16+
17+
- Fixed panic in delay overflow handling for debug builds - @david-sawatzke
18+
1519
## [v0.11.1] - 2019-01-05
1620

1721
### Added

src/delay.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ impl DelayUs<u32> for Delay {
9999

100100
let start_count = SYST::get_current();
101101
total_rvr -= current_rvr;
102-
while ((start_count - SYST::get_current()) % MAX_SYSTICK) < current_rvr {}
102+
while (start_count.wrapping_sub(SYST::get_current()) % MAX_SYSTICK) < current_rvr {}
103103
}
104104
}
105105
}

0 commit comments

Comments
 (0)