esp_efuse_rtc_table.h 3.1 KB

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