esp_efuse_rtc_table.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. #include <stdbool.h>
  11. #include <stdint.h>
  12. #include "esp_err.h"
  13. #include "sdkconfig.h"
  14. //This is the ADC calibration value version burnt in efuse
  15. #define ESP_EFUSE_ADC_CALIB_VER 2
  16. #define ESP_EFUSE_ADC_CALIB_VER_MIN ESP_EFUSE_ADC_CALIB_VER
  17. #define ESP_EFUSE_ADC_CALIB_VER_MAX ESP_EFUSE_ADC_CALIB_VER
  18. #define RTCCALIB_ESP32S2_ADCCOUNT 2
  19. #define RTCCALIB_ESP32S2_ATTENCOUNT 4
  20. #define RTCCALIB_V1_PARAM_VLOW 0
  21. #define RTCCALIB_V1_PARAM_VHIGH 1
  22. #define RTCCALIB_V2_PARAM_VHIGH 0
  23. #define RTCCALIB_V2_PARAM_VINIT 1
  24. // these are the tags. Either use them directly or use esp_efuse_rtc_table_get_tag to calculate
  25. // the corresponding tag.
  26. #define RTCCALIB_V1IDX_A10L 1
  27. #define RTCCALIB_V1IDX_A11L 2
  28. #define RTCCALIB_V1IDX_A12L 3
  29. #define RTCCALIB_V1IDX_A13L 4
  30. #define RTCCALIB_V1IDX_A20L 5
  31. #define RTCCALIB_V1IDX_A21L 6
  32. #define RTCCALIB_V1IDX_A22L 7
  33. #define RTCCALIB_V1IDX_A23L 8
  34. #define RTCCALIB_V1IDX_A10H 9
  35. #define RTCCALIB_V1IDX_A11H 10
  36. #define RTCCALIB_V1IDX_A12H 11
  37. #define RTCCALIB_V1IDX_A13H 12
  38. #define RTCCALIB_V1IDX_A20H 13
  39. #define RTCCALIB_V1IDX_A21H 14
  40. #define RTCCALIB_V1IDX_A22H 15
  41. #define RTCCALIB_V1IDX_A23H 16
  42. #define RTCCALIB_V2IDX_A10H 17
  43. #define RTCCALIB_V2IDX_A11H 18
  44. #define RTCCALIB_V2IDX_A12H 19
  45. #define RTCCALIB_V2IDX_A13H 20
  46. #define RTCCALIB_V2IDX_A20H 21
  47. #define RTCCALIB_V2IDX_A21H 22
  48. #define RTCCALIB_V2IDX_A22H 23
  49. #define RTCCALIB_V2IDX_A23H 24
  50. #define RTCCALIB_V2IDX_A10I 25
  51. #define RTCCALIB_V2IDX_A11I 26
  52. #define RTCCALIB_V2IDX_A12I 27
  53. #define RTCCALIB_V2IDX_A13I 28
  54. #define RTCCALIB_V2IDX_A20I 29
  55. #define RTCCALIB_V2IDX_A21I 30
  56. #define RTCCALIB_V2IDX_A22I 31
  57. #define RTCCALIB_V2IDX_A23I 32
  58. #define RTCCALIB_IDX_TMPSENSOR 33
  59. /**
  60. * @brief Get rtc calibration version.
  61. */
  62. int esp_efuse_rtc_table_read_calib_version(void);
  63. /**
  64. * @brief Helper function to calculate a tag from human-readable parameters.
  65. * Tag is used to index the desired data from the efuse.
  66. * For example, (1, 1, 3, 1) yields the tag RTCCALIB_V1IDX_A13H
  67. * extra params are used for identification when a adc_num-atten combination has
  68. * multiple efuse values.
  69. * @param adc_channel_num verbatim numbering of the ADC channel. For channel 1, use 1 and not 0.
  70. * @param atten attenuation. use the enum value.
  71. * @param version the version of the scheme to index for.
  72. * @param extra_params defined differently for each version.
  73. * */
  74. int esp_efuse_rtc_table_get_tag(int version, int adc_channel_num, int atten, int extra_params);
  75. /**
  76. * @brief Fetches a raw value from efuse and does signed bit parsing
  77. * @param tag tag obtained with esp_efuse_rtc_table_get_tag
  78. *
  79. * */
  80. int esp_efuse_rtc_table_get_raw_efuse_value(int tag);
  81. /**
  82. * @brief Fetches a raw value from efuse and resolve it to get
  83. * the original number that it meant to represent.
  84. *
  85. * @param tag tag obtained with esp_efuse_rtc_table_get_tag
  86. * @param use_zero_inputs Does not perform the raw value fetching before resolving the number,
  87. * but proceed as if all zeros were read from efuse.
  88. *
  89. * */
  90. int esp_efuse_rtc_table_get_parsed_efuse_value(int tag, bool skip_efuse_reading);
  91. #ifdef __cplusplus
  92. }
  93. #endif