1 /* 2 * SPDX-FileCopyrightText: 2016-2022 Espressif Systems (Shanghai) CO LTD 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef PHY_INIT_DATA_H 8 #define PHY_INIT_DATA_H /* don't use #pragma once here, we compile this file sometimes */ 9 #include "esp_phy_init.h" 10 #include "sdkconfig.h" 11 12 #ifdef __cplusplus 13 extern "C" { 14 #endif 15 16 // constrain a value between 'low' and 'high', inclusive 17 #define LIMIT(val, low, high) ((val < low) ? low : (val > high) ? high : val) 18 19 #define PHY_INIT_MAGIC "PHYINIT" 20 21 // define the lowest tx power as LOWEST_PHY_TX_POWER 22 #define PHY_TX_POWER_LOWEST LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 52) 23 #define PHY_TX_POWER_OFFSET 2 24 #define PHY_TX_POWER_NUM 14 25 26 #if CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN 27 #define PHY_CRC_ALGORITHM 1 28 #define PHY_COUNTRY_CODE_LEN 2 29 #define PHY_INIT_DATA_TYPE_OFFSET 126 30 #define PHY_SUPPORT_MULTIPLE_BIN_OFFSET 125 31 #endif 32 33 static const char phy_init_magic_pre[] = PHY_INIT_MAGIC; 34 35 /** 36 * @brief Structure containing default recommended PHY initialization parameters. 37 */ 38 static const esp_phy_init_data_t phy_init_data= { { 39 0x80, 40 0x00, 41 LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x4E), 42 LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x4E), 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, 0x48), 46 LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x48), 47 LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x48), 48 LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x48), 49 LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x44), 50 LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x44), 51 LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x48), 52 LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x48), 53 LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x44), 54 LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 0x42), 55 0x00, 56 0x00, 57 0x00, 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 0xff, 102 0xff, 103 0xff, 104 0xff, 105 0xff, 106 0xff, 107 0xff, 108 0xff, 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 0, 159 0, 160 0, 161 0, 162 0, 163 0, 164 0, 165 0, 166 0xf1 167 } }; 168 169 static const char phy_init_magic_post[] = PHY_INIT_MAGIC; 170 171 #if CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN 172 /** 173 * @brief PHY init data control infomation structure 174 */ 175 typedef struct { 176 uint8_t control_info_checksum[4]; /*!< 4-byte control infomation checksum */ 177 uint8_t multiple_bin_checksum[4]; /*!< 4-byte multiple bin checksum */ 178 uint8_t check_algorithm; /*!< check algorithm */ 179 uint8_t version; /*!< PHY init data bin version */ 180 uint8_t number; /*!< PHY init data bin number */ 181 uint8_t length[2]; /*!< Length of each PHY init data bin */ 182 uint8_t reserved[19]; /*!< 19-byte reserved */ 183 } __attribute__ ((packed)) phy_control_info_data_t; 184 185 /** 186 * @brief Country corresponds to PHY init data type structure 187 */ 188 typedef struct { 189 char cc[PHY_COUNTRY_CODE_LEN]; 190 uint8_t type; 191 } phy_country_to_bin_type_t; 192 #endif 193 194 #ifdef __cplusplus 195 } 196 #endif 197 198 #endif /* PHY_INIT_DATA_H */ 199