1 /* 2 * SPDX-FileCopyrightText: 2016-2021 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_ESP32_PHY_MAX_TX_POWER * 4, 0, 52) 23 #define PHY_TX_POWER_OFFSET 44 24 #define PHY_TX_POWER_NUM 5 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 __attribute__((section(".rodata"))) 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 0x00, 40 0x00, 41 LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 0x50), 42 LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 0x50), 43 LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 0x50), 44 LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 0x4c), 45 LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 0x4c), 46 LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 0x48), 47 LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 0x4c), 48 LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 0x48), 49 LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 0x48), 50 LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 0x44), 51 LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 0x4a), 52 LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 0x46), 53 LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 0, 0x46), 54 LIMIT(CONFIG_ESP32_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 0x74 151 } }; 152 153 static const char __attribute__((section(".rodata"))) phy_init_magic_post[] = PHY_INIT_MAGIC; 154 155 #if CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN 156 /** 157 * @brief PHY init data control infomation structure 158 */ 159 typedef struct { 160 uint8_t control_info_checksum[4]; /*!< 4-byte control infomation checksum */ 161 uint8_t multiple_bin_checksum[4]; /*!< 4-byte multiple bin checksum */ 162 uint8_t check_algorithm; /*!< check algorithm */ 163 uint8_t version; /*!< PHY init data bin version */ 164 uint8_t number; /*!< PHY init data bin number */ 165 uint8_t length[2]; /*!< Length of each PHY init data bin */ 166 uint8_t reserved[19]; /*!< 19-byte reserved */ 167 } __attribute__ ((packed)) phy_control_info_data_t; 168 169 /** 170 * @brief Country corresponds to PHY init data type structure 171 */ 172 typedef struct { 173 char cc[PHY_COUNTRY_CODE_LEN]; 174 uint8_t type; 175 } phy_country_to_bin_type_t; 176 #endif 177 178 #ifdef __cplusplus 179 } 180 #endif 181 182 #endif /* PHY_INIT_DATA_H */ 183