Skip to content

Commit

Permalink
Fix invocation of esp32_update_cpu_freq (#124)
Browse files Browse the repository at this point in the history
* Fix invocation of esp32_update_cpu_freq

* Update comment for `esp32_update_cpu_freq`
  • Loading branch information
bjoernQ authored Jul 27, 2022
1 parent 1bf89b3 commit ffc6c16
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions esp-hal-common/src/clocks_ll/esp32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,16 +360,16 @@ pub(crate) fn set_cpu_freq(cpu_freq_mhz: crate::clock::CpuClock) {
.store5
.modify(|_, w| w.scratch5().bits(value as u32));

esp32_update_cpu_freq(cpu_freq_mhz.frequency().to_Hz());
esp32_update_cpu_freq(cpu_freq_mhz.mhz());
}
}

/// Set the real CPU ticks per us to the ets, so that ets_delay_us
/// Pass the CPU clock in MHz so that ets_delay_us
/// will be accurate. Call this function when CPU frequency is changed.
fn esp32_update_cpu_freq(ticks_per_us: u32) {
fn esp32_update_cpu_freq(mhz: u32) {
const G_TICKS_PER_US_PRO: u32 = 0x3ffe01e0;
unsafe {
// Update scale factors used by esp_rom_delay_us
(G_TICKS_PER_US_PRO as *mut u32).write_volatile(ticks_per_us);
(G_TICKS_PER_US_PRO as *mut u32).write_volatile(mhz);
}
}

0 comments on commit ffc6c16

Please sign in to comment.