phy_init_data.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. // constrain a value between 'low' and 'high', inclusive
  22. #define LIMIT(val, low, high) ((val < low) ? low : (val > high) ? high : val)
  23. #define PHY_INIT_MAGIC "PHYINIT"
  24. // define the lowest tx power as LOWEST_PHY_TX_POWER
  25. #define PHY_TX_POWER_LOWEST LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 52)
  26. #define PHY_TX_POWER_OFFSET 44
  27. #define PHY_TX_POWER_NUM 5
  28. #if CONFIG_ESP32_SUPPORT_MULTIPLE_PHY_INIT_DATA_BIN
  29. #define PHY_CRC_ALGORITHM 1
  30. #define PHY_COUNTRY_CODE_LEN 2
  31. #define PHY_INIT_DATA_TYPE_OFFSET 126
  32. #define PHY_SUPPORT_MULTIPLE_BIN_OFFSET 125
  33. #endif
  34. static const char phy_init_magic_pre[] = PHY_INIT_MAGIC;
  35. /**
  36. * @brief Structure containing default recommended PHY initialization parameters.
  37. */
  38. static const esp_phy_init_data_t phy_init_data= { {
  39. 3,
  40. 0,
  41. 0x04,
  42. 0x05,
  43. 0x04,
  44. 0x05,
  45. 0x05,
  46. 0x04,
  47. 0x06,
  48. 0x06,
  49. 0x06,
  50. 0x05,
  51. 0x06,
  52. 0x00,
  53. 0x00,
  54. 0x00,
  55. 0x00,
  56. 0x05,
  57. 0x09,
  58. 0x06,
  59. 0x05,
  60. 0x03,
  61. 0x06,
  62. 0x05,
  63. 0x00,
  64. 0x00,
  65. 0x00,
  66. 0x00,
  67. 0x00,
  68. 0x00,
  69. 0x00,
  70. 0x00,
  71. 0xf4,
  72. 0xf8,
  73. 0xf8,
  74. 0xf0,
  75. 0xf0,
  76. 0xf0,
  77. 0xe0,
  78. 0xe0,
  79. 0xe0,
  80. 0x18,
  81. 0x18,
  82. 0x18,
  83. LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 84),
  84. LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 72),
  85. LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 66),
  86. LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 60),
  87. LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 56),
  88. LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 52),
  89. 0,
  90. 1,
  91. 1,
  92. 2,
  93. 2,
  94. 3,
  95. 4,
  96. 5,
  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. 0,
  144. 0,
  145. 0,
  146. } };
  147. static const char phy_init_magic_post[] = PHY_INIT_MAGIC;
  148. #if CONFIG_ESP32_SUPPORT_MULTIPLE_PHY_INIT_DATA_BIN
  149. /**
  150. * @brief PHY init data control infomation structure
  151. */
  152. typedef struct {
  153. uint8_t control_info_checksum[4]; /*!< 4-byte control infomation checksum */
  154. uint8_t multiple_bin_checksum[4]; /*!< 4-byte multiple bin checksum */
  155. uint8_t check_algorithm; /*!< check algorithm */
  156. uint8_t version; /*!< PHY init data bin version */
  157. uint8_t number; /*!< PHY init data bin number */
  158. uint8_t length[2]; /*!< Length of each PHY init data bin */
  159. uint8_t reserved[19]; /*!< 19-byte reserved */
  160. } __attribute__ ((packed)) phy_control_info_data_t;
  161. /**
  162. * @brief Country corresponds to PHY init data type structure
  163. */
  164. typedef struct {
  165. char cc[PHY_COUNTRY_CODE_LEN];
  166. uint8_t type;
  167. } phy_country_to_bin_type_t;
  168. #endif
  169. #ifdef __cplusplus
  170. }
  171. #endif
  172. #endif /* PHY_INIT_DATA_H */