Skip to content

Commit

Permalink
Merge branch 'feat/support_setting_event_for_154_txrx_5_1' into 'rele…
Browse files Browse the repository at this point in the history
…ase/v5.1'

feat(15.4): support setting 15.4 txrx pti when coex is enabled (backport to 5.1)

See merge request espressif/esp-idf!36103
  • Loading branch information
chshu committed Jan 6, 2025
2 parents 79f444f + 35ed2be commit 515b025
Show file tree
Hide file tree
Showing 27 changed files with 294 additions and 25 deletions.
10 changes: 7 additions & 3 deletions components/esp_coex/include/esp_coex_i154.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __COEXIST_I154_H__
#define __COEXIST_I154_H__

#ifdef CONFIG_SOC_IEEE802154_SUPPORTED
typedef enum {
IEEE802154_HIGH = 1,
IEEE802154_MIDDLE,
Expand All @@ -15,11 +14,16 @@ typedef enum {
IEEE802154_EVENT_MAX,
} ieee802154_coex_event_t;

typedef struct {
ieee802154_coex_event_t idle;
ieee802154_coex_event_t txrx;
ieee802154_coex_event_t txrx_at;
} esp_ieee802154_coex_config_t;

void esp_coex_ieee802154_txrx_pti_set(ieee802154_coex_event_t event);
void esp_coex_ieee802154_ack_pti_set(ieee802154_coex_event_t event);
void esp_coex_ieee802154_coex_break_notify(void);
void esp_coex_ieee802154_extcoex_tx_stage(void);
void esp_coex_ieee802154_extcoex_rx_stage(void);
#endif

#endif
2 changes: 1 addition & 1 deletion components/esp_coex/include/esp_coexist.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ esp_err_t esp_enable_extern_coex_gpio_pin(external_coex_wire_t wire_type,
* @brief Disable external coex.
* @return : ESP_OK - success, other - failed
*/
esp_err_t esp_disable_extern_coex_gpio_pin();
esp_err_t esp_disable_extern_coex_gpio_pin(void);

#if SOC_EXTERNAL_COEX_ADVANCE
/**
Expand Down
2 changes: 1 addition & 1 deletion components/esp_coex/src/coexist.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ esp_err_t esp_enable_extern_coex_gpio_pin(external_coex_wire_t wire_type, esp_ex
return ESP_OK;
}

esp_err_t esp_disable_extern_coex_gpio_pin()
esp_err_t esp_disable_extern_coex_gpio_pin(void)
{
esp_coex_external_stop();

Expand Down
3 changes: 2 additions & 1 deletion components/ieee802154/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ idf_component_register(
INCLUDE_DIRS "${include}"
PRIV_INCLUDE_DIRS "${private_include}"
LDFRAGMENTS linker.lf
PRIV_REQUIRES esp_phy driver esp_timer esp_coex soc hal
REQUIRES esp_coex
PRIV_REQUIRES esp_phy driver esp_timer soc hal
)
27 changes: 23 additions & 4 deletions components/ieee802154/driver/esp_ieee802154_util.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand All @@ -22,20 +22,39 @@ uint8_t ieee802154_channel_to_freq(uint8_t channel)
}

#if !CONFIG_IEEE802154_TEST && (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE)

esp_ieee802154_coex_config_t s_coex_config = {
.idle = IEEE802154_IDLE,
.txrx = IEEE802154_LOW,
.txrx_at = IEEE802154_MIDDLE,
};

void ieee802154_set_coex_config(esp_ieee802154_coex_config_t config)
{
s_coex_config.idle = config.idle;
s_coex_config.txrx = config.txrx;
s_coex_config.txrx_at = config.txrx_at;
}

esp_ieee802154_coex_config_t ieee802154_get_coex_config(void)
{
return s_coex_config;
}

void ieee802154_set_txrx_pti(ieee802154_txrx_scene_t txrx_scene)
{

switch (txrx_scene) {
case IEEE802154_SCENE_IDLE:
esp_coex_ieee802154_txrx_pti_set(IEEE802154_IDLE);
esp_coex_ieee802154_txrx_pti_set(s_coex_config.idle);
break;
case IEEE802154_SCENE_TX:
case IEEE802154_SCENE_RX:
esp_coex_ieee802154_txrx_pti_set(IEEE802154_LOW);
esp_coex_ieee802154_txrx_pti_set(s_coex_config.txrx);
break;
case IEEE802154_SCENE_TX_AT:
case IEEE802154_SCENE_RX_AT:
esp_coex_ieee802154_txrx_pti_set(IEEE802154_MIDDLE);
esp_coex_ieee802154_txrx_pti_set(s_coex_config.txrx_at);
break;
default:
assert(false);
Expand Down
14 changes: 13 additions & 1 deletion components/ieee802154/esp_ieee802154.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -471,3 +471,15 @@ void esp_ieee802154_record_print(void)
ieee802154_record_print();
}
#endif // CONFIG_IEEE802154_RECORD

#if !CONFIG_IEEE802154_TEST && (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE)
void esp_ieee802154_set_coex_config(esp_ieee802154_coex_config_t config)
{
ieee802154_set_coex_config(config);
}

esp_ieee802154_coex_config_t esp_ieee802154_get_coex_config(void)
{
return ieee802154_get_coex_config();
}
#endif
27 changes: 26 additions & 1 deletion components/ieee802154/include/esp_ieee802154.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand All @@ -12,6 +12,10 @@
#include "esp_err.h"
#include "esp_ieee802154_types.h"

#if !CONFIG_IEEE802154_TEST && (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE)
#include "esp_coex_i154.h"
#endif

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -699,6 +703,27 @@ void esp_ieee802154_rx_buffer_statistic_print(void);
*/
void esp_ieee802154_record_print(void);
#endif // CONFIG_IEEE802154_RECORD

#if !CONFIG_IEEE802154_TEST && (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE)

/**
* @brief Set the IEEE802.15.4 coexist config.
*
* @param[in] config The config of IEEE802.15.4 coexist.
*
*/
void esp_ieee802154_set_coex_config(esp_ieee802154_coex_config_t config);

/**
* @brief Get the IEEE802.15.4 coexist config.
*
* @return
* - The config of IEEE802.15.4 coexist.
*
*/
esp_ieee802154_coex_config_t esp_ieee802154_get_coex_config(void);
#endif

#ifdef __cplusplus
}
#endif
22 changes: 21 additions & 1 deletion components/ieee802154/private_include/esp_ieee802154_util.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -368,6 +368,26 @@ void ieee802154_etm_set_event_task(uint32_t channel, uint32_t event, uint32_t ta
*/
void ieee802154_etm_channel_clear(uint32_t channel);

#if !CONFIG_IEEE802154_TEST && (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE)

/**
* @brief Set the IEEE802.15.4 coexist config.
*
* @param[in] config The config of IEEE802.15.4 coexist.
*
*/
void ieee802154_set_coex_config(esp_ieee802154_coex_config_t config);

/**
* @brief Get the IEEE802.15.4 coexist config.
*
* @return
* - The config of IEEE802.15.4 coexist.
*
*/
esp_ieee802154_coex_config_t ieee802154_get_coex_config(void);
#endif

#ifdef __cplusplus
}
#endif
2 changes: 1 addition & 1 deletion components/openthread/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ idf_component_register(SRC_DIRS "${src_dirs}"
PRIV_INCLUDE_DIRS "${private_include_dirs}"
REQUIRES esp_netif lwip driver
LDFRAGMENTS linker.lf
PRIV_REQUIRES console esp_event esp_partition esp_timer
PRIV_REQUIRES console esp_coex esp_event esp_partition esp_timer
ieee802154 mbedtls nvs_flash)

if(CONFIG_OPENTHREAD_RADIO_TREL)
Expand Down
2 changes: 1 addition & 1 deletion components/openthread/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ menu "OpenThread"

menu "Thread Memory Allocation"
depends on (SPIRAM_USE_CAPS_ALLOC || SPIRAM_USE_MALLOC)
config OPENTHREAD_MEM_ALLOC_EXTERNAL
config OPENTHREAD_PLATFORM_MALLOC_CAP_SPIRAM
bool 'Allocate memory from PSRAM'
default y
help
Expand Down
2 changes: 2 additions & 0 deletions components/openthread/private_include/esp_openthread_ncp.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@

#define SPINEL_PROP_VENDOR_ESP_SET_PENDINGMODE (SPINEL_PROP_VENDOR_ESP__BEGIN + 2)

#define SPINEL_PROP_VENDOR_ESP_COEX_EVENT (SPINEL_PROP_VENDOR_ESP__BEGIN + 3)

#endif
27 changes: 26 additions & 1 deletion components/openthread/private_include/esp_openthread_radio.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand All @@ -12,6 +12,10 @@
#include "esp_openthread_types.h"
#include "openthread/instance.h"

#if !CONFIG_IEEE802154_TEST && (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE)
#include "esp_coex_i154.h"
#endif

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -53,6 +57,27 @@ void esp_openthread_radio_update(esp_openthread_mainloop_context_t *mainloop);
*/
esp_err_t esp_openthread_radio_process(otInstance *instance, const esp_openthread_mainloop_context_t *mainloop);


#if !CONFIG_IEEE802154_TEST && (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE)

/**
* @brief Set the coexist config.
*
* @param[in] config The config of coexist.
*
*/
void esp_openthread_set_coex_config(esp_ieee802154_coex_config_t config);

/**
* @brief Get the coexist config.
*
* @return
* - The config of coexist.
*
*/
esp_ieee802154_coex_config_t esp_openthread_get_coex_config(void);
#endif

#ifdef __cplusplus
}
#endif
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -493,6 +493,17 @@
#ifndef OPENTHREAD_POSIX_CONFIG_RCP_TIME_SYNC_INTERVAL
#define OPENTHREAD_POSIX_CONFIG_RCP_TIME_SYNC_INTERVAL (60 * 1000 * 1000)
#endif

#if !CONFIG_IEEE802154_TEST && (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE)
/**
* @def OPENTHREAD_SPINEL_CONFIG_VENDOR_HOOK_ENABLE
*
* Enables compilation of vendor specific code for Spinel
*/
#ifndef OPENTHREAD_SPINEL_CONFIG_VENDOR_HOOK_ENABLE
#define OPENTHREAD_SPINEL_CONFIG_VENDOR_HOOK_ENABLE 1
#endif
#endif
#endif // !CONFIG_OPENTHREAD_RADIO_NATIVE

#if CONFIG_OPENTHREAD_LINK_METRICS
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -50,11 +50,15 @@
#define OPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT 3
#endif

/**
* @def OPENTHREAD_SPINEL_CONFIG_VENDOR_HOOK_ENABLE
*
* Enables compilation of vendor specific code for Spinel
*/
#ifndef OPENTHREAD_SPINEL_CONFIG_VENDOR_HOOK_ENABLE
#define OPENTHREAD_SPINEL_CONFIG_VENDOR_HOOK_ENABLE 1
#endif


/**
* @def OPENTHREAD_SPINEL_CONFIG_COMPATIBILITY_ERROR_CALLBACK_ENABLE
*
Expand Down
33 changes: 32 additions & 1 deletion components/openthread/src/ncp/esp_openthread_ncp.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand All @@ -9,6 +9,10 @@
#include "esp_openthread_ncp.h"
#include "ncp_base.hpp"

#if !CONFIG_IEEE802154_TEST && (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE)
#include "esp_coex_i154.h"
#endif

#if CONFIG_OPENTHREAD_RCP_UART
#include "utils/uart.h"
#endif
Expand Down Expand Up @@ -65,6 +69,16 @@ otError NcpBase::VendorGetPropertyHandler(spinel_prop_key_t aPropKey)

switch (aPropKey)
{
case SPINEL_PROP_VENDOR_ESP_COEX_EVENT: {
#if !CONFIG_IEEE802154_TEST && (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE)
esp_ieee802154_coex_config_t config = esp_ieee802154_get_coex_config();
const uint8_t *args = reinterpret_cast<const uint8_t *>(&config);
error = mEncoder.WriteDataWithLen(args, sizeof(esp_ieee802154_coex_config_t));
#else
error = OT_ERROR_NOT_IMPLEMENTED;
#endif
break;
}

default:
error = OT_ERROR_NOT_FOUND;
Expand Down Expand Up @@ -95,6 +109,23 @@ otError NcpBase::VendorSetPropertyHandler(spinel_prop_key_t aPropKey)
esp_ieee802154_set_pending_mode(static_cast<esp_ieee802154_pending_mode_t>(pending_mode));
break;
}
case SPINEL_PROP_VENDOR_ESP_COEX_EVENT: {
#if !CONFIG_IEEE802154_TEST && (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE)
const uint8_t *args = nullptr;
uint16_t len = 0;
mDecoder.ReadDataWithLen(args, len);
if (len == sizeof(esp_ieee802154_coex_config_t)) {
esp_ieee802154_coex_config_t config;
memcpy(&config, args, len);
esp_ieee802154_set_coex_config(config);
} else {
error = OT_ERROR_INVALID_ARGS;
}
#else
error = OT_ERROR_NOT_IMPLEMENTED;
#endif
break;
}

default:
error = OT_ERROR_NOT_FOUND;
Expand Down
Loading

0 comments on commit 515b025

Please sign in to comment.