mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-09 12:35:28 +00:00
when brownout reset occurs,set the phy TX Power to the lowest
This commit is contained in:
@@ -531,6 +531,18 @@ static esp_err_t store_cal_data_to_nvs_handle(nvs_handle handle,
|
||||
return err;
|
||||
}
|
||||
|
||||
#if CONFIG_REDUCE_PHY_TX_POWER
|
||||
static void esp_phy_reduce_tx_power(esp_phy_init_data_t* init_data)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
for(i = 0; i < PHY_TX_POWER_NUM; i++) {
|
||||
// LOWEST_PHY_TX_POWER is the lowest tx power
|
||||
init_data->params[PHY_TX_POWER_OFFSET+i] = PHY_TX_POWER_LOWEST;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void esp_phy_load_cal_and_init(phy_rf_module_t module)
|
||||
{
|
||||
esp_phy_calibration_data_t* cal_data =
|
||||
@@ -540,11 +552,30 @@ void esp_phy_load_cal_and_init(phy_rf_module_t module)
|
||||
abort();
|
||||
}
|
||||
|
||||
#if CONFIG_REDUCE_PHY_TX_POWER
|
||||
const esp_phy_init_data_t* phy_init_data = esp_phy_get_init_data();
|
||||
if (phy_init_data == NULL) {
|
||||
ESP_LOGE(TAG, "failed to obtain PHY init data");
|
||||
abort();
|
||||
}
|
||||
|
||||
esp_phy_init_data_t* init_data = (esp_phy_init_data_t*) malloc(sizeof(esp_phy_init_data_t));
|
||||
if (init_data == NULL) {
|
||||
ESP_LOGE(TAG, "failed to allocate memory for phy init data");
|
||||
abort();
|
||||
}
|
||||
|
||||
memcpy(init_data, phy_init_data, sizeof(esp_phy_init_data_t));
|
||||
if (esp_reset_reason() == ESP_RST_BROWNOUT) {
|
||||
esp_phy_reduce_tx_power(init_data);
|
||||
}
|
||||
#else
|
||||
const esp_phy_init_data_t* init_data = esp_phy_get_init_data();
|
||||
if (init_data == NULL) {
|
||||
ESP_LOGE(TAG, "failed to obtain PHY init data");
|
||||
abort();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE
|
||||
esp_phy_calibration_mode_t calibration_mode = PHY_RF_CAL_PARTIAL;
|
||||
@@ -571,7 +602,12 @@ void esp_phy_load_cal_and_init(phy_rf_module_t module)
|
||||
esp_phy_rf_init(init_data, PHY_RF_CAL_FULL, cal_data, module);
|
||||
#endif
|
||||
|
||||
#if CONFIG_REDUCE_PHY_TX_POWER
|
||||
esp_phy_release_init_data(phy_init_data);
|
||||
free(init_data);
|
||||
#else
|
||||
esp_phy_release_init_data(init_data);
|
||||
#endif
|
||||
|
||||
free(cal_data); // PHY maintains a copy of calibration data, so we can free this
|
||||
}
|
||||
|
Reference in New Issue
Block a user