2021-09-29 22:53:26 -04:00
/*
2024-03-28 06:31:03 -04:00
* SPDX - FileCopyrightText : 2015 - 2024 Espressif Systems ( Shanghai ) CO LTD
2021-09-29 22:53:26 -04:00
*
* SPDX - License - Identifier : Apache - 2.0
*/
2016-11-15 05:36:18 -05:00
# pragma once
# include <stdint.h>
2017-02-17 02:29:11 -05:00
# include <stdbool.h>
2016-11-15 05:36:18 -05:00
# include "esp_err.h"
# ifdef __cplusplus
extern " C " {
# endif
2016-11-17 12:18:39 -05:00
/**
2022-05-11 03:52:09 -04:00
* @ file
* init parameters and API
2016-11-17 12:18:39 -05:00
*/
/**
* @ brief Structure holding PHY init parameters
*/
2016-11-15 05:36:18 -05:00
typedef struct {
2024-03-28 06:31:03 -04:00
# if CONFIG_IDF_TARGET_ESP32C5
uint8_t params [ 256 ] ; /*!< opaque PHY initialization parameters */
# else
uint8_t params [ 128 ] ; /*!< opaque PHY initialization parameters */
# endif
2016-11-15 05:36:18 -05:00
} esp_phy_init_data_t ;
2023-07-27 00:11:01 -04:00
/**
* @ brief PHY enable or disable modem
*/
typedef enum {
PHY_MODEM_WIFI = 1 , /*!< PHY modem WIFI */
PHY_MODEM_BT = 2 , /*!< PHY modem BT */
PHY_MODEM_IEEE802154 = 4 , /*!< PHY modem IEEE802154 */
} esp_phy_modem_t ;
2016-11-17 12:18:39 -05:00
/**
* @ brief Opaque PHY calibration data
*/
2016-11-15 05:36:18 -05:00
typedef struct {
2018-05-19 00:13:34 -04:00
uint8_t version [ 4 ] ; /*!< PHY version */
uint8_t mac [ 6 ] ; /*!< The MAC address of the station */
uint8_t opaque [ 1894 ] ; /*!< calibration data */
2016-11-15 05:36:18 -05:00
} esp_phy_calibration_data_t ;
2022-05-11 03:52:09 -04:00
/**
* @ brief PHY calibration mode
*
*/
2016-11-15 05:36:18 -05:00
typedef enum {
PHY_RF_CAL_PARTIAL = 0x00000000 , /*!< Do part of RF calibration. This should be used after power-on reset. */
PHY_RF_CAL_NONE = 0x00000001 , /*!< Don't do any RF calibration. This mode is only suggested to be used after deep sleep reset. */
PHY_RF_CAL_FULL = 0x00000002 /*!< Do full RF calibration. Produces best results, but also consumes a lot of time and current. Suggested to be used once. */
} esp_phy_calibration_mode_t ;
2021-06-15 23:39:08 -04:00
# if CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN
2019-10-15 23:22:50 -04:00
/**
* @ brief PHY init data type
*/
typedef enum {
ESP_PHY_INIT_DATA_TYPE_DEFAULT = 0 ,
ESP_PHY_INIT_DATA_TYPE_SRRC ,
ESP_PHY_INIT_DATA_TYPE_FCC ,
ESP_PHY_INIT_DATA_TYPE_CE ,
ESP_PHY_INIT_DATA_TYPE_NCC ,
ESP_PHY_INIT_DATA_TYPE_KCC ,
ESP_PHY_INIT_DATA_TYPE_MIC ,
ESP_PHY_INIT_DATA_TYPE_IC ,
ESP_PHY_INIT_DATA_TYPE_ACMA ,
ESP_PHY_INIT_DATA_TYPE_ANATEL ,
ESP_PHY_INIT_DATA_TYPE_ISED ,
ESP_PHY_INIT_DATA_TYPE_WPC ,
ESP_PHY_INIT_DATA_TYPE_OFCA ,
ESP_PHY_INIT_DATA_TYPE_IFETEL ,
ESP_PHY_INIT_DATA_TYPE_RCM ,
ESP_PHY_INIT_DATA_TYPE_NUMBER ,
} phy_init_data_type_t ;
# endif
2016-11-15 05:36:18 -05:00
/**
2016-11-17 12:18:39 -05:00
* @ brief 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 ) .
2016-11-15 05:36:18 -05:00
*
2016-11-17 12:18:39 -05:00
* 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 .
*
* @ return pointer to PHY init data structure
*/
2019-07-16 05:33:30 -04:00
const esp_phy_init_data_t * esp_phy_get_init_data ( void ) ;
2016-11-17 12:18:39 -05:00
/**
* @ brief Release PHY init data
* @ param data pointer to PHY init data structure obtained from
* esp_phy_get_init_data function
2016-11-15 05:36:18 -05:00
*/
2016-11-17 12:18:39 -05:00
void esp_phy_release_init_data ( const esp_phy_init_data_t * data ) ;
2016-11-15 05:36:18 -05:00
2016-11-17 12:18:39 -05:00
/**
2023-04-17 02:36:12 -04:00
* @ brief Function called by esp_phy_load_cal_and_init to load PHY calibration data
2016-11-17 12:18:39 -05:00
*
* 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 .
*
* @ param out_cal_data pointer to calibration data structure to be filled with
* loaded data .
* @ return ESP_OK on success
*/
esp_err_t esp_phy_load_cal_data_from_nvs ( esp_phy_calibration_data_t * out_cal_data ) ;
2016-11-15 05:36:18 -05:00
/**
2023-04-17 02:36:12 -04:00
* @ brief Function called by esp_phy_load_cal_and_init to store PHY calibration data
2016-11-17 12:18:39 -05:00
*
* This is a convenience function which can be used to store PHY calibration
2023-04-17 02:36:12 -04:00
* data to the NVS . Calibration data is returned by esp_phy_load_cal_and_init function .
2016-11-17 12:18:39 -05:00
* Data saved using this function to the NVS can later be loaded using
* esp_phy_store_cal_data_to_nvs function .
2016-11-15 05:36:18 -05:00
*
2016-11-17 12:18:39 -05:00
* @ param cal_data pointer to calibration data which has to be saved .
* @ return ESP_OK on success
2016-11-15 05:36:18 -05:00
*/
2016-11-17 12:18:39 -05:00
esp_err_t esp_phy_store_cal_data_to_nvs ( const esp_phy_calibration_data_t * cal_data ) ;
2016-11-15 05:36:18 -05:00
2018-11-29 03:07:28 -05:00
/**
* @ brief Erase PHY calibration data which is stored in the NVS
*
2020-11-10 02:40:01 -05:00
* 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
2018-11-29 03:07:28 -05:00
* ( e . g . an option provided in some diagnostic mode ) .
*
* @ return ESP_OK on success
* @ return others on fail . Please refer to NVS API return value error number .
*/
esp_err_t esp_phy_erase_cal_data_in_nvs ( void ) ;
2016-11-15 05:36:18 -05:00
/**
2020-05-22 05:15:28 -04:00
* @ brief Enable PHY and RF module
2016-11-17 12:18:39 -05:00
*
2020-05-22 05:15:28 -04:00
* 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
2017-02-16 06:05:07 -05:00
* call this API in their application .
2016-11-15 05:36:18 -05:00
*
2023-07-27 00:11:01 -04:00
* @ param modem the modem to call the phy enable .
2016-11-15 05:36:18 -05:00
*/
2023-07-27 00:11:01 -04:00
void esp_phy_enable ( esp_phy_modem_t modem ) ;
2016-11-15 05:36:18 -05:00
2017-02-16 06:05:07 -05:00
/**
2020-05-22 05:15:28 -04:00
* @ brief Disable PHY and RF module
2017-02-16 06:05:07 -05:00
*
2020-05-22 05:15:28 -04:00
* 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
2017-02-16 06:05:07 -05:00
* call this API in their application .
*
2023-07-27 00:11:01 -04:00
* @ param modem the modem to call the phy disable .
2017-02-16 06:05:07 -05:00
*/
2023-07-27 00:11:01 -04:00
void esp_phy_disable ( esp_phy_modem_t modem ) ;
2017-02-16 09:06:02 -05:00
2022-12-19 07:29:52 -05:00
/**
* @ brief 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 .
*
*/
void esp_btbb_enable ( void ) ;
2023-03-17 04:18:27 -04:00
/**
* @ brief Disable BTBB module
*
2024-03-28 06:31:03 -04:00
* Disable BTBB module , used by IEEE802154 or Bluetooth .
2023-03-17 04:18:27 -04:00
* Users should not call this API in their application .
*
*/
void esp_btbb_disable ( void ) ;
2017-02-16 09:06:02 -05:00
/**
* @ brief Load calibration data from NVS and initialize PHY and RF module
*/
2020-05-22 05:15:28 -04:00
void esp_phy_load_cal_and_init ( void ) ;
2017-11-09 21:54:50 -05:00
2022-06-16 08:27:59 -04:00
/**
* @ brief Initialize backup memory for Phy power up / down
*/
2022-11-24 07:18:27 -05:00
void esp_phy_modem_init ( void ) ;
2022-06-16 08:27:59 -04:00
/**
* @ brief Deinitialize backup memory for Phy power up / down
2022-11-24 07:18:27 -05:00
* Set phy_init_flag if all modems deinit on ESP32C3
2022-06-16 08:27:59 -04:00
*/
2022-11-24 07:18:27 -05:00
void esp_phy_modem_deinit ( void ) ;
2022-06-16 08:27:59 -04:00
2021-01-10 03:16:28 -05:00
# if CONFIG_MAC_BB_PD
/**
* @ brief Initialize backup memory for MAC and Baseband power up / down
*/
void esp_mac_bb_pd_mem_init ( void ) ;
2022-05-28 12:13:32 -04:00
/**
* @ brief Deinitialize backup memory for MAC and Baseband power up / down
*/
void esp_mac_bb_pd_mem_deinit ( void ) ;
2021-01-10 03:16:28 -05:00
/**
* @ brief Power up MAC and Baseband
*/
void esp_mac_bb_power_up ( void ) ;
/**
* @ brief Power down MAC and Baseband
*/
void esp_mac_bb_power_down ( void ) ;
# endif
2019-08-20 03:47:42 -04:00
/**
* @ brief Enable WiFi / BT common clock
*
*/
void esp_phy_common_clock_enable ( void ) ;
/**
* @ brief Disable WiFi / BT common clock
*
*/
void esp_phy_common_clock_disable ( void ) ;
2018-12-11 03:49:01 -05:00
/**
* @ brief Get the time stamp when PHY / RF was switched on
* @ return return 0 if PHY / RF is never switched on . Otherwise return time in
* microsecond since boot when phy / rf was last switched on
*/
int64_t esp_phy_rf_get_on_ts ( void ) ;
2019-10-15 23:22:50 -04:00
/**
* @ brief Update the corresponding PHY init type according to the country code of Wi - Fi .
2022-05-11 03:52:09 -04:00
*
* @ param country country code
* @ return ESP_OK on success .
* @ return esp_err_t code describing the error on fail
2019-10-15 23:22:50 -04:00
*/
esp_err_t esp_phy_update_country_info ( const char * country ) ;
2021-01-28 09:28:04 -05:00
2021-06-15 23:39:08 -04:00
# if CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN
2020-11-10 02:40:01 -05:00
/**
2019-10-15 23:22:50 -04:00
* @ brief Apply PHY init bin to PHY
* @ return ESP_OK on success .
* @ return ESP_FAIL on fail .
*/
esp_err_t esp_phy_apply_phy_init_data ( uint8_t * init_data ) ;
# endif
2020-11-13 03:11:11 -05:00
/**
* @ brief Get PHY lib version
* @ return PHY lib version .
*/
char * get_phy_version_str ( void ) ;
2023-08-03 23:07:57 -04:00
/**
* @ brief Set PHY init parameters
* @ param param is 1 means combo module
*/
void phy_init_param_set ( uint8_t param ) ;
/**
* @ brief Wi - Fi RX enable
2023-09-07 03:30:48 -04:00
* @ param enable True for enable wifi receiving mode as default , false for closing wifi receiving mode as default .
2023-08-03 23:07:57 -04:00
*/
void phy_wifi_enable_set ( uint8_t enable ) ;
2016-11-15 05:36:18 -05:00
# ifdef __cplusplus
}
# endif