From e3388e5902b6212518ad09ca8708ae1b00a2e098 Mon Sep 17 00:00:00 2001 From: Zhang Jun Hao Date: Fri, 6 Sep 2019 17:36:53 +0800 Subject: [PATCH] feat(esp8266): set phy cal option according to cal data check --- components/esp8266/Kconfig | 9 ++++++--- components/esp8266/source/phy.h | 2 ++ components/esp8266/source/phy_init.c | 4 ++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/components/esp8266/Kconfig b/components/esp8266/Kconfig index 67bdcdb4..6eef3d65 100644 --- a/components/esp8266/Kconfig +++ b/components/esp8266/Kconfig @@ -472,9 +472,12 @@ config ESP_PHY_CALIBRATION_AND_DATA_STORAGE default y help If this option is enabled, NVS will be initialized and calibration data will be loaded from there. - PHY calibration will be skipped on deep sleep wakeup. If calibration data is not found, full calibration - will be performed and stored in NVS. Normally, only partial calibration will be performed. - If this option is disabled, full calibration will be performed. + If calibration data is not found, full calibration will be performed and stored in NVS. Normally, + only partial calibration will be performed. If this option is disabled, full calibration will be performed. + + Full calibration needs 170 - 180ms. + Partial calibration needs 35 - 40ms. + No calibration needs 3.260 - 3.264ms. If it's easy that your board calibrate bad data, choose 'n'. Two cases for example, you should choose 'n': diff --git a/components/esp8266/source/phy.h b/components/esp8266/source/phy.h index 32c5376d..b3cd5fd1 100644 --- a/components/esp8266/source/phy.h +++ b/components/esp8266/source/phy.h @@ -26,6 +26,8 @@ uint8_t phy_check_data_table(uint32_t *table, uint8_t, uint8_t); void phy_afterwake_set_rfoption(uint8_t); +void phy_set_powerup_option(uint8_t); + void write_data_to_rtc(uint8_t *); void get_data_from_rtc(uint8_t *); diff --git a/components/esp8266/source/phy_init.c b/components/esp8266/source/phy_init.c index 3f981412..3dedf5d8 100644 --- a/components/esp8266/source/phy_init.c +++ b/components/esp8266/source/phy_init.c @@ -76,6 +76,7 @@ esp_err_t esp_phy_rf_init(const esp_phy_init_data_t* init_data, esp_phy_calibrat #endif memcpy(local_init_data, init_data->params, 128); + memcpy(local_init_data + 128, calibration_data->rf_cal_data, 128); extern uint32_t* phy_rx_gain_dc_table; phy_rx_gain_dc_table = calibration_data->rx_gain_dc_table; @@ -85,7 +86,10 @@ esp_err_t esp_phy_rf_init(const esp_phy_init_data_t* init_data, esp_phy_calibrat phy_afterwake_set_rfoption(1); if (!cal_data_check) { + phy_set_powerup_option(1); write_data_to_rtc(calibration_data->rf_cal_data); + } else { + phy_set_powerup_option(3); } esp_efuse_mac_get_default(sta_mac);