Skip to content
This repository was archived by the owner on Aug 9, 2022. It is now read-only.

Commit 1ace82b

Browse files
authored
Merge pull request #27 from esp-rs/fix-rollover-blinky
Fix blinky example
2 parents 3811669 + ab2d50c commit 1ace82b

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

examples/blinky.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,9 @@ fn disable_timg_wdts(timg0: &mut hal::esp32::TIMG0, timg1: &mut hal::esp32::TIMG
7575

7676
/// cycle accurate delay using the cycle counter register
7777
pub fn delay(clocks: u32) {
78-
// NOTE: does not account for rollover
79-
let target = get_cycle_count() + clocks;
78+
let start = get_cycle_count();
8079
loop {
81-
if get_cycle_count() > target {
80+
if get_cycle_count().wrapping_sub(start) >= clocks {
8281
break;
8382
}
8483
}

0 commit comments

Comments
 (0)