Skip to content

Commit

Permalink
wait for timer value to be latched for esp32(c3/c6)
Browse files Browse the repository at this point in the history
  • Loading branch information
ju6ge committed Feb 18, 2024
1 parent 172d2b8 commit 6bacf73
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions esp-hal/src/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,17 @@ where
fn now(&self) -> u64 {
let reg_block = unsafe { &*TG::register_block() };

#[cfg(not(any(esp32c3, esp32c6)))]
reg_block.t0update().write(|w| unsafe { w.bits(0) });

#[cfg(any(esp32c3, esp32c6))]
{
reg_block
.t0update()
.write(|w| unsafe { w.update().set_bit() });
while reg_block.t0update().read().update().bit_is_set() {}
}

let value_lo = reg_block.t0lo().read().bits() as u64;
let value_hi = (reg_block.t0hi().read().bits() as u64) << 32;

Expand Down

0 comments on commit 6bacf73

Please sign in to comment.