forked from espressif/esp-idf
Merge branch 'refactor/remove_tsens_legacy' into 'master'
refactor(temperature_sensor): Remove legacy temperature sensor driver Closes IDF-12570 and IDF-13366 See merge request espressif/esp-idf!39840
This commit is contained in:
@@ -45,11 +45,6 @@ if(CONFIG_SOC_SDM_SUPPORTED)
|
||||
list(APPEND srcs "deprecated/sigma_delta_legacy.c")
|
||||
endif()
|
||||
|
||||
# Temperature Sensor related source files
|
||||
if(CONFIG_SOC_TEMP_SENSOR_SUPPORTED)
|
||||
list(APPEND srcs "deprecated/rtc_temperature_legacy.c")
|
||||
endif()
|
||||
|
||||
# Touch Sensor related source files
|
||||
if(CONFIG_SOC_TOUCH_SENSOR_SUPPORTED)
|
||||
if(CONFIG_SOC_TOUCH_SENSOR_VERSION LESS 3)
|
||||
|
@@ -145,23 +145,6 @@ menu "Driver Configurations"
|
||||
This configuration option allows the user to bypass the conflict check mechanism with legacy code.
|
||||
endmenu # Legacy SDM Driver Configurationss
|
||||
|
||||
menu "Legacy Temperature Sensor Driver Configurations"
|
||||
depends on SOC_TEMP_SENSOR_SUPPORTED
|
||||
config TEMP_SENSOR_SUPPRESS_DEPRECATE_WARN
|
||||
bool "Suppress legacy driver deprecated warning"
|
||||
default n
|
||||
help
|
||||
whether to suppress the deprecation warnings when using legacy temperature sensor driver
|
||||
(driver/temp_sensor.h). If you want to continue using the legacy driver,
|
||||
and don't want to see related deprecation warnings, you can enable this option.
|
||||
|
||||
config TEMP_SENSOR_SKIP_LEGACY_CONFLICT_CHECK
|
||||
bool "Skip legacy conflict check"
|
||||
default n
|
||||
help
|
||||
This configuration option allows the user to bypass the conflict check mechanism with legacy code.
|
||||
endmenu # Legacy Temperature Sensor Driver Configurationss
|
||||
|
||||
menu "Legacy Touch Sensor Driver Configurations"
|
||||
depends on SOC_TOUCH_SENSOR_SUPPORTED
|
||||
config TOUCH_SUPPRESS_DEPRECATE_WARN
|
||||
|
@@ -1,77 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2010-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_err.h"
|
||||
#include "driver/temp_sensor_types_legacy.h"
|
||||
|
||||
#if !CONFIG_TEMP_SENSOR_SUPPRESS_DEPRECATE_WARN
|
||||
#warning "legacy temperature sensor driver is deprecated, please migrate to driver/temperature_sensor.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Set parameter of temperature sensor.
|
||||
* @param tsens
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
*/
|
||||
esp_err_t temp_sensor_set_config(temp_sensor_config_t tsens);
|
||||
|
||||
/**
|
||||
* @brief Get parameter of temperature sensor.
|
||||
* @param tsens
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
*/
|
||||
esp_err_t temp_sensor_get_config(temp_sensor_config_t *tsens);
|
||||
|
||||
/**
|
||||
* @brief Start temperature sensor measure.
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_STATE if temperature sensor is started already.
|
||||
*/
|
||||
esp_err_t temp_sensor_start(void);
|
||||
|
||||
/**
|
||||
* @brief Stop temperature sensor measure.
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_STATE if temperature sensor is stopped already.
|
||||
*/
|
||||
esp_err_t temp_sensor_stop(void);
|
||||
|
||||
/**
|
||||
* @brief Read temperature sensor raw data.
|
||||
* @param tsens_out Pointer to raw data, Range: 0 ~ 255
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG `tsens_out` is NULL
|
||||
* - ESP_ERR_INVALID_STATE temperature sensor dont start
|
||||
*/
|
||||
esp_err_t temp_sensor_read_raw(uint32_t *tsens_out);
|
||||
|
||||
/**
|
||||
* @brief Read temperature sensor data that is converted to degrees Celsius.
|
||||
* @note Should not be called from interrupt.
|
||||
* @param celsius The measure output value.
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG ARG is NULL.
|
||||
* - ESP_ERR_INVALID_STATE The ambient temperature is out of range.
|
||||
*/
|
||||
esp_err_t temp_sensor_read_celsius(float *celsius);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2010-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
TSENS_DAC_L0 = 0, /*!< offset = -2, measure range: 50℃ ~ 125℃, error < 3℃. */
|
||||
TSENS_DAC_L1, /*!< offset = -1, measure range: 20℃ ~ 100℃, error < 2℃. */
|
||||
TSENS_DAC_L2, /*!< offset = 0, measure range:-10℃ ~ 80℃, error < 1℃. */
|
||||
TSENS_DAC_L3, /*!< offset = 1, measure range:-30℃ ~ 50℃, error < 2℃. */
|
||||
TSENS_DAC_L4, /*!< offset = 2, measure range:-40℃ ~ 20℃, error < 3℃. */
|
||||
TSENS_DAC_MAX,
|
||||
TSENS_DAC_DEFAULT = TSENS_DAC_L2,
|
||||
} temp_sensor_dac_offset_t;
|
||||
|
||||
/**
|
||||
* @brief Configuration for temperature sensor reading
|
||||
*/
|
||||
typedef struct {
|
||||
temp_sensor_dac_offset_t dac_offset; /*!< The temperature measurement range is configured with a built-in temperature offset DAC. */
|
||||
uint8_t clk_div; /*!< Default: 6 */
|
||||
} temp_sensor_config_t;
|
||||
|
||||
#define TSENS_CONFIG_DEFAULT() {.dac_offset = TSENS_DAC_L2, \
|
||||
.clk_div = 6}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@@ -1,179 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2016-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_types.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_check.h"
|
||||
#include "esp_compiler.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "esp_private/regi2c_ctrl.h"
|
||||
#include "soc/regi2c_saradc.h"
|
||||
#include "esp_efuse_rtc_calib.h"
|
||||
#include "hal/temperature_sensor_ll.h"
|
||||
#include "driver/temp_sensor_types_legacy.h"
|
||||
#include "esp_private/periph_ctrl.h"
|
||||
#include "esp_private/sar_periph_ctrl.h"
|
||||
|
||||
static const char *TAG = "tsens";
|
||||
|
||||
#define TSENS_ADC_FACTOR (0.4386)
|
||||
#define TSENS_DAC_FACTOR (27.88)
|
||||
#define TSENS_SYS_OFFSET (20.52)
|
||||
|
||||
typedef struct {
|
||||
int index;
|
||||
int offset;
|
||||
int reg_val;
|
||||
int range_min;
|
||||
int range_max;
|
||||
int error_max;
|
||||
} tsens_dac_offset_t;
|
||||
|
||||
static const tsens_dac_offset_t dac_offset[TSENS_DAC_MAX] = {
|
||||
/* DAC Offset reg_val min max error */
|
||||
{TSENS_DAC_L0, -2, 5, 50, 125, 3},
|
||||
{TSENS_DAC_L1, -1, 7, 20, 100, 2},
|
||||
{TSENS_DAC_L2, 0, 15, -10, 80, 1},
|
||||
{TSENS_DAC_L3, 1, 11, -30, 50, 2},
|
||||
{TSENS_DAC_L4, 2, 10, -40, 20, 3},
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
TSENS_HW_STATE_UNCONFIGURED,
|
||||
TSENS_HW_STATE_CONFIGURED,
|
||||
TSENS_HW_STATE_STARTED,
|
||||
} tsens_hw_state_t;
|
||||
|
||||
static tsens_hw_state_t tsens_hw_state = TSENS_HW_STATE_UNCONFIGURED;
|
||||
|
||||
static float s_deltaT = NAN; // Unused number
|
||||
static int s_tsens_range;
|
||||
|
||||
esp_err_t temp_sensor_set_config(temp_sensor_config_t tsens)
|
||||
{
|
||||
esp_err_t err = ESP_OK;
|
||||
if (tsens_hw_state == TSENS_HW_STATE_STARTED) {
|
||||
ESP_LOGE(TAG, "Do not configure the temp sensor when it's running!");
|
||||
err = ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
temperature_sensor_ll_set_clk_div(tsens.clk_div);
|
||||
temp_sensor_sync_tsens_idx(tsens.dac_offset);
|
||||
s_tsens_range = dac_offset[tsens.dac_offset].reg_val;
|
||||
ESP_LOGI(TAG, "Config range [%d°C ~ %d°C], error < %d°C",
|
||||
dac_offset[tsens.dac_offset].range_min,
|
||||
dac_offset[tsens.dac_offset].range_max,
|
||||
dac_offset[tsens.dac_offset].error_max);
|
||||
tsens_hw_state = TSENS_HW_STATE_CONFIGURED;
|
||||
return err;
|
||||
}
|
||||
|
||||
esp_err_t temp_sensor_get_config(temp_sensor_config_t *tsens)
|
||||
{
|
||||
ESP_RETURN_ON_FALSE(tsens != NULL, ESP_ERR_INVALID_ARG, TAG, "no tsens specified");
|
||||
tsens->dac_offset = temperature_sensor_ll_get_offset();
|
||||
for (int i = TSENS_DAC_L0; i < TSENS_DAC_MAX; i++) {
|
||||
if ((int)tsens->dac_offset == dac_offset[i].reg_val) {
|
||||
tsens->dac_offset = dac_offset[i].index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
tsens->clk_div = temperature_sensor_ll_get_clk_div();
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t temp_sensor_start(void)
|
||||
{
|
||||
esp_err_t err = ESP_OK;
|
||||
if (tsens_hw_state != TSENS_HW_STATE_CONFIGURED) {
|
||||
ESP_LOGE(TAG, "Is already running or not be configured");
|
||||
err = ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
temperature_sensor_power_acquire();
|
||||
temperature_sensor_ll_set_range(s_tsens_range);
|
||||
temperature_sensor_ll_clk_sel(TEMPERATURE_SENSOR_CLK_SRC_DEFAULT);
|
||||
tsens_hw_state = TSENS_HW_STATE_STARTED;
|
||||
return err;
|
||||
}
|
||||
|
||||
esp_err_t temp_sensor_stop(void)
|
||||
{
|
||||
temperature_sensor_power_release();
|
||||
tsens_hw_state = TSENS_HW_STATE_CONFIGURED;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t temp_sensor_read_raw(uint32_t *tsens_out)
|
||||
{
|
||||
ESP_RETURN_ON_FALSE(tsens_out != NULL, ESP_ERR_INVALID_ARG, TAG, "no tsens_out specified");
|
||||
if (tsens_hw_state != TSENS_HW_STATE_STARTED) {
|
||||
ESP_LOGE(TAG, "Has not been started");
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
ESP_COMPILER_DIAGNOSTIC_PUSH_IGNORE("-Wanalyzer-use-of-uninitialized-value") // False-positive detection. TODO GCC-366
|
||||
*tsens_out = temperature_sensor_ll_get_raw_value();
|
||||
ESP_COMPILER_DIAGNOSTIC_POP("-Wanalyzer-use-of-uninitialized-value")
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t read_delta_t_from_efuse(void)
|
||||
{
|
||||
ESP_RETURN_ON_ERROR(esp_efuse_rtc_calib_get_tsens_val(&s_deltaT), TAG, "Calibration error");
|
||||
ESP_LOGD(TAG, "s_deltaT = %f", s_deltaT);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static float parse_temp_sensor_raw_value(uint32_t tsens_raw)
|
||||
{
|
||||
if (isnan(s_deltaT)) { //suggests that the value is not initialized
|
||||
read_delta_t_from_efuse();
|
||||
}
|
||||
float result = tsens_raw - s_deltaT / 10.0;
|
||||
return result;
|
||||
}
|
||||
|
||||
esp_err_t temp_sensor_read_celsius(float *celsius)
|
||||
{
|
||||
ESP_RETURN_ON_FALSE(celsius != NULL, ESP_ERR_INVALID_ARG, TAG, "celsius points to nothing");
|
||||
if (tsens_hw_state != TSENS_HW_STATE_STARTED) {
|
||||
ESP_LOGE(TAG, "Has not been started");
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
temp_sensor_config_t tsens;
|
||||
temp_sensor_get_config(&tsens);
|
||||
bool range_changed;
|
||||
uint16_t tsens_out = temp_sensor_get_raw_value(&range_changed);
|
||||
*celsius = parse_temp_sensor_raw_value(tsens_out);
|
||||
if (*celsius < TEMPERATURE_SENSOR_LL_MEASURE_MIN || *celsius > TEMPERATURE_SENSOR_LL_MEASURE_MAX) {
|
||||
ESP_LOGE(TAG, "Exceeding temperature measure range.");
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
if (range_changed) {
|
||||
temp_sensor_get_config(&tsens);
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
#if !CONFIG_TEMP_SENSOR_SKIP_LEGACY_CONFLICT_CHECK
|
||||
/**
|
||||
* @brief This function will be called during start up, to check that this legacy temp sensor driver is not running along with the new driver
|
||||
*/
|
||||
__attribute__((constructor))
|
||||
static void check_legacy_temp_sensor_driver_conflict(void)
|
||||
{
|
||||
// This function was declared as weak here. temperature_sensor driver has one implementation.
|
||||
// So if temperature_sensor driver is not linked in, then `temperature_sensor_install()` should be NULL at runtime.
|
||||
extern __attribute__((weak)) esp_err_t temperature_sensor_install(const void *tsens_config, void **ret_tsens);
|
||||
if ((void *)temperature_sensor_install != NULL) {
|
||||
ESP_EARLY_LOGE(TAG, "CONFLICT! driver_ng is not allowed to be used with the legacy driver");
|
||||
abort();
|
||||
}
|
||||
ESP_EARLY_LOGW(TAG, "legacy driver is deprecated, please migrate to `driver/temperature_sensor.h`");
|
||||
}
|
||||
#endif //CONFIG_TEMP_SENSOR_SKIP_LEGACY_CONFLICT_CHECK
|
@@ -34,10 +34,6 @@ components/driver/test_apps/legacy_rmt_driver:
|
||||
depends_filepatterns:
|
||||
- components/driver/deprecated/**/*rmt*
|
||||
|
||||
components/driver/test_apps/legacy_rtc_temp_driver:
|
||||
disable:
|
||||
- if: SOC_TEMP_SENSOR_SUPPORTED != 1
|
||||
|
||||
components/driver/test_apps/legacy_sigma_delta_driver:
|
||||
disable:
|
||||
- if: SOC_SDM_SUPPORTED != 1
|
||||
|
@@ -1,8 +0,0 @@
|
||||
# This is the project CMakeLists.txt file for the test subproject
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
# "Trim" the build. Include the minimal set of components, main, and anything it depends on.
|
||||
set(COMPONENTS main)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(legacy_rtc_temp_driver_test)
|
@@ -1,2 +0,0 @@
|
||||
| Supported Targets | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-C61 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 |
|
||||
| ----------------- | -------- | -------- | -------- | -------- | --------- | -------- | -------- | -------- | -------- |
|
@@ -1,8 +0,0 @@
|
||||
set(srcs "test_app_main.c"
|
||||
"test_rtc_temp_driver.c")
|
||||
|
||||
# In order for the cases defined by `TEST_CASE` to be linked into the final elf,
|
||||
# the component can be registered as WHOLE_ARCHIVE
|
||||
idf_component_register(SRCS ${srcs}
|
||||
PRIV_REQUIRES unity driver
|
||||
WHOLE_ARCHIVE)
|
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "unity.h"
|
||||
#include "unity_test_runner.h"
|
||||
#include "esp_heap_caps.h"
|
||||
|
||||
#define TEST_MEMORY_LEAK_THRESHOLD (-600)
|
||||
|
||||
static size_t before_free_8bit;
|
||||
static size_t before_free_32bit;
|
||||
|
||||
static void check_leak(size_t before_free, size_t after_free, const char *type)
|
||||
{
|
||||
ssize_t delta = after_free - before_free;
|
||||
printf("MALLOC_CAP_%s: Before %u bytes free, After %u bytes free (delta %d)\n", type, before_free, after_free, delta);
|
||||
TEST_ASSERT_MESSAGE(delta >= TEST_MEMORY_LEAK_THRESHOLD, "memory leak");
|
||||
}
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
before_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
|
||||
before_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
{
|
||||
size_t after_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
|
||||
size_t after_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
|
||||
check_leak(before_free_8bit, after_free_8bit, "8BIT");
|
||||
check_leak(before_free_32bit, after_free_32bit, "32BIT");
|
||||
}
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
unity_run_menu();
|
||||
}
|
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "esp_log.h"
|
||||
#include "unity.h"
|
||||
#include "driver/temp_sensor.h"
|
||||
|
||||
TEST_CASE("Temperature_legacy_workflow_test", "[hw_timer]")
|
||||
{
|
||||
printf("Initializing Temperature sensor\n");
|
||||
float tsens_out;
|
||||
temp_sensor_config_t temp_sensor = TSENS_CONFIG_DEFAULT();
|
||||
TEST_ESP_OK(temp_sensor_get_config(&temp_sensor));
|
||||
printf("default dac %d, clk_div %d\n", temp_sensor.dac_offset, temp_sensor.clk_div);
|
||||
temp_sensor.dac_offset = TSENS_DAC_DEFAULT; // DEFAULT: range:-10℃ ~ 80℃, error < 1℃.
|
||||
TEST_ESP_OK(temp_sensor_set_config(temp_sensor));
|
||||
TEST_ESP_OK(temp_sensor_start());
|
||||
printf("Temperature sensor started\n");
|
||||
TEST_ESP_OK(temp_sensor_read_celsius(&tsens_out));
|
||||
printf("Temperature out celsius %f°C\n", tsens_out);
|
||||
TEST_ESP_OK(temp_sensor_stop());
|
||||
#if !CONFIG_IDF_TARGET_ESP32H2 // disable on eps32h2, seems have some issues on esp32h2
|
||||
temp_sensor.dac_offset = TSENS_DAC_L3;
|
||||
TEST_ESP_OK(temp_sensor_set_config(temp_sensor));
|
||||
TEST_ESP_OK(temp_sensor_start());
|
||||
printf("Temperature sensor started again\n");
|
||||
TEST_ESP_OK(temp_sensor_read_celsius(&tsens_out));
|
||||
printf("Temperature out celsius %f°C\n", tsens_out);
|
||||
TEST_ESP_OK(temp_sensor_stop());
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_CASE("Temperature legacy double start error cause test", "[temperature_sensor]")
|
||||
{
|
||||
printf("Initializing Temperature sensor\n");
|
||||
temp_sensor_config_t temp_sensor = TSENS_CONFIG_DEFAULT();
|
||||
TEST_ESP_OK(temp_sensor_set_config(temp_sensor));
|
||||
TEST_ESP_OK(temp_sensor_start());
|
||||
TEST_ESP_ERR(ESP_ERR_INVALID_STATE, temp_sensor_start());
|
||||
TEST_ESP_OK(temp_sensor_stop());
|
||||
}
|
||||
|
||||
TEST_CASE("Temperature legacy double Start-Stop test", "[temperature_sensor]")
|
||||
{
|
||||
printf("Initializing Temperature sensor\n");
|
||||
float tsens_out;
|
||||
temp_sensor_config_t temp_sensor = TSENS_CONFIG_DEFAULT();
|
||||
TEST_ESP_OK(temp_sensor_get_config(&temp_sensor));
|
||||
printf("default dac %d, clk_div %d\n", temp_sensor.dac_offset, temp_sensor.clk_div);
|
||||
temp_sensor.dac_offset = TSENS_DAC_DEFAULT; // DEFAULT: range:-10℃ ~ 80℃, error < 1℃.
|
||||
TEST_ESP_OK(temp_sensor_set_config(temp_sensor));
|
||||
TEST_ESP_OK(temp_sensor_start());
|
||||
printf("Temperature sensor started\n");
|
||||
TEST_ESP_OK(temp_sensor_read_celsius(&tsens_out));
|
||||
printf("Temperature out celsius %f°C\n", tsens_out);
|
||||
TEST_ESP_OK(temp_sensor_stop());
|
||||
TEST_ESP_OK(temp_sensor_start());
|
||||
printf("Temperature sensor started again\n");
|
||||
TEST_ESP_OK(temp_sensor_read_celsius(&tsens_out));
|
||||
printf("Temperature out celsius %f°C\n", tsens_out);
|
||||
TEST_ESP_OK(temp_sensor_stop());
|
||||
}
|
@@ -1,22 +0,0 @@
|
||||
# SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
import pytest
|
||||
from pytest_embedded import Dut
|
||||
from pytest_embedded_idf.utils import idf_parametrize
|
||||
|
||||
|
||||
@pytest.mark.generic
|
||||
@pytest.mark.parametrize(
|
||||
'config',
|
||||
[
|
||||
'release',
|
||||
],
|
||||
indirect=True,
|
||||
)
|
||||
@idf_parametrize(
|
||||
'target',
|
||||
['esp32s2', 'esp32c3', 'esp32s3', 'esp32c2', 'esp32c6', 'esp32h2', 'esp32p4', 'esp32c5', 'esp32c61'],
|
||||
indirect=['target'],
|
||||
)
|
||||
def test_legacy_temp_sensor_driver(dut: Dut) -> None:
|
||||
dut.run_all_single_board_cases(timeout=120)
|
@@ -1,5 +0,0 @@
|
||||
CONFIG_PM_ENABLE=y
|
||||
CONFIG_FREERTOS_USE_TICKLESS_IDLE=y
|
||||
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
|
||||
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
|
||||
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y
|
@@ -1,2 +0,0 @@
|
||||
CONFIG_ESP_TASK_WDT_EN=n
|
||||
CONFIG_TEMP_SENSOR_SUPPRESS_DEPRECATE_WARN=y
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -108,21 +108,3 @@ esp_err_t esp_efuse_rtc_calib_get_cal_voltage(int version, uint32_t adc_unit, in
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_efuse_rtc_calib_get_tsens_val(float* tsens_cal)
|
||||
{
|
||||
const esp_efuse_desc_t** cal_temp_efuse;
|
||||
cal_temp_efuse = ESP_EFUSE_TEMP_CALIB;
|
||||
int cal_temp_size = esp_efuse_get_field_size(cal_temp_efuse);
|
||||
assert(cal_temp_size == 9);
|
||||
|
||||
uint32_t cal_temp = 0;
|
||||
esp_err_t err = esp_efuse_read_field_blob(cal_temp_efuse, &cal_temp, cal_temp_size);
|
||||
if (err != ESP_OK) {
|
||||
*tsens_cal = 0.0;
|
||||
return err;
|
||||
}
|
||||
// BIT(8) stands for sign: 1: negative, 0: positive
|
||||
*tsens_cal = ((cal_temp & BIT(8)) != 0)? -(uint8_t)cal_temp: (uint8_t)cal_temp;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -47,16 +47,6 @@ uint32_t esp_efuse_rtc_calib_get_init_code(int version, uint32_t adc_unit, int a
|
||||
*/
|
||||
esp_err_t esp_efuse_rtc_calib_get_cal_voltage(int version, uint32_t adc_unit, int atten, uint32_t *out_digi, uint32_t *out_vol_mv);
|
||||
|
||||
/**
|
||||
* @brief Get the temperature sensor calibration number delta_T stored in the efuse.
|
||||
*
|
||||
* @param tsens_cal Pointer of the specification of temperature sensor calibration number in efuse.
|
||||
*
|
||||
* @return ESP_OK if get the calibration value successfully.
|
||||
* ESP_ERR_INVALID_ARG if can't get the calibration value.
|
||||
*/
|
||||
esp_err_t esp_efuse_rtc_calib_get_tsens_val(float* tsens_cal);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -82,24 +82,3 @@ esp_err_t esp_efuse_rtc_calib_get_cal_voltage(int version, uint32_t adc_unit, in
|
||||
*out_vol_mv = calib_vol_expected_mv;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_efuse_rtc_calib_get_tsens_val(float* tsens_cal)
|
||||
{
|
||||
uint32_t version = esp_efuse_rtc_calib_get_ver();
|
||||
if (version != 1) {
|
||||
*tsens_cal = 0.0;
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
const esp_efuse_desc_t** cal_temp_efuse;
|
||||
cal_temp_efuse = ESP_EFUSE_TEMP_CALIB;
|
||||
int cal_temp_size = esp_efuse_get_field_size(cal_temp_efuse);
|
||||
assert(cal_temp_size == 9);
|
||||
|
||||
uint32_t cal_temp = 0;
|
||||
esp_err_t err = esp_efuse_read_field_blob(cal_temp_efuse, &cal_temp, cal_temp_size);
|
||||
assert(err == ESP_OK);
|
||||
(void)err;
|
||||
// BIT(8) stands for sign: 1: negtive, 0: positive
|
||||
*tsens_cal = ((cal_temp & BIT(8)) != 0)? -(uint8_t)cal_temp: (uint8_t)cal_temp;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -47,16 +47,6 @@ uint32_t esp_efuse_rtc_calib_get_init_code(int version, uint32_t adc_unit, int a
|
||||
*/
|
||||
esp_err_t esp_efuse_rtc_calib_get_cal_voltage(int version, uint32_t adc_unit, int atten, uint32_t* out_digi, uint32_t* out_vol_mv);
|
||||
|
||||
/**
|
||||
* @brief Get the temperature sensor calibration number delta_T stored in the efuse.
|
||||
*
|
||||
* @param tsens_cal Pointer of the specification of temperature sensor calibration number in efuse.
|
||||
*
|
||||
* @return ESP_OK if get the calibration value successfully.
|
||||
* ESP_ERR_INVALID_ARG if can't get the calibration value.
|
||||
*/
|
||||
esp_err_t esp_efuse_rtc_calib_get_tsens_val(float* tsens_cal);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -145,21 +145,3 @@ esp_err_t esp_efuse_rtc_calib_get_cal_voltage(int version, uint32_t adc_unit, in
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_efuse_rtc_calib_get_tsens_val(float* tsens_cal)
|
||||
{
|
||||
const esp_efuse_desc_t** cal_temp_efuse;
|
||||
cal_temp_efuse = ESP_EFUSE_TEMPERATURE_SENSOR;
|
||||
int cal_temp_size = esp_efuse_get_field_size(cal_temp_efuse);
|
||||
assert(cal_temp_size == 9);
|
||||
|
||||
uint32_t cal_temp = 0;
|
||||
esp_err_t err = esp_efuse_read_field_blob(cal_temp_efuse, &cal_temp, cal_temp_size);
|
||||
if (err != ESP_OK) {
|
||||
*tsens_cal = 0.0;
|
||||
return err;
|
||||
}
|
||||
// BIT(8) stands for sign: 1: negative, 0: positive
|
||||
*tsens_cal = ((cal_temp & BIT(8)) != 0)? -(uint8_t)cal_temp: (uint8_t)cal_temp;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -59,16 +59,6 @@ int esp_efuse_rtc_calib_get_chan_compens(int version, uint32_t adc_unit, uint32_
|
||||
*/
|
||||
esp_err_t esp_efuse_rtc_calib_get_cal_voltage(int version, uint32_t adc_unit, int atten, uint32_t* out_digi, uint32_t* out_vol_mv);
|
||||
|
||||
/**
|
||||
* @brief Get the temperature sensor calibration number delta_T stored in the efuse.
|
||||
*
|
||||
* @param tsens_cal Pointer of the specification of temperature sensor calibration number in efuse.
|
||||
*
|
||||
* @return ESP_OK if get the calibration value successfully.
|
||||
* ESP_ERR_INVALID_ARG if can't get the calibration value.
|
||||
*/
|
||||
esp_err_t esp_efuse_rtc_calib_get_tsens_val(float* tsens_cal);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -129,21 +129,3 @@ esp_err_t esp_efuse_rtc_calib_get_cal_voltage(int version, uint32_t adc_unit, in
|
||||
*out_vol_mv = input_vout_mv[VER2IDX(version)][atten];
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_efuse_rtc_calib_get_tsens_val(float* tsens_cal)
|
||||
{
|
||||
const esp_efuse_desc_t** cal_temp_efuse;
|
||||
cal_temp_efuse = ESP_EFUSE_TEMP_CALIB;
|
||||
int cal_temp_size = esp_efuse_get_field_size(cal_temp_efuse);
|
||||
assert(cal_temp_size == 9);
|
||||
|
||||
uint32_t cal_temp = 0;
|
||||
esp_err_t err = esp_efuse_read_field_blob(cal_temp_efuse, &cal_temp, cal_temp_size);
|
||||
if (err != ESP_OK) {
|
||||
*tsens_cal = 0.0;
|
||||
return err;
|
||||
}
|
||||
// BIT(8) stands for sign: 1: negative, 0: positive
|
||||
*tsens_cal = ((cal_temp & BIT(8)) != 0)? -(uint8_t)cal_temp: (uint8_t)cal_temp;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -59,16 +59,6 @@ int esp_efuse_rtc_calib_get_chan_compens(int version, uint32_t adc_unit, uint32_
|
||||
*/
|
||||
esp_err_t esp_efuse_rtc_calib_get_cal_voltage(int version, uint32_t adc_unit, int atten, uint32_t* out_digi, uint32_t* out_vol_mv);
|
||||
|
||||
/**
|
||||
* @brief Get the temperature sensor calibration number delta_T stored in the efuse.
|
||||
*
|
||||
* @param tsens_cal Pointer of the specification of temperature sensor calibration number in efuse.
|
||||
*
|
||||
* @return ESP_OK if get the calibration value successfully.
|
||||
* ESP_ERR_INVALID_ARG if can't get the calibration value.
|
||||
*/
|
||||
esp_err_t esp_efuse_rtc_calib_get_tsens_val(float* tsens_cal);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -46,21 +46,3 @@ esp_err_t esp_efuse_rtc_calib_get_cal_voltage(int version, uint32_t adc_unit, in
|
||||
abort();
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_efuse_rtc_calib_get_tsens_val(float* tsens_cal)
|
||||
{
|
||||
const esp_efuse_desc_t** cal_temp_efuse;
|
||||
cal_temp_efuse = ESP_EFUSE_TEMPERATURE_SENSOR;
|
||||
int cal_temp_size = esp_efuse_get_field_size(cal_temp_efuse);
|
||||
assert(cal_temp_size == 9);
|
||||
|
||||
uint32_t cal_temp = 0;
|
||||
esp_err_t err = esp_efuse_read_field_blob(cal_temp_efuse, &cal_temp, cal_temp_size);
|
||||
if (err != ESP_OK) {
|
||||
*tsens_cal = 0.0;
|
||||
return err;
|
||||
}
|
||||
// BIT(8) stands for sign: 1: negative, 0: positive
|
||||
*tsens_cal = ((cal_temp & BIT(8)) != 0)? -(uint8_t)cal_temp: (uint8_t)cal_temp;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -61,16 +61,6 @@ int esp_efuse_rtc_calib_get_chan_compens(int version, uint32_t adc_unit, uint32_
|
||||
*/
|
||||
esp_err_t esp_efuse_rtc_calib_get_cal_voltage(int version, uint32_t adc_unit, int atten, uint32_t* out_digi, uint32_t* out_vol_mv);
|
||||
|
||||
/**
|
||||
* @brief Get the temperature sensor calibration number delta_T stored in the efuse.
|
||||
*
|
||||
* @param tsens_cal Pointer of the specification of temperature sensor calibration number in efuse.
|
||||
*
|
||||
* @return ESP_OK if get the calibration value successfully.
|
||||
* ESP_ERR_INVALID_ARG if can't get the calibration value.
|
||||
*/
|
||||
esp_err_t esp_efuse_rtc_calib_get_tsens_val(float* tsens_cal);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -121,21 +121,3 @@ esp_err_t esp_efuse_rtc_calib_get_cal_voltage(int version, uint32_t adc_unit, in
|
||||
*out_vol_mv = input_vout_mv[VER2IDX(version)][atten];
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_efuse_rtc_calib_get_tsens_val(float* tsens_cal)
|
||||
{
|
||||
const esp_efuse_desc_t** cal_temp_efuse;
|
||||
cal_temp_efuse = ESP_EFUSE_TEMP_CALIB;
|
||||
int cal_temp_size = esp_efuse_get_field_size(cal_temp_efuse);
|
||||
assert(cal_temp_size == 9);
|
||||
|
||||
uint32_t cal_temp = 0;
|
||||
esp_err_t err = esp_efuse_read_field_blob(cal_temp_efuse, &cal_temp, cal_temp_size);
|
||||
if (err != ESP_OK) {
|
||||
*tsens_cal = 0.0;
|
||||
return err;
|
||||
}
|
||||
// BIT(8) stands for sign: 1: negative, 0: positive
|
||||
*tsens_cal = ((cal_temp & BIT(8)) != 0)? -(uint8_t)cal_temp: (uint8_t)cal_temp;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -58,16 +58,6 @@ int esp_efuse_rtc_calib_get_chan_compens(int version, uint32_t adc_unit, uint32_
|
||||
*/
|
||||
esp_err_t esp_efuse_rtc_calib_get_cal_voltage(int version, uint32_t adc_unit, int atten, uint32_t* out_digi, uint32_t* out_vol_mv);
|
||||
|
||||
/**
|
||||
* @brief Get the temperature sensor calibration number delta_T stored in the efuse.
|
||||
*
|
||||
* @param tsens_cal Pointer of the specification of temperature sensor calibration number in efuse.
|
||||
*
|
||||
* @return ESP_OK if get the calibration value successfully.
|
||||
* ESP_ERR_INVALID_ARG if can't get the calibration value.
|
||||
*/
|
||||
esp_err_t esp_efuse_rtc_calib_get_tsens_val(float* tsens_cal);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -46,9 +46,3 @@ esp_err_t esp_efuse_rtc_calib_get_cal_voltage(int version, uint32_t adc_unit, in
|
||||
// TODO: [ESP32H21] IDF-11590
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_efuse_rtc_calib_get_tsens_val(float* tsens_cal)
|
||||
{
|
||||
// TODO: [ESP32H21] IDF-11624
|
||||
return ESP_OK;
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -60,16 +60,6 @@ int esp_efuse_rtc_calib_get_chan_compens(int version, uint32_t adc_unit, uint32_
|
||||
*/
|
||||
esp_err_t esp_efuse_rtc_calib_get_cal_voltage(int version, uint32_t adc_unit, int atten, uint32_t* out_digi, uint32_t* out_vol_mv);
|
||||
|
||||
/**
|
||||
* @brief Get the temperature sensor calibration number delta_T stored in the efuse.
|
||||
*
|
||||
* @param tsens_cal Pointer of the specification of temperature sensor calibration number in efuse.
|
||||
*
|
||||
* @return ESP_OK if get the calibration value successfully.
|
||||
* ESP_ERR_INVALID_ARG if can't get the calibration value.
|
||||
*/
|
||||
esp_err_t esp_efuse_rtc_calib_get_tsens_val(float* tsens_cal);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -193,21 +193,3 @@ int esp_efuse_rtc_calib_get_chan_compens(int version, uint32_t adc_unit, uint32_
|
||||
|
||||
return RTC_CALIB_GET_SIGNED_VAL(chan_diff, 3) * (4 - atten);
|
||||
}
|
||||
|
||||
esp_err_t esp_efuse_rtc_calib_get_tsens_val(float* tsens_cal)
|
||||
{
|
||||
const esp_efuse_desc_t** cal_temp_efuse;
|
||||
cal_temp_efuse = ESP_EFUSE_TEMPERATURE_SENSOR;
|
||||
int cal_temp_size = esp_efuse_get_field_size(cal_temp_efuse);
|
||||
assert(cal_temp_size == 9);
|
||||
|
||||
uint32_t cal_temp = 0;
|
||||
esp_err_t err = esp_efuse_read_field_blob(cal_temp_efuse, &cal_temp, cal_temp_size);
|
||||
if (err != ESP_OK) {
|
||||
*tsens_cal = 0.0;
|
||||
return err;
|
||||
}
|
||||
// BIT(8) stands for sign: 1: negative, 0: positive
|
||||
*tsens_cal = ((cal_temp & BIT(8)) != 0)? -(uint8_t)cal_temp: (uint8_t)cal_temp;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
@@ -57,16 +57,6 @@ int esp_efuse_rtc_calib_get_chan_compens(int version, uint32_t adc_unit, uint32_
|
||||
*/
|
||||
esp_err_t esp_efuse_rtc_calib_get_cal_voltage(int version, uint32_t adc_unit, int atten, uint32_t* out_digi, uint32_t* out_vol_mv);
|
||||
|
||||
/**
|
||||
* @brief Get the temperature sensor calibration number delta_T stored in the efuse.
|
||||
*
|
||||
* @param tsens_cal Pointer of the specification of temperature sensor calibration number in efuse.
|
||||
*
|
||||
* @return ESP_OK if get the calibration value successfully.
|
||||
* ESP_ERR_INVALID_ARG if can't get the calibration value.
|
||||
*/
|
||||
esp_err_t esp_efuse_rtc_calib_get_tsens_val(float* tsens_cal);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -1,22 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "esp_bit_defs.h"
|
||||
#include "esp_efuse.h"
|
||||
#include "esp_efuse_rtc_table.h"
|
||||
|
||||
esp_err_t esp_efuse_rtc_calib_get_tsens_val(float* tsens_cal)
|
||||
{
|
||||
uint32_t version = esp_efuse_rtc_table_read_calib_version();
|
||||
if ((version != 1) && (version != 2)) {
|
||||
*tsens_cal = 0.0;
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
*tsens_cal = esp_efuse_rtc_table_get_parsed_efuse_value(RTCCALIB_IDX_TMPSENSOR, false);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "esp_types.h"
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get the temperature sensor calibration number delta_T stored in the efuse.
|
||||
*
|
||||
* @param tsens_cal Pointer of the specification of temperature sensor calibration number in efuse.
|
||||
*
|
||||
* @return ESP_OK if get the calibration value successfully.
|
||||
* ESP_ERR_INVALID_ARG if can't get the calibration value.
|
||||
*/
|
||||
esp_err_t esp_efuse_rtc_calib_get_tsens_val(float* tsens_cal);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@@ -1,5 +1,4 @@
|
||||
set(EFUSE_SOC_SRCS "esp_efuse_table.c"
|
||||
"esp_efuse_fields.c"
|
||||
"esp_efuse_rtc_table.c"
|
||||
"esp_efuse_rtc_calib.c"
|
||||
"esp_efuse_utility.c")
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -97,24 +97,3 @@ esp_err_t esp_efuse_rtc_calib_get_cal_voltage(int version, uint32_t adc_unit, in
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_efuse_rtc_calib_get_tsens_val(float* tsens_cal)
|
||||
{
|
||||
uint32_t version = esp_efuse_rtc_calib_get_ver();
|
||||
if (version != 1) {
|
||||
*tsens_cal = 0.0;
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
const esp_efuse_desc_t** cal_temp_efuse;
|
||||
cal_temp_efuse = ESP_EFUSE_TEMP_CALIB;
|
||||
int cal_temp_size = esp_efuse_get_field_size(cal_temp_efuse);
|
||||
assert(cal_temp_size == 9);
|
||||
|
||||
uint32_t cal_temp = 0;
|
||||
esp_err_t err = esp_efuse_read_field_blob(cal_temp_efuse, &cal_temp, cal_temp_size);
|
||||
assert(err == ESP_OK);
|
||||
(void)err;
|
||||
// BIT(8) stands for sign: 1: negtive, 0: positive
|
||||
*tsens_cal = ((cal_temp & BIT(8)) != 0)? -(uint8_t)cal_temp: (uint8_t)cal_temp;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -47,16 +47,6 @@ uint32_t esp_efuse_rtc_calib_get_init_code(int version, uint32_t adc_unit, int a
|
||||
*/
|
||||
esp_err_t esp_efuse_rtc_calib_get_cal_voltage(int version, uint32_t adc_unit, int atten, uint32_t* out_digi, uint32_t* out_vol_mv);
|
||||
|
||||
/**
|
||||
* @brief Get the temperature sensor calibration number delta_T stored in the efuse.
|
||||
*
|
||||
* @param tsens_cal Pointer of the specification of temperature sensor calibration number in efuse.
|
||||
*
|
||||
* @return ESP_OK if get the calibration value successfully.
|
||||
* ESP_ERR_INVALID_ARG if can't get the calibration value.
|
||||
*/
|
||||
esp_err_t esp_efuse_rtc_calib_get_tsens_val(float* tsens_cal);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -22,7 +22,6 @@
|
||||
#include "clk_ctrl_os.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "driver/temperature_sensor.h"
|
||||
#include "esp_efuse_rtc_calib.h"
|
||||
#include "esp_private/periph_ctrl.h"
|
||||
#include "temperature_sensor_private.h"
|
||||
#include "hal/temperature_sensor_ll.h"
|
||||
@@ -36,7 +35,7 @@
|
||||
|
||||
static const char *TAG = "temperature_sensor";
|
||||
|
||||
static float s_deltaT = NAN; // unused number
|
||||
static int s_deltaT = INT_MIN; // unused number
|
||||
|
||||
#if SOC_TEMPERATURE_SENSOR_INTR_SUPPORT
|
||||
static int8_t s_temperature_regval_2_celsius(temperature_sensor_handle_t tsens, uint8_t regval);
|
||||
@@ -274,19 +273,20 @@ esp_err_t temperature_sensor_disable(temperature_sensor_handle_t tsens)
|
||||
|
||||
static esp_err_t read_delta_t_from_efuse(void)
|
||||
{
|
||||
if (esp_efuse_rtc_calib_get_tsens_val(&s_deltaT) != ESP_OK) {
|
||||
ESP_LOGW(TAG, "Calibration failed");
|
||||
s_deltaT = temperature_sensor_ll_load_calib_param();
|
||||
if (s_deltaT == 0) {
|
||||
ESP_LOGW(TAG, "No calibration param in eFuse");
|
||||
}
|
||||
ESP_LOGD(TAG, "s_deltaT = %f", s_deltaT);
|
||||
ESP_LOGD(TAG, "s_deltaT = %d", s_deltaT);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static float parse_temp_sensor_raw_value(int16_t tsens_raw)
|
||||
{
|
||||
if (isnan(s_deltaT)) { //suggests that the value is not initialized
|
||||
if (s_deltaT == INT_MIN) { //suggests that the value is not initialized
|
||||
read_delta_t_from_efuse();
|
||||
}
|
||||
float result = tsens_raw - s_deltaT / 10.0;
|
||||
float result = tsens_raw - (float)s_deltaT / 10.0;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "hal/temperature_sensor_types.h"
|
||||
#include "hal/assert.h"
|
||||
#include "hal/misc.h"
|
||||
#include "soc/efuse_struct.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -151,6 +152,20 @@ static inline void temperature_sensor_ll_set_clk_div(uint8_t clk_div)
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(APB_SARADC.saradc_apb_tsens_ctrl, saradc_reg_tsens_clk_div, clk_div);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Retrieve and calculate the temperature sensor calibration value.
|
||||
*
|
||||
* @return Temperature calibration value.
|
||||
*/
|
||||
static inline int temperature_sensor_ll_load_calib_param(void)
|
||||
{
|
||||
uint32_t cal_temp = 0;
|
||||
cal_temp = EFUSE.rd_blk2_data2.temp_calib;
|
||||
// BIT(8) stands for sign: 1: negative, 0: positive
|
||||
int tsens_cal = ((cal_temp & BIT(8)) != 0)? -(uint8_t)cal_temp: (uint8_t)cal_temp;
|
||||
return tsens_cal;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "hal/temperature_sensor_types.h"
|
||||
#include "hal/assert.h"
|
||||
#include "hal/misc.h"
|
||||
#include "hal/efuse_ll.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -151,6 +152,22 @@ static inline void temperature_sensor_ll_set_clk_div(uint8_t clk_div)
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(APB_SARADC.apb_tsens_ctrl, tsens_clk_div, clk_div);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Retrieve and calculate the temperature sensor calibration value.
|
||||
*
|
||||
* @return Temperature calibration value.
|
||||
*/
|
||||
static inline int temperature_sensor_ll_load_calib_param(void)
|
||||
{
|
||||
if (efuse_ll_get_blk_version_major() == 0) {
|
||||
return 0;
|
||||
}
|
||||
uint32_t cal_temp = EFUSE.rd_sys_part1_data4.temp_calib;
|
||||
// BIT(8) stands for sign: 1: negative, 0: positive
|
||||
int tsens_cal = ((cal_temp & BIT(8)) != 0)? -(uint8_t)cal_temp: (uint8_t)cal_temp;
|
||||
return tsens_cal;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "hal/temperature_sensor_types.h"
|
||||
#include "hal/assert.h"
|
||||
#include "hal/misc.h"
|
||||
#include "hal/efuse_ll.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -266,6 +267,19 @@ static inline void temperature_sensor_ll_set_sample_rate(uint16_t rate)
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(APB_SARADC.tsens_sample, saradc_tsens_sample_rate, rate);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Retrieve and calculate the temperature sensor calibration value.
|
||||
*
|
||||
* @return Temperature calibration value.
|
||||
*/
|
||||
static inline int temperature_sensor_ll_load_calib_param(void)
|
||||
{
|
||||
uint32_t cal_temp = EFUSE.rd_sys_part1_data4.temperature_sensor;
|
||||
// BIT(8) stands for sign: 1: negative, 0: positive
|
||||
int tsens_cal = ((cal_temp & BIT(8)) != 0)? -(uint8_t)cal_temp: (uint8_t)cal_temp;
|
||||
return tsens_cal;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "hal/temperature_sensor_types.h"
|
||||
#include "hal/assert.h"
|
||||
#include "hal/misc.h"
|
||||
#include "hal/efuse_ll.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -266,6 +267,19 @@ static inline void temperature_sensor_ll_set_sample_rate(uint16_t rate)
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(APB_SARADC.tsens_sample, saradc_tsens_sample_rate, rate);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Retrieve and calculate the temperature sensor calibration value.
|
||||
*
|
||||
* @return Temperature calibration value.
|
||||
*/
|
||||
static inline int temperature_sensor_ll_load_calib_param(void)
|
||||
{
|
||||
uint32_t cal_temp = EFUSE.rd_sys_part1_data4.temp_calib;
|
||||
// BIT(8) stands for sign: 1: negative, 0: positive
|
||||
int tsens_cal = ((cal_temp & BIT(8)) != 0)? -(uint8_t)cal_temp: (uint8_t)cal_temp;
|
||||
return tsens_cal;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "hal/temperature_sensor_types.h"
|
||||
#include "hal/assert.h"
|
||||
#include "hal/misc.h"
|
||||
#include "hal/efuse_ll.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -266,6 +267,19 @@ static inline void temperature_sensor_ll_set_sample_rate(uint16_t rate)
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(ADC.tsens_sample, saradc_tsens_sample_rate, rate);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Retrieve and calculate the temperature sensor calibration value.
|
||||
*
|
||||
* @return Temperature calibration value.
|
||||
*/
|
||||
static inline int temperature_sensor_ll_load_calib_param(void)
|
||||
{
|
||||
uint32_t cal_temp = EFUSE0.rd_sys_part1_data4.temperature_sensor;
|
||||
// BIT(8) stands for sign: 1: negative, 0: positive
|
||||
int tsens_cal = ((cal_temp & BIT(8)) != 0)? -(uint8_t)cal_temp: (uint8_t)cal_temp;
|
||||
return tsens_cal;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "hal/temperature_sensor_types.h"
|
||||
#include "hal/assert.h"
|
||||
#include "hal/misc.h"
|
||||
#include "hal/efuse_ll.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -265,6 +266,19 @@ static inline void temperature_sensor_ll_set_sample_rate(uint16_t rate)
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(APB_SARADC.tsens_sample, saradc_tsens_sample_rate, rate);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Retrieve and calculate the temperature sensor calibration value.
|
||||
*
|
||||
* @return Temperature calibration value.
|
||||
*/
|
||||
static inline int temperature_sensor_ll_load_calib_param(void)
|
||||
{
|
||||
uint32_t cal_temp = EFUSE.rd_sys_part1_data4.temp_calib;
|
||||
// BIT(8) stands for sign: 1: negative, 0: positive
|
||||
int tsens_cal = ((cal_temp & BIT(8)) != 0)? -(uint8_t)cal_temp: (uint8_t)cal_temp;
|
||||
return tsens_cal;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "hal/temperature_sensor_types.h"
|
||||
#include "hal/assert.h"
|
||||
#include "hal/misc.h"
|
||||
#include "hal/efuse_ll.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -258,6 +259,19 @@ static inline void temperature_sensor_ll_set_sample_rate(uint16_t rate)
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(LP_TSENS.sample_rate, sample_rate, rate);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Retrieve and calculate the temperature sensor calibration value.
|
||||
*
|
||||
* @return Temperature calibration value.
|
||||
*/
|
||||
static inline int temperature_sensor_ll_load_calib_param(void)
|
||||
{
|
||||
uint32_t cal_temp = EFUSE.rd_sys_part2_data3.temperature_sensor;
|
||||
// BIT(8) stands for sign: 1: negative, 0: positive
|
||||
int tsens_cal = ((cal_temp & BIT(8)) != 0)? -(uint8_t)cal_temp: (uint8_t)cal_temp;
|
||||
return tsens_cal;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "soc/sens_struct.h"
|
||||
#include "hal/temperature_sensor_types.h"
|
||||
#include "hal/misc.h"
|
||||
#include "hal/efuse_ll.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -140,6 +141,22 @@ static inline void temperature_sensor_ll_set_clk_div(uint8_t clk_div)
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(SENS.sar_tctrl, tsens_clk_div, clk_div);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Retrieve and calculate the temperature sensor calibration value.
|
||||
*
|
||||
* @return Temperature calibration value.
|
||||
*/
|
||||
static inline int temperature_sensor_ll_load_calib_param(void)
|
||||
{
|
||||
if (efuse_ll_get_blk_version_major() == 0) {
|
||||
return 0;
|
||||
}
|
||||
uint32_t cal_temp = EFUSE.rd_sys_part1_data4.temp_calib;
|
||||
// BIT(8) stands for sign: 1: negative, 0: positive
|
||||
int tsens_cal = ((cal_temp & BIT(8)) != 0)? -(uint8_t)cal_temp: (uint8_t)cal_temp;
|
||||
return tsens_cal;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "soc/sens_struct.h"
|
||||
#include "hal/temperature_sensor_types.h"
|
||||
#include "hal/misc.h"
|
||||
#include "hal/efuse_ll.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -140,6 +141,22 @@ static inline void temperature_sensor_ll_set_clk_div(uint8_t clk_div)
|
||||
HAL_FORCE_MODIFY_U32_REG_FIELD(SENS.sar_tctrl, tsens_clk_div, clk_div);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Retrieve and calculate the temperature sensor calibration value.
|
||||
*
|
||||
* @return Temperature calibration value.
|
||||
*/
|
||||
static inline int temperature_sensor_ll_load_calib_param(void)
|
||||
{
|
||||
if (efuse_ll_get_blk_version_major() == 0) {
|
||||
return 0;
|
||||
}
|
||||
uint32_t cal_temp = EFUSE.rd_sys_part1_data4.temp_calib;
|
||||
// BIT(8) stands for sign: 1: negative, 0: positive
|
||||
int tsens_cal = ((cal_temp & BIT(8)) != 0)? -(uint8_t)cal_temp: (uint8_t)cal_temp;
|
||||
return tsens_cal;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -4536,7 +4536,6 @@ typedef struct {
|
||||
} efuse_dev_t;
|
||||
|
||||
extern efuse_dev_t EFUSE0;
|
||||
extern efuse_dev_t EFUSE1;
|
||||
|
||||
#ifndef __cplusplus
|
||||
_Static_assert(sizeof(efuse_dev_t) == 0x70c, "Invalid size of efuse_dev_t structure");
|
||||
|
@@ -294,12 +294,14 @@ LEDC
|
||||
|
||||
.. only:: SOC_TEMP_SENSOR_SUPPORTED
|
||||
|
||||
Temperature Sensor Driver
|
||||
-------------------------
|
||||
.. _deprecate_tsens_legacy_driver:
|
||||
|
||||
Legacy Temperature Sensor Driver is Deprecated
|
||||
----------------------------------------------
|
||||
|
||||
The temperature sensor driver has been redesigned and it is recommended to use the new driver. However, the old driver is still available but cannot be used with the new driver simultaneously.
|
||||
|
||||
The new driver can be included via ``driver/temperature_sensor.h``. The old driver is still available in the previous include path ``driver/temp_sensor.h``. However, including ``driver/temp_sensor.h`` triggers the build warning below by default. The warning can be suppressed by enabling the menuconfig option :ref:`CONFIG_TEMP_SENSOR_SUPPRESS_DEPRECATE_WARN`.
|
||||
The new driver can be included via ``driver/temperature_sensor.h``. The old driver is still available in the previous include path ``driver/temp_sensor.h``. However, including ``driver/temp_sensor.h`` triggers the build warning below by default. The warning can be suppressed by enabling the menuconfig option ``CONFIG_TEMP_SENSOR_SUPPRESS_DEPRECATE_WARN``.
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
|
@@ -93,3 +93,10 @@ SDMMC
|
||||
------------------------------------
|
||||
|
||||
The legacy DAC driver ``driver/dac.h`` is deprecated since version 5.1 (see :ref:`deprecate_dac_legacy_driver`). Starting from version 6.0, the legacy driver is completely removed. The new driver is placed in the :component:`esp_driver_dac`, and the header file path is ``driver/dac_oneshot.h``, ``driver/dac_continuous.h`` and ``driver/dac_cosine.h``.
|
||||
|
||||
.. only:: SOC_TEMP_SENSOR_SUPPORTED
|
||||
|
||||
Legacy Temperature Sensor Driver is Removed
|
||||
-------------------------------------------
|
||||
|
||||
The legacy temperature sensor driver ``driver/temp_sensor.h`` is deprecated since version 5.0 (see :ref:`deprecate_tsens_legacy_driver`). Starting from version 6.0, the legacy driver is completely removed. The new driver is placed in the :component:`esp_driver_tsens`, and the header file path is ``driver/temperature_sensor.h``.
|
||||
|
@@ -294,12 +294,14 @@ LEDC
|
||||
|
||||
.. only:: SOC_TEMP_SENSOR_SUPPORTED
|
||||
|
||||
温度传感器驱动
|
||||
.. _deprecate_tsens_legacy_driver:
|
||||
|
||||
旧版温度传感器驱动已被弃用
|
||||
------------------------------------------------------------
|
||||
|
||||
温度传感器的驱动已更新,推荐用户使用新驱动。旧版驱动仍然可用,但是无法与新驱动同时使用。
|
||||
|
||||
新驱动的头文件引用路径为 ``driver/temperature_sensor.h``。旧版驱动仍然可用,保留在引用路径 ``driver/temp_sensor.h`` 中。但是,引用路径 ``driver/temp_sensor.h`` 会默认触发如下编译警告,可通过设置 Kconfig 选项 :ref:`CONFIG_TEMP_SENSOR_SUPPRESS_DEPRECATE_WARN` 来关闭该警告。
|
||||
新驱动的头文件引用路径为 ``driver/temperature_sensor.h``。旧版驱动仍然可用,保留在引用路径 ``driver/temp_sensor.h`` 中。但是,引用路径 ``driver/temp_sensor.h`` 会默认触发如下编译警告,可通过设置 Kconfig 选项 ``CONFIG_TEMP_SENSOR_SUPPRESS_DEPRECATE_WARN`` 来关闭该警告。
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
|
@@ -93,3 +93,10 @@ SDMMC
|
||||
----------------------
|
||||
|
||||
旧版的 DAC 驱动 ``driver/dac.h`` 在 5.1 的版本中就已经被弃用(请参考 :ref:`deprecate_dac_legacy_driver`)。从 6.0 版本开始,旧版驱动被完全移除。新驱动位于 :component:`esp_driver_dac` 组件中,头文件引用路径为 ``driver/dac_oneshot.h``, ``driver/dac_continuous.h`` 和 ``driver/dac_cosine.h``。
|
||||
|
||||
.. only:: SOC_TEMP_SENSOR_SUPPORTED
|
||||
|
||||
旧版温度传感器驱动被移除
|
||||
------------------------------------
|
||||
|
||||
旧版的温度传感器驱动 ``driver/temp_sensor.h`` 在 5.1 的版本中就已经被弃用(请参考 :ref:`deprecate_tsens_legacy_driver`)。从 6.0 版本开始,旧版驱动被完全移除。新驱动位于 :component:`esp_driver_tsens` 组件中,头文件引用路径为 ``driver/temperature_sensor.h``。
|
||||
|
Reference in New Issue
Block a user