Allow phy to be initialized only if WiFi/BLE is used/enabled
fixes: https://github.com/espressif/arduino-esp32/issues/72
This commit is contained in:
parent
57c3650ea2
commit
8904f52c39
@ -18,6 +18,51 @@
|
||||
#include "freertos/task.h"
|
||||
#include "esp_attr.h"
|
||||
|
||||
#if !CONFIG_ESP32_PHY_AUTO_INIT
|
||||
#include "nvs_flash.h"
|
||||
#include "esp_phy_init.h"
|
||||
#include "rom/rtc.h"
|
||||
void arduino_phy_init()
|
||||
{
|
||||
static bool initialized = false;
|
||||
if(initialized){
|
||||
return;
|
||||
}
|
||||
nvs_flash_init();
|
||||
esp_phy_calibration_mode_t calibration_mode = PHY_RF_CAL_PARTIAL;
|
||||
if (rtc_get_reset_reason(0) == DEEPSLEEP_RESET) {
|
||||
calibration_mode = PHY_RF_CAL_NONE;
|
||||
}
|
||||
const esp_phy_init_data_t* init_data = esp_phy_get_init_data();
|
||||
if (init_data == NULL) {
|
||||
printf("failed to obtain PHY init data\n");
|
||||
abort();
|
||||
}
|
||||
esp_phy_calibration_data_t* cal_data =
|
||||
(esp_phy_calibration_data_t*) calloc(sizeof(esp_phy_calibration_data_t), 1);
|
||||
if (cal_data == NULL) {
|
||||
printf("failed to allocate memory for RF calibration data\n");
|
||||
abort();
|
||||
}
|
||||
esp_err_t err = esp_phy_load_cal_data_from_nvs(cal_data);
|
||||
if (err != ESP_OK) {
|
||||
printf("failed to load RF calibration data, falling back to full calibration\n");
|
||||
calibration_mode = PHY_RF_CAL_FULL;
|
||||
}
|
||||
|
||||
esp_phy_init(init_data, calibration_mode, cal_data);
|
||||
|
||||
if (calibration_mode != PHY_RF_CAL_NONE) {
|
||||
err = esp_phy_store_cal_data_to_nvs(cal_data);
|
||||
} else {
|
||||
err = ESP_OK;
|
||||
}
|
||||
esp_phy_release_init_data(init_data);
|
||||
free(cal_data); // PHY maintains a copy of calibration data, so we can free this
|
||||
initialized = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
uint32_t IRAM_ATTR micros()
|
||||
{
|
||||
uint32_t ccount;
|
||||
|
@ -65,6 +65,10 @@ uint32_t millis();
|
||||
void delay(uint32_t);
|
||||
void delayMicroseconds(uint32_t us);
|
||||
|
||||
#if !CONFIG_ESP32_PHY_AUTO_INIT
|
||||
void arduino_phy_init();
|
||||
#endif
|
||||
|
||||
#if !CONFIG_AUTOSTART_ARDUINO
|
||||
void initArduino();
|
||||
#endif
|
||||
|
@ -52,6 +52,9 @@ extern "C" {
|
||||
static bool _esp_wifi_initalized = false;
|
||||
extern void initWiFi()
|
||||
{
|
||||
#if !CONFIG_ESP32_PHY_AUTO_INIT
|
||||
arduino_phy_init();
|
||||
#endif
|
||||
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
||||
tcpip_adapter_init();
|
||||
esp_event_loop_init(&WiFiGenericClass::_eventCallback, NULL);
|
||||
|
@ -58,7 +58,7 @@
|
||||
#define CONFIG_PARTITION_TABLE_CUSTOM_FILENAME "partitions.csv"
|
||||
#define CONFIG_FREERTOS_ISR_STACKSIZE 1536
|
||||
#define CONFIG_OPTIMIZATION_LEVEL_DEBUG 1
|
||||
#define CONFIG_ESP32_PHY_AUTO_INIT 1
|
||||
#define CONFIG_ESP32_PHY_AUTO_INIT 0
|
||||
#define CONFIG_SYSTEM_EVENT_QUEUE_SIZE 32
|
||||
#define CONFIG_ESPTOOLPY_BAUD_921600B 1
|
||||
#define CONFIG_APP_OFFSET 0x10000
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user