esp_efuse_rtc_table.h 3.4 KB

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