change(ieee802154): add sleep deinit API

This commit is contained in:
xiaqilin 2024-03-04 17:13:29 +08:00 committed by Li Shuai
parent fc308a4234
commit 7f94f5bf72

View File

@ -69,6 +69,7 @@ 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_deinit(void);
static void next_operation(void);
static esp_err_t ieee802154_transmit_internal(const uint8_t *frame, bool cca);
@ -710,12 +711,6 @@ void ieee802154_enable(void)
void ieee802154_disable(void)
{
modem_clock_module_disable(ieee802154_periph.module);
#if SOC_PM_MODEM_RETENTION_BY_REGDMA && CONFIG_FREERTOS_USE_TICKLESS_IDLE
#if SOC_PM_RETENTION_HAS_CLOCK_BUG && CONFIG_MAC_BB_PD
sleep_modem_unregister_mac_bb_module_prepare_callback(sleep_modem_mac_bb_power_down_prepare,
sleep_modem_mac_bb_power_up_prepare);
#endif // SOC_PM_RETENTION_HAS_CLOCK_BUG && CONFIG_MAC_BB_PD
#endif // SOC_PM_MODEM_RETENTION_BY_REGDMA && CONFIG_FREERTOS_USE_TICKLESS_IDLE
ieee802154_set_state(IEEE802154_STATE_DISABLE);
}
@ -768,6 +763,7 @@ esp_err_t ieee802154_mac_deinit(void)
ret = esp_intr_free(s_ieee802154_isr_handle);
s_ieee802154_isr_handle = NULL;
}
ret = ieee802154_sleep_deinit();
return ret;
}
@ -950,6 +946,22 @@ static esp_err_t ieee802154_sleep_init(void)
return err;
}
static esp_err_t ieee802154_sleep_deinit(void)
{
esp_err_t err = ESP_OK;
#if SOC_PM_MODEM_RETENTION_BY_REGDMA && CONFIG_FREERTOS_USE_TICKLESS_IDLE
err = sleep_retention_module_free(SLEEP_RETENTION_MODULE_802154_MAC);
if (err == ESP_OK) {
err = sleep_retention_module_deinit(SLEEP_RETENTION_MODULE_802154_MAC);
}
#if SOC_PM_RETENTION_HAS_CLOCK_BUG && CONFIG_MAC_BB_PD
sleep_modem_unregister_mac_bb_module_prepare_callback(sleep_modem_mac_bb_power_down_prepare,
sleep_modem_mac_bb_power_up_prepare);
#endif // SOC_PM_RETENTION_HAS_CLOCK_BUG && CONFIG_MAC_BB_PD
#endif // SOC_PM_MODEM_RETENTION_BY_REGDMA && CONFIG_FREERTOS_USE_TICKLESS_IDLE
return err;
}
IRAM_ATTR void ieee802154_rf_disable(void)
{
if (s_rf_closed == false) {