14#include <hal/nrf_radio.h>
16#include <zephyr/sys/util.h>
17#include <zephyr/types.h>
36#define ESB_DEFAULT_CONFIG \
38 .protocol = ESB_PROTOCOL_ESB_DPL, \
39 .mode = ESB_MODE_PTX, \
41 .bitrate = ESB_BITRATE_2MBPS, \
42 .crc = ESB_CRC_16BIT, \
43 .tx_output_power = 0, \
44 .retransmit_delay = 600, \
45 .retransmit_count = 3, \
46 .tx_mode = ESB_TXMODE_AUTO, \
47 .payload_length = 32, \
48 .selective_auto_ack = false, \
49 .use_fast_ramp_up = false \
56#define ESB_LEGACY_CONFIG \
58 .protocol = ESB_PROTOCOL_ESB, \
59 .mode = ESB_MODE_PTX, \
61 .bitrate = ESB_BITRATE_2MBPS, \
62 .crc = ESB_CRC_8BIT, \
63 .tx_output_power = 0, \
64 .retransmit_delay = 600, \
65 .retransmit_count = 3, \
66 .tx_mode = ESB_TXMODE_AUTO, \
67 .payload_length = 32, \
68 .selective_auto_ack = false, \
69 .use_fast_ramp_up = false \
84#define ESB_CREATE_PAYLOAD(_pipe, ...) \
87 .length = NUM_VA_ARGS_LESS_1(_pipe, __VA_ARGS__), \
113#if defined(RADIO_MODE_MODE_Nrf_250Kbit) || defined(__DOXYGEN__)
121#if defined(RADIO_MODE_MODE_Ble_2Mbit) || defined(__DOXYGEN__)
126#if defined(RADIO_MODE_MODE_Nrf_4Mbit_0BT6) || defined(__DOXYGEN__)
141#if defined(RADIO_TXPOWER_TXPOWER_Pos10dBm) || defined(__DOXYGEN__)
145#if defined(RADIO_TXPOWER_TXPOWER_Pos9dBm) || defined(__DOXYGEN__)
149#if defined(RADIO_TXPOWER_TXPOWER_Pos8dBm) || defined(__DOXYGEN__)
153#if defined(RADIO_TXPOWER_TXPOWER_Pos7dBm) || defined(__DOXYGEN__)
157#if defined(RADIO_TXPOWER_TXPOWER_Pos6dBm) || defined(__DOXYGEN__)
161#if defined(RADIO_TXPOWER_TXPOWER_Pos5dBm) || defined(__DOXYGEN__)
165#if defined(RADIO_TXPOWER_TXPOWER_Pos4dBm) || defined(__DOXYGEN__)
169#if defined(RADIO_TXPOWER_TXPOWER_Pos3dBm) || defined(__DOXYGEN__)
173#if defined(RADIO_TXPOWER_TXPOWER_Pos2dBm) || defined(__DOXYGEN__)
177#if defined(RADIO_TXPOWER_TXPOWER_Pos1dBm) || defined(__DOXYGEN__)
181#if defined(RADIO_TXPOWER_TXPOWER_0dBm) || defined(__DOXYGEN__)
185#if defined(RADIO_TXPOWER_TXPOWER_Neg1dBm) || defined(__DOXYGEN__)
189#if defined(RADIO_TXPOWER_TXPOWER_Neg2dBm) || defined(__DOXYGEN__)
193#if defined(RADIO_TXPOWER_TXPOWER_Neg3dBm) || defined(__DOXYGEN__)
197#if defined(RADIO_TXPOWER_TXPOWER_Neg4dBm) || defined(__DOXYGEN__)
201#if defined(RADIO_TXPOWER_TXPOWER_Neg5dBm) || defined(__DOXYGEN__)
205#if defined(RADIO_TXPOWER_TXPOWER_Neg6dBm) || defined(__DOXYGEN__)
209#if defined(RADIO_TXPOWER_TXPOWER_Neg7dBm) || defined(__DOXYGEN__)
213#if defined(RADIO_TXPOWER_TXPOWER_Neg8dBm) || defined(__DOXYGEN__)
217#if defined(RADIO_TXPOWER_TXPOWER_Neg9dBm) || defined(__DOXYGEN__)
221#if defined(RADIO_TXPOWER_TXPOWER_Neg10dBm) || defined(__DOXYGEN__)
225#if defined(RADIO_TXPOWER_TXPOWER_Neg12dBm) || defined(__DOXYGEN__)
229#if defined(RADIO_TXPOWER_TXPOWER_Neg14dBm) || defined(__DOXYGEN__)
233#if defined(RADIO_TXPOWER_TXPOWER_Neg16dBm) || defined(__DOXYGEN__)
237#if defined(RADIO_TXPOWER_TXPOWER_Neg20dBm) || defined(__DOXYGEN__)
241#if defined(RADIO_TXPOWER_TXPOWER_Neg26dBm) || defined(__DOXYGEN__)
245#if defined(RADIO_TXPOWER_TXPOWER_Neg30dBm) || defined(__DOXYGEN__)
249#if defined(RADIO_TXPOWER_TXPOWER_Neg40dBm) || defined(__DOXYGEN__)
253#if defined(RADIO_TXPOWER_TXPOWER_Neg46dBm) || defined(__DOXYGEN__)
257#if defined(RADIO_TXPOWER_TXPOWER_Neg70dBm) || defined(__DOXYGEN__)
285#if IS_ENABLED(CONFIG_ESB_MPSL_TIMESLOT) || defined(__DOXYGEN__)
303 uint8_t
data[CONFIG_ESB_MAX_PAYLOAD_LENGTH];
int esb_set_retransmit_delay(uint16_t delay)
Set the packet retransmit delay.
esb_mode
Enhanced ShockBurst modes.
Definition esb.h:100
@ ESB_MODE_MONITOR
Definition esb.h:103
@ ESB_MODE_PTX
Definition esb.h:101
@ ESB_MODE_PRX
Definition esb.h:102
int esb_start_rx(void)
Start receiving data.
int esb_set_base_address_0(const uint8_t *addr)
Set the base address for pipe 0.
int esb_read_rx_payload(struct esb_payload *payload)
Read a payload.
int esb_set_prefixes(const uint8_t *prefixes, uint8_t num_pipes)
Set the number of pipes and the pipe prefix addresses.
int esb_start_tx(void)
Start transmitting data.
esb_tx_mode
Enhanced ShockBurst transmission modes.
Definition esb.h:264
@ ESB_TXMODE_MANUAL
Definition esb.h:272
@ ESB_TXMODE_AUTO
Definition esb.h:268
@ ESB_TXMODE_MANUAL_START
Definition esb.h:277
int esb_stop_rx(void)
Stop data reception.
esb_crc
Enhanced ShockBurst CRC modes.
Definition esb.h:133
@ ESB_CRC_OFF
Definition esb.h:136
@ ESB_CRC_16BIT
Definition esb.h:134
@ ESB_CRC_8BIT
Definition esb.h:135
esb_evt_id
Enhanced ShockBurst event IDs.
Definition esb.h:281
@ ESB_EVENT_TX_SUCCESS
Definition esb.h:282
@ ESB_EVENT_TX_FAILED
Definition esb.h:283
@ ESB_EVENT_TIMESLOT_FAILED
Definition esb.h:286
@ ESB_EVENT_RX_RECEIVED
Definition esb.h:284
int esb_update_prefix(uint8_t pipe, uint8_t prefix)
Update pipe prefix.
int esb_set_tx_power(int8_t tx_output_power)
Set the radio output power.
int esb_set_address_length(uint8_t length)
Set the length of the address.
esb_bitrate
Enhanced ShockBurst bitrate modes.
Definition esb.h:107
@ ESB_BITRATE_1MBPS
Definition esb.h:109
@ ESB_BITRATE_1MBPS_BLE
Definition esb.h:119
@ ESB_BITRATE_4MBPS
Definition esb.h:128
@ ESB_BITRATE_2MBPS
Definition esb.h:111
@ ESB_BITRATE_250KBPS
Definition esb.h:115
@ ESB_BITRATE_2MBPS_BLE
Definition esb.h:123
int esb_write_payload(const struct esb_payload *payload)
Write a payload for transmission or acknowledgement.
int esb_set_rf_channel(uint32_t channel)
Set the channel to use for the radio.
int esb_set_bitrate(enum esb_bitrate bitrate)
Set the radio bitrate.
void(* esb_event_handler)(const struct esb_evt *event)
Event handler prototype.
Definition esb.h:313
esb_tx_power
Enhanced ShockBurst radio transmission power modes.
Definition esb.h:140
@ ESB_TX_POWER_NEG40DBM
Definition esb.h:251
@ ESB_TX_POWER_NEG2DBM
Definition esb.h:191
@ ESB_TX_POWER_10DBM
Definition esb.h:143
@ ESB_TX_POWER_NEG7DBM
Definition esb.h:211
@ ESB_TX_POWER_NEG4DBM
Definition esb.h:199
@ ESB_TX_POWER_NEG30DBM
Definition esb.h:247
@ ESB_TX_POWER_8DBM
Definition esb.h:151
@ ESB_TX_POWER_1DBM
Definition esb.h:179
@ ESB_TX_POWER_NEG12DBM
Definition esb.h:227
@ ESB_TX_POWER_4DBM
Definition esb.h:167
@ ESB_TX_POWER_0DBM
Definition esb.h:183
@ ESB_TX_POWER_5DBM
Definition esb.h:163
@ ESB_TX_POWER_NEG9DBM
Definition esb.h:219
@ ESB_TX_POWER_NEG20DBM
Definition esb.h:239
@ ESB_TX_POWER_3DBM
Definition esb.h:171
@ ESB_TX_POWER_NEG26DBM
Definition esb.h:243
@ ESB_TX_POWER_NEG6DBM
Definition esb.h:207
@ ESB_TX_POWER_6DBM
Definition esb.h:159
@ ESB_TX_POWER_NEG1DBM
Definition esb.h:187
@ ESB_TX_POWER_NEG5DBM
Definition esb.h:203
@ ESB_TX_POWER_2DBM
Definition esb.h:175
@ ESB_TX_POWER_NEG8DBM
Definition esb.h:215
@ ESB_TX_POWER_7DBM
Definition esb.h:155
@ ESB_TX_POWER_9DBM
Definition esb.h:147
@ ESB_TX_POWER_NEG46DBM
Definition esb.h:255
@ ESB_TX_POWER_NEG3DBM
Definition esb.h:195
@ ESB_TX_POWER_NEG16DBM
Definition esb.h:235
@ ESB_TX_POWER_NEG10DBM
Definition esb.h:223
@ ESB_TX_POWER_NEG70DBM
Definition esb.h:259
@ ESB_TX_POWER_NEG14DBM
Definition esb.h:231
bool esb_tx_full(void)
Check if there is some free space left in TX FIFO.
int esb_reuse_pid(uint8_t pipe)
Reuse a packet ID for a specific pipe.
int esb_set_retransmit_count(uint16_t count)
Set the number of retransmission attempts.
int esb_suspend(void)
Suspend the Enhanced ShockBurst module.
int esb_flush_tx(void)
Flush the TX buffer.
bool esb_is_idle(void)
Check if the Enhanced ShockBurst module is idle.
int esb_pop_tx(void)
Pop the first item from the TX buffer.
esb_protocol
Enhanced ShockBurst protocols.
Definition esb.h:94
@ ESB_PROTOCOL_ESB
Definition esb.h:95
@ ESB_PROTOCOL_ESB_DPL
Definition esb.h:96
int esb_flush_rx(void)
Flush the RX buffer.
int esb_get_rf_channel(uint32_t *channel)
Get the current radio channel.
void esb_disable(void)
Disable the Enhanced ShockBurst module.
int esb_set_base_address_1(const uint8_t *addr)
Set the base address for pipe 1 to pipe 7.
int esb_init(const struct esb_config *config)
Initialize the Enhanced ShockBurst module.
int esb_enable_pipes(uint8_t enable_mask)
Enable select pipes.
uint8_t payload_length
Definition esb.h:342
esb_event_handler event_handler
Definition esb.h:319
int8_t tx_output_power
Definition esb.h:323
enum esb_protocol protocol
Definition esb.h:317
bool selective_auto_ack
Definition esb.h:345
enum esb_bitrate bitrate
Definition esb.h:321
uint16_t retransmit_delay
Definition esb.h:327
enum esb_crc crc
Definition esb.h:322
enum esb_mode mode
Definition esb.h:318
uint16_t retransmit_count
Definition esb.h:335
enum esb_tx_mode tx_mode
Definition esb.h:340
bool use_fast_ramp_up
Definition esb.h:350
Main configuration structure for the module.
Definition esb.h:316
uint32_t tx_attempts
Definition esb.h:309
enum esb_evt_id evt_id
Definition esb.h:308
Enhanced ShockBurst event.
Definition esb.h:307
uint8_t noack
Definition esb.h:299
uint8_t data[CONFIG_ESB_MAX_PAYLOAD_LENGTH]
Definition esb.h:303
uint8_t pid
Definition esb.h:302
uint8_t length
Definition esb.h:296
int8_t rssi
Definition esb.h:298
uint8_t pipe
Definition esb.h:297
Enhanced ShockBurst payload.
Definition esb.h:295