forked from espressif/esp-idf
fix(soc): Fix wrong efuse register on esp32c61
This commit is contained in:
@@ -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 (temperature_sensor_ll_calib_get_tsens_val(&s_deltaT) != true) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@@ -155,18 +155,15 @@ static inline void temperature_sensor_ll_set_clk_div(uint8_t clk_div)
|
||||
/**
|
||||
* @brief Retrieve and calculate the temperature sensor calibration value.
|
||||
*
|
||||
* @param[out] tsens_cal Pointer to a float where the calculated calibration value will be stored.
|
||||
* The output is a signed floating-point value based on the efuse data.
|
||||
*
|
||||
* @return returns true to indicate successful retrieval. false for calibration failed.
|
||||
* @return Temperature calibration value.
|
||||
*/
|
||||
static inline bool temperature_sensor_ll_calib_get_tsens_val(float* tsens_cal)
|
||||
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
|
||||
*tsens_cal = ((cal_temp & BIT(8)) != 0)? -(uint8_t)cal_temp: (uint8_t)cal_temp;
|
||||
return true;
|
||||
int tsens_cal = ((cal_temp & BIT(8)) != 0)? -(uint8_t)cal_temp: (uint8_t)cal_temp;
|
||||
return tsens_cal;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@@ -155,22 +155,17 @@ static inline void temperature_sensor_ll_set_clk_div(uint8_t clk_div)
|
||||
/**
|
||||
* @brief Retrieve and calculate the temperature sensor calibration value.
|
||||
*
|
||||
* @param[out] tsens_cal Pointer to a float where the calculated calibration value will be stored.
|
||||
* The output is a signed floating-point value based on the efuse data.
|
||||
*
|
||||
* @return returns true to indicate successful retrieval. false for calibration failed.
|
||||
* @return Temperature calibration value.
|
||||
*/
|
||||
static inline bool temperature_sensor_ll_calib_get_tsens_val(float* tsens_cal)
|
||||
static inline int temperature_sensor_ll_load_calib_param(void)
|
||||
{
|
||||
uint32_t version = efuse_ll_get_blk_version_major();
|
||||
if (version == 0) {
|
||||
*tsens_cal = 0.0;
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
if (efuse_ll_get_blk_version_major() == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t cal_temp = EFUSE.rd_sys_part1_data4.temp_calib;
|
||||
*tsens_cal = ((cal_temp & BIT(8)) != 0)? -(uint8_t)cal_temp: (uint8_t)cal_temp;
|
||||
return ESP_OK;
|
||||
// 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
|
||||
|
@@ -270,16 +270,14 @@ static inline void temperature_sensor_ll_set_sample_rate(uint16_t rate)
|
||||
/**
|
||||
* @brief Retrieve and calculate the temperature sensor calibration value.
|
||||
*
|
||||
* @param[out] tsens_cal Pointer to a float where the calculated calibration value will be stored.
|
||||
* The output is a signed floating-point value based on the efuse data.
|
||||
*
|
||||
* @return returns true to indicate successful retrieval. false for calibration failed.
|
||||
* @return Temperature calibration value.
|
||||
*/
|
||||
static inline bool temperature_sensor_ll_calib_get_tsens_val(float* tsens_cal)
|
||||
static inline int temperature_sensor_ll_load_calib_param(void)
|
||||
{
|
||||
uint32_t cal_temp = EFUSE.rd_sys_part1_data4.temperature_sensor;
|
||||
*tsens_cal = ((cal_temp & BIT(8)) != 0)? -(uint8_t)cal_temp: (uint8_t)cal_temp;
|
||||
return true;
|
||||
// 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
|
||||
|
@@ -270,16 +270,14 @@ static inline void temperature_sensor_ll_set_sample_rate(uint16_t rate)
|
||||
/**
|
||||
* @brief Retrieve and calculate the temperature sensor calibration value.
|
||||
*
|
||||
* @param[out] tsens_cal Pointer to a float where the calculated calibration value will be stored.
|
||||
* The output is a signed floating-point value based on the efuse data.
|
||||
*
|
||||
* @return returns true to indicate successful retrieval. false for calibration failed.
|
||||
* @return Temperature calibration value.
|
||||
*/
|
||||
static inline bool temperature_sensor_ll_calib_get_tsens_val(float* tsens_cal)
|
||||
static inline int temperature_sensor_ll_load_calib_param(void)
|
||||
{
|
||||
uint32_t cal_temp = EFUSE.rd_sys_part1_data4.temp_calib;
|
||||
*tsens_cal = ((cal_temp & BIT(8)) != 0)? -(uint8_t)cal_temp: (uint8_t)cal_temp;
|
||||
return true;
|
||||
// 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
|
||||
|
@@ -270,16 +270,14 @@ static inline void temperature_sensor_ll_set_sample_rate(uint16_t rate)
|
||||
/**
|
||||
* @brief Retrieve and calculate the temperature sensor calibration value.
|
||||
*
|
||||
* @param[out] tsens_cal Pointer to a float where the calculated calibration value will be stored.
|
||||
* The output is a signed floating-point value based on the efuse data.
|
||||
*
|
||||
* @return returns true to indicate successful retrieval. false for calibration failed.
|
||||
* @return Temperature calibration value.
|
||||
*/
|
||||
static inline bool temperature_sensor_ll_calib_get_tsens_val(float* tsens_cal)
|
||||
static inline int temperature_sensor_ll_load_calib_param(void)
|
||||
{
|
||||
uint32_t cal_temp = EFUSE0.rd_sys_part1_data4.temperature_sensor;
|
||||
*tsens_cal = ((cal_temp & BIT(8)) != 0)? -(uint8_t)cal_temp: (uint8_t)cal_temp;
|
||||
return true;
|
||||
// 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
|
||||
|
@@ -269,16 +269,14 @@ static inline void temperature_sensor_ll_set_sample_rate(uint16_t rate)
|
||||
/**
|
||||
* @brief Retrieve and calculate the temperature sensor calibration value.
|
||||
*
|
||||
* @param[out] tsens_cal Pointer to a float where the calculated calibration value will be stored.
|
||||
* The output is a signed floating-point value based on the efuse data.
|
||||
*
|
||||
* @return returns true to indicate successful retrieval. false for calibration failed.
|
||||
* @return Temperature calibration value.
|
||||
*/
|
||||
static inline bool temperature_sensor_ll_calib_get_tsens_val(float* tsens_cal)
|
||||
static inline int temperature_sensor_ll_load_calib_param(void)
|
||||
{
|
||||
uint32_t cal_temp = EFUSE.rd_sys_part1_data4.temp_calib;
|
||||
*tsens_cal = ((cal_temp & BIT(8)) != 0)? -(uint8_t)cal_temp: (uint8_t)cal_temp;
|
||||
return true;
|
||||
// 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
|
||||
|
@@ -262,16 +262,14 @@ static inline void temperature_sensor_ll_set_sample_rate(uint16_t rate)
|
||||
/**
|
||||
* @brief Retrieve and calculate the temperature sensor calibration value.
|
||||
*
|
||||
* @param[out] tsens_cal Pointer to a float where the calculated calibration value will be stored.
|
||||
* The output is a signed floating-point value based on the efuse data.
|
||||
*
|
||||
* @return returns true to indicate successful retrieval. false for calibration failed.
|
||||
* @return Temperature calibration value.
|
||||
*/
|
||||
static inline bool temperature_sensor_ll_calib_get_tsens_val(float* tsens_cal)
|
||||
static inline int temperature_sensor_ll_load_calib_param(void)
|
||||
{
|
||||
uint32_t cal_temp = EFUSE.rd_sys_part2_data3.temperature_sensor;
|
||||
*tsens_cal = ((cal_temp & BIT(8)) != 0)? -(uint8_t)cal_temp: (uint8_t)cal_temp;
|
||||
return true;
|
||||
// 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
|
||||
|
@@ -144,22 +144,17 @@ static inline void temperature_sensor_ll_set_clk_div(uint8_t clk_div)
|
||||
/**
|
||||
* @brief Retrieve and calculate the temperature sensor calibration value.
|
||||
*
|
||||
* @param[out] tsens_cal Pointer to a float where the calculated calibration value will be stored.
|
||||
* The output is a signed floating-point value based on the efuse data.
|
||||
*
|
||||
* @return returns true to indicate successful retrieval. false for calibration failed.
|
||||
* @return Temperature calibration value.
|
||||
*/
|
||||
static inline bool temperature_sensor_ll_calib_get_tsens_val(float* tsens_cal)
|
||||
static inline int temperature_sensor_ll_load_calib_param(void)
|
||||
{
|
||||
uint32_t version = efuse_ll_get_blk_version_major();
|
||||
if (version == 0) {
|
||||
*tsens_cal = 0.0;
|
||||
return false;
|
||||
if (efuse_ll_get_blk_version_major() == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t cal_temp = EFUSE.rd_sys_part1_data4.temp_calib;
|
||||
*tsens_cal = ((cal_temp & BIT(8)) != 0)? -(uint8_t)cal_temp: (uint8_t)cal_temp;
|
||||
return true;
|
||||
// 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
|
||||
|
@@ -144,22 +144,17 @@ static inline void temperature_sensor_ll_set_clk_div(uint8_t clk_div)
|
||||
/**
|
||||
* @brief Retrieve and calculate the temperature sensor calibration value.
|
||||
*
|
||||
* @param[out] tsens_cal Pointer to a float where the calculated calibration value will be stored.
|
||||
* The output is a signed floating-point value based on the efuse data.
|
||||
*
|
||||
* @return returns true to indicate successful retrieval. false for calibration failed.
|
||||
* @return Temperature calibration value.
|
||||
*/
|
||||
static inline bool temperature_sensor_ll_calib_get_tsens_val(float* tsens_cal)
|
||||
static inline int temperature_sensor_ll_load_calib_param(void)
|
||||
{
|
||||
uint32_t version = efuse_ll_get_blk_version_major();
|
||||
if (version == 0) {
|
||||
*tsens_cal = 0.0;
|
||||
return false;
|
||||
if (efuse_ll_get_blk_version_major() == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t cal_temp = EFUSE.rd_sys_part1_data4.temp_calib;
|
||||
*tsens_cal = ((cal_temp & BIT(8)) != 0)? -(uint8_t)cal_temp: (uint8_t)cal_temp;
|
||||
return true;
|
||||
// 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
|
||||
|
@@ -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");
|
||||
|
@@ -91,7 +91,7 @@ SDMMC
|
||||
|
||||
.. only:: SOC_TEMP_SENSOR_SUPPORTED
|
||||
|
||||
Legacy Temperature Senor Driver is Removed
|
||||
------------------------------------------
|
||||
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``.
|
||||
|
Reference in New Issue
Block a user