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