diff --git a/lib/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.cpp b/lib/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.cpp index dd47d8166..83c51c32d 100644 --- a/lib/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.cpp +++ b/lib/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.cpp @@ -318,9 +318,8 @@ int32_t analogAttach(uint32_t pin, bool output_invert) { // returns ledc chan return chan; } -uint32_t ledcReadFreq2(uint8_t chan) { -// _Z13ledcReadFreqh -// extern "C" uint32_t _Z13ledcReadFreqh(uint8_t chan) { +// uint32_t ledcReadFreq2(uint8_t chan) { +extern "C" uint32_t __wrap_ledcReadFreq(uint8_t chan) { if (chan > MAX_PWMS) { return 0; // wrong channel } diff --git a/lib/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.h b/lib/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.h index b43dd354d..3bfb412a5 100644 --- a/lib/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.h +++ b/lib/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.h @@ -43,7 +43,7 @@ * So it all happens like if there were only 4 timers and a single group of PWM channels. \*******************************************************************************************/ -uint32_t ledcReadFreq2(uint8_t chan); +extern "C" uint32_t ledcReadFreq(uint8_t chan); uint8_t ledcReadResolution(uint8_t chan); // // analogAttach - attach a GPIO to a hardware PWM diff --git a/platformio_tasmota32.ini b/platformio_tasmota32.ini index b735fee57..81bdf580b 100644 --- a/platformio_tasmota32.ini +++ b/platformio_tasmota32.ini @@ -33,6 +33,7 @@ build_flags = ${esp_defaults.build_flags} ; wrappers for the crash-recorder -Wl,--wrap=panicHandler -Wl,--wrap=xt_unhandled_exception -Wl,--wrap=_Z11analogWritehi ; `analogWrite(unsigned char, int)` use the Tasmota version of analogWrite for deeper integration and phase control + -Wl,--wrap=ledcReadFreq ; `uint32_t ledcReadFreq(uint8_t chan)` extra_scripts = pre:pio-tools/add_c_flags.py post:pio-tools/post_esp32.py ${esp_defaults.extra_scripts} diff --git a/tasmota/tasmota_support/support_pwm.ino b/tasmota/tasmota_support/support_pwm.ino index f729b628a..f34a82cfc 100644 --- a/tasmota/tasmota_support/support_pwm.ino +++ b/tasmota/tasmota_support/support_pwm.ino @@ -85,7 +85,7 @@ void PwmApplyGPIO(bool force_update_all) { int32_t chan = analogGetChannel2(pin); uint32_t res = ledcReadResolution(chan); uint32_t range = (1 << res) - 1; - uint32_t freq = ledcReadFreq2(chan); + uint32_t freq = ledcReadFreq(chan); // AddLog(LOG_LEVEL_INFO, "PWM: res0=%i freq0=%i pin=%i chan=%i res=%i timer=%i range=%i freq=%i", timer0_resolution, timer0_freq, pin, chan, res, analogGetTimerForChannel(chan), range, freq);