| 
									
										
										
										
											2021-09-30 10:53:26 +08:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * SPDX-FileCopyrightText: 2016-2021 Espressif Systems (Shanghai) CO LTD | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: Apache-2.0 | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2016-11-15 18:36:18 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-01 17:45:41 +08:00
										 |  |  | #ifndef PHY_INIT_DATA_H
 | 
					
						
							|  |  |  | #define PHY_INIT_DATA_H /* don't use #pragma once here, we compile this file sometimes */
 | 
					
						
							| 
									
										
										
										
											2016-11-15 18:36:18 +08:00
										 |  |  | #include "esp_phy_init.h"
 | 
					
						
							|  |  |  | #include "sdkconfig.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // constrain a value between 'low' and 'high', inclusive
 | 
					
						
							|  |  |  | #define LIMIT(val, low, high) ((val < low) ? low : (val > high) ? high : val)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define PHY_INIT_MAGIC "PHYINIT"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-25 17:28:56 +08:00
										 |  |  | // define the lowest tx power as LOWEST_PHY_TX_POWER
 | 
					
						
							| 
									
										
										
										
											2021-06-16 11:39:08 +08:00
										 |  |  | #define PHY_TX_POWER_LOWEST LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 0, 52)
 | 
					
						
							| 
									
										
										
										
											2018-07-25 17:28:56 +08:00
										 |  |  | #define PHY_TX_POWER_OFFSET 44
 | 
					
						
							|  |  |  | #define PHY_TX_POWER_NUM    5
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-16 11:39:08 +08:00
										 |  |  | #if CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN
 | 
					
						
							| 
									
										
										
										
											2019-10-16 11:22:50 +08:00
										 |  |  | #define PHY_CRC_ALGORITHM 1
 | 
					
						
							|  |  |  | #define PHY_COUNTRY_CODE_LEN 2
 | 
					
						
							|  |  |  | #define PHY_INIT_DATA_TYPE_OFFSET 126
 | 
					
						
							|  |  |  | #define PHY_SUPPORT_MULTIPLE_BIN_OFFSET 125
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2016-11-15 18:36:18 +08:00
										 |  |  | static const char phy_init_magic_pre[] = PHY_INIT_MAGIC; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * @brief Structure containing default recommended PHY initialization parameters. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2017-10-09 14:37:42 +08:00
										 |  |  | static const esp_phy_init_data_t phy_init_data= { { | 
					
						
							| 
									
										
										
										
											2017-10-17 11:22:46 +08:00
										 |  |  |         3, | 
					
						
							| 
									
										
										
										
											2017-10-09 14:37:42 +08:00
										 |  |  |         3, | 
					
						
							|  |  |  |         0x05, | 
					
						
							| 
									
										
										
										
											2017-10-17 11:22:46 +08:00
										 |  |  |         0x09, | 
					
						
							| 
									
										
										
										
											2017-10-09 14:37:42 +08:00
										 |  |  |         0x06, | 
					
						
							|  |  |  |         0x05, | 
					
						
							| 
									
										
										
										
											2017-10-17 11:22:46 +08:00
										 |  |  |         0x03, | 
					
						
							| 
									
										
										
										
											2017-10-09 14:37:42 +08:00
										 |  |  |         0x06, | 
					
						
							|  |  |  |         0x05, | 
					
						
							|  |  |  |         0x04, | 
					
						
							|  |  |  |         0x06, | 
					
						
							|  |  |  |         0x04, | 
					
						
							|  |  |  |         0x05, | 
					
						
							|  |  |  |         0x00, | 
					
						
							|  |  |  |         0x00, | 
					
						
							|  |  |  |         0x00, | 
					
						
							|  |  |  |         0x00, | 
					
						
							|  |  |  |         0x05, | 
					
						
							| 
									
										
										
										
											2017-10-17 11:22:46 +08:00
										 |  |  |         0x09, | 
					
						
							| 
									
										
										
										
											2017-10-09 14:37:42 +08:00
										 |  |  |         0x06, | 
					
						
							|  |  |  |         0x05, | 
					
						
							| 
									
										
										
										
											2017-10-17 11:22:46 +08:00
										 |  |  |         0x03, | 
					
						
							| 
									
										
										
										
											2017-10-09 14:37:42 +08:00
										 |  |  |         0x06, | 
					
						
							|  |  |  |         0x05, | 
					
						
							|  |  |  |         0x00, | 
					
						
							|  |  |  |         0x00, | 
					
						
							|  |  |  |         0x00, | 
					
						
							|  |  |  |         0x00, | 
					
						
							|  |  |  |         0x00, | 
					
						
							|  |  |  |         0x00, | 
					
						
							|  |  |  |         0x00, | 
					
						
							|  |  |  |         0x00, | 
					
						
							| 
									
										
										
										
											2017-10-17 11:22:46 +08:00
										 |  |  |         0xfc, | 
					
						
							|  |  |  |         0xfc, | 
					
						
							|  |  |  |         0xfe, | 
					
						
							| 
									
										
										
										
											2017-10-09 14:37:42 +08:00
										 |  |  |         0xf0, | 
					
						
							|  |  |  |         0xf0, | 
					
						
							|  |  |  |         0xf0, | 
					
						
							|  |  |  |         0xe0, | 
					
						
							|  |  |  |         0xe0, | 
					
						
							|  |  |  |         0xe0, | 
					
						
							|  |  |  |         0x18, | 
					
						
							|  |  |  |         0x18, | 
					
						
							|  |  |  |         0x18, | 
					
						
							| 
									
										
										
										
											2021-06-16 11:39:08 +08:00
										 |  |  |         LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 40, 78), | 
					
						
							|  |  |  |         LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 40, 72), | 
					
						
							|  |  |  |         LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 40, 66), | 
					
						
							|  |  |  |         LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 40, 60), | 
					
						
							|  |  |  |         LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 40, 56), | 
					
						
							|  |  |  |         LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 40, 52), | 
					
						
							| 
									
										
										
										
											2017-10-09 14:37:42 +08:00
										 |  |  |         0, | 
					
						
							|  |  |  |         1, | 
					
						
							|  |  |  |         1, | 
					
						
							|  |  |  |         2, | 
					
						
							| 
									
										
										
										
											2017-10-17 11:22:46 +08:00
										 |  |  |         2, | 
					
						
							| 
									
										
										
										
											2017-10-09 14:37:42 +08:00
										 |  |  |         3, | 
					
						
							|  |  |  |         4, | 
					
						
							|  |  |  |         5, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							| 
									
										
										
										
											2017-10-17 11:22:46 +08:00
										 |  |  |         0, | 
					
						
							|  |  |  |         0, | 
					
						
							| 
									
										
										
										
											2017-10-09 14:37:42 +08:00
										 |  |  | } }; | 
					
						
							| 
									
										
										
										
											2016-11-15 18:36:18 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | static const char phy_init_magic_post[] = PHY_INIT_MAGIC; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-16 11:39:08 +08:00
										 |  |  | #if CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN
 | 
					
						
							| 
									
										
										
										
											2019-10-16 11:22:50 +08:00
										 |  |  | /**
 | 
					
						
							| 
									
										
										
										
											2020-11-10 18:40:01 +11:00
										 |  |  |  * @brief PHY init data control infomation structure | 
					
						
							| 
									
										
										
										
											2019-10-16 11:22:50 +08:00
										 |  |  |  */ | 
					
						
							|  |  |  | typedef struct { | 
					
						
							|  |  |  |     uint8_t control_info_checksum[4];     /*!< 4-byte control infomation checksum */ | 
					
						
							|  |  |  |     uint8_t multiple_bin_checksum[4];     /*!< 4-byte multiple bin checksum */ | 
					
						
							|  |  |  |     uint8_t check_algorithm;              /*!< check algorithm */ | 
					
						
							|  |  |  |     uint8_t version;                      /*!< PHY init data bin version */ | 
					
						
							|  |  |  |     uint8_t number;                       /*!< PHY init data bin number */ | 
					
						
							|  |  |  |     uint8_t length[2];                    /*!< Length of each PHY init data bin */ | 
					
						
							|  |  |  |     uint8_t reserved[19];                 /*!< 19-byte reserved  */ | 
					
						
							|  |  |  | } __attribute__ ((packed)) phy_control_info_data_t; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * @brief Country corresponds to PHY init data type structure | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | typedef struct { | 
					
						
							|  |  |  |     char cc[PHY_COUNTRY_CODE_LEN]; | 
					
						
							|  |  |  |     uint8_t type; | 
					
						
							|  |  |  | } phy_country_to_bin_type_t; | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2018-02-01 17:45:41 +08:00
										 |  |  | #endif /* PHY_INIT_DATA_H */
 |