Merge branch 'bugfix/temperature_get_value_negative_v5.0' into 'release/v5.0'

bugfix(temperature_sensor): Fix issue that get the value is negative (backport v5.0)

See merge request espressif/esp-idf!25252
This commit is contained in:
Jiang Jiang Jian 2023-08-18 17:21:32 +08:00
commit 80d3e7a0b2
2 changed files with 4 additions and 4 deletions

View File

@ -126,7 +126,7 @@ static esp_err_t read_delta_t_from_efuse(void)
return ESP_OK;
}
static float parse_temp_sensor_raw_value(uint32_t tsens_raw)
static float parse_temp_sensor_raw_value(int16_t tsens_raw)
{
if (isnan(s_deltaT)) { //suggests that the value is not initialized
read_delta_t_from_efuse();
@ -145,7 +145,7 @@ esp_err_t temp_sensor_read_celsius(float *celsius)
temp_sensor_config_t tsens;
temp_sensor_get_config(&tsens);
bool range_changed;
uint16_t tsens_out = temp_sensor_get_raw_value(&range_changed);
int16_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.");

View File

@ -185,7 +185,7 @@ static esp_err_t read_delta_t_from_efuse(void)
return ESP_OK;
}
static float parse_temp_sensor_raw_value(uint32_t tsens_raw)
static float parse_temp_sensor_raw_value(int16_t tsens_raw)
{
if (isnan(s_deltaT)) { //suggests that the value is not initialized
read_delta_t_from_efuse();
@ -201,7 +201,7 @@ esp_err_t temperature_sensor_get_celsius(temperature_sensor_handle_t tsens, floa
ESP_RETURN_ON_FALSE(tsens->fsm == TEMP_SENSOR_FSM_ENABLE, ESP_ERR_INVALID_STATE, TAG, "tsens not enabled yet");
bool range_changed;
uint16_t tsens_out = temp_sensor_get_raw_value(&range_changed);
int16_t tsens_out = temp_sensor_get_raw_value(&range_changed);
*out_celsius = parse_temp_sensor_raw_value(tsens_out);
if (*out_celsius < TEMPERATURE_SENSOR_LL_MEASURE_MIN || *out_celsius > TEMPERATURE_SENSOR_LL_MEASURE_MAX) {