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