phy_init_data.h 3.5 KB

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