esp_efuse_rtc_calib.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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_VER_MIN ESP_EFUSE_ADC_CALIB_VER1
  14. #define ESP_EFUSE_ADC_CALIB_VER_MAX ESP_EFUSE_ADC_CALIB_VER1
  15. #define VER2IDX(ver) ((ver) - 1) // Version number to index number of the array
  16. /**
  17. * @brief Get the RTC calibration efuse version
  18. *
  19. * @return Version of the stored efuse
  20. */
  21. int esp_efuse_rtc_calib_get_ver(void);
  22. /**
  23. * @brief Get the init code in the efuse, for the corresponding attenuation.
  24. *
  25. * @param version Version of the stored efuse
  26. * @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)
  27. * @param atten Attenuation of the init code
  28. * @return The init code stored in efuse
  29. */
  30. uint32_t esp_efuse_rtc_calib_get_init_code(int version, uint32_t adc_unit, int atten);
  31. /**
  32. * @brief Get the channel specific calibration compensation
  33. *
  34. * @param version Version of the stored efuse
  35. * @param adc_unit ADC unit. Not used, for compatibility. ESP32H2 only supports one ADC unit
  36. * @param atten Attenuation of the init code
  37. * @return The channel calibration compensation value
  38. */
  39. int esp_efuse_rtc_calib_get_chan_compens(int version, uint32_t adc_unit, uint32_t adc_channel, int atten);
  40. /**
  41. * @brief Get the calibration digits stored in the efuse, and the corresponding voltage.
  42. *
  43. * @param version Version of the stored efuse
  44. * @param adc_unit ADC unit (not used on ESP32H2, for compatibility)
  45. * @param atten Attenuation to use
  46. * @param out_digi Output buffer of the digits
  47. * @param out_vol_mv Output of the voltage, in mV
  48. * @return
  49. * - ESP_ERR_INVALID_ARG: If efuse version or attenuation is invalid
  50. * - ESP_OK: if success
  51. */
  52. 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);
  53. /**
  54. * @brief Get the temperature sensor calibration number delta_T stored in the efuse.
  55. *
  56. * @param tsens_cal Pointer of the specification of temperature sensor calibration number in efuse.
  57. *
  58. * @return ESP_OK if get the calibration value successfully.
  59. * ESP_ERR_INVALID_ARG if can't get the calibration value.
  60. */
  61. esp_err_t esp_efuse_rtc_calib_get_tsens_val(float* tsens_cal);
  62. #ifdef __cplusplus
  63. }
  64. #endif