forked from espressif/arduino-esp32
Major IDF and Arduino Update
WiFi and BlueTooth can now be started and stopped at will. basic functions added to esp32-hal to start and stop the BT radio SimpleBLE class added to show the most basic functionality Example to show how to switch between BT, WiFi or Both
This commit is contained in:
@ -19,49 +19,6 @@
|
||||
#include "esp_attr.h"
|
||||
#include "nvs_flash.h"
|
||||
|
||||
#if !CONFIG_ESP32_PHY_AUTO_INIT
|
||||
#include "esp_phy_init.h"
|
||||
#include "rom/rtc.h"
|
||||
void arduino_phy_init()
|
||||
{
|
||||
static bool initialized = false;
|
||||
if(initialized){
|
||||
return;
|
||||
}
|
||||
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
|
||||
|
||||
void yield()
|
||||
{
|
||||
vPortYield();
|
||||
@ -106,18 +63,10 @@ void initVariant() {}
|
||||
void init() __attribute__((weak));
|
||||
void init() {}
|
||||
|
||||
void initWiFi() __attribute__((weak));
|
||||
void initWiFi() {}
|
||||
|
||||
void initBT() __attribute__((weak));
|
||||
void initBT() {}
|
||||
|
||||
void initArduino(){
|
||||
nvs_flash_init();
|
||||
init();
|
||||
initVariant();
|
||||
initWiFi();
|
||||
initBT();
|
||||
}
|
||||
|
||||
//used by hal log
|
||||
|
Reference in New Issue
Block a user