Skip to content

Commit caf1a18

Browse files
committed
refactor(temperature_sensor): Move calibration function from efuse to hal
1 parent d839ecb commit caf1a18

File tree

31 files changed

+190
-322
lines changed

31 files changed

+190
-322
lines changed

components/efuse/esp32c2/esp_efuse_rtc_calib.c

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -108,21 +108,3 @@ esp_err_t esp_efuse_rtc_calib_get_cal_voltage(int version, uint32_t adc_unit, in
108108

109109
return ESP_OK;
110110
}
111-
112-
esp_err_t esp_efuse_rtc_calib_get_tsens_val(float* tsens_cal)
113-
{
114-
const esp_efuse_desc_t** cal_temp_efuse;
115-
cal_temp_efuse = ESP_EFUSE_TEMP_CALIB;
116-
int cal_temp_size = esp_efuse_get_field_size(cal_temp_efuse);
117-
assert(cal_temp_size == 9);
118-
119-
uint32_t cal_temp = 0;
120-
esp_err_t err = esp_efuse_read_field_blob(cal_temp_efuse, &cal_temp, cal_temp_size);
121-
if (err != ESP_OK) {
122-
*tsens_cal = 0.0;
123-
return err;
124-
}
125-
// BIT(8) stands for sign: 1: negative, 0: positive
126-
*tsens_cal = ((cal_temp & BIT(8)) != 0)? -(uint8_t)cal_temp: (uint8_t)cal_temp;
127-
return ESP_OK;
128-
}

components/efuse/esp32c2/include/esp_efuse_rtc_calib.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -47,16 +47,6 @@ uint32_t esp_efuse_rtc_calib_get_init_code(int version, uint32_t adc_unit, int a
4747
*/
4848
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);
4949

50-
/**
51-
* @brief Get the temperature sensor calibration number delta_T stored in the efuse.
52-
*
53-
* @param tsens_cal Pointer of the specification of temperature sensor calibration number in efuse.
54-
*
55-
* @return ESP_OK if get the calibration value successfully.
56-
* ESP_ERR_INVALID_ARG if can't get the calibration value.
57-
*/
58-
esp_err_t esp_efuse_rtc_calib_get_tsens_val(float* tsens_cal);
59-
6050
#ifdef __cplusplus
6151
}
6252
#endif

components/efuse/esp32c3/esp_efuse_rtc_calib.c

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -82,24 +82,3 @@ esp_err_t esp_efuse_rtc_calib_get_cal_voltage(int version, uint32_t adc_unit, in
8282
*out_vol_mv = calib_vol_expected_mv;
8383
return ESP_OK;
8484
}
85-
86-
esp_err_t esp_efuse_rtc_calib_get_tsens_val(float* tsens_cal)
87-
{
88-
uint32_t version = esp_efuse_rtc_calib_get_ver();
89-
if (version != 1) {
90-
*tsens_cal = 0.0;
91-
return ESP_ERR_NOT_SUPPORTED;
92-
}
93-
const esp_efuse_desc_t** cal_temp_efuse;
94-
cal_temp_efuse = ESP_EFUSE_TEMP_CALIB;
95-
int cal_temp_size = esp_efuse_get_field_size(cal_temp_efuse);
96-
assert(cal_temp_size == 9);
97-
98-
uint32_t cal_temp = 0;
99-
esp_err_t err = esp_efuse_read_field_blob(cal_temp_efuse, &cal_temp, cal_temp_size);
100-
assert(err == ESP_OK);
101-
(void)err;
102-
// BIT(8) stands for sign: 1: negtive, 0: positive
103-
*tsens_cal = ((cal_temp & BIT(8)) != 0)? -(uint8_t)cal_temp: (uint8_t)cal_temp;
104-
return ESP_OK;
105-
}

components/efuse/esp32c3/include/esp_efuse_rtc_calib.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -47,16 +47,6 @@ uint32_t esp_efuse_rtc_calib_get_init_code(int version, uint32_t adc_unit, int a
4747
*/
4848
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);
4949

50-
/**
51-
* @brief Get the temperature sensor calibration number delta_T stored in the efuse.
52-
*
53-
* @param tsens_cal Pointer of the specification of temperature sensor calibration number in efuse.
54-
*
55-
* @return ESP_OK if get the calibration value successfully.
56-
* ESP_ERR_INVALID_ARG if can't get the calibration value.
57-
*/
58-
esp_err_t esp_efuse_rtc_calib_get_tsens_val(float* tsens_cal);
59-
6050
#ifdef __cplusplus
6151
}
6252
#endif

components/efuse/esp32c5/esp_efuse_rtc_calib.c

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -145,21 +145,3 @@ esp_err_t esp_efuse_rtc_calib_get_cal_voltage(int version, uint32_t adc_unit, in
145145

146146
return ESP_OK;
147147
}
148-
149-
esp_err_t esp_efuse_rtc_calib_get_tsens_val(float* tsens_cal)
150-
{
151-
const esp_efuse_desc_t** cal_temp_efuse;
152-
cal_temp_efuse = ESP_EFUSE_TEMPERATURE_SENSOR;
153-
int cal_temp_size = esp_efuse_get_field_size(cal_temp_efuse);
154-
assert(cal_temp_size == 9);
155-
156-
uint32_t cal_temp = 0;
157-
esp_err_t err = esp_efuse_read_field_blob(cal_temp_efuse, &cal_temp, cal_temp_size);
158-
if (err != ESP_OK) {
159-
*tsens_cal = 0.0;
160-
return err;
161-
}
162-
// BIT(8) stands for sign: 1: negative, 0: positive
163-
*tsens_cal = ((cal_temp & BIT(8)) != 0)? -(uint8_t)cal_temp: (uint8_t)cal_temp;
164-
return ESP_OK;
165-
}

components/efuse/esp32c5/include/esp_efuse_rtc_calib.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -59,16 +59,6 @@ int esp_efuse_rtc_calib_get_chan_compens(int version, uint32_t adc_unit, uint32_
5959
*/
6060
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);
6161

62-
/**
63-
* @brief Get the temperature sensor calibration number delta_T stored in the efuse.
64-
*
65-
* @param tsens_cal Pointer of the specification of temperature sensor calibration number in efuse.
66-
*
67-
* @return ESP_OK if get the calibration value successfully.
68-
* ESP_ERR_INVALID_ARG if can't get the calibration value.
69-
*/
70-
esp_err_t esp_efuse_rtc_calib_get_tsens_val(float* tsens_cal);
71-
7262
#ifdef __cplusplus
7363
}
7464
#endif

components/efuse/esp32c6/esp_efuse_rtc_calib.c

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -129,21 +129,3 @@ esp_err_t esp_efuse_rtc_calib_get_cal_voltage(int version, uint32_t adc_unit, in
129129
*out_vol_mv = input_vout_mv[VER2IDX(version)][atten];
130130
return ESP_OK;
131131
}
132-
133-
esp_err_t esp_efuse_rtc_calib_get_tsens_val(float* tsens_cal)
134-
{
135-
const esp_efuse_desc_t** cal_temp_efuse;
136-
cal_temp_efuse = ESP_EFUSE_TEMP_CALIB;
137-
int cal_temp_size = esp_efuse_get_field_size(cal_temp_efuse);
138-
assert(cal_temp_size == 9);
139-
140-
uint32_t cal_temp = 0;
141-
esp_err_t err = esp_efuse_read_field_blob(cal_temp_efuse, &cal_temp, cal_temp_size);
142-
if (err != ESP_OK) {
143-
*tsens_cal = 0.0;
144-
return err;
145-
}
146-
// BIT(8) stands for sign: 1: negative, 0: positive
147-
*tsens_cal = ((cal_temp & BIT(8)) != 0)? -(uint8_t)cal_temp: (uint8_t)cal_temp;
148-
return ESP_OK;
149-
}

components/efuse/esp32c6/include/esp_efuse_rtc_calib.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -59,16 +59,6 @@ int esp_efuse_rtc_calib_get_chan_compens(int version, uint32_t adc_unit, uint32_
5959
*/
6060
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);
6161

62-
/**
63-
* @brief Get the temperature sensor calibration number delta_T stored in the efuse.
64-
*
65-
* @param tsens_cal Pointer of the specification of temperature sensor calibration number in efuse.
66-
*
67-
* @return ESP_OK if get the calibration value successfully.
68-
* ESP_ERR_INVALID_ARG if can't get the calibration value.
69-
*/
70-
esp_err_t esp_efuse_rtc_calib_get_tsens_val(float* tsens_cal);
71-
7262
#ifdef __cplusplus
7363
}
7464
#endif

components/efuse/esp32c61/esp_efuse_rtc_calib.c

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -46,21 +46,3 @@ esp_err_t esp_efuse_rtc_calib_get_cal_voltage(int version, uint32_t adc_unit, in
4646
abort();
4747
return ESP_OK;
4848
}
49-
50-
esp_err_t esp_efuse_rtc_calib_get_tsens_val(float* tsens_cal)
51-
{
52-
const esp_efuse_desc_t** cal_temp_efuse;
53-
cal_temp_efuse = ESP_EFUSE_TEMPERATURE_SENSOR;
54-
int cal_temp_size = esp_efuse_get_field_size(cal_temp_efuse);
55-
assert(cal_temp_size == 9);
56-
57-
uint32_t cal_temp = 0;
58-
esp_err_t err = esp_efuse_read_field_blob(cal_temp_efuse, &cal_temp, cal_temp_size);
59-
if (err != ESP_OK) {
60-
*tsens_cal = 0.0;
61-
return err;
62-
}
63-
// BIT(8) stands for sign: 1: negative, 0: positive
64-
*tsens_cal = ((cal_temp & BIT(8)) != 0)? -(uint8_t)cal_temp: (uint8_t)cal_temp;
65-
return ESP_OK;
66-
}

components/efuse/esp32c61/include/esp_efuse_rtc_calib.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -61,16 +61,6 @@ int esp_efuse_rtc_calib_get_chan_compens(int version, uint32_t adc_unit, uint32_
6161
*/
6262
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);
6363

64-
/**
65-
* @brief Get the temperature sensor calibration number delta_T stored in the efuse.
66-
*
67-
* @param tsens_cal Pointer of the specification of temperature sensor calibration number in efuse.
68-
*
69-
* @return ESP_OK if get the calibration value successfully.
70-
* ESP_ERR_INVALID_ARG if can't get the calibration value.
71-
*/
72-
esp_err_t esp_efuse_rtc_calib_get_tsens_val(float* tsens_cal);
73-
7464
#ifdef __cplusplus
7565
}
7666
#endif

0 commit comments

Comments
 (0)