From 91d308207a5d7a61910a1ca95b5cf0e9bdf8c311 Mon Sep 17 00:00:00 2001 From: bjoernQ Date: Wed, 27 Jul 2022 14:07:31 +0200 Subject: [PATCH 1/2] Fix invocation of esp32_update_cpu_freq --- esp-hal-common/src/clocks_ll/esp32.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/esp-hal-common/src/clocks_ll/esp32.rs b/esp-hal-common/src/clocks_ll/esp32.rs index 047d36a5462..54f6917ed08 100644 --- a/esp-hal-common/src/clocks_ll/esp32.rs +++ b/esp-hal-common/src/clocks_ll/esp32.rs @@ -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 /// 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); } } From f8a08849aed7f3017fc31e5ebe93b336f9cef18c Mon Sep 17 00:00:00 2001 From: bjoernQ Date: Wed, 27 Jul 2022 15:01:24 +0200 Subject: [PATCH 2/2] Update comment for `esp32_update_cpu_freq` --- esp-hal-common/src/clocks_ll/esp32.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esp-hal-common/src/clocks_ll/esp32.rs b/esp-hal-common/src/clocks_ll/esp32.rs index 54f6917ed08..fb9b4ece2a7 100644 --- a/esp-hal-common/src/clocks_ll/esp32.rs +++ b/esp-hal-common/src/clocks_ll/esp32.rs @@ -364,7 +364,7 @@ pub(crate) fn set_cpu_freq(cpu_freq_mhz: crate::clock::CpuClock) { } } -/// 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(mhz: u32) { const G_TICKS_PER_US_PRO: u32 = 0x3ffe01e0;