fix(openthread): turn off rx for SSED running CSL during idle

This commit is contained in:
Tan Yan Quan
2025-03-25 12:06:18 +08:00
parent 8685219916
commit dc2500bd08
12 changed files with 300 additions and 104 deletions
+5 -3
View File
@@ -259,6 +259,7 @@ menu "OpenThread"
config OPENTHREAD_LINK_METRICS
bool "Enable link metrics feature"
default n
select IEEE802154_TIMING_OPTIMIZATION if IEEE802154_ENABLED
help
Select this option to enable link metrics feature
@@ -271,6 +272,7 @@ menu "OpenThread"
config OPENTHREAD_CSL_ENABLE
bool "Enable CSL feature"
default n
select IEEE802154_TIMING_OPTIMIZATION if IEEE802154_ENABLED
help
Select this option to enable CSL feature
menu "CSL Configurations"
@@ -278,13 +280,13 @@ menu "OpenThread"
config OPENTHREAD_CSL_ACCURACY
int "The current CSL rx/tx scheduling drift, in units of ± ppm"
default 1
default 20
help
The current accuracy of the clock used for scheduling CSL operations
config OPENTHREAD_CSL_UNCERTAIN
int "The CSL Uncertainty in units of 10 us."
default 1
default 0
help
The fixed uncertainty of the Device for scheduling CSL Transmissions in units of 10 microseconds.
@@ -374,7 +376,7 @@ menu "OpenThread"
config OPENTHREAD_XTAL_ACCURACY
int "The accuracy of the XTAL"
default 130
default 10
help
The device's XTAL accuracy, in ppm.
@@ -726,11 +726,21 @@
/**
* @def OPENTHREAD_CONFIG_MAC_CSL_REQUEST_AHEAD_US
*
* Define as 1 to set the ahead time for CSL transmit timing.
* Define how many microseconds ahead should MAC deliver CSL frame to SubMac.
*
*/
#ifndef OPENTHREAD_CONFIG_MAC_CSL_REQUEST_AHEAD_US
#define OPENTHREAD_CONFIG_MAC_CSL_REQUEST_AHEAD_US 20000
#define OPENTHREAD_CONFIG_MAC_CSL_REQUEST_AHEAD_US (2 * 1000000 / CONFIG_FREERTOS_HZ)
#endif
/**
* @def OPENTHREAD_CONFIG_CSL_RECEIVE_TIME_AHEAD
*
* Reception scheduling and ramp up time needed for the CSL receiver to be ready, in units of microseconds.
*
*/
#ifndef OPENTHREAD_CONFIG_CSL_RECEIVE_TIME_AHEAD
#define OPENTHREAD_CONFIG_CSL_RECEIVE_TIME_AHEAD (OPENTHREAD_CONFIG_MAC_CSL_REQUEST_AHEAD_US + 320)
#endif
/**
@@ -400,3 +400,52 @@
#ifndef OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_MARK_ECN_INTERVAL
#define OPENTHREAD_CONFIG_DELAY_AWARE_QUEUE_MANAGEMENT_MARK_ECN_INTERVAL 1000
#endif
#ifdef OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
#error `OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE` is redefined.
#endif
#if CONFIG_OPENTHREAD_CSL_ENABLE
/**
* @def OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
*
* Define as 1 to support Thread 1.2 CSL feature.
*
*/
#define OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE 1
/**
* @def OPENTHREAD_CONFIG_MAC_CSL_DEBUG_ENABLE
*
* Define as 1 to enable support Thread 1.2 CSL debug.
*
*/
#ifdef OPENTHREAD_CONFIG_MAC_CSL_DEBUG_ENABLE
#error `OPENTHREAD_CONFIG_MAC_CSL_DEBUG_ENABLE` is redefined.
#endif
#define OPENTHREAD_CONFIG_MAC_CSL_DEBUG_ENABLE CONFIG_OPENTHREAD_CSL_DEBUG_ENABLE
#else
#define OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE 0
#endif // CONFIG_OPENTHREAD_CSL_ENABLE
/**
* @def OPENTHREAD_CONFIG_MAC_CSL_REQUEST_AHEAD_US
*
* Define how many microseconds ahead should MAC deliver CSL frame to SubMac.
*
*/
#ifndef OPENTHREAD_CONFIG_MAC_CSL_REQUEST_AHEAD_US
#define OPENTHREAD_CONFIG_MAC_CSL_REQUEST_AHEAD_US (2 * 1000000 / CONFIG_FREERTOS_HZ)
#endif
/**
* @def OPENTHREAD_CONFIG_CSL_RECEIVE_TIME_AHEAD
*
* Reception scheduling and ramp up time needed for the CSL receiver to be ready, in units of microseconds.
*
*/
#ifndef OPENTHREAD_CONFIG_CSL_RECEIVE_TIME_AHEAD
#define OPENTHREAD_CONFIG_CSL_RECEIVE_TIME_AHEAD (OPENTHREAD_CONFIG_MAC_CSL_REQUEST_AHEAD_US + 320)
#endif
@@ -47,6 +47,7 @@
#define EVENT_TX_FAILED (1 << 1)
#define EVENT_RX_DONE (1 << 2)
#define EVENT_ENERGY_DETECT_DONE (1 << 3)
#define EVENT_SLEEP (1 << 4)
typedef struct {
uint8_t length;
@@ -241,6 +242,11 @@ esp_err_t esp_openthread_radio_process(otInstance *aInstance, const esp_openthre
}
}
if (get_event(EVENT_SLEEP)) {
clr_event(EVENT_SLEEP);
esp_ieee802154_sleep();
}
return ESP_OK;
}
@@ -312,7 +318,11 @@ otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame)
aFrame->mPsdu[-1] = aFrame->mLength; // length locates one byte before the psdu (esp_openthread_radio_tx_psdu);
if (otMacFrameIsSecurityEnabled(aFrame) && !aFrame->mInfo.mTxInfo.mIsSecurityProcessed) {
#if OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
if (!s_transmit_frame.mInfo.mTxInfo.mIsARetx || s_csl_period > 0) {
#else
if (!s_transmit_frame.mInfo.mTxInfo.mIsARetx) {
#endif // OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE
otMacFrameSetFrameCounter(aFrame, s_mac_frame_counter++);
}
if (otMacFrameIsKeyIdMode1(aFrame)) {
@@ -362,7 +372,8 @@ otRadioCaps otPlatRadioGetCaps(otInstance *aInstance)
otError otPlatRadioReceiveAt(otInstance *aInstance, uint8_t aChannel, uint32_t aStart, uint32_t aDuration)
{
esp_ieee802154_receive_at((aStart + aDuration));
esp_ieee802154_set_channel(aChannel);
esp_ieee802154_receive_at(aStart, aDuration);
return OT_ERROR_NONE;
}
@@ -826,3 +837,8 @@ esp_ieee802154_coex_config_t esp_openthread_get_coex_config(void)
return esp_ieee802154_get_coex_config();
}
#endif
void esp_ieee802154_receive_at_done(void)
{
set_event(EVENT_SLEEP);
}