From 4a0f4f4b68c65b56e9ee80d2a31b17d350c77670 Mon Sep 17 00:00:00 2001 From: Florent de Lamotte Date: Tue, 11 Mar 2025 09:11:14 +0100 Subject: [PATCH] set cpu freq in ESP32Board.h --- examples/companion_radio/main.cpp | 4 ---- examples/simple_repeater/main.cpp | 4 ---- examples/simple_room_server/main.cpp | 5 ----- examples/simple_secure_chat/main.cpp | 5 ----- platformio.ini | 3 ++- src/helpers/ESP32Board.h | 4 ++++ 6 files changed, 6 insertions(+), 19 deletions(-) diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index e719e900..29ec7028 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -1246,10 +1246,6 @@ void setup() { Serial.begin(115200); board.begin(); -#ifdef ESP32_CPU_FREQ - setCpuFrequencyMhz(ESP32_CPU_FREQ); -#endif - #ifdef SX126X_DIO3_TCXO_VOLTAGE float tcxo = SX126X_DIO3_TCXO_VOLTAGE; #else diff --git a/examples/simple_repeater/main.cpp b/examples/simple_repeater/main.cpp index e9f6d480..5743647b 100644 --- a/examples/simple_repeater/main.cpp +++ b/examples/simple_repeater/main.cpp @@ -664,10 +664,6 @@ void setup() { delay(1000); board.begin(); - -#ifdef ESP32_CPU_FREQ - setCpuFrequencyMhz(ESP32_CPU_FREQ); -#endif #ifdef ESP32 fallback_clock.begin(); #endif diff --git a/examples/simple_room_server/main.cpp b/examples/simple_room_server/main.cpp index 5f7d577a..285d59c6 100644 --- a/examples/simple_room_server/main.cpp +++ b/examples/simple_room_server/main.cpp @@ -726,11 +726,6 @@ void setup() { delay(1000); board.begin(); - -#ifdef ESP32_CPU_FREQ - setCpuFrequencyMhz(ESP32_CPU_FREQ); -#endif - #ifdef ESP32 fallback_clock.begin(); #endif diff --git a/examples/simple_secure_chat/main.cpp b/examples/simple_secure_chat/main.cpp index f34f025f..951d51dc 100644 --- a/examples/simple_secure_chat/main.cpp +++ b/examples/simple_secure_chat/main.cpp @@ -566,11 +566,6 @@ void setup() { Serial.begin(115200); board.begin(); - -#ifdef ESP32_CPU_FREQ - setCpuFrequencyMhz(ESP32_CPU_FREQ); -#endif - #ifdef SX126X_DIO3_TCXO_VOLTAGE float tcxo = SX126X_DIO3_TCXO_VOLTAGE; #else diff --git a/platformio.ini b/platformio.ini index 7ecb7ff4..d89737ea 100644 --- a/platformio.ini +++ b/platformio.ini @@ -31,6 +31,8 @@ extends = arduino_base platform = espressif32 monitor_filters = esp32_exception_decoder extra_scripts = merge-bin.py +build_flags = ${arduino_base.build_flags} +; -D ESP32_CPU_FREQ=80 ; change it to your need build_src_filter = ${arduino_base.build_src_filter} ; ================ @@ -126,7 +128,6 @@ build_flags = -D SX126X_DIO3_TCXO_VOLTAGE=1.8 -D SX126X_CURRENT_LIMIT=130.0f ; for best TX power! -D SX126X_RX_BOOSTED_GAIN=true - -D ESP32_CPU_FREQ=240 build_src_filter = ${esp32_base.build_src_filter} lib_deps = ${esp32_base.lib_deps} diff --git a/src/helpers/ESP32Board.h b/src/helpers/ESP32Board.h index 45fb16bd..70e29575 100644 --- a/src/helpers/ESP32Board.h +++ b/src/helpers/ESP32Board.h @@ -17,6 +17,10 @@ public: // for future use, sub-classes SHOULD call this from their begin() startup_reason = BD_STARTUP_NORMAL; + #ifdef ESP32_CPU_FREQ + setCpuFrequencyMhz(ESP32_CPU_FREQ); + #endif + #ifdef PIN_VBAT_READ // battery read support pinMode(PIN_VBAT_READ, INPUT);