Skip to content

Commit cc31281

Browse files
committed
feat(phy): add a config for pll track feature
1 parent 22ae972 commit cc31281

File tree

4 files changed

+35
-4
lines changed

4 files changed

+35
-4
lines changed

components/esp_phy/Kconfig

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,12 @@ menu "PHY"
166166
high interference, enable this option will sacrifice Wi-Fi OFDM receive performance.
167167
But to guarantee 11b receive performance serves as a bottom line in this case.
168168

169+
config ESP_PHY_PLL_TRACK_PERIOD_MS
170+
int "Set the period of the pll track"
171+
default 1000
172+
help
173+
Set the period of the pll track.
174+
169175
config ESP_PHY_PLL_TRACK_DEBUG
170176
bool "Enable pll track logging"
171177
default n
@@ -186,5 +192,20 @@ menu "PHY"
186192
When this option is disabled, more than 1.1Kbytes of IRAM memory will be saved,
187193
but PHY performance will be reduced. This config only affect esp32c2 now.
188194

195+
menuconfig ESP_PHY_DEBUG
196+
bool "Enable PHY Debug"
197+
default n
198+
help
199+
Enabling this option allows different kinds of phy debugging features.
200+
201+
config ESP_PHY_DISABLE_PLL_TRACK
202+
bool "Disable phy pll track(only for experimental)"
203+
depends on ESP_PHY_DEBUG
204+
default n
205+
help
206+
Disable pll track. This configuration option is used for experimental.
207+
PLL track helps the PHY module adapt to temperature changes, ensuring stable performance.
208+
When pll enabled, the ESP PHY module will periodically track and adjust PLL parameters.
209+
189210
endif
190211
endmenu # PHY

components/esp_phy/src/phy_common.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ static const char* TAG = "phy_comm";
2626

2727
static volatile uint16_t s_phy_modem_flag = 0;
2828

29+
#if !CONFIG_ESP_PHY_DISABLE_PLL_TRACK
2930
extern void phy_param_track_tot(bool en_wifi, bool en_ble_154);
3031
static esp_timer_handle_t phy_track_pll_timer;
3132
#if CONFIG_ESP_WIFI_ENABLED
@@ -34,8 +35,9 @@ static volatile int64_t s_wifi_prev_timestamp;
3435
#if CONFIG_IEEE802154_ENABLED || CONFIG_BT_ENABLED
3536
static volatile int64_t s_bt_154_prev_timestamp;
3637
#endif
37-
#define PHY_TRACK_PLL_PERIOD_IN_US 1000000
38+
#define PHY_TRACK_PLL_PERIOD_IN_US (CONFIG_ESP_PHY_PLL_TRACK_PERIOD_MS * 1000)
3839
static void phy_track_pll_internal(void);
40+
#endif
3941

4042
static esp_phy_ant_gpio_config_t s_phy_ant_gpio_config = { 0 };
4143
static esp_phy_ant_config_t s_phy_ant_config = { 0 };
@@ -47,6 +49,7 @@ bool phy_enabled_modem_contains(esp_phy_modem_t modem)
4749
}
4850
#endif
4951

52+
#if !CONFIG_ESP_PHY_DISABLE_PLL_TRACK
5053
void phy_track_pll(void)
5154
{
5255
// Light sleep scenario: enabling and disabling PHY frequently, the timer will not get triggered.
@@ -121,6 +124,7 @@ void phy_track_pll_deinit(void)
121124
ESP_ERROR_CHECK(esp_timer_stop(phy_track_pll_timer));
122125
ESP_ERROR_CHECK(esp_timer_delete(phy_track_pll_timer));
123126
}
127+
#endif
124128

125129
void phy_set_modem_flag(esp_phy_modem_t modem)
126130
{

components/esp_phy/src/phy_init.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ void esp_phy_enable(esp_phy_modem_t modem)
329329
#endif
330330

331331
// ESP32 will track pll in the wifi/BT modem interrupt handler.
332-
#if !CONFIG_IDF_TARGET_ESP32
332+
#if !CONFIG_IDF_TARGET_ESP32 && !CONFIG_ESP_PHY_DISABLE_PLL_TRACK
333333
phy_track_pll_init();
334334
#endif
335335

@@ -340,7 +340,7 @@ void esp_phy_enable(esp_phy_modem_t modem)
340340

341341
}
342342
phy_set_modem_flag(modem);
343-
#if !CONFIG_IDF_TARGET_ESP32
343+
#if !CONFIG_IDF_TARGET_ESP32 && !CONFIG_ESP_PHY_DISABLE_PLL_TRACK
344344
// Immediately track pll when phy enabled.
345345
phy_track_pll();
346346
#endif
@@ -360,7 +360,7 @@ void esp_phy_disable(esp_phy_modem_t modem)
360360
phy_clr_modem_flag(modem);
361361
if (phy_get_modem_flag() == 0) {
362362
// ESP32 will track pll in the wifi/BT modem interrupt handler.
363-
#if !CONFIG_IDF_TARGET_ESP32
363+
#if !CONFIG_IDF_TARGET_ESP32 && !CONFIG_ESP_PHY_DISABLE_PLL_TRACK
364364
phy_track_pll_deinit();
365365
#endif
366366
#if SOC_PM_MODEM_RETENTION_BY_BACKUPDMA

components/esp_phy/src/phy_init_esp32hxx.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,15 @@ void esp_phy_enable(esp_phy_modem_t modem)
113113
} else {
114114
phy_wakeup_init();
115115
}
116+
#if !CONFIG_ESP_PHY_DISABLE_PLL_TRACK
116117
phy_track_pll_init();
118+
#endif
117119
}
118120
phy_set_modem_flag(modem);
119121
// Immediately track pll when phy enabled.
122+
#if !CONFIG_ESP_PHY_DISABLE_PLL_TRACK
120123
phy_track_pll();
124+
#endif
121125
#if CONFIG_ESP_PHY_RECORD_USED_TIME
122126
phy_record_time(true, modem);
123127
#endif
@@ -133,7 +137,9 @@ void esp_phy_disable(esp_phy_modem_t modem)
133137
phy_clr_modem_flag(modem);
134138
if (phy_get_modem_flag() == 0) {
135139

140+
#if !CONFIG_ESP_PHY_DISABLE_PLL_TRACK
136141
phy_track_pll_deinit();
142+
#endif
137143
phy_close_rf();
138144
phy_xpd_tsens();
139145
#if SOC_MODEM_CLOCK_IS_INDEPENDENT

0 commit comments

Comments
 (0)