From aeaa66ec08c88b14c845d0fdf9936df763b155f6 Mon Sep 17 00:00:00 2001 From: Zhang Jun Hao Date: Thu, 18 Apr 2019 11:35:58 +0800 Subject: [PATCH] feat(esp8266): add settings for wifi tx power to menuconfig --- components/esp8266/Kconfig | 8 ++++++++ components/esp8266/source/phy_init_data.h | 14 ++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/components/esp8266/Kconfig b/components/esp8266/Kconfig index fe7cb1b7..1e798789 100644 --- a/components/esp8266/Kconfig +++ b/components/esp8266/Kconfig @@ -455,5 +455,13 @@ config ESP_PHY_INIT_DATA_VDD33_CONST When the ADC reference voltage is set to the actual VDD33 power supply voltage, the value range of vdd33_const is [18,36], the unit is 0.1V. When the ADC reference voltage is set to the default value of 3.3V as the supply voltage, the range of vdd33_const is [0, 18] or (36, 255). +config ESP8266_PHY_MAX_WIFI_TX_POWER + int "Max WiFi TX power (dBm)" + range 0 21 + default 20 + help + Set maximum transmit power for WiFi radio. Actual transmit power for high + data rates may be lower than this setting. + endmenu # PHY diff --git a/components/esp8266/source/phy_init_data.h b/components/esp8266/source/phy_init_data.h index 55853b19..d3a055f0 100644 --- a/components/esp8266/source/phy_init_data.h +++ b/components/esp8266/source/phy_init_data.h @@ -17,6 +17,8 @@ #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" static const char phy_init_magic_pre[] = PHY_INIT_MAGIC; @@ -59,12 +61,12 @@ static const esp_phy_init_data_t phy_init_data= { { 0x00, 0xf8, 0xf8, - 0x52, - 0x4e, - 0x4a, - 0x44, - 0x40, - 0x38, + LIMIT(CONFIG_ESP8266_PHY_MAX_WIFI_TX_POWER * 4, 0, 0x52), + LIMIT(CONFIG_ESP8266_PHY_MAX_WIFI_TX_POWER * 4, 0, 0x4e), + LIMIT(CONFIG_ESP8266_PHY_MAX_WIFI_TX_POWER * 4, 0, 0x4a), + LIMIT(CONFIG_ESP8266_PHY_MAX_WIFI_TX_POWER * 4, 0, 0x44), + LIMIT(CONFIG_ESP8266_PHY_MAX_WIFI_TX_POWER * 4, 0, 0x40), + LIMIT(CONFIG_ESP8266_PHY_MAX_WIFI_TX_POWER * 4, 0, 0x38), 0x00, 0x00, 0x01,