1 /* 2 * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #include <esp_types.h> 8 #include <esp_err.h> 9 10 #ifdef __cplusplus 11 extern "C" { 12 #endif 13 14 //This is the ADC calibration value version burnt in efuse 15 #define ESP_EFUSE_ADC_CALIB_VER1 1 16 #define ESP_EFUSE_ADC_CALIB_VER_MIN ESP_EFUSE_ADC_CALIB_VER1 17 #define ESP_EFUSE_ADC_CALIB_VER_MAX ESP_EFUSE_ADC_CALIB_VER1 18 #define VER2IDX(ver) ((ver) - 1) // Version number to index number of the array 19 20 /** 21 * @brief Get the RTC calibration efuse version 22 * 23 * @return Version of the stored efuse 24 */ 25 int esp_efuse_rtc_calib_get_ver(void); 26 27 /** 28 * @brief Get the init code in the efuse, for the corresponding attenuation. 29 * 30 * @param version Version of the stored efuse 31 * @param adc_unit ADC unit. Not used, for compatibility. On esp32h2, for calibration v1, both ADC units use the same init code (calibrated by ADC1) 32 * @param atten Attenuation of the init code 33 * @return The init code stored in efuse 34 */ 35 uint32_t esp_efuse_rtc_calib_get_init_code(int version, uint32_t adc_unit, int atten); 36 37 /** 38 * @brief Get the channel specific calibration compensation 39 * 40 * @param version Version of the stored efuse 41 * @param adc_unit ADC unit. Not used, for compatibility. ESP32H2 only supports one ADC unit 42 * @param atten Attenuation of the init code 43 * @return The channel calibration compensation value 44 */ 45 int esp_efuse_rtc_calib_get_chan_compens(int version, uint32_t adc_unit, uint32_t adc_channel, int atten); 46 47 /** 48 * @brief Get the calibration digits stored in the efuse, and the corresponding voltage. 49 * 50 * @param version Version of the stored efuse 51 * @param adc_unit ADC unit (not used on ESP32H2, for compatibility) 52 * @param atten Attenuation to use 53 * @param out_digi Output buffer of the digits 54 * @param out_vol_mv Output of the voltage, in mV 55 * @return 56 * - ESP_ERR_INVALID_ARG: If efuse version or attenuation is invalid 57 * - ESP_OK: if success 58 */ 59 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); 60 61 /** 62 * @brief Get the temperature sensor calibration number delta_T stored in the efuse. 63 * 64 * @param tsens_cal Pointer of the specification of temperature sensor calibration number in efuse. 65 * 66 * @return ESP_OK if get the calibration value successfully. 67 * ESP_ERR_INVALID_ARG if can't get the calibration value. 68 */ 69 esp_err_t esp_efuse_rtc_calib_get_tsens_val(float* tsens_cal); 70 71 #ifdef __cplusplus 72 } 73 #endif 74