ESP32 supports three RF calibration methods during RF initialization:
Partial calibration
Full calibration
No calibration
During RF initialization, the partial calibration method is used by default for RF calibration. It is done based on the full calibration data which is stored in the NVS. To use this method, please go to menuconfig
and enable CONFIG_ESP_PHY_CALIBRATION_AND_DATA_STORAGE.
Full calibration is triggered in the following conditions:
NVS does not exist.
The NVS partition to store calibration data has been erased.
Hardware MAC address has changed.
PHY library version has changed.
The RF calibration data loaded from the NVS partition is broken.
Full calibration takes 100 ms longer than the partial calibration method. If boot duration is not of critical importance to the application, the full calibration method is recommended. To switch to the full calibration method, go to menuconfig
and disable CONFIG_ESP_PHY_CALIBRATION_AND_DATA_STORAGE. If you use the default method of RF calibration, there are two ways to add the function of triggering full calibration as a last-resort remedy.
Erase the NVS partition if you do not mind all of the data stored in the NVS partition is erased. That is indeed the easiest way.
Call API esp_phy_erase_cal_data_in_nvs()
before initializing Wi-Fi and Bluetooth®/Bluetooth Low Energy based on some conditions (e.g., an option provided in some diagnostic mode). In this case, only the PHY namespace of the NVS partition is erased.
The no calibration method is only used when the device wakes up from Deep-sleep mode.
PHY Initialization DataïThe PHY initialization data is used for RF calibration. There are two ways to get the PHY initialization data.
One is to use the default initialization data which is located in the header file components/esp_phy/esp32/include/phy_init_data.h. It is embedded into the application binary after compiling and then stored into read-only memory (DROM). To use the default initialization data, please go to menuconfig
and disable CONFIG_ESP_PHY_INIT_DATA_IN_PARTITION.
An alternative is to store the initialization data in a PHY data partition. A PHY data partition is included in the default partition table. However, when using a custom partition table, please ensure that a PHY data partition (type: data
, subtype: phy
) is included in the custom partition table. Whether you are using a custom partition table or the default partition table, if initialization data is stored in a partition, it has to be flashed there, otherwise a runtime error occurs. If you want to use initialization data stored in a partition, go to menuconfig
and enable the option CONFIG_ESP_PHY_INIT_DATA_IN_PARTITION.
Get PHY init data.
If "Use a partition to store PHY init data" option is set in menuconfig, This function will load PHY init data from a partition. Otherwise, PHY init data will be compiled into the application itself, and this function will return a pointer to PHY init data located in read-only memory (DROM).
If "Use a partition to store PHY init data" option is enabled, this function may return NULL if the data loaded from flash is not valid.
Note
Call esp_phy_release_init_data to release the pointer obtained using this function after the call to esp_wifi_init.
pointer to PHY init data structure
Release PHY init data.
data -- pointer to PHY init data structure obtained from esp_phy_get_init_data function
Function called by esp_phy_load_cal_and_init to load PHY calibration data.
This is a convenience function which can be used to load PHY calibration data from NVS. Data can be stored to NVS using esp_phy_store_cal_data_to_nvs function.
If calibration data is not present in the NVS, or data is not valid (was obtained for a chip with a different MAC address, or obtained for a different version of software), this function will return an error.
out_cal_data -- pointer to calibration data structure to be filled with loaded data.
ESP_OK on success
Function called by esp_phy_load_cal_and_init to store PHY calibration data.
This is a convenience function which can be used to store PHY calibration data to the NVS. Calibration data is returned by esp_phy_load_cal_and_init function. Data saved using this function to the NVS can later be loaded using esp_phy_store_cal_data_to_nvs function.
cal_data -- pointer to calibration data which has to be saved.
ESP_OK on success
Erase PHY calibration data which is stored in the NVS.
This is a function which can be used to trigger full calibration as a last-resort remedy if partial calibration is used. It can be called in the application based on some conditions (e.g. an option provided in some diagnostic mode).
ESP_OK on success
others on fail. Please refer to NVS API return value error number.
Enable PHY and RF module.
PHY and RF module should be enabled in order to use WiFi or BT. Now PHY and RF enabling job is done automatically when start WiFi or BT. Users should not call this API in their application.
modem -- the modem to call the phy enable.
Disable PHY and RF module.
PHY module should be disabled in order to shutdown WiFi or BT. Now PHY and RF disabling job is done automatically when stop WiFi or BT. Users should not call this API in their application.
modem -- the modem to call the phy disable.
Enable BTBB module.
BTBB module should be enabled in order to use IEEE802154 or BT. Now BTBB enabling job is done automatically when start IEEE802154 or BT. Users should not call this API in their application.
Disable BTBB module.
Disable BTBB module, used by IEEE802154 or Bluetooth. Users should not call this API in their application.
Load calibration data from NVS and initialize PHY and RF module.
Initialize backup memory for Phy power up/down.
Deinitialize backup memory for Phy power up/down Set phy_init_flag if all modems deinit on ESP32C3.
Enable WiFi/BT common clock.
Disable WiFi/BT common clock.
Get the time stamp when PHY/RF was switched on.
return 0 if PHY/RF is never switched on. Otherwise return time in microsecond since boot when phy/rf was last switched on
Update the corresponding PHY init type according to the country code of Wi-Fi.
country -- country code
ESP_OK on success.
esp_err_t code describing the error on fail
Get PHY lib version.
PHY lib version.
Set PHY init parameters.
param -- is 1 means combo module
Wi-Fi RX enable.
enable -- True for enable wifi receiving mode as default, false for closing wifi receiving mode as default.
Power on Bluetooth Wi-Fi power domain.
Power off Bluetooth Wi-Fi power domain.
Structure holding PHY init parameters.
Public Members
opaque PHY initialization parameters
Opaque PHY calibration data.
Public Members
PHY version
The MAC address of the station
calibration data
PHY enable or disable modem.
Values:
PHY modem WIFI
PHY modem BT
PHY modem IEEE802154
Don't use it. Used by ESP_PHY_MODEM_COUNT_MAX
PHY calibration mode.
Values:
Do part of RF calibration. This should be used after power-on reset.
Don't do any RF calibration. This mode is only suggested to be used after deep sleep reset.
Do full RF calibration. Produces best results, but also consumes a lot of time and current. Suggested to be used once.
This header file can be included with:
#include "esp_phy_cert_test.h"
This header file is a part of the API provided by the esp_phy
component. To declare that your component depends on esp_phy
, add the following to your CMakeLists.txt:
Wifi power domain power on.
Wifi power domain power off.
Environment variable configuration.
conf -- Set to 1 to enter RF test mode.
RF initialization configuration.
TX Continuous mode.
contin_en -- Set to true for continuous packet sending, which can be used for certification testing; Set to false to cancel continuous mode, which is the default mode and can be used for WLAN tester.
HT40/HT20 mode selection.
en -- Set to false to enter 11n HT20 mode; Set to true to enter 11n HT40 mode;
Wi-Fi TX command.
chan -- channel setting, 1~14;
rate -- rate setting;
backoff -- Transmit power attenuation, unit is 0.25dB. For example, 4 means that the power is attenuated by 1dB;
length_byte -- TX packet length configuration, indicating PSDU Length, unit is byte;
packet_delay -- TX packet interval configuration, unit is us;
packet_num -- The number of packets sent, 0 means sending packets continuously, other values represent the number of packets to send.
Test start/stop command, used to stop transmitting or receiving state.
value -- Value should be set to 3 before TX/RX. Set value to 0 to end TX/RX state.
Wi-Fi RX command.
chan -- channel setting, 1~14;
rate -- rate setting;
Wi-Fi Carrier Wave(CW) TX command.
start -- enable CW, 1 means transmit, 0 means stop transmitting;
chan -- CW channel setting, 1~14;
backoff -- CW power attenuation parameter, unit is 0.25dB. 4 indicates the power is attenuated by 1dB.
BLE TX command.
txpwr -- Transmit power level. Tx power is about (level-8)*3 dBm, step is 3dB. Level 8 is around 0 dBm;
chan -- channel setting, range is 0~39, corresponding frequency = 2402+chan*2;
len -- Payload length setting, range is 0-255, unit is byte, 37 bytes is employed generally;
data_type -- Data type setting;
syncw -- Packet identification (need to be provided by the packet generator or instrument manufacturer), 0x71764129 is employed generally;
rate -- rate setting;
tx_num_in -- The number of packets sent, 0 means sending packets continuously, other values represent the number of packets to send.
BLE RX command.
chan -- channel selection, range is 0-39; Channels 0, 1, 2~10 correspond to 2404MHz, 2406MHz, 2408MHz~2424MHz respectively; Channels 11, 12, 13~36 correspond to 2428MHz, 2430MHz, 2432MHz~2478MHz respectively; Channel 37: 2402MHz, Channel 38: 2426MHz, Channel 39: 2480MHz;
syncw -- Packet identification (need to be provided by the packet generator or instrument manufacturer), 0x71764129 is employed generally;
rate -- rate setting;
BLE Carrier Wave(CW) TX command.
start -- enable CW, 1 means transmit, 0 means stop transmitting;
chan -- Single carrier transmission channel selection, range is 0~39, corresponding frequency freq = 2402+chan*2;
power -- CW power attenuation parameter, unit is 0.25dB. 4 indicates the power is attenuated by 1dB.
Get some RX information.
rx_result -- This struct for storing RX information;
Structure holding PHY RX result.
Public Members
The number of desired packets received
Average RSSI of desired packets
The number of total packets received
0 means no RX info; 1 means the latest Wi-Fi RX info; 2 means the latest BLE RX info.
Values:
Values:
Values:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4