From 33a616d6a0e9a87e1de3b00e939d2aff47ab1f28 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Tue, 26 Oct 2021 16:09:26 +0800 Subject: [PATCH] esp_phy: fix esp32c3 phy USB & RSSI issue --- components/esp_wifi/Kconfig | 8 ++++++++ components/esp_wifi/include/phy.h | 8 ++++++++ components/esp_wifi/lib | 2 +- components/esp_wifi/src/phy_init.c | 4 ++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/components/esp_wifi/Kconfig b/components/esp_wifi/Kconfig index 07c25a5b96..bc73ea8168 100644 --- a/components/esp_wifi/Kconfig +++ b/components/esp_wifi/Kconfig @@ -413,4 +413,12 @@ menu "PHY" by a small amount but increases RAM use by approximately 4 KB(Wi-Fi only), 2 KB(Bluetooth only) or 5.3 KB(Wi-Fi + Bluetooth). + config ESP_PHY_ENABLE_USB + bool "Enable USB when phy init" + depends on ESP_CONSOLE_USB_SERIAL_JTAG + default y + help + When using USB Serial/JTAG controller, PHY should enable USB, otherwise log will + not be displayed. But working with USB, the RF performance may be affected. + endmenu # PHY diff --git a/components/esp_wifi/include/phy.h b/components/esp_wifi/include/phy.h index c0eadbf2ba..14e1286db0 100644 --- a/components/esp_wifi/include/phy.h +++ b/components/esp_wifi/include/phy.h @@ -93,6 +93,14 @@ uint8_t phy_dig_reg_backup(bool backup_en, uint32_t *mem_addr); void phy_freq_mem_backup(bool backup_en, uint32_t *mem); #endif + +#if CONFIG_ESP_PHY_ENABLE_USB +/** + * @brief Enable or disable USB when phy init. + */ +void phy_bbpll_en_usb(bool en); +#endif + #ifdef __cplusplus } #endif diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index 3cc2b74980..52cb084bd5 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit 3cc2b74980f1768ef68dd85e5d9f6ecf94a594ba +Subproject commit 52cb084bd5469659934dde8a8733106fe75824ac diff --git a/components/esp_wifi/src/phy_init.c b/components/esp_wifi/src/phy_init.c index ab1f471350..9e1cf4aaf5 100644 --- a/components/esp_wifi/src/phy_init.c +++ b/components/esp_wifi/src/phy_init.c @@ -612,6 +612,10 @@ void esp_phy_load_cal_and_init(void) } #endif +#if CONFIG_ESP_PHY_ENABLE_USB + phy_bbpll_en_usb(true); +#endif + #ifdef CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE esp_phy_calibration_mode_t calibration_mode = PHY_RF_CAL_PARTIAL; uint8_t sta_mac[6];