Skip to content

Commit

Permalink
Merge branch 'bugfix/temperature_get_value_negative' into 'master'
Browse files Browse the repository at this point in the history
bugfix(temperature_sensor): Fix issue that get the value is negative

See merge request espressif/esp-idf!25165
  • Loading branch information
suda-morris committed Aug 4, 2023
2 parents 23c89cd + 4ccbec9 commit a296532
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions components/driver/temperature_sensor/temperature_sensor.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,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();
Expand All @@ -230,7 +230,7 @@ esp_err_t temperature_sensor_get_celsius(temperature_sensor_handle_t tsens, floa
ESP_RETURN_ON_FALSE(out_celsius != NULL, ESP_ERR_INVALID_ARG, TAG, "Celsius points to nothing");
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) {
Expand Down

0 comments on commit a296532

Please sign in to comment.