-
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
Conversation
- Improved `esb_suspend` to suspend the protocol. - Changed `esb_flush_tx` to allow clearing the FIFO queue when ESB is in the IDLE state. - Fixed `esb_pop_tx` to use the correct pointer. - Renamed `tx_fifo_remove_last` to `tx_fifo_remove_first` Ref: NCSDK-36153 Signed-off-by: Marcin Jelinski <marcin.jelinski@nordicsemi.no>
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.
Pull Request Overview
This PR enhances the ESB (Enhanced ShockBurst) protocol implementation with critical bug fixes and improvements. The changes focus on properly suspending the protocol, fixing FIFO queue operations, and ensuring complete peripheral disconnection.
Key changes:
- Enhanced
esb_suspend()to properly stop radio and timer peripherals before transitioning to IDLE state - Fixed
esb_pop_tx()to use the correct FIFO pointer (frontinstead ofback) - Renamed
tx_fifo_remove_last()totx_fifo_remove_first()for clarity
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| subsys/esb/esb.c | Core ESB implementation with improved suspend logic, fixed FIFO operations, and renamed internal function |
| subsys/esb/esb_ppi.c | Added complete PPI endpoint cleanup to fully disconnect peripherals during suspend |
| subsys/esb/esb_dppi.c | Added complete DPPI publish/subscribe clearing to fully disconnect peripherals during suspend |
| include/esb.h | Updated documentation for esb_flush_tx() to clarify radio state requirements and return values |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 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); |
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); |
| nrf_radio_subscribe_clear(NRF_RADIO, NRF_RADIO_TASK_RXEN); | ||
| nrf_radio_subscribe_clear(NRF_RADIO, NRF_RADIO_TASK_TXEN); | ||
| nrf_radio_subscribe_clear(NRF_RADIO, NRF_RADIO_TASK_DISABLE); | ||
|
|
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.
| nrf_timer_publish_clear(ESB_NRF_TIMER_INSTANCE, NRF_TIMER_EVENT_COMPARE1); | ||
| nrf_timer_subscribe_clear(ESB_NRF_TIMER_INSTANCE, NRF_TIMER_TASK_START); | ||
| nrf_timer_subscribe_clear(ESB_NRF_TIMER_INSTANCE, NRF_TIMER_TASK_STOP); | ||
|
|
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.
| { | ||
| if (!esb_initialized) { | ||
| return -EACCES; | ||
| } else if (esb_state != ESB_STATE_IDLE) { |
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] Use separate if statements instead of else-if for better clarity and to avoid unnecessary coupling between unrelated error conditions.
| } 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
CI InformationTo view the history of this post, click the 'edited' button above Inputs:Sources:sdk-nrf: PR head: a9b1965aa83de258a383907aefe8b016ac331b38 more detailssdk-nrf:
Github labels
List of changed files detected by CI (4)Outputs:ToolchainVersion: df3cc9d822 Test Spec & Results: ✅ Success; ❌ Failure; 🟠 Queued; 🟡 Progress; ◻️ Skipped;
|
|
You can find the documentation preview for this PR here. Preview links for modified nRF Connect SDK documents: https://ncsdoc.z6.web.core.windows.net/PR-25479/nrf/releases_and_maturity/software_maturity.html |
Szynkaa
left a comment
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.
using esb_pop_tx can cause same corruption as esb_flush_tx
| BIT(timer_compare0_radio_disable) | | ||
| BIT(radio_end_timer_start) | | ||
| (IS_ENABLED(CONFIG_ESB_NEVER_DISABLE_TX) ? | ||
| BIT(timer_compare1_radio_txen) : 0)); |
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 think this 2 channels are swapped, radio_end_timer_start depends on CONFIG_ESB_NEVER_DISABLE_TX and timer_compare1_radio_txen is used as retx trigger
same thing is below in clearing endpoint
| BIT(timer_compare0_radio_disable) | | ||
| BIT(radio_end_timer_start) | | ||
| (IS_ENABLED(CONFIG_ESB_NEVER_DISABLE_TX) ? | ||
| BIT(timer_compare1_radio_txen) : 0)); |
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 think this 2 channels are swapped, radio_end_timer_start depends on CONFIG_ESB_NEVER_DISABLE_TX
|
|
||
| /* Clear Radio */ | ||
| nrf_radio_publish_clear(NRF_RADIO, NRF_RADIO_EVENT_ADDRESS); | ||
| 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
| 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); |
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
| } | ||
|
|
||
| /* Clear PPI */ | ||
| nrf_radio_event_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.
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 |
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.
esb_fem_reset also do that
| { | ||
| if (!esb_initialized) { | ||
| return -EACCES; | ||
| } else 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
esb_suspendto suspend the protocol.esb_flush_txto allow clearing the FIFO queue when ESB is in the IDLE state.esb_pop_txto use the correct pointer.tx_fifo_remove_lasttotx_fifo_remove_first