esp_efuse_rtc_table.h 3.0 KB

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