Skip to content

Commit 6f8c76d

Browse files
author
Jiang Jiang Jian
committed
Merge branch 'feat/support_setting_event_for_154_txrx' into 'master'
feat(15.4): support setting 15.4 txrx pti when coex is enabled See merge request espressif/esp-idf!35207
2 parents d0ffd25 + bd2480b commit 6f8c76d

17 files changed

+258
-12
lines changed
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
/*
2-
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66
#ifndef __COEXIST_I154_H__
77
#define __COEXIST_I154_H__
88

9-
#ifdef CONFIG_SOC_IEEE802154_SUPPORTED
109
typedef enum {
1110
IEEE802154_HIGH = 1,
1211
IEEE802154_MIDDLE,
@@ -15,11 +14,16 @@ typedef enum {
1514
IEEE802154_EVENT_MAX,
1615
} ieee802154_coex_event_t;
1716

17+
typedef struct {
18+
ieee802154_coex_event_t idle;
19+
ieee802154_coex_event_t txrx;
20+
ieee802154_coex_event_t txrx_at;
21+
} esp_ieee802154_coex_config_t;
22+
1823
void esp_coex_ieee802154_txrx_pti_set(ieee802154_coex_event_t event);
1924
void esp_coex_ieee802154_ack_pti_set(ieee802154_coex_event_t event);
2025
void esp_coex_ieee802154_coex_break_notify(void);
2126
void esp_coex_ieee802154_extcoex_tx_stage(void);
2227
void esp_coex_ieee802154_extcoex_rx_stage(void);
23-
#endif
2428

2529
#endif

components/ieee802154/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,6 @@ idf_component_register(
3535
INCLUDE_DIRS "${include}"
3636
PRIV_INCLUDE_DIRS "${private_include}"
3737
LDFRAGMENTS linker.lf
38-
PRIV_REQUIRES esp_phy esp_timer esp_coex soc hal esp_pm
38+
REQUIRES esp_coex
39+
PRIV_REQUIRES esp_phy esp_timer soc hal esp_pm
3940
)

components/ieee802154/driver/esp_ieee802154_util.c

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -22,20 +22,39 @@ uint8_t ieee802154_channel_to_freq(uint8_t channel)
2222
}
2323

2424
#if !CONFIG_IEEE802154_TEST && (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE)
25+
26+
esp_ieee802154_coex_config_t s_coex_config = {
27+
.idle = IEEE802154_IDLE,
28+
.txrx = IEEE802154_LOW,
29+
.txrx_at = IEEE802154_MIDDLE,
30+
};
31+
32+
void ieee802154_set_coex_config(esp_ieee802154_coex_config_t config)
33+
{
34+
s_coex_config.idle = config.idle;
35+
s_coex_config.txrx = config.txrx;
36+
s_coex_config.txrx_at = config.txrx_at;
37+
}
38+
39+
esp_ieee802154_coex_config_t ieee802154_get_coex_config(void)
40+
{
41+
return s_coex_config;
42+
}
43+
2544
void ieee802154_set_txrx_pti(ieee802154_txrx_scene_t txrx_scene)
2645
{
2746

2847
switch (txrx_scene) {
2948
case IEEE802154_SCENE_IDLE:
30-
esp_coex_ieee802154_txrx_pti_set(IEEE802154_IDLE);
49+
esp_coex_ieee802154_txrx_pti_set(s_coex_config.idle);
3150
break;
3251
case IEEE802154_SCENE_TX:
3352
case IEEE802154_SCENE_RX:
34-
esp_coex_ieee802154_txrx_pti_set(IEEE802154_LOW);
53+
esp_coex_ieee802154_txrx_pti_set(s_coex_config.txrx);
3554
break;
3655
case IEEE802154_SCENE_TX_AT:
3756
case IEEE802154_SCENE_RX_AT:
38-
esp_coex_ieee802154_txrx_pti_set(IEEE802154_MIDDLE);
57+
esp_coex_ieee802154_txrx_pti_set(s_coex_config.txrx_at);
3958
break;
4059
default:
4160
assert(false);

components/ieee802154/esp_ieee802154.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,3 +471,15 @@ void esp_ieee802154_record_print(void)
471471
ieee802154_record_print();
472472
}
473473
#endif // CONFIG_IEEE802154_RECORD
474+
475+
#if !CONFIG_IEEE802154_TEST && (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE)
476+
void esp_ieee802154_set_coex_config(esp_ieee802154_coex_config_t config)
477+
{
478+
ieee802154_set_coex_config(config);
479+
}
480+
481+
esp_ieee802154_coex_config_t esp_ieee802154_get_coex_config(void)
482+
{
483+
return ieee802154_get_coex_config();
484+
}
485+
#endif

components/ieee802154/include/esp_ieee802154.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
#include "esp_err.h"
1313
#include "esp_ieee802154_types.h"
1414

15+
#if !CONFIG_IEEE802154_TEST && (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE)
16+
#include "esp_coex_i154.h"
17+
#endif
18+
1519
#ifdef __cplusplus
1620
extern "C" {
1721
#endif
@@ -699,6 +703,27 @@ void esp_ieee802154_rx_buffer_statistic_print(void);
699703
*/
700704
void esp_ieee802154_record_print(void);
701705
#endif // CONFIG_IEEE802154_RECORD
706+
707+
#if !CONFIG_IEEE802154_TEST && (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE)
708+
709+
/**
710+
* @brief Set the IEEE802.15.4 coexist config.
711+
*
712+
* @param[in] config The config of IEEE802.15.4 coexist.
713+
*
714+
*/
715+
void esp_ieee802154_set_coex_config(esp_ieee802154_coex_config_t config);
716+
717+
/**
718+
* @brief Get the IEEE802.15.4 coexist config.
719+
*
720+
* @return
721+
* - The config of IEEE802.15.4 coexist.
722+
*
723+
*/
724+
esp_ieee802154_coex_config_t esp_ieee802154_get_coex_config(void);
725+
#endif
726+
702727
#ifdef __cplusplus
703728
}
704729
#endif

components/ieee802154/private_include/esp_ieee802154_util.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,26 @@ void ieee802154_etm_set_event_task(uint32_t channel, uint32_t event, uint32_t ta
368368
*/
369369
void ieee802154_etm_channel_clear(uint32_t channel);
370370

371+
#if !CONFIG_IEEE802154_TEST && (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE)
372+
373+
/**
374+
* @brief Set the IEEE802.15.4 coexist config.
375+
*
376+
* @param[in] config The config of IEEE802.15.4 coexist.
377+
*
378+
*/
379+
void ieee802154_set_coex_config(esp_ieee802154_coex_config_t config);
380+
381+
/**
382+
* @brief Get the IEEE802.15.4 coexist config.
383+
*
384+
* @return
385+
* - The config of IEEE802.15.4 coexist.
386+
*
387+
*/
388+
esp_ieee802154_coex_config_t ieee802154_get_coex_config(void);
389+
#endif
390+
371391
#ifdef __cplusplus
372392
}
373393
#endif

components/openthread/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ idf_component_register(SRC_DIRS "${src_dirs}"
274274
PRIV_INCLUDE_DIRS "${private_include_dirs}"
275275
REQUIRES esp_netif lwip esp_driver_uart driver
276276
LDFRAGMENTS linker.lf
277-
PRIV_REQUIRES console esp_event esp_partition esp_timer
277+
PRIV_REQUIRES console esp_coex esp_event esp_partition esp_timer
278278
ieee802154 mbedtls nvs_flash)
279279

280280
if(CONFIG_OPENTHREAD_RADIO_TREL)

components/openthread/private_include/esp_openthread_ncp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@
1212

1313
#define SPINEL_PROP_VENDOR_ESP_SET_PENDINGMODE (SPINEL_PROP_VENDOR_ESP__BEGIN + 2)
1414

15+
#define SPINEL_PROP_VENDOR_ESP_COEX_EVENT (SPINEL_PROP_VENDOR_ESP__BEGIN + 3)
16+
1517
#endif

components/openthread/private_include/esp_openthread_radio.h

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -12,6 +12,10 @@
1212
#include "esp_openthread_types.h"
1313
#include "openthread/instance.h"
1414

15+
#if !CONFIG_IEEE802154_TEST && (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE)
16+
#include "esp_coex_i154.h"
17+
#endif
18+
1519
#ifdef __cplusplus
1620
extern "C" {
1721
#endif
@@ -53,6 +57,27 @@ void esp_openthread_radio_update(esp_openthread_mainloop_context_t *mainloop);
5357
*/
5458
esp_err_t esp_openthread_radio_process(otInstance *instance, const esp_openthread_mainloop_context_t *mainloop);
5559

60+
61+
#if !CONFIG_IEEE802154_TEST && (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE)
62+
63+
/**
64+
* @brief Set the coexist config.
65+
*
66+
* @param[in] config The config of coexist.
67+
*
68+
*/
69+
void esp_openthread_set_coex_config(esp_ieee802154_coex_config_t config);
70+
71+
/**
72+
* @brief Get the coexist config.
73+
*
74+
* @return
75+
* - The config of coexist.
76+
*
77+
*/
78+
esp_ieee802154_coex_config_t esp_openthread_get_coex_config(void);
79+
#endif
80+
5681
#ifdef __cplusplus
5782
}
5883
#endif

components/openthread/private_include/openthread-core-esp32x-ftd-config.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,17 @@
493493
#ifndef OPENTHREAD_POSIX_CONFIG_RCP_TIME_SYNC_INTERVAL
494494
#define OPENTHREAD_POSIX_CONFIG_RCP_TIME_SYNC_INTERVAL (60 * 1000 * 1000)
495495
#endif
496+
497+
#if !CONFIG_IEEE802154_TEST && (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE)
498+
/**
499+
* @def OPENTHREAD_SPINEL_CONFIG_VENDOR_HOOK_ENABLE
500+
*
501+
* Enables compilation of vendor specific code for Spinel
502+
*/
503+
#ifndef OPENTHREAD_SPINEL_CONFIG_VENDOR_HOOK_ENABLE
504+
#define OPENTHREAD_SPINEL_CONFIG_VENDOR_HOOK_ENABLE 1
505+
#endif
506+
#endif
496507
#endif // !CONFIG_OPENTHREAD_RADIO_NATIVE
497508

498509
#if CONFIG_OPENTHREAD_LINK_METRICS

components/openthread/private_include/openthread-core-esp32x-spinel-config.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,15 @@
5050
#define OPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT 3
5151
#endif
5252

53+
/**
54+
* @def OPENTHREAD_SPINEL_CONFIG_VENDOR_HOOK_ENABLE
55+
*
56+
* Enables compilation of vendor specific code for Spinel
57+
*/
5358
#ifndef OPENTHREAD_SPINEL_CONFIG_VENDOR_HOOK_ENABLE
5459
#define OPENTHREAD_SPINEL_CONFIG_VENDOR_HOOK_ENABLE 1
5560
#endif
5661

57-
5862
/**
5963
* @def OPENTHREAD_SPINEL_CONFIG_COMPATIBILITY_ERROR_CALLBACK_ENABLE
6064
*

components/openthread/src/ncp/esp_openthread_ncp.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
#include "esp_openthread_ncp.h"
1010
#include "ncp_base.hpp"
1111

12+
#if !CONFIG_IEEE802154_TEST && (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE)
13+
#include "esp_coex_i154.h"
14+
#endif
15+
1216
#if CONFIG_OPENTHREAD_RCP_UART
1317
#include "utils/uart.h"
1418
#endif
@@ -65,6 +69,16 @@ otError NcpBase::VendorGetPropertyHandler(spinel_prop_key_t aPropKey)
6569

6670
switch (aPropKey)
6771
{
72+
case SPINEL_PROP_VENDOR_ESP_COEX_EVENT: {
73+
#if !CONFIG_IEEE802154_TEST && (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE)
74+
esp_ieee802154_coex_config_t config = esp_ieee802154_get_coex_config();
75+
const uint8_t *args = reinterpret_cast<const uint8_t *>(&config);
76+
error = mEncoder.WriteDataWithLen(args, sizeof(esp_ieee802154_coex_config_t));
77+
#else
78+
error = OT_ERROR_NOT_IMPLEMENTED;
79+
#endif
80+
break;
81+
}
6882

6983
default:
7084
error = OT_ERROR_NOT_FOUND;
@@ -95,6 +109,23 @@ otError NcpBase::VendorSetPropertyHandler(spinel_prop_key_t aPropKey)
95109
esp_ieee802154_set_pending_mode(static_cast<esp_ieee802154_pending_mode_t>(pending_mode));
96110
break;
97111
}
112+
case SPINEL_PROP_VENDOR_ESP_COEX_EVENT: {
113+
#if !CONFIG_IEEE802154_TEST && (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE)
114+
const uint8_t *args = nullptr;
115+
uint16_t len = 0;
116+
mDecoder.ReadDataWithLen(args, len);
117+
if (len == sizeof(esp_ieee802154_coex_config_t)) {
118+
esp_ieee802154_coex_config_t config;
119+
memcpy(&config, args, len);
120+
esp_ieee802154_set_coex_config(config);
121+
} else {
122+
error = OT_ERROR_INVALID_ARGS;
123+
}
124+
#else
125+
error = OT_ERROR_NOT_IMPLEMENTED;
126+
#endif
127+
break;
128+
}
98129

99130
default:
100131
error = OT_ERROR_NOT_FOUND;

components/openthread/src/port/esp_openthread_radio.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
#include "utils/link_metrics.h"
3333
#include "utils/mac_frame.h"
3434

35+
#if !CONFIG_IEEE802154_TEST && (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE)
36+
#include "esp_coex_i154.h"
37+
#endif
38+
3539
#define ESP_RECEIVE_SENSITIVITY -120
3640
#define ESP_OPENTHREAD_XTAL_ACCURACY CONFIG_OPENTHREAD_XTAL_ACCURACY
3741
#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
@@ -810,3 +814,15 @@ uint32_t otPlatRadioGetSupportedChannelMask(otInstance *aInstance)
810814
OT_UNUSED_VARIABLE(aInstance);
811815
return CONFIG_OPENTHREAD_SUPPORTED_CHANNEL_MASK;
812816
}
817+
818+
#if !CONFIG_IEEE802154_TEST && (CONFIG_ESP_COEX_SW_COEXIST_ENABLE || CONFIG_EXTERNAL_COEX_ENABLE)
819+
void esp_openthread_set_coex_config(esp_ieee802154_coex_config_t config)
820+
{
821+
esp_ieee802154_set_coex_config(config);
822+
}
823+
824+
esp_ieee802154_coex_config_t esp_openthread_get_coex_config(void)
825+
{
826+
return esp_ieee802154_get_coex_config();
827+
}
828+
#endif

0 commit comments

Comments
 (0)