-
Notifications
You must be signed in to change notification settings - Fork 1.4k
ESB: Fixes and improvements #25479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
ESB: Fixes and improvements #25479
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -1072,7 +1072,7 @@ static void initialize_fifos(void) | |||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| static void tx_fifo_remove_last(void) | ||||||||
| static void tx_fifo_remove_first(void) | ||||||||
| { | ||||||||
| if (tx_fifo.count == 0) { | ||||||||
| return; | ||||||||
|
|
@@ -1332,7 +1332,7 @@ static void on_timer_compare1_tx_noack(void) | |||||||
| esb_ppi_for_wait_for_rx_clear(); | ||||||||
|
|
||||||||
| interrupt_flags |= INT_TX_SUCCESS_MSK; | ||||||||
| tx_fifo_remove_last(); | ||||||||
| tx_fifo_remove_first(); | ||||||||
|
|
||||||||
| if (tx_fifo.count == 0) { | ||||||||
| esb_state = ESB_STATE_PTX_TXIDLE; | ||||||||
|
|
@@ -1349,7 +1349,7 @@ static void on_radio_disabled_tx_noack(void) | |||||||
| esb_ppi_for_txrx_clear(false, false); | ||||||||
|
|
||||||||
| interrupt_flags |= INT_TX_SUCCESS_MSK; | ||||||||
| tx_fifo_remove_last(); | ||||||||
| tx_fifo_remove_first(); | ||||||||
|
|
||||||||
| if (tx_fifo.count == 0) { | ||||||||
| esb_state = ESB_STATE_IDLE; | ||||||||
|
|
@@ -1440,7 +1440,7 @@ static void on_radio_disabled_tx_wait_for_ack(void) | |||||||
| interrupt_flags |= INT_TX_SUCCESS_MSK; | ||||||||
| last_tx_attempts = esb_cfg.retransmit_count - retransmits_remaining + 1; | ||||||||
|
|
||||||||
| tx_fifo_remove_last(); | ||||||||
| tx_fifo_remove_first(); | ||||||||
|
|
||||||||
| if ((esb_cfg.protocol != ESB_PROTOCOL_ESB) && (rx_pdu->type.dpl_pdu.length > 0)) { | ||||||||
| if (rx_fifo_push_rfbuf( | ||||||||
|
|
@@ -2100,15 +2100,45 @@ int esb_init(const struct esb_config *config) | |||||||
|
|
||||||||
| int esb_suspend(void) | ||||||||
| { | ||||||||
| if (esb_state != ESB_STATE_IDLE) { | ||||||||
| return -EBUSY; | ||||||||
| if (esb_state == ESB_STATE_IDLE) { | ||||||||
| return -EALREADY; | ||||||||
| } | ||||||||
| on_radio_disabled = NULL; | ||||||||
|
|
||||||||
| /* Stop radio */ | ||||||||
| nrf_radio_shorts_disable(NRF_RADIO, 0xFFFFFFFF); | ||||||||
| nrf_radio_int_disable(NRF_RADIO, 0xFFFFFFFF); | ||||||||
|
|
||||||||
| nrf_radio_event_clear(NRF_RADIO, NRF_RADIO_EVENT_DISABLED); | ||||||||
| nrf_radio_task_trigger(NRF_RADIO, NRF_RADIO_TASK_DISABLE); | ||||||||
|
|
||||||||
| while (!nrf_radio_event_check(NRF_RADIO, NRF_RADIO_EVENT_DISABLED)) { | ||||||||
| /* wait for register to settle */ | ||||||||
| } | ||||||||
|
|
||||||||
| /* Clear PPI */ | ||||||||
| nrf_radio_event_clear(NRF_RADIO, NRF_RADIO_EVENT_DISABLED); | ||||||||
|
|
||||||||
| /* Stop timer */ | ||||||||
| nrf_timer_shorts_disable(esb_timer.p_reg, 0xFFFFFFFF); | ||||||||
| nrf_timer_int_disable(esb_timer.p_reg, 0xFFFFFFFF); | ||||||||
|
|
||||||||
| nrf_timer_event_clear(esb_timer.p_reg, NRF_TIMER_EVENT_COMPARE0); | ||||||||
| nrf_timer_event_clear(esb_timer.p_reg, NRF_TIMER_EVENT_COMPARE1); | ||||||||
| nrf_timer_event_clear(esb_timer.p_reg, NRF_TIMER_EVENT_COMPARE2); | ||||||||
| nrf_timer_event_clear(esb_timer.p_reg, NRF_TIMER_EVENT_COMPARE3); | ||||||||
|
Comment on lines
+2125
to
+2128
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is needed |
||||||||
|
|
||||||||
| #if NRF_TIMER_HAS_SHUTDOWN | ||||||||
| nrf_timer_task_trigger(esb_timer.p_reg, NRF_TIMER_TASK_SHUTDOWN); | ||||||||
| #else | ||||||||
| nrf_timer_task_trigger(esb_timer.p_reg, NRF_TIMER_TASK_STOP); | ||||||||
| nrf_timer_task_trigger(esb_timer.p_reg, NRF_TIMER_TASK_CLEAR); | ||||||||
| #endif | ||||||||
|
Comment on lines
+2130
to
+2135
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. esb_fem_reset also do that |
||||||||
|
|
||||||||
| esb_ppi_disable_all(); | ||||||||
| esb_fem_reset(); | ||||||||
|
|
||||||||
| esb_state = ESB_STATE_IDLE; | ||||||||
| errata_216_off(); | ||||||||
| esb_state = ESB_STATE_IDLE; | ||||||||
|
|
||||||||
| return 0; | ||||||||
| } | ||||||||
|
|
@@ -2313,33 +2343,15 @@ int esb_stop_rx(void) | |||||||
| return -EINVAL; | ||||||||
| } | ||||||||
|
|
||||||||
| on_radio_disabled = NULL; | ||||||||
|
|
||||||||
| esb_ppi_for_txrx_clear(true, false); | ||||||||
| esb_fem_reset(); | ||||||||
|
|
||||||||
| nrf_radio_shorts_disable(NRF_RADIO, 0xFFFFFFFF); | ||||||||
| nrf_radio_int_disable(NRF_RADIO, 0xFFFFFFFF); | ||||||||
|
|
||||||||
| nrf_radio_event_clear(NRF_RADIO, NRF_RADIO_EVENT_DISABLED); | ||||||||
| nrf_radio_task_trigger(NRF_RADIO, NRF_RADIO_TASK_DISABLE); | ||||||||
|
|
||||||||
| while (!nrf_radio_event_check(NRF_RADIO, NRF_RADIO_EVENT_DISABLED)) { | ||||||||
| /* wait for register to settle */ | ||||||||
| } | ||||||||
|
|
||||||||
| nrf_radio_event_clear(NRF_RADIO, NRF_RADIO_EVENT_DISABLED); | ||||||||
|
|
||||||||
| esb_state = ESB_STATE_IDLE; | ||||||||
| errata_216_off(); | ||||||||
|
|
||||||||
| return 0; | ||||||||
| return esb_suspend(); | ||||||||
| } | ||||||||
|
|
||||||||
| int esb_flush_tx(void) | ||||||||
| { | ||||||||
| if (!esb_initialized) { | ||||||||
| return -EACCES; | ||||||||
| } else if (esb_state != ESB_STATE_IDLE) { | ||||||||
|
||||||||
| } else if (esb_state != ESB_STATE_IDLE) { | |
| } | |
| if (esb_state != ESB_STATE_IDLE) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -294,6 +294,33 @@ | |||||||||||||||||
| BIT(timer_compare1_radio_txen) : 0)); | ||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this 2 channels are swapped, |
||||||||||||||||||
|
|
||||||||||||||||||
| nrf_dppi_channels_disable(ESB_DPPIC, channels_mask); | ||||||||||||||||||
|
|
||||||||||||||||||
| /* Clear all publish/subscribe connections to fully disconnect peripherals */ | ||||||||||||||||||
|
|
||||||||||||||||||
|
||||||||||||||||||
Copilot
AI
Nov 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Remove this empty line to maintain consistent code style.
| /* Clear Radio */ | |
| nrf_radio_publish_clear(NRF_RADIO, NRF_RADIO_EVENT_ADDRESS); | |
| nrf_radio_publish_clear(NRF_RADIO, NRF_RADIO_EVENT_DISABLED); | |
| /* Clear Radio */ | |
| nrf_radio_publish_clear(NRF_RADIO, NRF_RADIO_EVENT_ADDRESS); | |
| nrf_radio_publish_clear(NRF_RADIO, NRF_RADIO_EVENT_DISABLED); | |
| nrf_radio_publish_clear(NRF_RADIO, NRF_RADIO_EVENT_DISABLED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we cannot clear publish for NRF_RADIO_EVENT_DISABLED here, because it comes from ppi_init
also clear for ESB_RADIO_EVENT_END is problematic because on nrf54X it alias for NRF_RADIO_EVENT_PHYEND and it's set in ppi_init for CONFIG_ESB_FAST_SWITCHING
Copilot
AI
Nov 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Remove this empty line to maintain consistent code style.
Copilot
AI
Nov 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Remove this empty line to maintain consistent code style.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -254,6 +254,21 @@ void esb_ppi_disable_all(void) | |
| BIT(timer_compare1_radio_txen) : 0)); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this 2 channels are swapped, same thing is below in clearing endpoint |
||
|
|
||
| nrf_ppi_channels_disable(NRF_PPI, channels_mask); | ||
|
|
||
| /* Clear all PPI endpoints to fully disconnect peripherals */ | ||
| nrf_ppi_channel_and_fork_endpoint_setup(NRF_PPI, egu_ramp_up, 0, 0, 0); | ||
| nrf_ppi_channel_endpoint_setup(NRF_PPI, disabled_egu, 0, 0); | ||
| nrf_ppi_channel_endpoint_setup(NRF_PPI, egu_timer_start, 0, 0); | ||
| nrf_ppi_channel_endpoint_setup(NRF_PPI, radio_address_timer_stop, 0, 0); | ||
| nrf_ppi_channel_endpoint_setup(NRF_PPI, timer_compare0_radio_disable, 0, 0); | ||
| nrf_ppi_channel_endpoint_setup(NRF_PPI, radio_end_timer_start, 0, 0); | ||
|
|
||
| if (IS_ENABLED(CONFIG_ESB_NEVER_DISABLE_TX)) { | ||
| nrf_ppi_channel_endpoint_setup(NRF_PPI, timer_compare1_radio_txen, 0, 0); | ||
| } | ||
|
|
||
| /* Remove channel from group */ | ||
| nrf_ppi_channel_remove_from_group(NRF_PPI, egu_ramp_up, ramp_up_ppi_group); | ||
| } | ||
|
|
||
| void esb_ppi_deinit(void) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is needed