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_VER2 2 17 #define ESP_EFUSE_ADC_CALIB_VER_MIN ESP_EFUSE_ADC_CALIB_VER1 18 #define ESP_EFUSE_ADC_CALIB_VER_MAX ESP_EFUSE_ADC_CALIB_VER2 19 #define VER2IDX(ver) ((ver) - 1) // Version number to index number of the array 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 esp32c6, 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. On esp32c6, for calibration v1, both ADC units use the same init code (calibrated by ADC1) 42 * @param adc_channel ADC channel number 43 * @param atten Attenuation of the init code 44 * @return The channel calibration compensation value 45 */ 46 int esp_efuse_rtc_calib_get_chan_compens(int version, uint32_t adc_unit, uint32_t adc_channel, int atten); 47 48 /** 49 * @brief Get the calibration digits stored in the efuse, and the corresponding voltage. 50 * 51 * @param version Version of the stored efuse 52 * @param adc_unit ADC unit (not used on ESP32C6, for compatibility) 53 * @param atten Attenuation to use 54 * @param out_digi Output buffer of the digits 55 * @param out_vol_mv Output of the voltage, in mV 56 * @return 57 * - ESP_ERR_INVALID_ARG: If efuse version or attenuation is invalid 58 * - ESP_OK: if success 59 */ 60 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); 61 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 72 #ifdef __cplusplus 73 } 74 #endif 75