phy_init_data.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. /*
  2. * SPDX-FileCopyrightText: 2016-2022 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. 0x80,
  32. 0x00,
  33. LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x4E),
  34. LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x4E),
  35. LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x48),
  36. LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x48),
  37. LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x48),
  38. LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x48),
  39. LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x48),
  40. LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x48),
  41. LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x44),
  42. LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x44),
  43. LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x48),
  44. LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x48),
  45. LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x44),
  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. 0,
  143. 0,
  144. 0,
  145. 0,
  146. 0,
  147. 0,
  148. 0,
  149. 0,
  150. 0,
  151. 0,
  152. 0,
  153. 0,
  154. 0,
  155. 0,
  156. 0,
  157. 0,
  158. 0xf1
  159. } };
  160. static const char phy_init_magic_post[] = PHY_INIT_MAGIC;
  161. #if CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN
  162. /**
  163. * @brief PHY init data control infomation structure
  164. */
  165. typedef struct {
  166. uint8_t control_info_checksum[4]; /*!< 4-byte control infomation checksum */
  167. uint8_t multiple_bin_checksum[4]; /*!< 4-byte multiple bin checksum */
  168. uint8_t check_algorithm; /*!< check algorithm */
  169. uint8_t version; /*!< PHY init data bin version */
  170. uint8_t number; /*!< PHY init data bin number */
  171. uint8_t length[2]; /*!< Length of each PHY init data bin */
  172. uint8_t reserved[19]; /*!< 19-byte reserved */
  173. } __attribute__ ((packed)) phy_control_info_data_t;
  174. /**
  175. * @brief Country corresponds to PHY init data type structure
  176. */
  177. typedef struct {
  178. char cc[PHY_COUNTRY_CODE_LEN];
  179. uint8_t type;
  180. } phy_country_to_bin_type_t;
  181. #endif
  182. #ifdef __cplusplus
  183. }
  184. #endif
  185. #endif /* PHY_INIT_DATA_H */