mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-02 20:24:32 +02:00
Merge branch 'bugfix/fix_some_wifi_bugs_230713_v5.1' into 'release/v5.1'
Wifi: Backport some wifi bugs 230713 to v5.1(Backport v5.1) See merge request espressif/esp-idf!24753
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "esp_err.h"
|
#include "esp_err.h"
|
||||||
|
#include "hal/gpio_types.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -28,6 +29,7 @@ typedef enum {
|
|||||||
EXTERN_COEX_WIRE_1 = 0,
|
EXTERN_COEX_WIRE_1 = 0,
|
||||||
EXTERN_COEX_WIRE_2,
|
EXTERN_COEX_WIRE_2,
|
||||||
EXTERN_COEX_WIRE_3,
|
EXTERN_COEX_WIRE_3,
|
||||||
|
EXTERN_COEX_WIRE_4,
|
||||||
EXTERN_COEX_WIRE_NUM,
|
EXTERN_COEX_WIRE_NUM,
|
||||||
} external_coex_wire_t;
|
} external_coex_wire_t;
|
||||||
|
|
||||||
@@ -45,12 +47,25 @@ typedef enum {
|
|||||||
* @brief external coex gpio pti
|
* @brief external coex gpio pti
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t in_pin0;
|
union {
|
||||||
uint32_t in_pin1;
|
uint32_t in_pin0 __attribute__((deprecated("Use 'request' instead")));
|
||||||
uint32_t out_pin0;
|
gpio_num_t request; /**< request gpio signal from slave to master */
|
||||||
uint32_t out_pin1;
|
};
|
||||||
|
union {
|
||||||
|
uint32_t in_pin1 __attribute__((deprecated("Use 'priority' instead")));
|
||||||
|
gpio_num_t priority; /**< request gpio signal priority from slave to master */
|
||||||
|
};
|
||||||
|
union {
|
||||||
|
uint32_t out_pin0 __attribute__((deprecated("Use 'grant' instead")));
|
||||||
|
gpio_num_t grant; /**< grant gpio signal from master to slave */
|
||||||
|
};
|
||||||
|
union {
|
||||||
|
uint32_t out_pin1 __attribute__((deprecated("Use 'tx_line' instead")));
|
||||||
|
gpio_num_t tx_line; /**< tx_line gpio signal from master to slave, indicates whether the master's WiFi is transmitting or not*/
|
||||||
|
};
|
||||||
} esp_external_coex_gpio_set_t;
|
} esp_external_coex_gpio_set_t;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief external coex pti level
|
* @brief external coex pti level
|
||||||
*/
|
*/
|
||||||
@@ -60,14 +75,6 @@ typedef enum {
|
|||||||
EXTERN_COEX_PTI_NUM,
|
EXTERN_COEX_PTI_NUM,
|
||||||
} esp_coex_pti_level_t;
|
} esp_coex_pti_level_t;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief external coex follower pti
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
uint32_t pti_val1;
|
|
||||||
uint32_t pti_val2;
|
|
||||||
} esp_external_coex_follower_pti_t;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief external coex role
|
* @brief external coex role
|
||||||
*/
|
*/
|
||||||
@@ -77,18 +84,6 @@ typedef enum {
|
|||||||
EXTERNAL_COEX_UNKNOWN_ROLE,
|
EXTERNAL_COEX_UNKNOWN_ROLE,
|
||||||
} esp_extern_coex_work_mode_t;
|
} esp_extern_coex_work_mode_t;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief external coex wiretype & role composition
|
|
||||||
*/
|
|
||||||
typedef enum {
|
|
||||||
wire_3_leader_mode = 0,
|
|
||||||
wire_2_leader_mode,
|
|
||||||
wire_1_leader_mode,
|
|
||||||
wire_3_follower_mode,
|
|
||||||
wire_2_follower_mode,
|
|
||||||
wire_1_follower_mode,
|
|
||||||
} external_coex_classification;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief external coex advance setup
|
* @brief external coex advance setup
|
||||||
*/
|
*/
|
||||||
@@ -143,6 +138,13 @@ esp_err_t esp_coex_status_bit_set(esp_coex_status_type_t type, uint32_t status);
|
|||||||
esp_err_t esp_coex_status_bit_clear(esp_coex_status_type_t type, uint32_t status);
|
esp_err_t esp_coex_status_bit_clear(esp_coex_status_type_t type, uint32_t status);
|
||||||
|
|
||||||
#if CONFIG_EXTERNAL_COEX_ENABLE
|
#if CONFIG_EXTERNAL_COEX_ENABLE
|
||||||
|
/**
|
||||||
|
* @brief Configure work mode, the default work mode is leader role.
|
||||||
|
* @param work_mode : work mode.
|
||||||
|
* @return : ESP_OK - success, other - failed
|
||||||
|
*/
|
||||||
|
esp_err_t esp_external_coex_set_work_mode(esp_extern_coex_work_mode_t work_mode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Setup gpio pin and corresponding pti level, start external coex,
|
* @brief Setup gpio pin and corresponding pti level, start external coex,
|
||||||
* the default work mode is leader role, the default output grant validate pin is high,
|
* the default work mode is leader role, the default output grant validate pin is high,
|
||||||
@@ -165,21 +167,25 @@ esp_err_t esp_disable_extern_coex_gpio_pin();
|
|||||||
* @brief Configure leader work mode, gpio pin correspondly and finally enable external coex,
|
* @brief Configure leader work mode, gpio pin correspondly and finally enable external coex,
|
||||||
* demand not to call the legacy function of `esp_enable_extern_coex_gpio_pin` any more.
|
* demand not to call the legacy function of `esp_enable_extern_coex_gpio_pin` any more.
|
||||||
* @param wire_type : to select the whole external coex gpio number.
|
* @param wire_type : to select the whole external coex gpio number.
|
||||||
* @param gpio_pin : gpio pin number to select.
|
* @param request : request gpio pin number to select.
|
||||||
|
* @param priority : priority gpio pin number to select.
|
||||||
|
* @param grant : grant gpio pin number to select.
|
||||||
* @return : ESP_OK - success, other - failed
|
* @return : ESP_OK - success, other - failed
|
||||||
*/
|
*/
|
||||||
esp_err_t esp_external_coex_leader_role_set_gpio_pin(external_coex_wire_t wire_type, uint32_t in_pin0,
|
esp_err_t esp_external_coex_leader_role_set_gpio_pin(external_coex_wire_t wire_type, uint32_t request, uint32_t priority,
|
||||||
uint32_t in_pin1, uint32_t out_pin0);
|
uint32_t grant) __attribute__((deprecated("Please use esp_external_coex_set_work_mode and esp_enable_extern_coex_gpio_pin instead")));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Configure follower work mode, gpio pin correspondly and finally enable external coex,
|
* @brief Configure follower work mode, gpio pin correspondly and finally enable external coex,
|
||||||
* demand not to call the legacy function of `esp_enable_extern_coex_gpio_pin` any more.
|
* demand not to call the legacy function of `esp_enable_extern_coex_gpio_pin` any more.
|
||||||
* @param wire_type : to select the whole external coex gpio number.
|
* @param wire_type : to select the whole external coex gpio number.
|
||||||
* @param gpio_pin : gpio pin number to select.
|
* @param request : request gpio pin number to select.
|
||||||
|
* @param priority : priority gpio pin number to select.
|
||||||
|
* @param grant : grant gpio pin number to select.
|
||||||
* @return : ESP_OK - success, other - failed
|
* @return : ESP_OK - success, other - failed
|
||||||
*/
|
*/
|
||||||
esp_err_t esp_external_coex_follower_role_set_gpio_pin(external_coex_wire_t wire_type, uint32_t in_pin0,
|
esp_err_t esp_external_coex_follower_role_set_gpio_pin(external_coex_wire_t wire_type, uint32_t request, uint32_t priority,
|
||||||
uint32_t out_pin0, uint32_t out_pin1);
|
uint32_t grant) __attribute__((deprecated("Please use esp_external_coex_set_work_mode and esp_enable_extern_coex_gpio_pin instead")));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Configure output grant signal latency in delay microseconds only for leader role of external coex,
|
* @brief Configure output grant signal latency in delay microseconds only for leader role of external coex,
|
||||||
@@ -198,8 +204,8 @@ esp_err_t esp_external_coex_set_grant_delay(uint8_t delay_us);
|
|||||||
* @return : ESP_OK - success, other - failed
|
* @return : ESP_OK - success, other - failed
|
||||||
*/
|
*/
|
||||||
esp_err_t esp_external_coex_set_validate_high(bool is_high_valid);
|
esp_err_t esp_external_coex_set_validate_high(bool is_high_valid);
|
||||||
#endif
|
#endif /* SOC_EXTERNAL_COEX_ADVANCE */
|
||||||
#endif
|
#endif /* CONFIG_EXTERNAL_COEX_ENABLE */
|
||||||
|
|
||||||
#if CONFIG_ESP_COEX_SW_COEXIST_ENABLE && CONFIG_SOC_IEEE802154_SUPPORTED
|
#if CONFIG_ESP_COEX_SW_COEXIST_ENABLE && CONFIG_SOC_IEEE802154_SUPPORTED
|
||||||
/**
|
/**
|
||||||
|
@@ -306,26 +306,15 @@ esp_err_t esp_coex_adapter_register(coex_adapter_funcs_t *funcs);
|
|||||||
|
|
||||||
#if CONFIG_EXTERNAL_COEX_ENABLE
|
#if CONFIG_EXTERNAL_COEX_ENABLE
|
||||||
/**
|
/**
|
||||||
* @brief Force RX Anttena only in external coex situation.
|
* @brief Set external coexistence advanced informations, like working mode.
|
||||||
*/
|
|
||||||
extern void phy_coex_force_rx_ant(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Dismiss RX Anttena only in external coex situation.
|
|
||||||
*/
|
|
||||||
extern void phy_coex_dismiss_rx_ant(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set external coexistence advanced informations, like working mode and grant mode in which level.
|
|
||||||
*
|
*
|
||||||
* @param outpti1 Only for slave mode, external coex output priority in level1.
|
* @param out_pti1 This parameter no longer works, will be deprecated and later removed in future releases.
|
||||||
* @param output2 Only for slave mode, external coex output priority in level2.
|
* @param out_pti2 This parameter no longer works, will be deprecated and later removed in future releases.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
* - ESP_OK: succeed
|
* - ESP_OK: succeed
|
||||||
*/
|
*/
|
||||||
esp_err_t esp_coex_external_params(esp_external_coex_advance_t coex_info,
|
esp_err_t esp_coex_external_params(esp_external_coex_advance_t coex_info, uint32_t out_pti1, uint32_t out_pti2);
|
||||||
uint32_t out_pti1, uint32_t out_pti2);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set external coexistence pti level and enable it.
|
* @brief Set external coexistence pti level and enable it.
|
||||||
@@ -347,6 +336,18 @@ esp_err_t esp_coex_external_set(esp_coex_pti_level_t level1,
|
|||||||
* - ESP_OK: succeed
|
* - ESP_OK: succeed
|
||||||
*/
|
*/
|
||||||
void esp_coex_external_stop(void);
|
void esp_coex_external_stop(void);
|
||||||
|
|
||||||
|
#if SOC_EXTERNAL_COEX_LEADER_TX_LINE
|
||||||
|
/**
|
||||||
|
* @brief Enable external coexist tx line
|
||||||
|
*
|
||||||
|
* @param en Enable external coex tx line
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - ESP_OK: succeed
|
||||||
|
*/
|
||||||
|
void esp_coex_external_set_txline(bool en);
|
||||||
|
#endif /*SOC_EXTERNAL_COEX_LEADER_TX_LINE*/
|
||||||
#endif /*External Coex*/
|
#endif /*External Coex*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Submodule components/esp_coex/lib updated: 08e1c246c7...37698e17a4
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2018-2021 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2018-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -15,6 +15,22 @@
|
|||||||
#include "hal/gpio_types.h"
|
#include "hal/gpio_types.h"
|
||||||
#include "soc/gpio_periph.h"
|
#include "soc/gpio_periph.h"
|
||||||
#include "soc/gpio_struct.h"
|
#include "soc/gpio_struct.h"
|
||||||
|
#include "esp_attr.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if SOC_EXTERNAL_COEX_ADVANCE
|
||||||
|
#define EXTERNAL_COEX_SIGNAL_I0_IDX EXTERN_ACTIVE_I_IDX
|
||||||
|
#define EXTERNAL_COEX_SIGNAL_I1_IDX EXTERN_PRIORITY_I_IDX
|
||||||
|
#define EXTERNAL_COEX_SIGNAL_O0_IDX EXTERN_ACTIVE_O_IDX
|
||||||
|
#define EXTERNAL_COEX_SIGNAL_O1_IDX EXTERN_PRIORITY_O_IDX
|
||||||
|
#else
|
||||||
|
#define EXTERNAL_COEX_SIGNAL_I0_IDX GPIO_BT_ACTIVE_IDX
|
||||||
|
#define EXTERNAL_COEX_SIGNAL_I1_IDX GPIO_BT_PRIORITY_IDX
|
||||||
|
#define EXTERNAL_COEX_SIGNAL_O0_IDX GPIO_WLAN_ACTIVE_IDX
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if SOC_EXTERNAL_COEX_LEADER_TX_LINE
|
||||||
|
#define EXTERNAL_COEX_SIGNAL_O1_TXLINE_IDX BB_DIAG9_IDX
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char *esp_coex_version_get(void)
|
const char *esp_coex_version_get(void)
|
||||||
@@ -29,352 +45,166 @@ esp_err_t esp_coex_preference_set(esp_coex_prefer_t prefer)
|
|||||||
|
|
||||||
#if CONFIG_EXTERNAL_COEX_ENABLE
|
#if CONFIG_EXTERNAL_COEX_ENABLE
|
||||||
#define GPIO_PIN_REG(a) (GPIO_PIN0_REG + a * 0x04)
|
#define GPIO_PIN_REG(a) (GPIO_PIN0_REG + a * 0x04)
|
||||||
|
|
||||||
#if SOC_EXTERNAL_COEX_ADVANCE
|
|
||||||
static const char *TAG = "external_coex";
|
static const char *TAG = "external_coex";
|
||||||
|
|
||||||
external_coex_classification s_external_coex_partner[EXTERNAL_COEX_UNKNOWN_ROLE][EXTERN_COEX_WIRE_NUM] = {
|
|
||||||
{ wire_1_leader_mode, wire_2_leader_mode, wire_3_leader_mode },
|
|
||||||
{},
|
|
||||||
{ wire_1_follower_mode, wire_2_follower_mode, wire_3_follower_mode },
|
|
||||||
};
|
|
||||||
|
|
||||||
static esp_external_coex_advance_t g_external_coex_params = { EXTERNAL_COEX_LEADER_ROLE, 0, true };
|
static esp_external_coex_advance_t g_external_coex_params = { EXTERNAL_COEX_LEADER_ROLE, 0, true };
|
||||||
esp_external_coex_follower_pti_t g_external_coex_follower_pti_val = { 0, 0 };
|
|
||||||
|
|
||||||
esp_err_t esp_external_coex_set_work_mode(esp_extern_coex_work_mode_t work_mode)
|
esp_err_t esp_external_coex_set_work_mode(esp_extern_coex_work_mode_t work_mode)
|
||||||
{
|
{
|
||||||
|
#if !SOC_EXTERNAL_COEX_ADVANCE
|
||||||
|
if(work_mode != EXTERNAL_COEX_LEADER_ROLE)
|
||||||
|
{
|
||||||
|
return ESP_ERR_INVALID_ARG;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
g_external_coex_params.work_mode = work_mode;
|
g_external_coex_params.work_mode = work_mode;
|
||||||
|
return ESP_OK;
|
||||||
if(EXTERNAL_COEX_FOLLOWER_ROLE == work_mode) {
|
|
||||||
g_external_coex_follower_pti_val.pti_val1 = 8;
|
|
||||||
g_external_coex_follower_pti_val.pti_val2 = 13;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool is_legal_external_coex_gpio(external_coex_wire_t wire_type, esp_external_coex_gpio_set_t gpio_pin)
|
||||||
|
{
|
||||||
|
switch (wire_type)
|
||||||
|
{
|
||||||
|
case EXTERN_COEX_WIRE_4:
|
||||||
|
{
|
||||||
|
if(!GPIO_IS_VALID_GPIO(gpio_pin.tx_line)
|
||||||
|
|| gpio_pin.tx_line == gpio_pin.priority || gpio_pin.tx_line == gpio_pin.grant || gpio_pin.tx_line == gpio_pin.request) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
__attribute__((fallthrough));
|
||||||
|
case EXTERN_COEX_WIRE_3:
|
||||||
|
{
|
||||||
|
if(!GPIO_IS_VALID_GPIO(gpio_pin.priority) || gpio_pin.priority == gpio_pin.grant || gpio_pin.priority == gpio_pin.request) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
__attribute__((fallthrough));
|
||||||
|
case EXTERN_COEX_WIRE_2:
|
||||||
|
{
|
||||||
|
if(!GPIO_IS_VALID_GPIO(gpio_pin.grant) || gpio_pin.grant == gpio_pin.request) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
__attribute__((fallthrough));
|
||||||
|
case EXTERN_COEX_WIRE_1:
|
||||||
|
{
|
||||||
|
if(!GPIO_IS_VALID_GPIO(gpio_pin.request)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if SOC_EXTERNAL_COEX_ADVANCE
|
||||||
|
esp_err_t esp_external_coex_set_gpio_pin(esp_external_coex_gpio_set_t *gpio_pin, external_coex_wire_t wire_type, uint32_t request, uint32_t priority, uint32_t grant)
|
||||||
|
{
|
||||||
|
switch (wire_type) {
|
||||||
|
case EXTERN_COEX_WIRE_3:
|
||||||
|
gpio_pin->priority = priority;
|
||||||
|
__attribute__((fallthrough));
|
||||||
|
case EXTERN_COEX_WIRE_2:
|
||||||
|
gpio_pin->grant = grant;
|
||||||
|
__attribute__((fallthrough));
|
||||||
|
case EXTERN_COEX_WIRE_1:
|
||||||
|
{
|
||||||
|
gpio_pin->request = request;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
gpio_pin->request = request;
|
||||||
|
gpio_pin->priority = priority;
|
||||||
|
gpio_pin->grant = grant;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t esp_external_coex_set_grant_delay(uint8_t delay_us)
|
esp_err_t esp_external_coex_set_grant_delay(uint8_t delay_us)
|
||||||
{
|
{
|
||||||
g_external_coex_params.delay_us = delay_us;
|
g_external_coex_params.delay_us = delay_us;
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t esp_external_coex_set_validate_high(bool is_high_valid)
|
esp_err_t esp_external_coex_set_validate_high(bool is_high_valid)
|
||||||
{
|
{
|
||||||
g_external_coex_params.is_high_valid = is_high_valid;
|
g_external_coex_params.is_high_valid = is_high_valid;
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_legal_external_coex_gpio(external_coex_wire_t wire_type, esp_external_coex_gpio_set_t gpio_pin)
|
esp_err_t esp_external_coex_leader_role_set_gpio_pin(external_coex_wire_t wire_type, uint32_t request, uint32_t priority, uint32_t grant)
|
||||||
{
|
|
||||||
external_coex_classification external_coex_configure = s_external_coex_partner[g_external_coex_params.work_mode][wire_type];
|
|
||||||
|
|
||||||
switch (external_coex_configure)
|
|
||||||
{
|
|
||||||
case wire_3_leader_mode:
|
|
||||||
{
|
|
||||||
if(gpio_pin.in_pin0 == gpio_pin.in_pin1) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(gpio_pin.in_pin0 == gpio_pin.out_pin0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(gpio_pin.in_pin1 == gpio_pin.out_pin0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(gpio_pin.in_pin0 >= SOC_GPIO_PIN_COUNT) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(gpio_pin.in_pin1 >= SOC_GPIO_PIN_COUNT) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(gpio_pin.out_pin0 >= SOC_GPIO_PIN_COUNT) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case wire_3_follower_mode:
|
|
||||||
{
|
|
||||||
if(gpio_pin.in_pin0 == gpio_pin.out_pin0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(gpio_pin.in_pin0 == gpio_pin.out_pin1) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(gpio_pin.out_pin0 == gpio_pin.out_pin1) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(gpio_pin.in_pin0 >= SOC_GPIO_PIN_COUNT) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(gpio_pin.out_pin1 >= SOC_GPIO_PIN_COUNT) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(gpio_pin.out_pin0 >= SOC_GPIO_PIN_COUNT) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case wire_2_leader_mode:
|
|
||||||
case wire_2_follower_mode:
|
|
||||||
{
|
|
||||||
if(gpio_pin.in_pin0 == gpio_pin.out_pin0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(gpio_pin.in_pin0 >= SOC_GPIO_PIN_COUNT) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(gpio_pin.out_pin0 >= SOC_GPIO_PIN_COUNT) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case wire_1_leader_mode:
|
|
||||||
{
|
|
||||||
if(gpio_pin.in_pin0 >= SOC_GPIO_PIN_COUNT) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case wire_1_follower_mode:
|
|
||||||
{
|
|
||||||
if(gpio_pin.out_pin0 >= SOC_GPIO_PIN_COUNT) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_err_t esp_external_coex_leader_role_set_gpio_pin(external_coex_wire_t wire_type, uint32_t in_pin0, uint32_t in_pin1, uint32_t out_pin0)
|
|
||||||
{
|
{
|
||||||
esp_external_coex_set_work_mode(EXTERNAL_COEX_LEADER_ROLE);
|
esp_external_coex_set_work_mode(EXTERNAL_COEX_LEADER_ROLE);
|
||||||
esp_external_coex_gpio_set_t gpio_pin;
|
esp_external_coex_gpio_set_t gpio_pin;
|
||||||
|
esp_external_coex_set_gpio_pin(&gpio_pin, wire_type, request, priority, grant);
|
||||||
switch (wire_type) {
|
|
||||||
case EXTERN_COEX_WIRE_3:
|
|
||||||
{
|
|
||||||
gpio_pin.in_pin0 = in_pin0;
|
|
||||||
gpio_pin.in_pin1 = in_pin1;
|
|
||||||
gpio_pin.out_pin0 = out_pin0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case EXTERN_COEX_WIRE_2:
|
|
||||||
{
|
|
||||||
gpio_pin.in_pin0 = in_pin0;
|
|
||||||
gpio_pin.out_pin0 = out_pin0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case EXTERN_COEX_WIRE_1:
|
|
||||||
{
|
|
||||||
gpio_pin.in_pin0 = in_pin0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
gpio_pin.in_pin0 = in_pin0;
|
|
||||||
gpio_pin.in_pin1 = in_pin1;
|
|
||||||
gpio_pin.out_pin0 = out_pin0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return esp_enable_extern_coex_gpio_pin(wire_type, gpio_pin);
|
return esp_enable_extern_coex_gpio_pin(wire_type, gpio_pin);
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t esp_external_coex_follower_role_set_gpio_pin(external_coex_wire_t wire_type, uint32_t in_pin0, uint32_t out_pin0, uint32_t out_pin1)
|
esp_err_t esp_external_coex_follower_role_set_gpio_pin(external_coex_wire_t wire_type, uint32_t request, uint32_t priority, uint32_t grant)
|
||||||
{
|
{
|
||||||
esp_external_coex_set_work_mode(EXTERNAL_COEX_FOLLOWER_ROLE);
|
esp_external_coex_set_work_mode(EXTERNAL_COEX_FOLLOWER_ROLE);
|
||||||
esp_external_coex_gpio_set_t gpio_pin;
|
esp_external_coex_gpio_set_t gpio_pin;
|
||||||
|
esp_external_coex_set_gpio_pin(&gpio_pin, wire_type, request, priority, grant);
|
||||||
switch (wire_type) {
|
|
||||||
case EXTERN_COEX_WIRE_3:
|
|
||||||
{
|
|
||||||
gpio_pin.in_pin0 = in_pin0;
|
|
||||||
gpio_pin.out_pin0 = out_pin0;
|
|
||||||
gpio_pin.out_pin1 = out_pin1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case EXTERN_COEX_WIRE_2:
|
|
||||||
{
|
|
||||||
gpio_pin.in_pin0 = in_pin0;
|
|
||||||
gpio_pin.out_pin0 = out_pin0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case EXTERN_COEX_WIRE_1:
|
|
||||||
{
|
|
||||||
gpio_pin.out_pin0 = out_pin0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
gpio_pin.in_pin0 = in_pin0;
|
|
||||||
gpio_pin.out_pin0 = out_pin0;
|
|
||||||
gpio_pin.out_pin1 = out_pin1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return esp_enable_extern_coex_gpio_pin(wire_type, gpio_pin);
|
return esp_enable_extern_coex_gpio_pin(wire_type, gpio_pin);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* SOC_EXTERNAL_COEX_ADVANCE */
|
||||||
|
|
||||||
esp_err_t esp_enable_extern_coex_gpio_pin(external_coex_wire_t wire_type, esp_external_coex_gpio_set_t gpio_pin)
|
esp_err_t esp_enable_extern_coex_gpio_pin(external_coex_wire_t wire_type, esp_external_coex_gpio_set_t gpio_pin)
|
||||||
{
|
{
|
||||||
#if SOC_EXTERNAL_COEX_ADVANCE
|
|
||||||
if(false == is_legal_external_coex_gpio(wire_type, gpio_pin))
|
if(false == is_legal_external_coex_gpio(wire_type, gpio_pin))
|
||||||
{
|
{
|
||||||
ESP_LOGE(TAG, "Configure external coex with unexpected gpio pin!!!\n");
|
ESP_LOGE(TAG, "Configure external coex with unexpected gpio pin!!!\n");
|
||||||
return ESP_ERR_INVALID_ARG;
|
return ESP_ERR_INVALID_ARG;
|
||||||
}
|
}
|
||||||
phy_coex_force_rx_ant();
|
|
||||||
|
|
||||||
esp_coex_external_params(g_external_coex_params, g_external_coex_follower_pti_val.pti_val1,
|
#if SOC_EXTERNAL_COEX_ADVANCE
|
||||||
g_external_coex_follower_pti_val.pti_val2);
|
esp_coex_external_params(g_external_coex_params, 0, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if(EXTERNAL_COEX_LEADER_ROLE == g_external_coex_params.work_mode) {
|
||||||
switch (wire_type)
|
switch (wire_type)
|
||||||
{
|
{
|
||||||
|
#if SOC_EXTERNAL_COEX_LEADER_TX_LINE
|
||||||
|
case EXTERN_COEX_WIRE_4:
|
||||||
|
{
|
||||||
|
esp_coex_external_set_txline(true);
|
||||||
|
gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[gpio_pin.tx_line], PIN_FUNC_GPIO);
|
||||||
|
gpio_set_direction(gpio_pin.tx_line, GPIO_MODE_OUTPUT);
|
||||||
|
REG_WRITE(GPIO_ENABLE_W1TC_REG, BIT(gpio_pin.tx_line));
|
||||||
|
esp_rom_gpio_connect_out_signal(gpio_pin.tx_line, EXTERNAL_COEX_SIGNAL_O1_TXLINE_IDX, false, false);
|
||||||
|
}
|
||||||
|
__attribute__((fallthrough));
|
||||||
|
#endif
|
||||||
case EXTERN_COEX_WIRE_3:
|
case EXTERN_COEX_WIRE_3:
|
||||||
{
|
{
|
||||||
#if SOC_EXTERNAL_COEX_ADVANCE
|
gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[gpio_pin.priority], PIN_FUNC_GPIO);
|
||||||
if(EXTERNAL_COEX_LEADER_ROLE == g_external_coex_params.work_mode) {
|
gpio_set_direction(gpio_pin.priority, GPIO_MODE_INPUT);
|
||||||
#endif
|
esp_rom_gpio_connect_in_signal(gpio_pin.priority, EXTERNAL_COEX_SIGNAL_I1_IDX, false);
|
||||||
/*Input gpio pin setup --> GPIO_BT_PRIORITY_IDX:GPIO_BT_ACTIVE_IDX*/
|
REG_SET_FIELD(GPIO_PIN_REG(gpio_pin.priority), GPIO_PIN1_SYNC1_BYPASS, 2);
|
||||||
gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[gpio_pin.in_pin0], PIN_FUNC_GPIO);
|
REG_SET_FIELD(GPIO_PIN_REG(gpio_pin.priority), GPIO_PIN1_SYNC2_BYPASS, 2);
|
||||||
gpio_set_direction(gpio_pin.in_pin0, GPIO_MODE_INPUT);
|
|
||||||
|
|
||||||
#if SOC_EXTERNAL_COEX_ADVANCE
|
|
||||||
esp_rom_gpio_connect_in_signal(gpio_pin.in_pin0, EXTERN_ACTIVE_I_IDX, false);
|
|
||||||
#else
|
|
||||||
esp_rom_gpio_connect_in_signal(gpio_pin.in_pin0, GPIO_BT_ACTIVE_IDX, false);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[gpio_pin.in_pin1], PIN_FUNC_GPIO);
|
|
||||||
gpio_set_direction(gpio_pin.in_pin1, GPIO_MODE_INPUT);
|
|
||||||
|
|
||||||
#if SOC_EXTERNAL_COEX_ADVANCE
|
|
||||||
esp_rom_gpio_connect_in_signal(gpio_pin.in_pin1, EXTERN_PRIORITY_I_IDX, false);
|
|
||||||
#else
|
|
||||||
esp_rom_gpio_connect_in_signal(gpio_pin.in_pin1, GPIO_BT_PRIORITY_IDX, false);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*Output gpio pin setup --> GPIO_WLAN_ACTIVE_IDX: 1 BT, 0 WiFi*/
|
|
||||||
gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[gpio_pin.out_pin0], PIN_FUNC_GPIO);
|
|
||||||
gpio_set_direction(gpio_pin.out_pin0, GPIO_MODE_OUTPUT);
|
|
||||||
REG_WRITE(GPIO_ENABLE_W1TC_REG, BIT(gpio_pin.out_pin0));
|
|
||||||
|
|
||||||
#if SOC_EXTERNAL_COEX_ADVANCE
|
|
||||||
esp_rom_gpio_connect_out_signal(gpio_pin.out_pin0, EXTERN_ACTIVE_O_IDX, false, false);
|
|
||||||
#else
|
|
||||||
esp_rom_gpio_connect_out_signal(gpio_pin.out_pin0, GPIO_WLAN_ACTIVE_IDX, false, false);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
REG_SET_FIELD(GPIO_PIN_REG(gpio_pin.in_pin0), GPIO_PIN1_SYNC1_BYPASS, 2);
|
|
||||||
REG_SET_FIELD(GPIO_PIN_REG(gpio_pin.in_pin0), GPIO_PIN1_SYNC2_BYPASS, 2);
|
|
||||||
REG_SET_FIELD(GPIO_PIN_REG(gpio_pin.in_pin1), GPIO_PIN1_SYNC1_BYPASS, 2);
|
|
||||||
REG_SET_FIELD(GPIO_PIN_REG(gpio_pin.in_pin1), GPIO_PIN1_SYNC2_BYPASS, 2);
|
|
||||||
#if SOC_EXTERNAL_COEX_ADVANCE
|
|
||||||
}
|
|
||||||
else if(EXTERNAL_COEX_FOLLOWER_ROLE == g_external_coex_params.work_mode) {
|
|
||||||
/*Input gpio pin setup --> GPIO_BT_PRIORITY_IDX:GPIO_BT_ACTIVE_IDX*/
|
|
||||||
gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[gpio_pin.in_pin0], PIN_FUNC_GPIO);
|
|
||||||
gpio_set_direction(gpio_pin.in_pin0, GPIO_MODE_INPUT);
|
|
||||||
|
|
||||||
esp_rom_gpio_connect_in_signal(gpio_pin.in_pin0, EXTERN_ACTIVE_I_IDX, false);
|
|
||||||
|
|
||||||
/*Output gpio pin setup --> GPIO_WLAN_ACTIVE_IDX: 1 BT, 0 WiFi*/
|
|
||||||
gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[gpio_pin.out_pin0], PIN_FUNC_GPIO);
|
|
||||||
gpio_set_direction(gpio_pin.out_pin0, GPIO_MODE_OUTPUT);
|
|
||||||
REG_WRITE(GPIO_ENABLE_W1TC_REG, BIT(gpio_pin.out_pin0));
|
|
||||||
esp_rom_gpio_connect_out_signal(gpio_pin.out_pin0, EXTERN_ACTIVE_O_IDX, false, false);
|
|
||||||
|
|
||||||
gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[gpio_pin.out_pin1], PIN_FUNC_GPIO);
|
|
||||||
gpio_set_direction(gpio_pin.out_pin1, GPIO_MODE_OUTPUT);
|
|
||||||
REG_WRITE(GPIO_ENABLE_W1TC_REG, BIT(gpio_pin.out_pin1));
|
|
||||||
esp_rom_gpio_connect_out_signal(gpio_pin.out_pin1, EXTERN_PRIORITY_O_IDX, false, false);
|
|
||||||
|
|
||||||
REG_SET_FIELD(GPIO_PIN_REG(gpio_pin.in_pin0), GPIO_PIN1_SYNC1_BYPASS, 2);
|
|
||||||
REG_SET_FIELD(GPIO_PIN_REG(gpio_pin.in_pin0), GPIO_PIN1_SYNC2_BYPASS, 2);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#endif
|
|
||||||
int ret = esp_coex_external_set(EXTERN_COEX_PTI_MID, EXTERN_COEX_PTI_MID, EXTERN_COEX_PTI_HIGH);
|
|
||||||
if (ESP_OK != ret) {
|
|
||||||
return ESP_FAIL;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
__attribute__((fallthrough));
|
||||||
case EXTERN_COEX_WIRE_2:
|
case EXTERN_COEX_WIRE_2:
|
||||||
{
|
{
|
||||||
/*Input gpio pin setup --> GPIO_BT_PRIORITY_IDX:GPIO_BT_ACTIVE_IDX*/
|
gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[gpio_pin.grant], PIN_FUNC_GPIO);
|
||||||
gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[gpio_pin.in_pin0], PIN_FUNC_GPIO);
|
gpio_set_direction(gpio_pin.grant, GPIO_MODE_OUTPUT);
|
||||||
gpio_set_direction(gpio_pin.in_pin0, GPIO_MODE_INPUT);
|
REG_WRITE(GPIO_ENABLE_W1TC_REG, BIT(gpio_pin.grant));
|
||||||
|
esp_rom_gpio_connect_out_signal(gpio_pin.grant, EXTERNAL_COEX_SIGNAL_O0_IDX, false, false);
|
||||||
#if SOC_EXTERNAL_COEX_ADVANCE
|
|
||||||
esp_rom_gpio_connect_in_signal(gpio_pin.in_pin0, EXTERN_ACTIVE_I_IDX, false);
|
|
||||||
#else
|
|
||||||
esp_rom_gpio_connect_in_signal(gpio_pin.in_pin0, GPIO_BT_ACTIVE_IDX, false);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*Output gpio pin setup --> GPIO_WLAN_ACTIVE_IDX: 1 BT, 0 WiFi*/
|
|
||||||
gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[gpio_pin.out_pin0], PIN_FUNC_GPIO);
|
|
||||||
gpio_set_direction(gpio_pin.out_pin0, GPIO_MODE_OUTPUT);
|
|
||||||
REG_WRITE(GPIO_ENABLE_W1TC_REG, BIT(gpio_pin.out_pin0));
|
|
||||||
|
|
||||||
#if SOC_EXTERNAL_COEX_ADVANCE
|
|
||||||
esp_rom_gpio_connect_out_signal(gpio_pin.out_pin0, EXTERN_ACTIVE_O_IDX, false, false);
|
|
||||||
#else
|
|
||||||
esp_rom_gpio_connect_out_signal(gpio_pin.out_pin0, GPIO_WLAN_ACTIVE_IDX, false, false);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
REG_SET_FIELD(GPIO_PIN_REG(gpio_pin.in_pin0), GPIO_PIN1_SYNC1_BYPASS, 2);
|
|
||||||
REG_SET_FIELD(GPIO_PIN_REG(gpio_pin.in_pin0), GPIO_PIN1_SYNC2_BYPASS, 2);
|
|
||||||
|
|
||||||
int ret = esp_coex_external_set(EXTERN_COEX_PTI_MID, EXTERN_COEX_PTI_MID, EXTERN_COEX_PTI_MID);
|
|
||||||
if (ESP_OK != ret) {
|
|
||||||
return ESP_FAIL;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
__attribute__((fallthrough));
|
||||||
case EXTERN_COEX_WIRE_1:
|
case EXTERN_COEX_WIRE_1:
|
||||||
{
|
{
|
||||||
#if SOC_EXTERNAL_COEX_ADVANCE
|
gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[gpio_pin.request], PIN_FUNC_GPIO);
|
||||||
if(EXTERNAL_COEX_LEADER_ROLE == g_external_coex_params.work_mode) {
|
gpio_set_direction(gpio_pin.request, GPIO_MODE_INPUT);
|
||||||
#endif
|
esp_rom_gpio_connect_in_signal(gpio_pin.request, EXTERNAL_COEX_SIGNAL_I0_IDX, false);
|
||||||
/*Input gpio pin setup --> GPIO_BT_PRIORITY_IDX:GPIO_BT_ACTIVE_IDX*/
|
REG_SET_FIELD(GPIO_PIN_REG(gpio_pin.request), GPIO_PIN1_SYNC1_BYPASS, 2);
|
||||||
gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[gpio_pin.in_pin0], PIN_FUNC_GPIO);
|
REG_SET_FIELD(GPIO_PIN_REG(gpio_pin.request), GPIO_PIN1_SYNC2_BYPASS, 2);
|
||||||
gpio_set_direction(gpio_pin.in_pin0, GPIO_MODE_INPUT);
|
|
||||||
|
|
||||||
#if SOC_EXTERNAL_COEX_ADVANCE
|
|
||||||
esp_rom_gpio_connect_in_signal(gpio_pin.in_pin0, EXTERN_ACTIVE_I_IDX, false);
|
|
||||||
#else
|
|
||||||
esp_rom_gpio_connect_in_signal(gpio_pin.in_pin0, GPIO_BT_ACTIVE_IDX, false);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
REG_SET_FIELD(GPIO_PIN_REG(gpio_pin.in_pin0), GPIO_PIN1_SYNC1_BYPASS, 2);
|
|
||||||
REG_SET_FIELD(GPIO_PIN_REG(gpio_pin.in_pin0), GPIO_PIN1_SYNC2_BYPASS, 2);
|
|
||||||
#if SOC_EXTERNAL_COEX_ADVANCE
|
|
||||||
}
|
|
||||||
else if(EXTERNAL_COEX_FOLLOWER_ROLE == g_external_coex_params.work_mode) {
|
|
||||||
/*Output gpio pin setup --> GPIO_WLAN_ACTIVE_IDX: 1 BT, 0 WiFi*/
|
|
||||||
gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[gpio_pin.out_pin0], PIN_FUNC_GPIO);
|
|
||||||
gpio_set_direction(gpio_pin.out_pin0, GPIO_MODE_OUTPUT);
|
|
||||||
REG_WRITE(GPIO_ENABLE_W1TC_REG, BIT(gpio_pin.out_pin0));
|
|
||||||
esp_rom_gpio_connect_out_signal(gpio_pin.out_pin0, EXTERN_ACTIVE_O_IDX, false, false);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int ret = esp_coex_external_set(EXTERN_COEX_PTI_HIGH, EXTERN_COEX_PTI_HIGH, EXTERN_COEX_PTI_HIGH);
|
|
||||||
if (ESP_OK != ret) {
|
|
||||||
return ESP_FAIL;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@@ -382,14 +212,62 @@ esp_err_t esp_enable_extern_coex_gpio_pin(external_coex_wire_t wire_type, esp_ex
|
|||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if(EXTERNAL_COEX_FOLLOWER_ROLE == g_external_coex_params.work_mode) {
|
||||||
|
#if SOC_EXTERNAL_COEX_ADVANCE
|
||||||
|
switch (wire_type)
|
||||||
|
{
|
||||||
|
case EXTERN_COEX_WIRE_4:
|
||||||
|
{
|
||||||
|
gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[gpio_pin.tx_line], PIN_FUNC_GPIO);
|
||||||
|
gpio_set_direction(gpio_pin.tx_line, GPIO_MODE_INPUT);
|
||||||
|
esp_rom_gpio_connect_in_signal(gpio_pin.tx_line, EXTERNAL_COEX_SIGNAL_I1_IDX, false);
|
||||||
|
REG_SET_FIELD(GPIO_PIN_REG(gpio_pin.tx_line), GPIO_PIN1_SYNC1_BYPASS, 2);
|
||||||
|
REG_SET_FIELD(GPIO_PIN_REG(gpio_pin.tx_line), GPIO_PIN1_SYNC2_BYPASS, 2);
|
||||||
|
}
|
||||||
|
__attribute__((fallthrough));
|
||||||
|
case EXTERN_COEX_WIRE_3:
|
||||||
|
{
|
||||||
|
gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[gpio_pin.priority], PIN_FUNC_GPIO);
|
||||||
|
gpio_set_direction(gpio_pin.priority, GPIO_MODE_OUTPUT);
|
||||||
|
REG_WRITE(GPIO_ENABLE_W1TC_REG, BIT(gpio_pin.priority));
|
||||||
|
esp_rom_gpio_connect_out_signal(gpio_pin.priority, EXTERNAL_COEX_SIGNAL_O1_IDX, false, false);
|
||||||
|
}
|
||||||
|
__attribute__((fallthrough));
|
||||||
|
case EXTERN_COEX_WIRE_2:
|
||||||
|
{
|
||||||
|
gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[gpio_pin.grant], PIN_FUNC_GPIO);
|
||||||
|
gpio_set_direction(gpio_pin.grant, GPIO_MODE_INPUT);
|
||||||
|
esp_rom_gpio_connect_in_signal(gpio_pin.grant, EXTERNAL_COEX_SIGNAL_I0_IDX, false);
|
||||||
|
REG_SET_FIELD(GPIO_PIN_REG(gpio_pin.grant), GPIO_PIN1_SYNC1_BYPASS, 2);
|
||||||
|
REG_SET_FIELD(GPIO_PIN_REG(gpio_pin.grant), GPIO_PIN1_SYNC2_BYPASS, 2);
|
||||||
|
}
|
||||||
|
__attribute__((fallthrough));
|
||||||
|
case EXTERN_COEX_WIRE_1:
|
||||||
|
{
|
||||||
|
gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[gpio_pin.request], PIN_FUNC_GPIO);
|
||||||
|
gpio_set_direction(gpio_pin.request, GPIO_MODE_OUTPUT);
|
||||||
|
REG_WRITE(GPIO_ENABLE_W1TC_REG, BIT(gpio_pin.request));
|
||||||
|
esp_rom_gpio_connect_out_signal(gpio_pin.request, EXTERNAL_COEX_SIGNAL_O0_IDX, false, false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return ESP_FAIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
return ESP_ERR_INVALID_ARG;
|
||||||
|
#endif /* SOC_EXTERNAL_COEX_ADVANCE */
|
||||||
|
}
|
||||||
|
esp_err_t ret = esp_coex_external_set(EXTERN_COEX_PTI_MID, EXTERN_COEX_PTI_MID, EXTERN_COEX_PTI_HIGH);
|
||||||
|
if (ESP_OK != ret) {
|
||||||
|
return ESP_FAIL;
|
||||||
|
}
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t esp_disable_extern_coex_gpio_pin()
|
esp_err_t esp_disable_extern_coex_gpio_pin()
|
||||||
{
|
{
|
||||||
#if SOC_EXTERNAL_COEX_ADVANCE
|
|
||||||
phy_coex_dismiss_rx_ant();
|
|
||||||
#endif
|
|
||||||
esp_coex_external_stop();
|
esp_coex_external_stop();
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -625,7 +625,7 @@ esp_err_t esp_wifi_get_channel(uint8_t *primary, wifi_second_chan_t *second);
|
|||||||
* it's up to the user to fill in all fields according to local regulations.
|
* it's up to the user to fill in all fields according to local regulations.
|
||||||
* Please use esp_wifi_set_country_code instead.
|
* Please use esp_wifi_set_country_code instead.
|
||||||
* @attention 2. The default country is "01" (world safe mode) {.cc="01", .schan=1, .nchan=11, .policy=WIFI_COUNTRY_POLICY_AUTO}.
|
* @attention 2. The default country is "01" (world safe mode) {.cc="01", .schan=1, .nchan=11, .policy=WIFI_COUNTRY_POLICY_AUTO}.
|
||||||
* @attention 3. The third octect of country code string is one of the following: ' ', 'O', 'I', 'X', otherwise it is considered as ' '.
|
* @attention 3. The third octet of country code string is one of the following: ' ', 'O', 'I', 'X', otherwise it is considered as ' '.
|
||||||
* @attention 4. When the country policy is WIFI_COUNTRY_POLICY_AUTO, the country info of the AP to which
|
* @attention 4. When the country policy is WIFI_COUNTRY_POLICY_AUTO, the country info of the AP to which
|
||||||
* the station is connected is used. E.g. if the configured country info is {.cc="US", .schan=1, .nchan=11}
|
* the station is connected is used. E.g. if the configured country info is {.cc="US", .schan=1, .nchan=11}
|
||||||
* and the country info of the AP to which the station is connected is {.cc="JP", .schan=1, .nchan=14}
|
* and the country info of the AP to which the station is connected is {.cc="JP", .schan=1, .nchan=14}
|
||||||
@@ -1276,7 +1276,7 @@ esp_err_t esp_wifi_connectionless_module_set_wake_interval(uint16_t wake_interva
|
|||||||
*
|
*
|
||||||
* @attention 7. When country code "01" (world safe mode) is set, SoftAP mode won't contain country IE.
|
* @attention 7. When country code "01" (world safe mode) is set, SoftAP mode won't contain country IE.
|
||||||
* @attention 8. The default country is "01" (world safe mode) and ieee80211d_enabled is TRUE.
|
* @attention 8. The default country is "01" (world safe mode) and ieee80211d_enabled is TRUE.
|
||||||
* @attention 9. The third octect of country code string is one of the following: ' ', 'O', 'I', 'X', otherwise it is considered as ' '.
|
* @attention 9. The third octet of country code string is one of the following: ' ', 'O', 'I', 'X', otherwise it is considered as ' '.
|
||||||
*
|
*
|
||||||
* @param country the configured country ISO code
|
* @param country the configured country ISO code
|
||||||
* @param ieee80211d_enabled 802.11d is enabled or not
|
* @param ieee80211d_enabled 802.11d is enabled or not
|
||||||
@@ -1364,6 +1364,20 @@ esp_err_t esp_wifi_sta_get_negotiated_phymode(wifi_phy_mode_t *phymode);
|
|||||||
*/
|
*/
|
||||||
esp_err_t esp_wifi_set_dynamic_cs(bool enabled);
|
esp_err_t esp_wifi_set_dynamic_cs(bool enabled);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the rssi info after station connected to AP
|
||||||
|
*
|
||||||
|
* @attention This API should be called after station connected to AP.
|
||||||
|
*
|
||||||
|
* @param rssi store the rssi info received from last beacon.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - ESP_OK: succeed
|
||||||
|
* - ESP_ERR_INVALID_ARG: invalid argument
|
||||||
|
* - ESP_FAIL: failed
|
||||||
|
*/
|
||||||
|
esp_err_t esp_wifi_sta_get_rssi(int *rssi);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Submodule components/esp_wifi/lib updated: fd77ffcf8e...82dd9020a4
@@ -591,6 +591,10 @@ config SOC_EXTERNAL_COEX_ADVANCE
|
|||||||
bool
|
bool
|
||||||
default y
|
default y
|
||||||
|
|
||||||
|
config SOC_EXTERNAL_COEX_LEADER_TX_LINE
|
||||||
|
bool
|
||||||
|
default n
|
||||||
|
|
||||||
config SOC_PHY_DIG_REGS_MEM_SIZE
|
config SOC_PHY_DIG_REGS_MEM_SIZE
|
||||||
int
|
int
|
||||||
default 21
|
default 21
|
||||||
@@ -635,6 +639,10 @@ config SOC_WIFI_HW_TSF
|
|||||||
bool
|
bool
|
||||||
default y
|
default y
|
||||||
|
|
||||||
|
config SOC_WIFI_FTM_SUPPORT
|
||||||
|
bool
|
||||||
|
default y
|
||||||
|
|
||||||
config SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW
|
config SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW
|
||||||
bool
|
bool
|
||||||
default y
|
default y
|
||||||
|
@@ -275,8 +275,9 @@
|
|||||||
/*-------------------------- COEXISTENCE HARDWARE PTI CAPS -------------------------------*/
|
/*-------------------------- COEXISTENCE HARDWARE PTI CAPS -------------------------------*/
|
||||||
#define SOC_COEX_HW_PTI (1)
|
#define SOC_COEX_HW_PTI (1)
|
||||||
|
|
||||||
/*-------------------------- HARDWARE ADVANCED EXTERNAL COEXISTENCE CAPS -------------------*/
|
/*-------------------------- EXTERNAL COEXISTENCE CAPS -------------------------------------*/
|
||||||
#define SOC_EXTERNAL_COEX_ADVANCE (1)
|
#define SOC_EXTERNAL_COEX_ADVANCE (1) /*!< HARDWARE ADVANCED EXTERNAL COEXISTENCE CAPS */
|
||||||
|
#define SOC_EXTERNAL_COEX_LEADER_TX_LINE (0) /*!< EXTERNAL COEXISTENCE TX LINE CAPS */
|
||||||
|
|
||||||
/*--------------- PHY REGISTER AND MEMORY SIZE CAPS --------------------------*/
|
/*--------------- PHY REGISTER AND MEMORY SIZE CAPS --------------------------*/
|
||||||
#define SOC_PHY_DIG_REGS_MEM_SIZE (21*4)
|
#define SOC_PHY_DIG_REGS_MEM_SIZE (21*4)
|
||||||
@@ -299,6 +300,7 @@
|
|||||||
|
|
||||||
/*------------------------------------ WI-FI CAPS ------------------------------------*/
|
/*------------------------------------ WI-FI CAPS ------------------------------------*/
|
||||||
#define SOC_WIFI_HW_TSF (1) /*!< Support hardware TSF */
|
#define SOC_WIFI_HW_TSF (1) /*!< Support hardware TSF */
|
||||||
|
#define SOC_WIFI_FTM_SUPPORT (1) /*!< Support FTM */
|
||||||
#define SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW (1) /*!< Support delta early time for rf phy on/off */
|
#define SOC_WIFI_SUPPORT_VARIABLE_BEACON_WINDOW (1) /*!< Support delta early time for rf phy on/off */
|
||||||
|
|
||||||
/*---------------------------------- Bluetooth CAPS ----------------------------------*/
|
/*---------------------------------- Bluetooth CAPS ----------------------------------*/
|
||||||
|
@@ -855,6 +855,14 @@ config SOC_COEX_HW_PTI
|
|||||||
bool
|
bool
|
||||||
default y
|
default y
|
||||||
|
|
||||||
|
config SOC_EXTERNAL_COEX_ADVANCE
|
||||||
|
bool
|
||||||
|
default n
|
||||||
|
|
||||||
|
config SOC_EXTERNAL_COEX_LEADER_TX_LINE
|
||||||
|
bool
|
||||||
|
default n
|
||||||
|
|
||||||
config SOC_PHY_DIG_REGS_MEM_SIZE
|
config SOC_PHY_DIG_REGS_MEM_SIZE
|
||||||
int
|
int
|
||||||
default 21
|
default 21
|
||||||
|
@@ -376,6 +376,10 @@
|
|||||||
/*-------------------------- COEXISTENCE HARDWARE PTI CAPS -------------------------------*/
|
/*-------------------------- COEXISTENCE HARDWARE PTI CAPS -------------------------------*/
|
||||||
#define SOC_COEX_HW_PTI (1)
|
#define SOC_COEX_HW_PTI (1)
|
||||||
|
|
||||||
|
/*-------------------------- EXTERNAL COEXISTENCE CAPS -------------------------------------*/
|
||||||
|
#define SOC_EXTERNAL_COEX_ADVANCE (0) /*!< HARDWARE ADVANCED EXTERNAL COEXISTENCE CAPS */
|
||||||
|
#define SOC_EXTERNAL_COEX_LEADER_TX_LINE (0) /*!< EXTERNAL COEXISTENCE TX LINE CAPS */
|
||||||
|
|
||||||
/*--------------- PHY REGISTER AND MEMORY SIZE CAPS --------------------------*/
|
/*--------------- PHY REGISTER AND MEMORY SIZE CAPS --------------------------*/
|
||||||
#define SOC_PHY_DIG_REGS_MEM_SIZE (21*4)
|
#define SOC_PHY_DIG_REGS_MEM_SIZE (21*4)
|
||||||
#define SOC_MAC_BB_PD_MEM_SIZE (192*4)
|
#define SOC_MAC_BB_PD_MEM_SIZE (192*4)
|
||||||
|
@@ -1087,6 +1087,14 @@ config SOC_COEX_HW_PTI
|
|||||||
bool
|
bool
|
||||||
default y
|
default y
|
||||||
|
|
||||||
|
config SOC_EXTERNAL_COEX_ADVANCE
|
||||||
|
bool
|
||||||
|
default y
|
||||||
|
|
||||||
|
config SOC_EXTERNAL_COEX_LEADER_TX_LINE
|
||||||
|
bool
|
||||||
|
default n
|
||||||
|
|
||||||
config SOC_PHY_DIG_REGS_MEM_SIZE
|
config SOC_PHY_DIG_REGS_MEM_SIZE
|
||||||
int
|
int
|
||||||
default 21
|
default 21
|
||||||
@@ -1213,7 +1221,7 @@ config SOC_WIFI_HW_TSF
|
|||||||
|
|
||||||
config SOC_WIFI_FTM_SUPPORT
|
config SOC_WIFI_FTM_SUPPORT
|
||||||
bool
|
bool
|
||||||
default y
|
default n
|
||||||
|
|
||||||
config SOC_WIFI_GCMP_SUPPORT
|
config SOC_WIFI_GCMP_SUPPORT
|
||||||
bool
|
bool
|
||||||
|
@@ -449,6 +449,10 @@
|
|||||||
/*-------------------------- COEXISTENCE HARDWARE PTI CAPS -------------------------------*/
|
/*-------------------------- COEXISTENCE HARDWARE PTI CAPS -------------------------------*/
|
||||||
#define SOC_COEX_HW_PTI (1)
|
#define SOC_COEX_HW_PTI (1)
|
||||||
|
|
||||||
|
/*-------------------------- EXTERNAL COEXISTENCE CAPS -------------------------------------*/
|
||||||
|
#define SOC_EXTERNAL_COEX_ADVANCE (1) /*!< HARDWARE ADVANCED EXTERNAL COEXISTENCE CAPS */
|
||||||
|
#define SOC_EXTERNAL_COEX_LEADER_TX_LINE (0) /*!< EXTERNAL COEXISTENCE TX LINE CAPS */
|
||||||
|
|
||||||
/*--------------- PHY REGISTER AND MEMORY SIZE CAPS --------------------------*/
|
/*--------------- PHY REGISTER AND MEMORY SIZE CAPS --------------------------*/
|
||||||
#define SOC_PHY_DIG_REGS_MEM_SIZE (21*4)
|
#define SOC_PHY_DIG_REGS_MEM_SIZE (21*4)
|
||||||
|
|
||||||
@@ -501,7 +505,7 @@
|
|||||||
|
|
||||||
/*------------------------------------ WI-FI CAPS ------------------------------------*/
|
/*------------------------------------ WI-FI CAPS ------------------------------------*/
|
||||||
#define SOC_WIFI_HW_TSF (1) /*!< Support hardware TSF */
|
#define SOC_WIFI_HW_TSF (1) /*!< Support hardware TSF */
|
||||||
#define SOC_WIFI_FTM_SUPPORT (1) /*!< Support FTM */
|
#define SOC_WIFI_FTM_SUPPORT (0) /*!< Support FTM */
|
||||||
#define SOC_WIFI_GCMP_SUPPORT (1) /*!< Support GCMP(GCMP128 and GCMP256) */
|
#define SOC_WIFI_GCMP_SUPPORT (1) /*!< Support GCMP(GCMP128 and GCMP256) */
|
||||||
#define SOC_WIFI_WAPI_SUPPORT (1) /*!< Support WAPI */
|
#define SOC_WIFI_WAPI_SUPPORT (1) /*!< Support WAPI */
|
||||||
#define SOC_WIFI_CSI_SUPPORT (1) /*!< Support CSI */
|
#define SOC_WIFI_CSI_SUPPORT (1) /*!< Support CSI */
|
||||||
|
@@ -1063,6 +1063,14 @@ config SOC_COEX_HW_PTI
|
|||||||
bool
|
bool
|
||||||
default y
|
default y
|
||||||
|
|
||||||
|
config SOC_EXTERNAL_COEX_ADVANCE
|
||||||
|
bool
|
||||||
|
default y
|
||||||
|
|
||||||
|
config SOC_EXTERNAL_COEX_LEADER_TX_LINE
|
||||||
|
bool
|
||||||
|
default n
|
||||||
|
|
||||||
config SOC_PHY_DIG_REGS_MEM_SIZE
|
config SOC_PHY_DIG_REGS_MEM_SIZE
|
||||||
int
|
int
|
||||||
default 21
|
default 21
|
||||||
|
@@ -443,6 +443,10 @@
|
|||||||
/*-------------------------- COEXISTENCE HARDWARE PTI CAPS -------------------------------*/
|
/*-------------------------- COEXISTENCE HARDWARE PTI CAPS -------------------------------*/
|
||||||
#define SOC_COEX_HW_PTI (1)
|
#define SOC_COEX_HW_PTI (1)
|
||||||
|
|
||||||
|
/*-------------------------- EXTERNAL COEXISTENCE CAPS -------------------------------------*/
|
||||||
|
#define SOC_EXTERNAL_COEX_ADVANCE (1) /*!< HARDWARE ADVANCED EXTERNAL COEXISTENCE CAPS */
|
||||||
|
#define SOC_EXTERNAL_COEX_LEADER_TX_LINE (0) /*!< EXTERNAL COEXISTENCE TX LINE CAPS */
|
||||||
|
|
||||||
// TODO: IDF-6337
|
// TODO: IDF-6337
|
||||||
/*--------------- PHY REGISTER AND MEMORY SIZE CAPS --------------------------*/
|
/*--------------- PHY REGISTER AND MEMORY SIZE CAPS --------------------------*/
|
||||||
#define SOC_PHY_DIG_REGS_MEM_SIZE (21*4)
|
#define SOC_PHY_DIG_REGS_MEM_SIZE (21*4)
|
||||||
|
@@ -1047,6 +1047,14 @@ config SOC_COEX_HW_PTI
|
|||||||
bool
|
bool
|
||||||
default y
|
default y
|
||||||
|
|
||||||
|
config SOC_EXTERNAL_COEX_ADVANCE
|
||||||
|
bool
|
||||||
|
default n
|
||||||
|
|
||||||
|
config SOC_EXTERNAL_COEX_LEADER_TX_LINE
|
||||||
|
bool
|
||||||
|
default y
|
||||||
|
|
||||||
config SOC_TEMPERATURE_SENSOR_SUPPORT_FAST_RC
|
config SOC_TEMPERATURE_SENSOR_SUPPORT_FAST_RC
|
||||||
bool
|
bool
|
||||||
default y
|
default y
|
||||||
|
@@ -450,6 +450,10 @@
|
|||||||
/* ---------------------------- Compatibility ------------------------------- */
|
/* ---------------------------- Compatibility ------------------------------- */
|
||||||
// No contents
|
// No contents
|
||||||
|
|
||||||
|
/*-------------------------- EXTERNAL COEXISTENCE CAPS -------------------------------------*/
|
||||||
|
#define SOC_EXTERNAL_COEX_ADVANCE (0) /*!< HARDWARE ADVANCED EXTERNAL COEXISTENCE CAPS */
|
||||||
|
#define SOC_EXTERNAL_COEX_LEADER_TX_LINE (1) /*!< EXTERNAL COEXISTENCE TX LINE CAPS */
|
||||||
|
|
||||||
/*-------------------------- Temperature Sensor CAPS -------------------------------------*/
|
/*-------------------------- Temperature Sensor CAPS -------------------------------------*/
|
||||||
#define SOC_TEMPERATURE_SENSOR_SUPPORT_FAST_RC (1)
|
#define SOC_TEMPERATURE_SENSOR_SUPPORT_FAST_RC (1)
|
||||||
|
|
||||||
|
@@ -1195,6 +1195,14 @@ config SOC_COEX_HW_PTI
|
|||||||
bool
|
bool
|
||||||
default y
|
default y
|
||||||
|
|
||||||
|
config SOC_EXTERNAL_COEX_ADVANCE
|
||||||
|
bool
|
||||||
|
default n
|
||||||
|
|
||||||
|
config SOC_EXTERNAL_COEX_LEADER_TX_LINE
|
||||||
|
bool
|
||||||
|
default y
|
||||||
|
|
||||||
config SOC_SDMMC_USE_GPIO_MATRIX
|
config SOC_SDMMC_USE_GPIO_MATRIX
|
||||||
bool
|
bool
|
||||||
default y
|
default y
|
||||||
|
@@ -480,6 +480,10 @@
|
|||||||
/*-------------------------- COEXISTENCE HARDWARE PTI CAPS -------------------------------*/
|
/*-------------------------- COEXISTENCE HARDWARE PTI CAPS -------------------------------*/
|
||||||
#define SOC_COEX_HW_PTI (1)
|
#define SOC_COEX_HW_PTI (1)
|
||||||
|
|
||||||
|
/*-------------------------- EXTERNAL COEXISTENCE CAPS -------------------------------------*/
|
||||||
|
#define SOC_EXTERNAL_COEX_ADVANCE (0) /*!< HARDWARE ADVANCED EXTERNAL COEXISTENCE CAPS */
|
||||||
|
#define SOC_EXTERNAL_COEX_LEADER_TX_LINE (1) /*!< EXTERNAL COEXISTENCE TX LINE CAPS */
|
||||||
|
|
||||||
/*-------------------------- SDMMC CAPS -----------------------------------------*/
|
/*-------------------------- SDMMC CAPS -----------------------------------------*/
|
||||||
|
|
||||||
/* Card detect, write protect, interrupt use GPIO Matrix on all chips.
|
/* Card detect, write protect, interrupt use GPIO Matrix on all chips.
|
||||||
|
@@ -12,7 +12,7 @@ The Wi-Fi libraries provide support for configuring and monitoring the {IDF_TARG
|
|||||||
- AP mode (aka Soft-AP mode or Access Point mode). Stations connect to the {IDF_TARGET_NAME}.
|
- AP mode (aka Soft-AP mode or Access Point mode). Stations connect to the {IDF_TARGET_NAME}.
|
||||||
- Station/AP-coexistence mode ({IDF_TARGET_NAME} is concurrently an access point and a station connected to another access point).
|
- Station/AP-coexistence mode ({IDF_TARGET_NAME} is concurrently an access point and a station connected to another access point).
|
||||||
|
|
||||||
- Various security modes for the above (WPA, WPA2, WEP, etc.)
|
- Various security modes for the above (WPA, WPA2, WPA3, etc.)
|
||||||
- Scanning for access points (active & passive scanning).
|
- Scanning for access points (active & passive scanning).
|
||||||
- Promiscuous mode for monitoring of IEEE802.11 Wi-Fi packets.
|
- Promiscuous mode for monitoring of IEEE802.11 Wi-Fi packets.
|
||||||
|
|
||||||
|
@@ -12,7 +12,7 @@ Wi-Fi 库支持配置及监控 {IDF_TARGET_NAME} Wi-Fi 连网功能。支持配
|
|||||||
- AP 模式(即 Soft-AP 模式或接入点模式),此时基站连接到 {IDF_TARGET_NAME}。
|
- AP 模式(即 Soft-AP 模式或接入点模式),此时基站连接到 {IDF_TARGET_NAME}。
|
||||||
- station/AP 共存模式({IDF_TARGET_NAME} 既是接入点,同时又作为基站连接到另外一个接入点)。
|
- station/AP 共存模式({IDF_TARGET_NAME} 既是接入点,同时又作为基站连接到另外一个接入点)。
|
||||||
|
|
||||||
- 上述模式的各种安全模式(WPA、WPA2 及 WEP 等)。
|
- 上述模式的各种安全模式(WPA、WPA2、WPA3 等)。
|
||||||
- 扫描接入点(包括主动扫描及被动扫描)。
|
- 扫描接入点(包括主动扫描及被动扫描)。
|
||||||
- 使用混杂模式监控 IEEE802.11 Wi-Fi 数据包。
|
- 使用混杂模式监控 IEEE802.11 Wi-Fi 数据包。
|
||||||
|
|
||||||
|
@@ -5,10 +5,9 @@ examples/wifi:
|
|||||||
- if: SOC_WIFI_SUPPORTED != 1
|
- if: SOC_WIFI_SUPPORTED != 1
|
||||||
|
|
||||||
examples/wifi/ftm:
|
examples/wifi/ftm:
|
||||||
enable:
|
disable:
|
||||||
- if: IDF_TARGET in ["esp32c3", "esp32s2", "esp32s3"]
|
- if: SOC_WIFI_FTM_SUPPORT != 1
|
||||||
temporary: true
|
reason: requires hardware support
|
||||||
reason: the other targets are not tested yet
|
|
||||||
|
|
||||||
examples/wifi/getting_started:
|
examples/wifi/getting_started:
|
||||||
disable:
|
disable:
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
| Supported Targets | ESP32-C3 | ESP32-S2 | ESP32-S3 |
|
| Supported Targets | ESP32-C2 | ESP32-C3 | ESP32-S2 | ESP32-S3 |
|
||||||
| ----------------- | -------- | -------- | -------- |
|
| ----------------- | -------- | -------- | -------- | -------- |
|
||||||
|
|
||||||
# FTM Example
|
# FTM Example
|
||||||
|
|
||||||
@@ -43,6 +43,7 @@ ftm>
|
|||||||
```
|
```
|
||||||
|
|
||||||
Use `help` to get a list of available commands and options. Use `scan` command to scan for AP's that support FTM Responder mode. Before initiating FTM with an external AP, make sure that `FTM Responder` tag is visible in the respective scan result entry. Alternatively, start SoftAP on another device using `ap` command, it supports FTM Responder by default. If external FTM Initiators get a large error in distance readings with the SoftAP, note down the reading at zero distance in centimeters, say `cm0`. This distance can be offset using command `ftm -R -o <cm0>` to give accurate readings with the Initiator.
|
Use `help` to get a list of available commands and options. Use `scan` command to scan for AP's that support FTM Responder mode. Before initiating FTM with an external AP, make sure that `FTM Responder` tag is visible in the respective scan result entry. Alternatively, start SoftAP on another device using `ap` command, it supports FTM Responder by default. If external FTM Initiators get a large error in distance readings with the SoftAP, note down the reading at zero distance in centimeters, say `cm0`. This distance can be offset using command `ftm -R -o <cm0>` to give accurate readings with the Initiator.
|
||||||
|
It is recommended to keep SoftAP bandwidth at 20MHz as it gives more accurate results.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
ftm> scan
|
ftm> scan
|
||||||
|
@@ -26,8 +26,17 @@
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
struct arg_str *ssid;
|
struct arg_str *ssid;
|
||||||
struct arg_str *password;
|
struct arg_str *password;
|
||||||
|
struct arg_lit *disconnect;
|
||||||
struct arg_end *end;
|
struct arg_end *end;
|
||||||
} wifi_args_t;
|
} wifi_sta_args_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
struct arg_str *ssid;
|
||||||
|
struct arg_str *password;
|
||||||
|
struct arg_int *channel;
|
||||||
|
struct arg_int *bandwidth;
|
||||||
|
struct arg_end *end;
|
||||||
|
} wifi_ap_args_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
struct arg_str *ssid;
|
struct arg_str *ssid;
|
||||||
@@ -48,8 +57,8 @@ typedef struct {
|
|||||||
struct arg_end *end;
|
struct arg_end *end;
|
||||||
} wifi_ftm_args_t;
|
} wifi_ftm_args_t;
|
||||||
|
|
||||||
static wifi_args_t sta_args;
|
static wifi_sta_args_t sta_args;
|
||||||
static wifi_args_t ap_args;
|
static wifi_ap_args_t ap_args;
|
||||||
static wifi_scan_arg_t scan_args;
|
static wifi_scan_arg_t scan_args;
|
||||||
static wifi_ftm_args_t ftm_args;
|
static wifi_ftm_args_t ftm_args;
|
||||||
|
|
||||||
@@ -61,6 +70,8 @@ wifi_config_t g_ap_config = {
|
|||||||
|
|
||||||
#define ETH_ALEN 6
|
#define ETH_ALEN 6
|
||||||
#define MAX_CONNECT_RETRY_ATTEMPTS 5
|
#define MAX_CONNECT_RETRY_ATTEMPTS 5
|
||||||
|
#define DEFAULT_AP_CHANNEL 1
|
||||||
|
#define DEFAULT_AP_BANDWIDTH 20
|
||||||
|
|
||||||
static bool s_reconnect = true;
|
static bool s_reconnect = true;
|
||||||
static int s_retry_num = 0;
|
static int s_retry_num = 0;
|
||||||
@@ -124,11 +135,11 @@ static void event_handler(void *arg, esp_event_base_t event_base,
|
|||||||
} else if (event_id == WIFI_EVENT_FTM_REPORT) {
|
} else if (event_id == WIFI_EVENT_FTM_REPORT) {
|
||||||
wifi_event_ftm_report_t *event = (wifi_event_ftm_report_t *) event_data;
|
wifi_event_ftm_report_t *event = (wifi_event_ftm_report_t *) event_data;
|
||||||
|
|
||||||
if (event->status == FTM_STATUS_SUCCESS) {
|
|
||||||
s_rtt_est = event->rtt_est;
|
s_rtt_est = event->rtt_est;
|
||||||
s_dist_est = event->dist_est;
|
s_dist_est = event->dist_est;
|
||||||
s_ftm_report = event->ftm_report_data;
|
s_ftm_report = event->ftm_report_data;
|
||||||
s_ftm_report_num_entries = event->ftm_report_num_entries;
|
s_ftm_report_num_entries = event->ftm_report_num_entries;
|
||||||
|
if (event->status == FTM_STATUS_SUCCESS) {
|
||||||
xEventGroupSetBits(s_ftm_event_group, FTM_REPORT_BIT);
|
xEventGroupSetBits(s_ftm_event_group, FTM_REPORT_BIT);
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGI(TAG_STA, "FTM procedure with Peer("MACSTR") failed! (Status - %d)",
|
ESP_LOGI(TAG_STA, "FTM procedure with Peer("MACSTR") failed! (Status - %d)",
|
||||||
@@ -147,6 +158,9 @@ static void ftm_process_report(void)
|
|||||||
int i;
|
int i;
|
||||||
char *log = NULL;
|
char *log = NULL;
|
||||||
|
|
||||||
|
if (s_ftm_report_num_entries == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
if (!g_report_lvl)
|
if (!g_report_lvl)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -170,7 +184,10 @@ static void ftm_process_report(void)
|
|||||||
log_ptr += sprintf(log_ptr, "%6d|", s_ftm_report[i].dlog_token);
|
log_ptr += sprintf(log_ptr, "%6d|", s_ftm_report[i].dlog_token);
|
||||||
}
|
}
|
||||||
if (g_report_lvl & BIT1) {
|
if (g_report_lvl & BIT1) {
|
||||||
log_ptr += sprintf(log_ptr, "%7" PRIu32 " |", s_ftm_report[i].rtt);
|
if (s_ftm_report[i].rtt != UINT32_MAX)
|
||||||
|
log_ptr += sprintf(log_ptr, "%7" PRIi32 " |", s_ftm_report[i].rtt);
|
||||||
|
else
|
||||||
|
log_ptr += sprintf(log_ptr, " INVALID |");
|
||||||
}
|
}
|
||||||
if (g_report_lvl & BIT2) {
|
if (g_report_lvl & BIT2) {
|
||||||
log_ptr += sprintf(log_ptr, "%14llu |%14llu |%14llu |%14llu |", s_ftm_report[i].t1,
|
log_ptr += sprintf(log_ptr, "%14llu |%14llu |%14llu |%14llu |", s_ftm_report[i].t1,
|
||||||
@@ -250,6 +267,13 @@ static int wifi_cmd_sta(int argc, char **argv)
|
|||||||
arg_print_errors(stderr, sta_args.end, argv[0]);
|
arg_print_errors(stderr, sta_args.end, argv[0]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
if (sta_args.disconnect->count) {
|
||||||
|
s_reconnect = false;
|
||||||
|
xEventGroupClearBits(s_wifi_event_group, CONNECTED_BIT);
|
||||||
|
esp_wifi_disconnect();
|
||||||
|
xEventGroupWaitBits(s_wifi_event_group, DISCONNECTED_BIT, 0, 1, portTICK_PERIOD_MS);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
ESP_LOGI(TAG_STA, "sta connecting to '%s'", sta_args.ssid->sval[0]);
|
ESP_LOGI(TAG_STA, "sta connecting to '%s'", sta_args.ssid->sval[0]);
|
||||||
wifi_cmd_sta_join(sta_args.ssid->sval[0], sta_args.password->sval[0]);
|
wifi_cmd_sta_join(sta_args.ssid->sval[0], sta_args.password->sval[0]);
|
||||||
@@ -315,7 +339,7 @@ static int wifi_cmd_scan(int argc, char **argv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool wifi_cmd_ap_set(const char* ssid, const char* pass)
|
static bool wifi_cmd_ap_set(const char* ssid, const char* pass, uint8_t channel, uint8_t bw)
|
||||||
{
|
{
|
||||||
s_reconnect = false;
|
s_reconnect = false;
|
||||||
strlcpy((char*) g_ap_config.ap.ssid, ssid, MAX_SSID_LEN);
|
strlcpy((char*) g_ap_config.ap.ssid, ssid, MAX_SSID_LEN);
|
||||||
@@ -327,13 +351,29 @@ static bool wifi_cmd_ap_set(const char* ssid, const char* pass)
|
|||||||
}
|
}
|
||||||
strlcpy((char*) g_ap_config.ap.password, pass, MAX_PASSPHRASE_LEN);
|
strlcpy((char*) g_ap_config.ap.password, pass, MAX_PASSPHRASE_LEN);
|
||||||
}
|
}
|
||||||
|
if (!(channel >=1 && channel <= 14)) {
|
||||||
|
ESP_LOGE(TAG_AP, "Channel cannot be %d!", channel);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (bw != 20 && bw != 40) {
|
||||||
|
ESP_LOGE(TAG_AP, "Cannot set %d MHz bandwidth!", bw);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (strlen(pass) == 0) {
|
if (strlen(pass) == 0) {
|
||||||
g_ap_config.ap.authmode = WIFI_AUTH_OPEN;
|
g_ap_config.ap.authmode = WIFI_AUTH_OPEN;
|
||||||
}
|
}
|
||||||
|
g_ap_config.ap.channel = channel;
|
||||||
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_AP));
|
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_AP));
|
||||||
ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_AP, &g_ap_config));
|
ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_AP, &g_ap_config));
|
||||||
|
if (bw == 40) {
|
||||||
|
esp_wifi_set_bandwidth(ESP_IF_WIFI_AP, WIFI_BW_HT40);
|
||||||
|
} else {
|
||||||
|
esp_wifi_set_bandwidth(ESP_IF_WIFI_AP, WIFI_BW_HT20);
|
||||||
|
}
|
||||||
|
ESP_LOGI(TAG_AP, "Starting SoftAP with FTM Responder support, SSID - %s, Password - %s, Primary Channel - %d, Bandwidth - %dMHz",
|
||||||
|
ap_args.ssid->sval[0], ap_args.password->sval[0], channel, bw);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -346,10 +386,12 @@ static int wifi_cmd_ap(int argc, char** argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (true == wifi_cmd_ap_set(ap_args.ssid->sval[0], ap_args.password->sval[0]))
|
if (!wifi_cmd_ap_set(ap_args.ssid->sval[0], ap_args.password->sval[0],
|
||||||
ESP_LOGI(TAG_AP, "Starting SoftAP with FTM Responder support, SSID - %s, Password - %s", ap_args.ssid->sval[0], ap_args.password->sval[0]);
|
ap_args.channel->count != 0 ? ap_args.channel->ival[0] : DEFAULT_AP_CHANNEL,
|
||||||
else
|
ap_args.bandwidth->count != 0 ? ap_args.bandwidth->ival[0] : DEFAULT_AP_BANDWIDTH)) {
|
||||||
ESP_LOGE(TAG_AP, "Failed to start SoftAP!");
|
ESP_LOGE(TAG_AP, "Failed to start SoftAP!");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -486,11 +528,11 @@ static int wifi_cmd_ftm(int argc, char **argv)
|
|||||||
bits = xEventGroupWaitBits(s_ftm_event_group, FTM_REPORT_BIT | FTM_FAILURE_BIT,
|
bits = xEventGroupWaitBits(s_ftm_event_group, FTM_REPORT_BIT | FTM_FAILURE_BIT,
|
||||||
pdTRUE, pdFALSE, portMAX_DELAY);
|
pdTRUE, pdFALSE, portMAX_DELAY);
|
||||||
/* Processing data from FTM session */
|
/* Processing data from FTM session */
|
||||||
if (bits & FTM_REPORT_BIT) {
|
|
||||||
ftm_process_report();
|
ftm_process_report();
|
||||||
free(s_ftm_report);
|
free(s_ftm_report);
|
||||||
s_ftm_report = NULL;
|
s_ftm_report = NULL;
|
||||||
s_ftm_report_num_entries = 0;
|
s_ftm_report_num_entries = 0;
|
||||||
|
if (bits & FTM_REPORT_BIT) {
|
||||||
ESP_LOGI(TAG_STA, "Estimated RTT - %" PRId32 " nSec, Estimated Distance - %" PRId32 ".%02" PRId32 " meters",
|
ESP_LOGI(TAG_STA, "Estimated RTT - %" PRId32 " nSec, Estimated Distance - %" PRId32 ".%02" PRId32 " meters",
|
||||||
s_rtt_est, s_dist_est / 100, s_dist_est % 100);
|
s_rtt_est, s_dist_est / 100, s_dist_est % 100);
|
||||||
} else {
|
} else {
|
||||||
@@ -533,8 +575,9 @@ ftm_responder:
|
|||||||
|
|
||||||
void register_wifi(void)
|
void register_wifi(void)
|
||||||
{
|
{
|
||||||
sta_args.ssid = arg_str1(NULL, NULL, "<ssid>", "SSID of AP");
|
sta_args.ssid = arg_str0(NULL, NULL, "<ssid>", "SSID of AP");
|
||||||
sta_args.password = arg_str0(NULL, NULL, "<pass>", "password of AP");
|
sta_args.password = arg_str0(NULL, NULL, "<pass>", "password of AP");
|
||||||
|
sta_args.disconnect = arg_lit0("d", "disconnect", "Disconnect from the connected AP");
|
||||||
sta_args.end = arg_end(2);
|
sta_args.end = arg_end(2);
|
||||||
|
|
||||||
const esp_console_cmd_t sta_cmd = {
|
const esp_console_cmd_t sta_cmd = {
|
||||||
@@ -547,8 +590,10 @@ void register_wifi(void)
|
|||||||
|
|
||||||
ESP_ERROR_CHECK( esp_console_cmd_register(&sta_cmd) );
|
ESP_ERROR_CHECK( esp_console_cmd_register(&sta_cmd) );
|
||||||
|
|
||||||
ap_args.ssid = arg_str1(NULL, NULL, "<ssid>", "SSID of AP");
|
ap_args.ssid = arg_str0(NULL, NULL, "<ssid>", "SSID of AP");
|
||||||
ap_args.password = arg_str0(NULL, NULL, "<pass>", "password of AP");
|
ap_args.password = arg_str0(NULL, NULL, "<pass>", "password of AP");
|
||||||
|
ap_args.channel = arg_int0("c", "channel", "<1-11>", "Primary channel of AP");
|
||||||
|
ap_args.bandwidth = arg_int0("b", "bandwidth", "<20/40>", "Channel bandwidth");
|
||||||
ap_args.end = arg_end(2);
|
ap_args.end = arg_end(2);
|
||||||
|
|
||||||
const esp_console_cmd_t ap_cmd = {
|
const esp_console_cmd_t ap_cmd = {
|
||||||
@@ -640,16 +685,20 @@ void app_main(void)
|
|||||||
register_system();
|
register_system();
|
||||||
register_wifi();
|
register_wifi();
|
||||||
|
|
||||||
printf("\n ==========================================================\n");
|
printf("\n ===============================================================\n");
|
||||||
printf(" | Steps to test FTM |\n");
|
printf(" | Steps to test FTM Initiator |\n");
|
||||||
printf(" | |\n");
|
printf(" | |\n");
|
||||||
printf(" | 1. Use 'help' for detailed information on parameters |\n");
|
printf(" | 1. Use 'scan' command to scan AP's. In results, check AP's |\n");
|
||||||
printf(" | 2. Start SoftAP with command 'ap <SSID> <password>' |\n");
|
printf(" | with tag '[FTM Responder]' for supported AP's |\n");
|
||||||
printf(" | OR |\n");
|
printf(" | 2. Optionally connect to the AP with 'sta <SSID> <password>'|\n");
|
||||||
printf(" | 2. Use 'scan' command to search for external AP's |\n");
|
printf(" | 3. Initiate FTM with 'ftm -I -s <SSID>' |\n");
|
||||||
printf(" | 3. On second device initiate FTM with an AP using |\n");
|
printf(" |______________________________________________________________|\n");
|
||||||
printf(" | command 'ftm -I -s <SSID>' |\n");
|
printf(" | Steps to test FTM Responder |\n");
|
||||||
printf(" ==========================================================\n\n");
|
printf(" | |\n");
|
||||||
|
printf(" | 1. Start SoftAP with command 'ap <SSID> <password>' |\n");
|
||||||
|
printf(" | 2. Optionally add '-c <ch>' to set channel, '-b 40' for 40M |\n");
|
||||||
|
printf(" | 3. Use 'help' for detailed information for all parameters |\n");
|
||||||
|
printf(" ================================================================\n\n");
|
||||||
|
|
||||||
// start console REPL
|
// start console REPL
|
||||||
ESP_ERROR_CHECK(esp_console_start_repl(repl));
|
ESP_ERROR_CHECK(esp_console_start_repl(repl));
|
||||||
|
@@ -172,19 +172,21 @@ void initialise_wifi(void)
|
|||||||
ESP_ERROR_CHECK(esp_wifi_start() );
|
ESP_ERROR_CHECK(esp_wifi_start() );
|
||||||
|
|
||||||
#if CONFIG_EXTERNAL_COEX_ENABLE
|
#if CONFIG_EXTERNAL_COEX_ENABLE
|
||||||
#if SOC_EXTERNAL_COEX_ADVANCE
|
|
||||||
uint32_t in_pin0 = 1;
|
|
||||||
uint32_t in_pin1 = 2;
|
|
||||||
uint32_t out_pin0 = 3;
|
|
||||||
ESP_ERROR_CHECK( esp_external_coex_leader_role_set_gpio_pin(EXTERN_COEX_WIRE_3, in_pin0, in_pin1, out_pin0) );
|
|
||||||
#else
|
|
||||||
esp_external_coex_gpio_set_t gpio_pin;
|
esp_external_coex_gpio_set_t gpio_pin;
|
||||||
gpio_pin.in_pin0 = 1;
|
gpio_pin.request = 1;
|
||||||
gpio_pin.in_pin1 = 2;
|
gpio_pin.priority = 2;
|
||||||
gpio_pin.out_pin0 = 3;
|
gpio_pin.grant = 3;
|
||||||
|
#if SOC_EXTERNAL_COEX_LEADER_TX_LINE
|
||||||
|
gpio_pin.tx_line = 4;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
esp_external_coex_set_work_mode(EXTERNAL_COEX_LEADER_ROLE);
|
||||||
|
#if SOC_EXTERNAL_COEX_LEADER_TX_LINE
|
||||||
|
ESP_ERROR_CHECK(esp_enable_extern_coex_gpio_pin(EXTERN_COEX_WIRE_4, gpio_pin));
|
||||||
|
#else
|
||||||
ESP_ERROR_CHECK(esp_enable_extern_coex_gpio_pin(EXTERN_COEX_WIRE_3, gpio_pin));
|
ESP_ERROR_CHECK(esp_enable_extern_coex_gpio_pin(EXTERN_COEX_WIRE_3, gpio_pin));
|
||||||
#endif
|
#endif /* SOC_EXTERNAL_COEX_LEADER_TX_LINE */
|
||||||
#endif
|
#endif /* CONFIG_EXTERNAL_COEX_ENABLE */
|
||||||
|
|
||||||
#if CONFIG_ESP_WIFI_ENABLE_WIFI_RX_STATS
|
#if CONFIG_ESP_WIFI_ENABLE_WIFI_RX_STATS
|
||||||
#if CONFIG_ESP_WIFI_ENABLE_WIFI_RX_MU_STATS
|
#if CONFIG_ESP_WIFI_ENABLE_WIFI_RX_MU_STATS
|
||||||
|
Reference in New Issue
Block a user