Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion esp-hal-common/src/delay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ mod delay {
let t0 = SystemTimer::now();
let clocks = (us as u64 * self.freq.raw()) / HertzU64::MHz(1).raw();

while SystemTimer::now().wrapping_sub(t0) <= clocks {}
while SystemTimer::now().wrapping_sub(t0) & SystemTimer::BIT_MASK <= clocks {}
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions esp-hal-common/src/systimer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ pub struct SystemTimer {
}

impl SystemTimer {
#[cfg(esp32s2)]
pub const BIT_MASK: u64 = u64::MAX;
#[cfg(any(esp32c2, esp32c3, esp32s3))]
pub const BIT_MASK: u64 = 0xFFFFFFFFFFFFF;

#[cfg(esp32s2)]
pub const TICKS_PER_SECOND: u64 = 80_000_000; // TODO this can change when we have support for changing APB frequency
#[cfg(any(esp32c2, esp32c3, esp32s3))]
Expand Down