esp_efuse_rtc_calib.h 2.6 KB

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