Merge branch 'feature/external_coex' into 'master'

Feature/external coex

See merge request espressif/esp-idf!14549
pull/7680/head
Jiang Jiang Jian 2021-10-12 08:39:57 +00:00
commit 44556fc46a
13 zmienionych plików z 307 dodań i 138 usunięć

Wyświetl plik

@ -1,16 +1,8 @@
// Copyright 2015-2018 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdint.h>
#include <string.h>
@ -474,7 +466,7 @@ IRAM_ATTR ESP_SYSTEM_INIT_FN(init_components0, BIT(0))
esp_apb_backup_dma_lock_init();
#endif
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
esp_coex_adapter_register(&g_coex_adapter_funcs);
coex_pre_init();
#endif

Wyświetl plik

@ -300,4 +300,16 @@ menu "Wi-Fi"
Select this option to enable power_management for station when disconnected.
Chip will do modem-sleep when rf module is not in use any more.
config ESP_WIFI_EXTERNAL_COEXIST_ENABLE
bool "WiFi External Coexistence"
default n
depends on (!BT_ENABLED && (IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32C3))
help
If enabled, HW External coexistence arbitration is managed by GPIO pins.
It can support three types of wired combinations so far which are 1-wired/2-wired/3-wired.
User can select GPIO pins in application code with configure interfaces.
This function depends on BT-off
because currently we don't support external coex and internal coex simultaneously.
endmenu # Wi-Fi

Wyświetl plik

@ -1,16 +1,8 @@
// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stddef.h>
#include <stdlib.h>
@ -489,7 +481,7 @@ static esp_err_t esp_read_mac_wrapper(uint8_t* mac, uint32_t type)
static int coex_init_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
return coex_init();
#else
return 0;
@ -498,14 +490,14 @@ static int coex_init_wrapper(void)
static void coex_deinit_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
coex_deinit();
#endif
}
static int coex_enable_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
return coex_enable();
#else
return 0;
@ -514,14 +506,14 @@ static int coex_enable_wrapper(void)
static void coex_disable_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
coex_disable();
#endif
}
static IRAM_ATTR uint32_t coex_status_get_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
return coex_status_get();
#else
return 0;
@ -530,14 +522,14 @@ static IRAM_ATTR uint32_t coex_status_get_wrapper(void)
static void coex_condition_set_wrapper(uint32_t type, bool dissatisfy)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
coex_condition_set(type, dissatisfy);
#endif
}
static int coex_wifi_request_wrapper(uint32_t event, uint32_t latency, uint32_t duration)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
return coex_wifi_request(event, latency, duration);
#else
return 0;
@ -546,7 +538,7 @@ static int coex_wifi_request_wrapper(uint32_t event, uint32_t latency, uint32_t
static IRAM_ATTR int coex_wifi_release_wrapper(uint32_t event)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
return coex_wifi_release(event);
#else
return 0;
@ -555,7 +547,7 @@ static IRAM_ATTR int coex_wifi_release_wrapper(uint32_t event)
static int coex_wifi_channel_set_wrapper(uint8_t primary, uint8_t secondary)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
return coex_wifi_channel_set(primary, secondary);
#else
return 0;
@ -564,7 +556,7 @@ static int coex_wifi_channel_set_wrapper(uint8_t primary, uint8_t secondary)
static IRAM_ATTR int coex_event_duration_get_wrapper(uint32_t event, uint32_t *duration)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
return coex_event_duration_get(event, duration);
#else
return 0;
@ -573,7 +565,7 @@ static IRAM_ATTR int coex_event_duration_get_wrapper(uint32_t event, uint32_t *d
static int coex_pti_get_wrapper(uint32_t event, uint8_t *pti)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
return coex_pti_get(event, pti);
#else
return 0;
@ -582,21 +574,21 @@ static int coex_pti_get_wrapper(uint32_t event, uint8_t *pti)
static void coex_schm_status_bit_clear_wrapper(uint32_t type, uint32_t status)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
coex_schm_status_bit_clear(type, status);
#endif
}
static void coex_schm_status_bit_set_wrapper(uint32_t type, uint32_t status)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
coex_schm_status_bit_set(type, status);
#endif
}
static IRAM_ATTR int coex_schm_interval_set_wrapper(uint32_t interval)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
return coex_schm_interval_set(interval);
#else
return 0;
@ -605,7 +597,7 @@ static IRAM_ATTR int coex_schm_interval_set_wrapper(uint32_t interval)
static uint32_t coex_schm_interval_get_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
return coex_schm_interval_get();
#else
return 0;
@ -614,7 +606,7 @@ static uint32_t coex_schm_interval_get_wrapper(void)
static uint8_t coex_schm_curr_period_get_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
return coex_schm_curr_period_get();
#else
return 0;
@ -623,7 +615,7 @@ static uint8_t coex_schm_curr_period_get_wrapper(void)
static void * coex_schm_curr_phase_get_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
return coex_schm_curr_phase_get();
#else
return NULL;
@ -632,7 +624,7 @@ static void * coex_schm_curr_phase_get_wrapper(void)
static int coex_schm_curr_phase_idx_set_wrapper(int idx)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
return coex_schm_curr_phase_idx_set(idx);
#else
return 0;
@ -641,7 +633,7 @@ static int coex_schm_curr_phase_idx_set_wrapper(int idx)
static int coex_schm_curr_phase_idx_get_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
return coex_schm_curr_phase_idx_get();
#else
return 0;

Wyświetl plik

@ -1,16 +1,8 @@
// Copyright 2015-2018 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stddef.h>
#include <stdlib.h>
@ -48,6 +40,8 @@
#include "nvs.h"
#include "os.h"
#include "esp_smartconfig.h"
#include "esp_coexist_internal.h"
#include "esp_coexist_adapter.h"
#define TAG "esp_adapter"
@ -277,6 +271,16 @@ static void * wifi_thread_semphr_get_wrapper(void)
return (void*)sem;
}
static int32_t IRAM_ATTR semphr_take_from_isr_wrapper(void *semphr, void *hptw)
{
return (int32_t)xSemaphoreTakeFromISR(semphr, hptw);
}
static int32_t IRAM_ATTR semphr_give_from_isr_wrapper(void *semphr, void *hptw)
{
return (int32_t)xSemaphoreGiveFromISR(semphr, hptw);
}
static int32_t semphr_take_wrapper(void *semphr, uint32_t block_time_tick)
{
if (block_time_tick == OSI_FUNCS_TIME_BLOCKING) {
@ -483,7 +487,7 @@ static void * IRAM_ATTR zalloc_internal_wrapper(size_t size)
static int coex_init_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_EXTERNAL_COEX_ENABLE
return coex_init();
#else
return 0;
@ -492,14 +496,14 @@ static int coex_init_wrapper(void)
static void coex_deinit_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_EXTERNAL_COEX_ENABLE
coex_deinit();
#endif
}
static int coex_enable_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_EXTERNAL_COEX_ENABLE
return coex_enable();
#else
return 0;
@ -508,14 +512,14 @@ static int coex_enable_wrapper(void)
static void coex_disable_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_EXTERNAL_COEX_ENABLE
coex_disable();
#endif
}
static IRAM_ATTR uint32_t coex_status_get_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_EXTERNAL_COEX_ENABLE
return coex_status_get();
#else
return 0;
@ -524,14 +528,14 @@ static IRAM_ATTR uint32_t coex_status_get_wrapper(void)
static void coex_condition_set_wrapper(uint32_t type, bool dissatisfy)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_EXTERNAL_COEX_ENABLE
coex_condition_set(type, dissatisfy);
#endif
}
static int coex_wifi_request_wrapper(uint32_t event, uint32_t latency, uint32_t duration)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_EXTERNAL_COEX_ENABLE
return coex_wifi_request(event, latency, duration);
#else
return 0;
@ -540,7 +544,7 @@ static int coex_wifi_request_wrapper(uint32_t event, uint32_t latency, uint32_t
static IRAM_ATTR int coex_wifi_release_wrapper(uint32_t event)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_EXTERNAL_COEX_ENABLE
return coex_wifi_release(event);
#else
return 0;
@ -549,7 +553,7 @@ static IRAM_ATTR int coex_wifi_release_wrapper(uint32_t event)
static int coex_wifi_channel_set_wrapper(uint8_t primary, uint8_t secondary)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_EXTERNAL_COEX_ENABLE
return coex_wifi_channel_set(primary, secondary);
#else
return 0;
@ -558,7 +562,7 @@ static int coex_wifi_channel_set_wrapper(uint8_t primary, uint8_t secondary)
static IRAM_ATTR int coex_event_duration_get_wrapper(uint32_t event, uint32_t *duration)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_EXTERNAL_COEX_ENABLE
return coex_event_duration_get(event, duration);
#else
return 0;
@ -567,26 +571,30 @@ static IRAM_ATTR int coex_event_duration_get_wrapper(uint32_t event, uint32_t *d
static int coex_pti_get_wrapper(uint32_t event, uint8_t *pti)
{
#if CONFIG_EXTERNAL_COEX_ENABLE
return coex_pti_get(event, pti);
#else
return 0;
#endif
}
static void coex_schm_status_bit_clear_wrapper(uint32_t type, uint32_t status)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_EXTERNAL_COEX_ENABLE
coex_schm_status_bit_clear(type, status);
#endif
}
static void coex_schm_status_bit_set_wrapper(uint32_t type, uint32_t status)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_EXTERNAL_COEX_ENABLE
coex_schm_status_bit_set(type, status);
#endif
}
static IRAM_ATTR int coex_schm_interval_set_wrapper(uint32_t interval)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_EXTERNAL_COEX_ENABLE
return coex_schm_interval_set(interval);
#else
return 0;
@ -595,7 +603,7 @@ static IRAM_ATTR int coex_schm_interval_set_wrapper(uint32_t interval)
static uint32_t coex_schm_interval_get_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_EXTERNAL_COEX_ENABLE
return coex_schm_interval_get();
#else
return 0;
@ -604,7 +612,7 @@ static uint32_t coex_schm_interval_get_wrapper(void)
static uint8_t coex_schm_curr_period_get_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_EXTERNAL_COEX_ENABLE
return coex_schm_curr_period_get();
#else
return 0;
@ -613,7 +621,7 @@ static uint8_t coex_schm_curr_period_get_wrapper(void)
static void * coex_schm_curr_phase_get_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_EXTERNAL_COEX_ENABLE
return coex_schm_curr_phase_get();
#else
return NULL;
@ -622,7 +630,7 @@ static void * coex_schm_curr_phase_get_wrapper(void)
static int coex_schm_curr_phase_idx_set_wrapper(int idx)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_EXTERNAL_COEX_ENABLE
return coex_schm_curr_phase_idx_set(idx);
#else
return 0;
@ -631,7 +639,7 @@ static int coex_schm_curr_phase_idx_set_wrapper(int idx)
static int coex_schm_curr_phase_idx_get_wrapper(void)
{
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_EXTERNAL_COEX_ENABLE
return coex_schm_curr_phase_idx_get();
#else
return 0;
@ -643,6 +651,11 @@ static void IRAM_ATTR esp_empty_wrapper(void)
}
int32_t IRAM_ATTR coex_is_in_isr_wrapper(void)
{
return !xPortCanYield();
}
wifi_osi_funcs_t g_wifi_osi_funcs = {
._version = ESP_WIFI_OS_ADAPTER_VERSION,
._env_is_chip = env_is_chip_wrapper,
@ -761,3 +774,19 @@ wifi_osi_funcs_t g_wifi_osi_funcs = {
._coex_schm_curr_phase_idx_get = coex_schm_curr_phase_idx_get_wrapper,
._magic = ESP_WIFI_OS_ADAPTER_MAGIC,
};
coex_adapter_funcs_t g_coex_adapter_funcs = {
._version = COEX_ADAPTER_VERSION,
._task_yield_from_isr = task_yield_from_isr_wrapper,
._semphr_create = semphr_create_wrapper,
._semphr_delete = semphr_delete_wrapper,
._semphr_take_from_isr = semphr_take_from_isr_wrapper,
._semphr_give_from_isr = semphr_give_from_isr_wrapper,
._semphr_take = semphr_take_wrapper,
._semphr_give = semphr_give_wrapper,
._is_in_isr = coex_is_in_isr_wrapper,
._malloc_internal = malloc_internal_wrapper,
._free = free,
._esp_timer_get_time = esp_timer_get_time,
._magic = COEX_ADAPTER_MAGIC,
};

Wyświetl plik

@ -1,16 +1,8 @@
// Copyright 2015-2018 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __ESP_COEXIST_H__
#define __ESP_COEXIST_H__
@ -32,6 +24,13 @@ typedef enum {
ESP_COEX_PREFER_NUM, /*!< Prefer value numbers */
} esp_coex_prefer_t;
typedef enum {
EXTERN_COEX_WIRE_1 = 0,
EXTERN_COEX_WIRE_2,
EXTERN_COEX_WIRE_3,
EXTERN_COEX_WIRE_NUM,
} external_coex_wire_t;
/**
* @brief coex status type
*/
@ -41,6 +40,36 @@ typedef enum {
ESP_COEX_ST_TYPE_BT,
} esp_coex_status_type_t;
/**
* @brief external coex gpio pti
*/
typedef struct {
int32_t in_pin0;
int32_t in_pin1;
int32_t out_pin0;
} esp_external_coex_gpio_set_t;
/**
* @brief external coex pti level
*/
typedef enum {
EXTERN_COEX_PTI_MID = 0,
EXTERN_COEX_PTI_HIGH,
EXTERN_COEX_PTI_NUM,
} esp_coex_pti_level_t;
/**
* @brief external coex pti
*/
typedef struct {
uint32_t in_pti1;
uint32_t in_pti2;
uint32_t in_pti3;
uint32_t out_pti1;
uint32_t out_pti2;
uint32_t out_pti3;
} esp_external_coex_pti_set_t;
#define ESP_COEX_BLE_ST_MESH_CONFIG 0x08
#define ESP_COEX_BLE_ST_MESH_TRAFFIC 0x10
#define ESP_COEX_BLE_ST_MESH_STANDBY 0x20
@ -84,6 +113,18 @@ 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);
#if CONFIG_EXTERNAL_COEX_ENABLE
/**
* @brief Setup gpio pin and corresponding pti level, start external coex.
* @param wire_type : to select the whole external coex gpio number.
* @param gpio_pin : gpio pin number to choose.
* @return : ESP_OK - success, other - failed
*/
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_disable_extern_coex_gpio_pin();
#endif
#ifdef __cplusplus
}

Wyświetl plik

@ -1,21 +1,14 @@
// Copyright 2018-2018 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2018-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __ESP_COEXIST_INTERNAL_H__
#define __ESP_COEXIST_INTERNAL_H__
#include <stdbool.h>
#include "esp_coexist.h"
#include "esp_coexist_adapter.h"
#ifdef __cplusplus
@ -210,6 +203,29 @@ int coex_schm_curr_phase_idx_get(void);
*/
esp_err_t esp_coex_adapter_register(coex_adapter_funcs_t *funcs);
#if CONFIG_EXTERNAL_COEX_ENABLE
/**
* @brief Set external coexistence pti level and enable it.
*
* @param level1 external coex low pti
* @param level2 external coex mid pti
* @param level3 external coex high pti
*
* @return
* - ESP_OK: succeed
*/
esp_err_t esp_coex_external_set(esp_coex_pti_level_t level1,
esp_coex_pti_level_t level2, esp_coex_pti_level_t level3);
/**
* @brief Disable external coexist
*
* @return
* - ESP_OK: succeed
*/
void esp_coex_external_stop(void);
#endif /*External Coex*/
/**
* @brief Check the MD5 values of the coexistence adapter header files in IDF and WiFi library
*

@ -1 +1 @@
Subproject commit 6f9d2a11850b9fc0d4fd4ce89c492129e06fd77c
Subproject commit 049fbb7f22962fc4e2316e732ad08fc95b14149f

Wyświetl plik

@ -2,3 +2,4 @@
# CONFIG_DEPRECATED_OPTION CONFIG_NEW_OPTION
CONFIG_SW_COEXIST_ENABLE CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE
CONFIG_EXTERNAL_COEX_ENABLE CONFIG_ESP_WIFI_EXTERNAL_COEXIST_ENABLE

Wyświetl plik

@ -1,20 +1,20 @@
// Copyright 2018-2018 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2018-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "esp_coexist.h"
#include "esp_coexist_internal.h"
#if CONFIG_EXTERNAL_COEX_ENABLE
#include "driver/gpio.h"
#include "esp_rom_gpio.h"
#include "hal/gpio_hal.h"
#include "hal/gpio_types.h"
#include "soc/gpio_periph.h"
#endif
const char *esp_coex_version_get(void)
{
return coex_version_get();
@ -24,3 +24,91 @@ esp_err_t esp_coex_preference_set(esp_coex_prefer_t prefer)
{
return coex_preference_set((coex_prefer_t)prefer);
}
#if CONFIG_EXTERNAL_COEX_ENABLE
#define GPIO_PIN_REG(a) (GPIO_PIN0_REG + a * 0x04)
esp_err_t esp_enable_extern_coex_gpio_pin(external_coex_wire_t wire_type, esp_external_coex_gpio_set_t gpio_pin)
{
switch (wire_type)
{
case EXTERN_COEX_WIRE_3:
{
/*Input gpio pin setup --> GPIO_BT_PRIORITY_IDXGPIO_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, GPIO_BT_ACTIVE_IDX, false);
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);
esp_rom_gpio_connect_in_signal(gpio_pin.in_pin1, GPIO_BT_PRIORITY_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, GPIO_WLAN_ACTIVE_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);
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);
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;
}
case EXTERN_COEX_WIRE_2:
{
/*Input gpio pin setup --> GPIO_BT_PRIORITY_IDXGPIO_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, GPIO_BT_ACTIVE_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, GPIO_WLAN_ACTIVE_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);
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;
}
case EXTERN_COEX_WIRE_1:
{
/*Input gpio pin setup --> GPIO_BT_PRIORITY_IDXGPIO_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, GPIO_BT_ACTIVE_IDX, 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);
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;
}
default:
{
return ESP_FAIL;
}
}
return ESP_OK;
}
esp_err_t esp_disable_extern_coex_gpio_pin()
{
esp_coex_external_stop();
return ESP_OK;
}
#endif/*External Coex*/

Wyświetl plik

@ -1,16 +1,8 @@
// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <esp_event.h>
#include <esp_wifi.h>
@ -237,7 +229,7 @@ esp_err_t esp_wifi_init(const wifi_init_config_t *config)
ESP_LOGW(TAG, "Failed to set default Wi-Fi event handlers (0x%x)", err);
}
#endif
#if CONFIG_SW_COEXIST_ENABLE
#if CONFIG_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE
coex_init();
#endif
esp_wifi_set_log_level();

Wyświetl plik

@ -332,5 +332,7 @@
#define SOC_PM_SUPPORT_TOUCH_SENSOR_WAKEUP (1) /*!<Supports waking up from touch pad trigger */
/*-------------------------- COEXISTENCE HARDWARE PTI CAPS -------------------------------*/
#define SOC_COEX_HW_PTI (1)
/* ---------------------------- Compatibility ------------------------------- */
// No contents

Wyświetl plik

@ -19,6 +19,7 @@
#include "esp_netif.h"
#include "esp_event.h"
#include "iperf.h"
#include "esp_coexist.h"
typedef struct {
struct arg_str *ip;
@ -142,6 +143,16 @@ void initialise_wifi(void)
ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM) );
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_NULL) );
ESP_ERROR_CHECK(esp_wifi_start() );
#if CONFIG_EXTERNAL_COEX_ENABLE
esp_external_coex_gpio_set_t gpio_pin;
gpio_pin.in_pin0 = 1;
gpio_pin.in_pin1 = 2;
gpio_pin.out_pin0 = 3;
ESP_ERROR_CHECK( esp_enable_extern_coex_gpio_pin(EXTERN_COEX_WIRE_3, gpio_pin) );
#endif
initialized = true;
}

Wyświetl plik

@ -1178,7 +1178,6 @@ components/esp_system/port/soc/esp32s3/reset_reason.c
components/esp_system/port/soc/esp32s3/system_internal.c
components/esp_system/port/soc/esp32s3/usb_console.c
components/esp_system/stack_check.c
components/esp_system/startup.c
components/esp_system/system_time.c
components/esp_system/task_wdt.c
components/esp_system/test/test_delay.c
@ -1207,12 +1206,8 @@ components/esp_websocket_client/esp_websocket_client.c
components/esp_websocket_client/include/esp_websocket_client.h
components/esp_websocket_client/test/test_websocket_client.c
components/esp_wifi/esp32/esp_adapter.c
components/esp_wifi/esp32c3/esp_adapter.c
components/esp_wifi/esp32s2/esp_adapter.c
components/esp_wifi/esp32s3/esp_adapter.c
components/esp_wifi/include/esp_coexist.h
components/esp_wifi/include/esp_coexist_adapter.h
components/esp_wifi/include/esp_coexist_internal.h
components/esp_wifi/include/esp_mesh.h
components/esp_wifi/include/esp_mesh_internal.h
components/esp_wifi/include/esp_now.h
@ -1227,13 +1222,11 @@ components/esp_wifi/include/esp_wifi_crypto_types.h
components/esp_wifi/include/esp_wifi_default.h
components/esp_wifi/include/esp_wifi_netif.h
components/esp_wifi/include/smartconfig_ack.h
components/esp_wifi/src/coexist.c
components/esp_wifi/src/lib_printf.c
components/esp_wifi/src/mesh_event.c
components/esp_wifi/src/smartconfig.c
components/esp_wifi/src/smartconfig_ack.c
components/esp_wifi/src/wifi_default.c
components/esp_wifi/src/wifi_init.c
components/esp_wifi/src/wifi_netif.c
components/esp_wifi/test/test_wifi.c
components/esp_wifi/test/test_wifi_init.c