phy_init_data.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. // Copyright 2016 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. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #ifndef PHY_INIT_DATA_H
  15. #define PHY_INIT_DATA_H /* don't use #pragma once here, we compile this file sometimes */
  16. #include "esp_phy_init.h"
  17. #include "sdkconfig.h"
  18. // constrain a value between 'low' and 'high', inclusive
  19. #define LIMIT(val, low, high) ((val < low) ? low : (val > high) ? high : val)
  20. #define PHY_INIT_MAGIC "PHYINIT"
  21. // define the lowest tx power as LOWEST_PHY_TX_POWER
  22. #define PHY_TX_POWER_LOWEST LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 52)
  23. #define PHY_TX_POWER_OFFSET 44
  24. #define PHY_TX_POWER_NUM 5
  25. #if CONFIG_ESP32_SUPPORT_MULTIPLE_PHY_INIT_DATA_BIN
  26. #define PHY_CRC_ALGORITHM 1
  27. #define PHY_COUNTRY_CODE_LEN 2
  28. #define PHY_INIT_DATA_TYPE_OFFSET 126
  29. #define PHY_SUPPORT_MULTIPLE_BIN_OFFSET 125
  30. #endif
  31. static const char phy_init_magic_pre[] = PHY_INIT_MAGIC;
  32. /**
  33. * @brief Structure containing default recommended PHY initialization parameters.
  34. */
  35. static const esp_phy_init_data_t phy_init_data= { {
  36. 3,
  37. 3,
  38. 0x05,
  39. 0x09,
  40. 0x06,
  41. 0x05,
  42. 0x03,
  43. 0x06,
  44. 0x05,
  45. 0x04,
  46. 0x06,
  47. 0x04,
  48. 0x05,
  49. 0x00,
  50. 0x00,
  51. 0x00,
  52. 0x00,
  53. 0x05,
  54. 0x09,
  55. 0x06,
  56. 0x05,
  57. 0x03,
  58. 0x06,
  59. 0x05,
  60. 0x00,
  61. 0x00,
  62. 0x00,
  63. 0x00,
  64. 0x00,
  65. 0x00,
  66. 0x00,
  67. 0x00,
  68. 0xfc,
  69. 0xfc,
  70. 0xfe,
  71. 0xf0,
  72. 0xf0,
  73. 0xf0,
  74. 0xe0,
  75. 0xe0,
  76. 0xe0,
  77. 0x18,
  78. 0x18,
  79. 0x18,
  80. LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 40, 84),
  81. LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 40, 72),
  82. LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 40, 66),
  83. LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 40, 60),
  84. LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 40, 56),
  85. LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 40, 52),
  86. 0,
  87. 1,
  88. 1,
  89. 2,
  90. 2,
  91. 3,
  92. 4,
  93. 5,
  94. 0,
  95. 0,
  96. 0,
  97. 0,
  98. 0,
  99. 0,
  100. 0,
  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. } };
  144. static const char phy_init_magic_post[] = PHY_INIT_MAGIC;
  145. #if CONFIG_ESP32_SUPPORT_MULTIPLE_PHY_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. #endif /* PHY_INIT_DATA_H */