diff --git a/components/ieee802154/driver/esp_ieee802154_dev.c b/components/ieee802154/driver/esp_ieee802154_dev.c index 79fbaa8013..0c3f7d4ddc 100644 --- a/components/ieee802154/driver/esp_ieee802154_dev.c +++ b/components/ieee802154/driver/esp_ieee802154_dev.c @@ -149,8 +149,6 @@ static IRAM_ATTR void receive_ack_timeout_timer_start(uint32_t duration) uint32_t current_time = (uint32_t)esp_timer_get_time(); ieee802154_timer0_fire_at_with_callback(current_time + duration, ieee802154_rx_ack_timeout_callback, (void*)s_tx_frame); - ieee802154_timer0_set_threshold(duration); - ieee802154_timer0_start(); } #endif @@ -406,20 +404,6 @@ static IRAM_ATTR void next_operation(void) } } -static void isr_handle_timer0_done(void) -{ - ieee802154_timer0_execute_callback(); -#if CONFIG_IEEE802154_TEST - extern void esp_ieee802154_timer0_done(void); - esp_ieee802154_timer0_done(); -#endif -} - -static void isr_handle_timer1_done(void) -{ - ieee802154_timer1_execute_callback(); -} - static IRAM_ATTR void isr_handle_tx_done(void) { event_end_process(); @@ -507,7 +491,6 @@ static IRAM_ATTR void isr_handle_rx_phase_rx_abort(ieee802154_ll_rx_abort_reason case IEEE802154_RX_ABORT_BY_TX_ACK_STOP: case IEEE802154_RX_ABORT_BY_ED_STOP: // do nothing - NEEDS_NEXT_OPT(false); return; case IEEE802154_RX_ABORT_BY_SFD_TIMEOUT: case IEEE802154_RX_ABORT_BY_CRC_ERROR: @@ -547,8 +530,6 @@ static IRAM_ATTR void isr_handle_tx_ack_phase_rx_abort(ieee802154_ll_rx_abort_re case IEEE802154_RX_ABORT_BY_RX_STOP: case IEEE802154_RX_ABORT_BY_TX_ACK_STOP: case IEEE802154_RX_ABORT_BY_ED_STOP: - NEEDS_NEXT_OPT(false); - return; case IEEE802154_RX_ABORT_BY_SFD_TIMEOUT: case IEEE802154_RX_ABORT_BY_CRC_ERROR: case IEEE802154_RX_ABORT_BY_INVALID_LEN: diff --git a/components/ieee802154/driver/esp_ieee802154_timer.c b/components/ieee802154/driver/esp_ieee802154_timer.c index 0bf928e71b..d44249e529 100644 --- a/components/ieee802154/driver/esp_ieee802154_timer.c +++ b/components/ieee802154/driver/esp_ieee802154_timer.c @@ -87,42 +87,52 @@ void ieee802154_timer1_fire_at(uint32_t fire_time) ieee802154_timer1_start(); } -void ieee802154_timer0_fire_at_with_callback(uint32_t fire_time, timer_callback_t timer0_cb, void *timer0_ctx) +void ieee802154_timer0_set_callback(timer_callback_t timer0_cb, void *timer0_ctx) { s_timer0_callback = timer0_cb; s_timer0_ctx = timer0_ctx; +} + +void ieee802154_timer1_set_callback(timer_callback_t timer1_cb, void *timer1_ctx) +{ + s_timer1_callback = timer1_cb; + s_timer1_ctx = timer1_ctx; +} + +void ieee802154_timer0_fire_at_with_callback(uint32_t fire_time, timer_callback_t timer0_cb, void *timer0_ctx) +{ + ieee802154_timer0_set_callback(timer0_cb, timer0_ctx); ieee802154_timer0_fire_at(fire_time); } void ieee802154_timer1_fire_at_with_callback(uint32_t fire_time, timer_callback_t timer1_cb, void *timer1_ctx) { - s_timer1_callback = timer1_cb; - s_timer1_ctx = timer1_ctx; + ieee802154_timer1_set_callback(timer1_cb, timer1_ctx); ieee802154_timer1_fire_at(fire_time); } -void ieee802154_timer0_execute_callback(void) +void isr_handle_timer0_done(void) { - timer_callback_t callback_tmp = s_timer0_callback; // tmp function used to allow new callback function to set a new callback without overwriting it - void* ctx_tmp = s_timer0_ctx; + if (s_timer0_callback) { + timer_callback_t callback_tmp = s_timer0_callback; // tmp function used to allow new callback function to set a new callback without overwriting it + void* ctx_tmp = s_timer0_ctx; - s_timer0_callback = NULL; - s_timer0_ctx = NULL; + s_timer0_callback = NULL; + s_timer0_ctx = NULL; - if (callback_tmp) { callback_tmp(ctx_tmp); } } -void ieee802154_timer1_execute_callback(void) +void isr_handle_timer1_done(void) { - timer_callback_t callback_tmp = s_timer1_callback; // tmp function used to allow new callback function to set a new callback without overwriting it - void* ctx_tmp = s_timer1_ctx; + if (s_timer1_callback) { + timer_callback_t callback_tmp = s_timer1_callback; // tmp function used to allow new callback function to set a new callback without overwriting it + void* ctx_tmp = s_timer1_ctx; - s_timer1_callback = NULL; - s_timer1_ctx = NULL; + s_timer1_callback = NULL; + s_timer1_ctx = NULL; - if (callback_tmp) { callback_tmp(ctx_tmp); } } diff --git a/components/ieee802154/linker.lf b/components/ieee802154/linker.lf index 1928229b66..ad766e556f 100644 --- a/components/ieee802154/linker.lf +++ b/components/ieee802154/linker.lf @@ -63,10 +63,12 @@ entries: esp_ieee802154_dev: stop_tx_cca (noflash) esp_ieee802154_pib: ieee802154_pib_update (noflash) esp_ieee802154_pib: ieee802154_txpower_convert (noflash) - esp_ieee802154_timer: ieee802154_timer0_execute_callback (noflash) esp_ieee802154_timer: ieee802154_timer0_fire_at (noflash) esp_ieee802154_timer: ieee802154_timer0_fire_at_with_callback (noflash) - esp_ieee802154_timer: ieee802154_timer1_execute_callback (noflash) + esp_ieee802154_timer: ieee802154_timer0_set_callback (noflash) esp_ieee802154_timer: ieee802154_timer1_fire_at (noflash) esp_ieee802154_timer: ieee802154_timer1_fire_at_with_callback (noflash) + esp_ieee802154_timer: ieee802154_timer1_set_callback (noflash) + esp_ieee802154_timer: isr_handle_timer0_done (noflash) + esp_ieee802154_timer: isr_handle_timer1_done (noflash) esp_ieee802154_util: ieee802154_channel_to_freq (noflash) diff --git a/components/ieee802154/private_include/esp_ieee802154_timer.h b/components/ieee802154/private_include/esp_ieee802154_timer.h index d07c9b4ea2..f445a281ec 100644 --- a/components/ieee802154/private_include/esp_ieee802154_timer.h +++ b/components/ieee802154/private_include/esp_ieee802154_timer.h @@ -93,6 +93,18 @@ void ieee802154_timer1_fire_at(uint32_t fire_time); typedef void (*timer_callback_t)(void* ctx); +/** + * @brief Set timer0 callback. + * + */ +void ieee802154_timer0_set_callback(timer_callback_t timer0_cb, void *timer0_ctx); + +/** + * @brief Set timer1 callback. + * + */ +void ieee802154_timer1_set_callback(timer_callback_t timer1_cb, void *timer1_ctx); + /** * @brief Set timer0 to fire at specific time with callback. * @@ -106,16 +118,16 @@ void ieee802154_timer0_fire_at_with_callback(uint32_t fire_time, timer_callback_ void ieee802154_timer1_fire_at_with_callback(uint32_t fire_time, timer_callback_t timer1_callback, void *timer1_ctx); /** - * @brief Execute timer0 callback. + * @brief ISR handle for timer0. * */ -void ieee802154_timer0_execute_callback(void); +void isr_handle_timer0_done(void); /** - * @brief Execute timer1 callback. + * @brief ISR handle for timer1. * */ -void ieee802154_timer1_execute_callback(void); +void isr_handle_timer1_done(void); #ifdef __cplusplus }