mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/ieee802154_deinit_v5.2' into 'release/v5.2'
Bugfix/ieee802154 deinit (Backport v5.2) See merge request espressif/esp-idf!27974
This commit is contained in:
commit
9d2d1e2d39
@ -2,7 +2,7 @@ menu "IEEE 802.15.4"
|
|||||||
visible if SOC_IEEE802154_SUPPORTED
|
visible if SOC_IEEE802154_SUPPORTED
|
||||||
|
|
||||||
config IEEE802154_ENABLED
|
config IEEE802154_ENABLED
|
||||||
bool
|
bool "IEEE802154 Enable"
|
||||||
default "y" if SOC_IEEE802154_SUPPORTED
|
default "y" if SOC_IEEE802154_SUPPORTED
|
||||||
|
|
||||||
config IEEE802154_RX_BUFFER_SIZE
|
config IEEE802154_RX_BUFFER_SIZE
|
||||||
@ -14,6 +14,7 @@ menu "IEEE 802.15.4"
|
|||||||
The number of 802.15.4 receive buffers
|
The number of 802.15.4 receive buffers
|
||||||
|
|
||||||
choice IEEE802154_CCA_MODE
|
choice IEEE802154_CCA_MODE
|
||||||
|
depends on IEEE802154_ENABLED
|
||||||
prompt "Clear Channel Assessment (CCA) mode"
|
prompt "Clear Channel Assessment (CCA) mode"
|
||||||
default IEEE802154_CCA_ED
|
default IEEE802154_CCA_ED
|
||||||
help
|
help
|
||||||
@ -41,6 +42,7 @@ menu "IEEE 802.15.4"
|
|||||||
endchoice
|
endchoice
|
||||||
|
|
||||||
config IEEE802154_CCA_MODE
|
config IEEE802154_CCA_MODE
|
||||||
|
depends on IEEE802154_ENABLED
|
||||||
int
|
int
|
||||||
default 0 if IEEE802154_CCA_CARRIER
|
default 0 if IEEE802154_CCA_CARRIER
|
||||||
default 1 if IEEE802154_CCA_ED
|
default 1 if IEEE802154_CCA_ED
|
||||||
@ -49,6 +51,7 @@ menu "IEEE 802.15.4"
|
|||||||
|
|
||||||
config IEEE802154_CCA_THRESHOLD
|
config IEEE802154_CCA_THRESHOLD
|
||||||
int "CCA detection threshold"
|
int "CCA detection threshold"
|
||||||
|
depends on IEEE802154_ENABLED
|
||||||
range -120 0
|
range -120 0
|
||||||
default -60
|
default -60
|
||||||
help
|
help
|
||||||
@ -56,6 +59,7 @@ menu "IEEE 802.15.4"
|
|||||||
|
|
||||||
config IEEE802154_PENDING_TABLE_SIZE
|
config IEEE802154_PENDING_TABLE_SIZE
|
||||||
int "Pending table size"
|
int "Pending table size"
|
||||||
|
depends on IEEE802154_ENABLED
|
||||||
range 1 100
|
range 1 100
|
||||||
default 20
|
default 20
|
||||||
help
|
help
|
||||||
@ -63,12 +67,14 @@ menu "IEEE 802.15.4"
|
|||||||
|
|
||||||
config IEEE802154_MULTI_PAN_ENABLE
|
config IEEE802154_MULTI_PAN_ENABLE
|
||||||
bool "Enable multi-pan feature for frame filter"
|
bool "Enable multi-pan feature for frame filter"
|
||||||
|
depends on IEEE802154_ENABLED
|
||||||
default n
|
default n
|
||||||
help
|
help
|
||||||
Enable IEEE802154 multi-pan
|
Enable IEEE802154 multi-pan
|
||||||
|
|
||||||
config IEEE802154_TIMING_OPTIMIZATION
|
config IEEE802154_TIMING_OPTIMIZATION
|
||||||
bool "Enable throughput optimization"
|
bool "Enable throughput optimization"
|
||||||
|
depends on IEEE802154_ENABLED
|
||||||
default n
|
default n
|
||||||
help
|
help
|
||||||
Enabling this option increases throughput by ~5% at the expense of ~2.1k
|
Enabling this option increases throughput by ~5% at the expense of ~2.1k
|
||||||
@ -77,7 +83,7 @@ menu "IEEE 802.15.4"
|
|||||||
config IEEE802154_SLEEP_ENABLE
|
config IEEE802154_SLEEP_ENABLE
|
||||||
# Todo: Remove when support safe power-down of the power domain (IDF-7317)
|
# Todo: Remove when support safe power-down of the power domain (IDF-7317)
|
||||||
bool "Enable IEEE802154 light sleep"
|
bool "Enable IEEE802154 light sleep"
|
||||||
depends on PM_ENABLE
|
depends on PM_ENABLE && IEEE802154_ENABLED
|
||||||
default n
|
default n
|
||||||
help
|
help
|
||||||
Enabling this option allows the IEEE802.15.4 module to be powered down during automatic light sleep,
|
Enabling this option allows the IEEE802.15.4 module to be powered down during automatic light sleep,
|
||||||
@ -85,6 +91,7 @@ menu "IEEE 802.15.4"
|
|||||||
|
|
||||||
menuconfig IEEE802154_DEBUG
|
menuconfig IEEE802154_DEBUG
|
||||||
bool "Enable IEEE802154 Debug"
|
bool "Enable IEEE802154 Debug"
|
||||||
|
depends on IEEE802154_ENABLED
|
||||||
default n
|
default n
|
||||||
help
|
help
|
||||||
Enabling this option allows different kinds of IEEE802154 debug output.
|
Enabling this option allows different kinds of IEEE802154 debug output.
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
#include "esp_private/esp_clk.h"
|
#include "esp_private/esp_clk.h"
|
||||||
#include "esp_private/sleep_retention.h"
|
#include "esp_private/sleep_retention.h"
|
||||||
#include "esp_private/sleep_modem.h"
|
#include "esp_private/sleep_modem.h"
|
||||||
static bool s_rf_closed = false;
|
|
||||||
#if SOC_PM_RETENTION_HAS_CLOCK_BUG
|
#if SOC_PM_RETENTION_HAS_CLOCK_BUG
|
||||||
#define IEEE802154_LINK_OWNER ENTRY(3)
|
#define IEEE802154_LINK_OWNER ENTRY(3)
|
||||||
#else
|
#else
|
||||||
@ -39,6 +38,7 @@ static bool s_rf_closed = false;
|
|||||||
#endif // SOC_PM_RETENTION_HAS_CLOCK_BUG
|
#endif // SOC_PM_RETENTION_HAS_CLOCK_BUG
|
||||||
#endif // SOC_PM_MODEM_RETENTION_BY_REGDMA && CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
#endif // SOC_PM_MODEM_RETENTION_BY_REGDMA && CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||||
|
|
||||||
|
static bool s_rf_closed = true;
|
||||||
#define CCA_DETECTION_TIME 8
|
#define CCA_DETECTION_TIME 8
|
||||||
|
|
||||||
extern void bt_bb_set_zb_tx_on_delay(uint16_t time);
|
extern void bt_bb_set_zb_tx_on_delay(uint16_t time);
|
||||||
@ -51,9 +51,9 @@ static uint8_t s_rx_index = 0;
|
|||||||
static uint8_t s_enh_ack_frame[128];
|
static uint8_t s_enh_ack_frame[128];
|
||||||
static uint8_t s_recent_rx_frame_info_index;
|
static uint8_t s_recent_rx_frame_info_index;
|
||||||
static portMUX_TYPE s_ieee802154_spinlock = portMUX_INITIALIZER_UNLOCKED;
|
static portMUX_TYPE s_ieee802154_spinlock = portMUX_INITIALIZER_UNLOCKED;
|
||||||
|
static intr_handle_t s_ieee802154_isr_handle = NULL;
|
||||||
|
|
||||||
static esp_err_t ieee802154_sleep_init(void);
|
static esp_err_t ieee802154_sleep_init(void);
|
||||||
static void ieee802154_rf_enable(void);
|
|
||||||
|
|
||||||
static IRAM_ATTR void event_end_process(void)
|
static IRAM_ATTR void event_end_process(void)
|
||||||
{
|
{
|
||||||
@ -660,7 +660,7 @@ esp_err_t ieee802154_mac_init(void)
|
|||||||
ieee802154_set_state(IEEE802154_STATE_IDLE);
|
ieee802154_set_state(IEEE802154_STATE_IDLE);
|
||||||
|
|
||||||
// TODO: Add flags for IEEE802154 ISR allocating. TZ-102
|
// TODO: Add flags for IEEE802154 ISR allocating. TZ-102
|
||||||
ret = esp_intr_alloc(ieee802154_periph.irq_id, 0, ieee802154_isr, NULL, NULL);
|
ret = esp_intr_alloc(ieee802154_periph.irq_id, 0, ieee802154_isr, NULL, &s_ieee802154_isr_handle);
|
||||||
ESP_RETURN_ON_FALSE(ret == ESP_OK, ESP_FAIL, IEEE802154_TAG, "IEEE802154 MAC init failed");
|
ESP_RETURN_ON_FALSE(ret == ESP_OK, ESP_FAIL, IEEE802154_TAG, "IEEE802154 MAC init failed");
|
||||||
|
|
||||||
ESP_RETURN_ON_FALSE(ieee802154_sleep_init() == ESP_OK, ESP_FAIL, IEEE802154_TAG, "IEEE802154 MAC sleep init failed");
|
ESP_RETURN_ON_FALSE(ieee802154_sleep_init() == ESP_OK, ESP_FAIL, IEEE802154_TAG, "IEEE802154 MAC sleep init failed");
|
||||||
@ -668,6 +668,16 @@ esp_err_t ieee802154_mac_init(void)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
esp_err_t ieee802154_mac_deinit(void)
|
||||||
|
{
|
||||||
|
esp_err_t ret = ESP_OK;
|
||||||
|
if (s_ieee802154_isr_handle) {
|
||||||
|
ret = esp_intr_free(s_ieee802154_isr_handle);
|
||||||
|
s_ieee802154_isr_handle = NULL;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
IEEE802154_STATIC void start_ed(uint32_t duration)
|
IEEE802154_STATIC void start_ed(uint32_t duration)
|
||||||
{
|
{
|
||||||
ieee802154_ll_enable_events(IEEE802154_EVENT_ED_DONE);
|
ieee802154_ll_enable_events(IEEE802154_EVENT_ED_DONE);
|
||||||
@ -693,7 +703,7 @@ IEEE802154_STATIC void tx_init(const uint8_t *frame)
|
|||||||
|
|
||||||
esp_err_t ieee802154_transmit(const uint8_t *frame, bool cca)
|
esp_err_t ieee802154_transmit(const uint8_t *frame, bool cca)
|
||||||
{
|
{
|
||||||
ieee802154_rf_enable();
|
IEEE802154_RF_ENABLE();
|
||||||
ieee802154_enter_critical();
|
ieee802154_enter_critical();
|
||||||
tx_init(frame);
|
tx_init(frame);
|
||||||
|
|
||||||
@ -721,7 +731,7 @@ esp_err_t ieee802154_transmit_at(const uint8_t *frame, bool cca, uint32_t time)
|
|||||||
{
|
{
|
||||||
uint32_t tx_target_time;
|
uint32_t tx_target_time;
|
||||||
uint32_t current_time;
|
uint32_t current_time;
|
||||||
ieee802154_rf_enable();
|
IEEE802154_RF_ENABLE();
|
||||||
tx_init(frame);
|
tx_init(frame);
|
||||||
IEEE802154_SET_TXRX_PTI(IEEE802154_SCENE_TX_AT);
|
IEEE802154_SET_TXRX_PTI(IEEE802154_SCENE_TX_AT);
|
||||||
if (cca) {
|
if (cca) {
|
||||||
@ -763,7 +773,7 @@ esp_err_t ieee802154_receive(void)
|
|||||||
// already in rx state, don't abort current rx operation
|
// already in rx state, don't abort current rx operation
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
ieee802154_rf_enable();
|
IEEE802154_RF_ENABLE();
|
||||||
|
|
||||||
ieee802154_enter_critical();
|
ieee802154_enter_critical();
|
||||||
rx_init();
|
rx_init();
|
||||||
@ -776,7 +786,7 @@ esp_err_t ieee802154_receive_at(uint32_t time)
|
|||||||
{
|
{
|
||||||
uint32_t rx_target_time = time - IEEE802154_RX_RAMPUP_TIME_US;
|
uint32_t rx_target_time = time - IEEE802154_RX_RAMPUP_TIME_US;
|
||||||
uint32_t current_time;
|
uint32_t current_time;
|
||||||
ieee802154_rf_enable();
|
IEEE802154_RF_ENABLE();
|
||||||
rx_init();
|
rx_init();
|
||||||
IEEE802154_SET_TXRX_PTI(IEEE802154_SCENE_RX_AT);
|
IEEE802154_SET_TXRX_PTI(IEEE802154_SCENE_RX_AT);
|
||||||
set_next_rx_buffer();
|
set_next_rx_buffer();
|
||||||
@ -810,24 +820,20 @@ static esp_err_t ieee802154_sleep_init(void)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
IRAM_ATTR static void ieee802154_rf_disable(void)
|
IRAM_ATTR void ieee802154_rf_disable(void)
|
||||||
{
|
{
|
||||||
#if SOC_PM_MODEM_RETENTION_BY_REGDMA && CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
|
||||||
if (s_rf_closed == false) {
|
if (s_rf_closed == false) {
|
||||||
esp_phy_disable(PHY_MODEM_IEEE802154);
|
esp_phy_disable(PHY_MODEM_IEEE802154);
|
||||||
s_rf_closed = true;
|
s_rf_closed = true;
|
||||||
}
|
}
|
||||||
#endif // SOC_PM_MODEM_RETENTION_BY_REGDMA && CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IRAM_ATTR static void ieee802154_rf_enable(void)
|
IRAM_ATTR void ieee802154_rf_enable(void)
|
||||||
{
|
{
|
||||||
#if SOC_PM_MODEM_RETENTION_BY_REGDMA && CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
|
||||||
if (s_rf_closed) {
|
if (s_rf_closed) {
|
||||||
esp_phy_enable(PHY_MODEM_IEEE802154);
|
esp_phy_enable(PHY_MODEM_IEEE802154);
|
||||||
s_rf_closed = false;
|
s_rf_closed = false;
|
||||||
}
|
}
|
||||||
#endif // SOC_PM_MODEM_RETENTION_BY_REGDMA && CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t ieee802154_sleep(void)
|
esp_err_t ieee802154_sleep(void)
|
||||||
@ -837,14 +843,14 @@ esp_err_t ieee802154_sleep(void)
|
|||||||
stop_current_operation();
|
stop_current_operation();
|
||||||
ieee802154_set_state(IEEE802154_STATE_SLEEP);
|
ieee802154_set_state(IEEE802154_STATE_SLEEP);
|
||||||
ieee802154_exit_critical();
|
ieee802154_exit_critical();
|
||||||
ieee802154_rf_disable(); // colse rf
|
IEEE802154_RF_DISABLE();
|
||||||
}
|
}
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t ieee802154_energy_detect(uint32_t duration)
|
esp_err_t ieee802154_energy_detect(uint32_t duration)
|
||||||
{
|
{
|
||||||
ieee802154_rf_enable();
|
IEEE802154_RF_ENABLE();
|
||||||
ieee802154_enter_critical();
|
ieee802154_enter_critical();
|
||||||
|
|
||||||
stop_current_operation();
|
stop_current_operation();
|
||||||
@ -860,7 +866,7 @@ esp_err_t ieee802154_energy_detect(uint32_t duration)
|
|||||||
|
|
||||||
esp_err_t ieee802154_cca(void)
|
esp_err_t ieee802154_cca(void)
|
||||||
{
|
{
|
||||||
ieee802154_rf_enable();
|
IEEE802154_RF_ENABLE();
|
||||||
ieee802154_enter_critical();
|
ieee802154_enter_critical();
|
||||||
|
|
||||||
stop_current_operation();
|
stop_current_operation();
|
||||||
|
@ -22,15 +22,17 @@
|
|||||||
esp_err_t esp_ieee802154_enable(void)
|
esp_err_t esp_ieee802154_enable(void)
|
||||||
{
|
{
|
||||||
ieee802154_enable();
|
ieee802154_enable();
|
||||||
esp_phy_enable(PHY_MODEM_IEEE802154);
|
ieee802154_rf_enable();
|
||||||
esp_btbb_enable();
|
esp_btbb_enable();
|
||||||
return ieee802154_mac_init();
|
return ieee802154_mac_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t esp_ieee802154_disable(void)
|
esp_err_t esp_ieee802154_disable(void)
|
||||||
{
|
{
|
||||||
|
esp_btbb_disable();
|
||||||
|
ieee802154_rf_disable();
|
||||||
ieee802154_disable();
|
ieee802154_disable();
|
||||||
return ESP_OK;
|
return ieee802154_mac_deinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t esp_ieee802154_get_channel(void)
|
uint8_t esp_ieee802154_get_channel(void)
|
||||||
|
@ -55,6 +55,17 @@ void ieee802154_enable(void);
|
|||||||
*/
|
*/
|
||||||
void ieee802154_disable(void);
|
void ieee802154_disable(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enable the RF.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void ieee802154_rf_enable(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Disable the RF.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void ieee802154_rf_disable(void);
|
||||||
/**
|
/**
|
||||||
* @brief Initialize the IEEE 802.15.4 MAC.
|
* @brief Initialize the IEEE 802.15.4 MAC.
|
||||||
*
|
*
|
||||||
@ -65,6 +76,16 @@ void ieee802154_disable(void);
|
|||||||
*/
|
*/
|
||||||
esp_err_t ieee802154_mac_init(void);
|
esp_err_t ieee802154_mac_init(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Deinitialize the IEEE 802.15.4 MAC.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - ESP_OK on success.
|
||||||
|
* - ESP_FAIL on failure.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
esp_err_t ieee802154_mac_deinit(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Transmit the given frame.
|
* @brief Transmit the given frame.
|
||||||
*
|
*
|
||||||
|
@ -15,6 +15,13 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if SOC_PM_MODEM_RETENTION_BY_REGDMA && CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||||
|
#define IEEE802154_RF_ENABLE() ieee802154_rf_enable()
|
||||||
|
#define IEEE802154_RF_DISABLE() ieee802154_rf_disable()
|
||||||
|
#else
|
||||||
|
#define IEEE802154_RF_ENABLE()
|
||||||
|
#define IEEE802154_RF_DISABLE()
|
||||||
|
#endif // SOC_PM_MODEM_RETENTION_BY_REGDMA && CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||||
#define IEEE802154_PROBE(a) do { \
|
#define IEEE802154_PROBE(a) do { \
|
||||||
IEEE802154_RECORD_EVENT(a); \
|
IEEE802154_RECORD_EVENT(a); \
|
||||||
ieee802154_record_abort(a); \
|
ieee802154_record_abort(a); \
|
||||||
|
Loading…
Reference in New Issue
Block a user