phy_init_data.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /*
  2. * SPDX-FileCopyrightText: 2016-2021 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #ifndef PHY_INIT_DATA_H
  7. #define PHY_INIT_DATA_H /* don't use #pragma once here, we compile this file sometimes */
  8. #include "esp_phy_init.h"
  9. #include "sdkconfig.h"
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. // constrain a value between 'low' and 'high', inclusive
  14. #define LIMIT(val, low, high) ((val < low) ? low : (val > high) ? high : val)
  15. #define PHY_INIT_MAGIC "PHYINIT"
  16. // define the lowest tx power as LOWEST_PHY_TX_POWER
  17. #define PHY_TX_POWER_LOWEST LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 52)
  18. #define PHY_TX_POWER_OFFSET 2
  19. #define PHY_TX_POWER_NUM 14
  20. #if CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN
  21. #define PHY_CRC_ALGORITHM 1
  22. #define PHY_COUNTRY_CODE_LEN 2
  23. #define PHY_INIT_DATA_TYPE_OFFSET 126
  24. #define PHY_SUPPORT_MULTIPLE_BIN_OFFSET 125
  25. #endif
  26. static const char phy_init_magic_pre[] = PHY_INIT_MAGIC;
  27. /**
  28. * @brief Structure containing default recommended PHY initialization parameters.
  29. */
  30. static const esp_phy_init_data_t phy_init_data= { {
  31. 0x00,
  32. 0x00,
  33. LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x50),
  34. LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x50),
  35. LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x50),
  36. LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x4c),
  37. LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x4c),
  38. LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x48),
  39. LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x4c),
  40. LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x48),
  41. LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x48),
  42. LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x44),
  43. LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x4a),
  44. LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x46),
  45. LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x46),
  46. LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x42),
  47. 0x00,
  48. 0x00,
  49. 0x00,
  50. 0xff,
  51. 0xff,
  52. 0xff,
  53. 0xff,
  54. 0xff,
  55. 0xff,
  56. 0xff,
  57. 0xff,
  58. 0xff,
  59. 0xff,
  60. 0xff,
  61. 0xff,
  62. 0xff,
  63. 0xff,
  64. 0xff,
  65. 0xff,
  66. 0xff,
  67. 0xff,
  68. 0xff,
  69. 0xff,
  70. 0xff,
  71. 0xff,
  72. 0xff,
  73. 0xff,
  74. 0xff,
  75. 0xff,
  76. 0xff,
  77. 0xff,
  78. 0xff,
  79. 0xff,
  80. 0xff,
  81. 0xff,
  82. 0xff,
  83. 0xff,
  84. 0xff,
  85. 0xff,
  86. 0xff,
  87. 0xff,
  88. 0xff,
  89. 0xff,
  90. 0xff,
  91. 0xff,
  92. 0xff,
  93. 0xff,
  94. 0xff,
  95. 0xff,
  96. 0xff,
  97. 0xff,
  98. 0xff,
  99. 0xff,
  100. 0xff,
  101. 0,
  102. 0,
  103. 0,
  104. 0,
  105. 0,
  106. 0,
  107. 0,
  108. 0,
  109. 0,
  110. 0,
  111. 0,
  112. 0,
  113. 0,
  114. 0,
  115. 0,
  116. 0,
  117. 0,
  118. 0,
  119. 0,
  120. 0,
  121. 0,
  122. 0,
  123. 0,
  124. 0,
  125. 0,
  126. 0,
  127. 0,
  128. 0,
  129. 0,
  130. 0,
  131. 0,
  132. 0,
  133. 0,
  134. 0,
  135. 0,
  136. 0,
  137. 0,
  138. 0,
  139. 0,
  140. 0,
  141. 0,
  142. 0x74
  143. } };
  144. static const char phy_init_magic_post[] = PHY_INIT_MAGIC;
  145. #if CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN
  146. /**
  147. * @brief PHY init data control infomation structure
  148. */
  149. typedef struct {
  150. uint8_t control_info_checksum[4]; /*!< 4-byte control infomation checksum */
  151. uint8_t multiple_bin_checksum[4]; /*!< 4-byte multiple bin checksum */
  152. uint8_t check_algorithm; /*!< check algorithm */
  153. uint8_t version; /*!< PHY init data bin version */
  154. uint8_t number; /*!< PHY init data bin number */
  155. uint8_t length[2]; /*!< Length of each PHY init data bin */
  156. uint8_t reserved[19]; /*!< 19-byte reserved */
  157. } __attribute__ ((packed)) phy_control_info_data_t;
  158. /**
  159. * @brief Country corresponds to PHY init data type structure
  160. */
  161. typedef struct {
  162. char cc[PHY_COUNTRY_CODE_LEN];
  163. uint8_t type;
  164. } phy_country_to_bin_type_t;
  165. #endif
  166. #ifdef __cplusplus
  167. }
  168. #endif
  169. #endif /* PHY_INIT_DATA_H */