This guide will go through the steps required to migrate an application from the µESB module available on GitHub to the nrf_esb module in the nRF5 SDK.
The nrf_esb module is based on the µESB module, but some changes have been done to the API to improve the module and to make it fit the SDK.
Because of similarities between them, porting from µESB to nrf_esb does not require a large structural change of the application.
Initialization of the nrf_esb module is changed a lot from µESB.
Many of the features that were previously located in the initialization struct have been moved to separate APIs.
This mean that more calls are necessary to achieve the same result when initializing, but it also allow you to change many parameters without reinitializing.
In the config struct the app should set all fields in the same way as it did in µESB.
Dynamic ack has been renamed to selective ack.
Set the base addresses and prefix through the three API calls:
Also set the address length through the API call:
Enable pipes through the API call:
Set the rf_channel through the API call:
The changes to the event system are the ones that require the largest changes for the application.
The events in µESB were very simple.
They occured in radio interrupt context and all parameters where avaialble through API calls as necessary.
Events in nrf_esb have been changed to include as many parameters as possible in the event itself as a struct.
This mean that the application must be altered to read these parameters from the struct instead of the old API calls.
my_tx_attemps = p_evt->tx_attempts;
//if (my_interrupt_flags & UESB_INT_RX_DR_MSK)
if (p_evt->evt_id == NRF_ESB_EVENT_RX_RECEIVED)
Events in nrf_esb are triggered in a software interrupt, allowing the radio to continue operating with higher priority than the events.
This reduces the risk of losing packets because of event handling, but require more complex behaviour from the application.
There might be more than one packet arriving between each event and packets may even arrive while treating the last event.
This mean that for every received payload event, there can be anywhere from 0 to NRF_ESB_CORE_RX_FIFO_SIZE payloads in the FIFO.
while(nrf_esb_read_rx_payload(&payload) == NRF_SUCCESS)
In µESB the disable function would wait for an idle state before disabling the radio.
If the application depends on completing its radio actions before disabling, it will have to wait until the state is idle before calling disable.
If the application does not depend on completing the current radio actions, disable can be called imminently and will be completed very fast.
In µESB there were three API calls for writing to the TX FIFO.
One for packets with ack, one for packets without ack and one for packets for ack with payload.
This API has been simplified in nrf_esb to only use one API call nrf_esb_write_payload().
When the module is in PRX mode all packets uploaded will be treated as packets for ack with payload.
When the module is in PTX mode all packets will be uploaded with or without ack based on the value of the ack field in the payload struct.
To migrate an application from µESB to nrf_esb, replace all write_payload calls with nrf_esb_write_payload() and set the ack field in each payload.
In the listing below the migration is shown:
p_payload->noack = false;
p_payload->noack = true;
In nrf_esb, no manual clearing of interrupts is required. It is managed by the module itself.
nice information keep sharing on this.
stock market training in Hyderabad Ameerpet
nice information keep share more on this.
Digital Marketing Course In Hyderabad Ameerpet
Great Post and thanks for sharing nice information.
Thanks for the tutorial. I am setting up an example project on the nRF51 DK. kitchenrally