From 3c8d617e6a1afbe7ad01b46ac9f80cf60aa8c8ee Mon Sep 17 00:00:00 2001 From: TD-er Date: Fri, 29 Sep 2023 21:31:48 +0200 Subject: [PATCH] [ESP32 temp] Fix specific includes for ESP32-S2 --- src/src/Helpers/Hardware.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/src/Helpers/Hardware.cpp b/src/src/Helpers/Hardware.cpp index b22fc597b3..df3d2be76f 100644 --- a/src/src/Helpers/Hardware.cpp +++ b/src/src/Helpers/Hardware.cpp @@ -620,7 +620,12 @@ uint8_t temprature_sens_read(); #include #if ESP_IDF_VERSION_MAJOR < 5 // Work-around for bug in ESP-IDF < 5.0 - #include + #if defined(ESP32S3) || defined(ESP32C3) + #include + #elif defined(ESP32S2) + #include + #endif + #endif #endif // ESP32_CLASSIC #endif // ESP32 @@ -643,6 +648,7 @@ float getInternalTemperature() { #endif if (raw != 128) { result = ESP_OK; + // Raw value is in Fahrenheit celsius = (raw - 32) / 1.8f; } #elif defined(ESP32C3) || defined(ESP32S2) || defined(ESP32S3) @@ -658,9 +664,18 @@ float getInternalTemperature() { // Thus dac_offset can be just about anything // dac_offset is used as index in an array without bounds checking { + #if defined(ESP32S3) || defined(ESP32C3) static float s_deltaT = (esp_efuse_rtc_calib_get_ver() == 1) ? (esp_efuse_rtc_calib_get_cal_temp(1) / 10.0f) : 0.0f; + #elif defined(ESP32S2) + static uint32_t version = esp_efuse_rtc_table_read_calib_version(); + static float s_deltaT = (version == 1 || version == 2) ? + (esp_efuse_rtc_table_get_parsed_efuse_value(RTCCALIB_IDX_TMPSENSOR, false) / 10.0f) : + 0.0f; + #endif + + /* if (isnan(s_deltaT)) { //suggests that the value is not initialized uint32_t version = esp_efuse_rtc_calib_get_ver();