nrf_esb.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. /* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved.
  2. *
  3. * The information contained herein is property of Nordic Semiconductor ASA.
  4. * Terms and conditions of usage are described in detail in NORDIC
  5. * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
  6. *
  7. * Licensees are granted free, non-transferable use of the information. NO
  8. * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
  9. * the file.
  10. *
  11. */
  12. #ifndef __MICRO_ESB_H
  13. #define __MICRO_ESB_H
  14. #include <stdbool.h>
  15. #include <stdint.h>
  16. #include "nrf.h"
  17. #include "app_util.h"
  18. /** @defgroup nrf_esb Enhanced ShockBurst
  19. * @{
  20. * @ingroup proprietary_api
  21. *
  22. * @brief Enhanced ShockBurst (ESB) is a basic protocol supporting two-way data
  23. * packet communication including packet buffering, packet acknowledgment
  24. * and automatic retransmission of lost packets.
  25. */
  26. #define DEBUGPIN1 12
  27. #define DEBUGPIN2 13
  28. #define DEBUGPIN3 14
  29. #define DEBUGPIN4 15
  30. #ifdef NRF_ESB_DEBUG
  31. #define DEBUG_PIN_SET(a) (NRF_GPIO->OUTSET = (1 << (a)))
  32. #define DEBUG_PIN_CLR(a) (NRF_GPIO->OUTCLR = (1 << (a)))
  33. #else
  34. #define DEBUG_PIN_SET(a)
  35. #define DEBUG_PIN_CLR(a)
  36. #endif
  37. // Hard coded parameters - change if necessary
  38. #ifndef NRF_ESB_MAX_PAYLOAD_LENGTH
  39. #define NRF_ESB_MAX_PAYLOAD_LENGTH 32 /**< The max size of the payload. Valid values are 1 to 252 */
  40. #endif
  41. #define NRF_ESB_TX_FIFO_SIZE 8 /**< The size of the transmission first in first out buffer. */
  42. #define NRF_ESB_RX_FIFO_SIZE 8 /**< The size of the reception first in first out buffer. */
  43. // 252 is the largest possible payload size according to the nRF5x architecture.
  44. STATIC_ASSERT(NRF_ESB_MAX_PAYLOAD_LENGTH <= 252);
  45. #define NRF_ESB_SYS_TIMER NRF_TIMER2 /**< The timer which will be used by the module. */
  46. #define NRF_ESB_SYS_TIMER_IRQ_Handler TIMER2_IRQHandler /**< The handler which will be used by NRF_ESB_SYS_TIMER. */
  47. #define NRF_ESB_PPI_TIMER_START 10 /**< The PPI channel used for timer start. */
  48. #define NRF_ESB_PPI_TIMER_STOP 11 /**< The PPI channel used for timer stop. */
  49. #define NRF_ESB_PPI_RX_TIMEOUT 12 /**< The PPI channel used for RX timeout. */
  50. #define NRF_ESB_PPI_TX_START 13 /**< The PPI channel used for starting TX. */
  51. // Interrupt flags
  52. #define NRF_ESB_INT_TX_SUCCESS_MSK 0x01 /**< The flag used to indicate a success since last event. */
  53. #define NRF_ESB_INT_TX_FAILED_MSK 0x02 /**< The flag used to indicate a failiure since last event. */
  54. #define NRF_ESB_INT_RX_DR_MSK 0x04 /**< The flag used to indicate a received packet since last event. */
  55. #define NRF_ESB_PID_RESET_VALUE 0xFF /**< Invalid PID value which is guaranteed to not colide with any valid PID value. */
  56. #define NRF_ESB_PID_MAX 3 /**< Maximum value for PID. */
  57. #define NRF_ESB_CRC_RESET_VALUE 0xFFFF /**< CRC reset value*/
  58. #ifdef NRF51
  59. #define ESB_EVT_IRQ SWI0_IRQn /**< ESB Event IRQ number when running on a nRF51 device. */
  60. #define ESB_EVT_IRQHandler SWI0_IRQHandler /**< The handler for ESB_EVT_IRQ when running on a nRF51 device. */
  61. #elif defined (NRF52)
  62. #define ESB_EVT_IRQ SWI0_EGU0_IRQn /**< ESB Event IRQ number when running on a nRF52 device. */
  63. #define ESB_EVT_IRQHandler SWI0_EGU0_IRQHandler /**< The handler for ESB_EVT_IRQ when running on a nRF52 device. */
  64. #endif /* NRF51 */
  65. #define NRF_ESB_SYS_TIMER NRF_TIMER2 /**< System timer used by nrf_esb */
  66. #define NRF_ESB_SYS_TIMER_IRQ_Handler TIMER2_IRQHandler /**< Timer IRQ handler used by nrf_esb */
  67. #define NRF_ESB_PPI_TIMER_START 10 /**< PPI channel for timer start. */
  68. #define NRF_ESB_PPI_TIMER_STOP 11 /**< PPI Channel for timer stop. */
  69. #define NRF_ESB_PPI_RX_TIMEOUT 12 /**< PPI channel for RX timeout. */
  70. #define NRF_ESB_PPI_TX_START 13 /**< PPI channel for TX start. */
  71. /** Default address configuration for ESB. Roughly equal to nRF24Lxx default (except pipe number which is only possible . */
  72. #define NRF_ESB_ADDR_DEFAULT \
  73. { \
  74. .base_addr_p0 = { 0xE7, 0xE7, 0xE7, 0xE7 }, \
  75. .base_addr_p1 = { 0xC2, 0xC2, 0xC2, 0xC2 }, \
  76. .pipe_prefixes = { 0xE7, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8 }, \
  77. .addr_length = 5, \
  78. .num_pipes = 8, \
  79. .rf_channel = 2, \
  80. .rx_pipes_enabled = 0xFF \
  81. }
  82. /** Default radio parameters. Roughly equal to nRF24Lxx default parameters (except CRC which is set to 16-bit, and protocol set to DPL). */
  83. #define NRF_ESB_DEFAULT_CONFIG {.protocol = NRF_ESB_PROTOCOL_ESB_DPL, \
  84. .mode = NRF_ESB_MODE_PTX, \
  85. .event_handler = 0, \
  86. .bitrate = NRF_ESB_BITRATE_2MBPS, \
  87. .crc = NRF_ESB_CRC_16BIT, \
  88. .tx_output_power = NRF_ESB_TX_POWER_0DBM, \
  89. .retransmit_delay = 250, \
  90. .retransmit_count = 3, \
  91. .tx_mode = NRF_ESB_TXMODE_AUTO, \
  92. .radio_irq_priority = 1, \
  93. .event_irq_priority = 2, \
  94. .payload_length = 32, \
  95. .selective_auto_ack = false \
  96. }
  97. /** Default legacy radio parameters, identical to nRF24L defaults. */
  98. #define NRF_ESB_LEGACY_CONFIG {.protocol = NRF_ESB_PROTOCOL_ESB, \
  99. .mode = NRF_ESB_MODE_PTX, \
  100. .event_handler = 0, \
  101. .bitrate = NRF_ESB_BITRATE_2MBPS, \
  102. .crc = NRF_ESB_CRC_8BIT, \
  103. .tx_output_power = NRF_ESB_TX_POWER_0DBM, \
  104. .retransmit_delay = 600, \
  105. .retransmit_count = 3, \
  106. .tx_mode = NRF_ESB_TXMODE_AUTO, \
  107. .radio_irq_priority = 1, \
  108. .event_irq_priority = 2, \
  109. .payload_length = 32, \
  110. .selective_auto_ack = false \
  111. }
  112. /**Macro to create initializer for a TX data packet.
  113. *
  114. * @details This macro generates an initializer. It is more efficient
  115. * than setting the individual parameters dynamically.
  116. *
  117. * @param[in] _pipe The pipe to use for the data packet.
  118. * @param[in] ... Comma separated list of character data to put in the TX buffer.
  119. * Supported values are from 1 to 63 characters.
  120. *
  121. * @return Initializer that sets up pipe, length and the byte array for content of the TX data.
  122. */
  123. #define NRF_ESB_CREATE_PAYLOAD(_pipe, ...) \
  124. {.pipe = _pipe, .length = NUM_VA_ARGS(__VA_ARGS__), .data = {__VA_ARGS__}}; \
  125. STATIC_ASSERT(NUM_VA_ARGS(__VA_ARGS__) > 0 && NUM_VA_ARGS(__VA_ARGS__) <= 63)
  126. /**@brief Enhanced ShockBurst protocol. */
  127. typedef enum {
  128. NRF_ESB_PROTOCOL_ESB, /*< Enhanced ShockBurst with fixed payload length. */
  129. NRF_ESB_PROTOCOL_ESB_DPL /*< Enhanced ShockBurst with dynamic payload length. */
  130. } nrf_esb_protocol_t;
  131. /**@brief Enhanced ShockBurst mode. */
  132. typedef enum {
  133. NRF_ESB_MODE_PTX, /*< Primary transmitter mode. */
  134. NRF_ESB_MODE_PRX /*< Primary receiver mode. */
  135. } nrf_esb_mode_t;
  136. /**@brief Enhanced ShockBurst bitrate mode. */
  137. typedef enum {
  138. NRF_ESB_BITRATE_2MBPS = RADIO_MODE_MODE_Nrf_2Mbit, /**< 2Mbit radio mode. */
  139. NRF_ESB_BITRATE_1MBPS = RADIO_MODE_MODE_Nrf_1Mbit, /**< 1Mbit radio mode. */
  140. NRF_ESB_BITRATE_250KBPS = RADIO_MODE_MODE_Nrf_250Kbit, /**< 250Kbit radio mode. */
  141. NRF_ESB_BITRATE_1MBPS_BLE = RADIO_MODE_MODE_Ble_1Mbit /**< 1Mbit radio mode using Bluetooth Low Energy radio parameters. */
  142. } nrf_esb_bitrate_t;
  143. /**@brief Enhanced ShockBurst CRC modes. */
  144. typedef enum {
  145. NRF_ESB_CRC_16BIT = RADIO_CRCCNF_LEN_Two, /**< Use two byte CRC. */
  146. NRF_ESB_CRC_8BIT = RADIO_CRCCNF_LEN_One, /**< Use one byte CRC. */
  147. NRF_ESB_CRC_OFF = RADIO_CRCCNF_LEN_Disabled /**< Disable CRC. */
  148. } nrf_esb_crc_t;
  149. /**@brief Enhanced ShockBurst radio transmission power modes. */
  150. typedef enum {
  151. NRF_ESB_TX_POWER_4DBM = RADIO_TXPOWER_TXPOWER_Pos4dBm, /**< 4 dBm radio transmit power. */
  152. NRF_ESB_TX_POWER_0DBM = RADIO_TXPOWER_TXPOWER_0dBm, /**< 0 dBm radio transmit power. */
  153. NRF_ESB_TX_POWER_NEG4DBM = RADIO_TXPOWER_TXPOWER_Neg4dBm, /**< -4 dBm radio transmit power. */
  154. NRF_ESB_TX_POWER_NEG8DBM = RADIO_TXPOWER_TXPOWER_Neg8dBm, /**< -8 dBm radio transmit power. */
  155. NRF_ESB_TX_POWER_NEG12DBM = RADIO_TXPOWER_TXPOWER_Neg12dBm, /**< -12 dBm radio transmit power. */
  156. NRF_ESB_TX_POWER_NEG16DBM = RADIO_TXPOWER_TXPOWER_Neg16dBm, /**< -16 dBm radio transmit power. */
  157. NRF_ESB_TX_POWER_NEG20DBM = RADIO_TXPOWER_TXPOWER_Neg20dBm, /**< -20 dBm radio transmit power. */
  158. NRF_ESB_TX_POWER_NEG30DBM = RADIO_TXPOWER_TXPOWER_Neg30dBm /**< -30 dBm radio transmit power. */
  159. } nrf_esb_tx_power_t;
  160. /**@brief Enhanced ShockBurst transmission modes. */
  161. typedef enum {
  162. NRF_ESB_TXMODE_AUTO, /*< Automatic TX mode - When the TX fifo is non-empty and the radio is idle packets will be sent automatically. */
  163. NRF_ESB_TXMODE_MANUAL, /*< Manual TX mode - Packets will not be sent until nrf_esb_start_tx() is called. Can be used to ensure consistent packet timing. */
  164. NRF_ESB_TXMODE_MANUAL_START /*< Manual start TX mode - Packets will not be sent until nrf_esb_start_tx() is called, but transmission will continue automatically until the TX fifo is empty. */
  165. } nrf_esb_tx_mode_t;
  166. /**@brief Enhanced ShockBurst event id used to indicate the type of the event. */
  167. typedef enum
  168. {
  169. NRF_ESB_EVENT_TX_SUCCESS, /**< Event triggered on TX success. */
  170. NRF_ESB_EVENT_TX_FAILED, /**< Event triggered on TX failed. */
  171. NRF_ESB_EVENT_RX_RECEIVED /**< Event triggered on RX Received. */
  172. } nrf_esb_evt_id_t;
  173. /**@brief Enhanced ShockBurst addresses.
  174. *
  175. * @details The module is able to transmit packets with the TX address stored in tx_address.
  176. The module can also receive packets from peers with up to eight different tx_addresses
  177. stored in esb_addr_p0 - esb_addr_p7. esb_addr_p0 can have 5 arbitrary bytes
  178. independent of the other addresses. esb_addr_p1 - esb_addr_p7 will share the
  179. same four byte base address found in the last four bytes of esb_addr_p1.
  180. They have an independent prefix byte found in esb_addr_p1[0] and esb_addr_p2 -
  181. esb_addr_p7.
  182. */
  183. typedef struct
  184. {
  185. uint8_t base_addr_p0[4]; /**< Base address for pipe 0 encoded in big endian. */
  186. uint8_t base_addr_p1[4]; /**< Base address for pipe 1-7 encoded in big endian. */
  187. uint8_t pipe_prefixes[8]; /**< Address prefix for pipe P0 to P7. */
  188. uint8_t num_pipes; /**< Number of pipes available. */
  189. uint8_t addr_length; /**< Length of address including prefix */
  190. uint8_t rx_pipes_enabled; /**< Bitfield for enabled pipes. */
  191. uint8_t rf_channel; /**< Which channel is to be used. Must be in range 0 and 125 to be valid. */
  192. } nrf_esb_address_t;
  193. /**@brief Enhanced ShockBurst payload.
  194. *
  195. * @note The payload is used both for transmission ions and receive with ack and payload.
  196. */
  197. typedef struct
  198. {
  199. uint8_t length; /**< Length of the packet. Should be equal or less than NRF_ESB_MAX_PAYLOAD_LENGTH. */
  200. uint8_t pipe; /**< Pipe used for this payload. */
  201. int8_t rssi; /**< RSSI for received packet. */
  202. uint8_t noack; /**< Flag indicating that this packet will not be acknowledged. */
  203. uint8_t pid; /**< PID assigned during communication. */
  204. uint8_t data[NRF_ESB_MAX_PAYLOAD_LENGTH]; /**< The payload data. */
  205. } nrf_esb_payload_t;
  206. /**@brief Enhanced ShockBurst event. */
  207. typedef struct
  208. {
  209. nrf_esb_evt_id_t evt_id; /**< Enhanced ShockBurst event id. */
  210. uint32_t tx_attempts; /**< Number of attempts of TX retransmits. */
  211. } nrf_esb_evt_t;
  212. /**@brief Definition of the event handler for the module. */
  213. typedef void (* nrf_esb_event_handler_t)(nrf_esb_evt_t const * p_event);
  214. /**@brief Main nrf_esb configuration struct. */
  215. typedef struct
  216. {
  217. nrf_esb_protocol_t protocol; /**< Enhanced ShockBurst protocol. */
  218. nrf_esb_mode_t mode; /**< Enhanced ShockBurst mode. */
  219. nrf_esb_event_handler_t event_handler; /**< Enhanced ShockBurst event handler. */
  220. // General RF parameters
  221. nrf_esb_bitrate_t bitrate; /**< Enhanced ShockBurst bitrate mode. */
  222. nrf_esb_crc_t crc; /**< Enhanced ShockBurst CRC modes. */
  223. nrf_esb_tx_power_t tx_output_power; /**< Enhanced ShockBurst radio transmission power mode.*/
  224. uint16_t retransmit_delay; /**< The delay between each retransmission of unacked packets. */
  225. uint16_t retransmit_count; /**< The number of retransmissions attempts before transmission fail. */
  226. // Control settings
  227. nrf_esb_tx_mode_t tx_mode; /**< Enhanced ShockBurst transmit mode. */
  228. uint8_t radio_irq_priority; /**< nRF radio interrupt priority. */
  229. uint8_t event_irq_priority; /**< ESB event interrupt priority. */
  230. uint8_t payload_length; /**< Length of payload. Maximum length depend on the platform used in each end. */
  231. bool selective_auto_ack; /**< Enable or disable selective auto acknowledgement. */
  232. } nrf_esb_config_t;
  233. /**@brief Function for initializing the Enhanced ShockBurst module.
  234. *
  235. * @param p_config Parameters for initializing the module.
  236. *
  237. * @retval NRF_SUCCESS Initialization successful.
  238. * @retval NRF_ERROR_NULL The argument parameters was NULL.
  239. * @retval NRF_ERROR_BUSY Function failed because radio is busy.
  240. */
  241. uint32_t nrf_esb_init(nrf_esb_config_t const * p_config);
  242. /**@brief Function for suspending Enhanced ShockBurst
  243. *
  244. * @note Will stop ongoing communications without changing the queues
  245. *
  246. * @retval NRF_SUCCESS Enhanced ShockBurst was disabled.
  247. * @retval NRF_ERROR_BUSY Function failed because radio is busy.
  248. */
  249. uint32_t nrf_esb_suspend(void);
  250. /**@brief Function for disabling Enhanced ShockBurst
  251. *
  252. * Disable the Enhanced ShockBurst module immediately. This may stop ongoing communication.
  253. *
  254. * @note All queues are flushed by this function.
  255. *
  256. * @retval NRF_SUCCESS Enhanced ShockBurst was disabled.
  257. */
  258. uint32_t nrf_esb_disable(void);
  259. /**@brief Function to check if nrf_esb is idle
  260. *
  261. * @retval idle state True if nrf_esb is idle, otherwise false.
  262. */
  263. bool nrf_esb_is_idle(void);
  264. /**@brief Function to write TX or ack payload.
  265. *
  266. * Function for writing a payload to be added to the queue. When the module is in PTX mode, the
  267. * payload will be queued for for a regular transmission. When the module is in PRX mode, the payload
  268. * will be queued for when a packet is received with ack with payload.
  269. *
  270. * @param[in] p_payload Pointer to structure containing information and state of payload.
  271. *
  272. * @retval NRF_SUCCESS Payload was successfully queued up for writing.
  273. * @retval NRF_ERROR_NULL Required parameter was NULL.
  274. * @retval NRF_INVALID_STATE Module is not initialized.
  275. * @retval NRF_ERROR_NOT_SUPPORTED p_payload->noack was false while selective ack was not enabled.
  276. * @retval NRF_ERROR_INVALID_LENGTH Payload length was invalid (zero or larger than max allowed).
  277. */
  278. uint32_t nrf_esb_write_payload(nrf_esb_payload_t const * p_payload);
  279. /**@brief Function to read RX payload.
  280. *
  281. * @param[in,out] p_payload Pointer to structure containing information and state of payload.
  282. *
  283. * @retval NRF_SUCCESS Data read successfully.
  284. * @retval NRF_ERROR_NULL Required parameter was NULL.
  285. * @retval NRF_INVALID_STATE Module is not initialized.
  286. */
  287. uint32_t nrf_esb_read_rx_payload(nrf_esb_payload_t * p_payload);
  288. /**@brief Function to start transmitting.
  289. *
  290. * @retval NRF_SUCCESS TX started successfully.
  291. * @retval NRF_ESB_ERROR_TX_FIFO_EMPTY TX won't start because FIFO buffer is empty.
  292. * @retval NRF_ERROR_BUSY Function failed because radio is busy.
  293. */
  294. uint32_t nrf_esb_start_tx(void);
  295. /**@brief Function to start transmitting data in FIFO buffer.
  296. *
  297. * @retval NRF_SUCCESS RX started successfully.
  298. * @retval NRF_ERROR_BUSY Function failed because radio is busy.
  299. */
  300. uint32_t nrf_esb_start_rx(void);
  301. /** @brief Function to stop receiving data
  302. *
  303. * @retval NRF_SUCCESS Rx started successfully.
  304. * @retval NRF_ERROR_BUSY Function failed because radio is busy.
  305. */
  306. uint32_t nrf_esb_stop_rx(void);
  307. /**@brief Function to remove remaining items from the TX buffer.
  308. *
  309. * @details When this function is run, the TX fifo buffer will be cleared.
  310. *
  311. * @retval NRF_SUCCESS Call was successful.
  312. * @retval NRF_ERROR_NULL Required parameter was NULL.
  313. * @retval NRF_INVALID_STATE Module is not initialized.
  314. */
  315. uint32_t nrf_esb_flush_tx(void);
  316. /**@brief Function to remove the first items from the TX buffer.
  317. *
  318. * @retval NRF_SUCCESS Call was successful.
  319. * @retval NRF_INVALID_STATE Module is not initialized.
  320. * @retval NRF_ERROR_BUFFER_EMPTY No items in queue to remove.
  321. */
  322. uint32_t nrf_esb_pop_tx(void);
  323. /**@brief Function to remove remaining items from the RX buffer.
  324. *
  325. * @retval NRF_SUCCESS Pending items in the RX buffer was successfully cleared.
  326. * @retval NRF_INVALID_STATE Module is not initialized.
  327. */
  328. uint32_t nrf_esb_flush_rx(void);
  329. /**@brief Function to clear pending interrupts
  330. *
  331. * @param[in,out] p_interrupts Pointer to value holding current interrupts.
  332. *
  333. * @retval NRF_SUCCESS Call was successful.
  334. * @retval NRF_ERROR_NULL Required parameter was NULL.
  335. * @retval NRF_INVALID_STATE Module is not initialized.
  336. */
  337. uint32_t nrf_esb_get_clear_interrupts(uint32_t * p_interrupts);
  338. /**@brief Function to set address length
  339. *
  340. * @param[in] length Length in bytes for esb address
  341. *
  342. * @retval NRF_SUCCESS Call was successful.
  343. * @retval NRF_ERROR_INVALID_PARAM Invalid address length
  344. * @retval NRF_ERROR_BUSY Function failed because radio is busy.
  345. */
  346. uint32_t nrf_esb_set_address_length(uint8_t length);
  347. /**@brief Function to set the base address 0
  348. *
  349. * @note This base address is used by pipe 0.
  350. *
  351. * @param[in] p_addr Pointer to the address data.
  352. *
  353. * @retval NRF_SUCCESS Call was successful.
  354. * @retval NRF_ERROR_BUSY Function failed because radio is busy.
  355. * @retval NRF_ERROR_NULL Required parameter was NULL.
  356. */
  357. uint32_t nrf_esb_set_base_address_0(uint8_t const * p_addr);
  358. /**@brief Function to set the base address 1.
  359. *
  360. * @note This base address is used by pipe 1 - 7.
  361. *
  362. * @param[in] p_addr Pointer to the address data.
  363. *
  364. * @retval NRF_SUCCESS Call was successful.
  365. * @retval NRF_ERROR_BUSY Function failed because radio is busy.
  366. * @retval NRF_ERROR_NULL Required parameter was NULL.
  367. */
  368. uint32_t nrf_esb_set_base_address_1(uint8_t const * p_addr);
  369. /**@brief Function to set pipe prefix addresses.
  370. *
  371. * @param[in] p_prefixes Pointer to char array containing prefixes for pipe 0 to 7.
  372. * @param num_pipes Number of pipes to set.
  373. *
  374. * @retval NRF_SUCCESS Call was successful.
  375. * @retval NRF_ERROR_BUSY Function failed because radio is busy.
  376. * @retval NRF_ERROR_NULL Required parameter was NULL.
  377. * @retval NRF_ERROR_INVALID_PARAM Invalid pipe number given.
  378. */
  379. uint32_t nrf_esb_set_prefixes(uint8_t const * p_prefixes, uint8_t num_pipes);
  380. /**@brief Function to control what pipes are enabled.
  381. *
  382. * @note The enable_mask must correspond to the number of pipes that has been enabled with nrf_esb_set_prefixes.
  383. * nrf_esb_set_pre
  384. *
  385. * @param enable_mask Bitfield mask to control enabling or disabling pipes. Setting bit to
  386. * 0 disables the pipe. Setting bit to 1 enables the pipe.
  387. */
  388. uint32_t nrf_esb_enable_pipes(uint8_t enable_mask);
  389. /**@brief Function to update prefix per pipe
  390. *
  391. * @param pipe Pipe to set the prefix.
  392. * @param prefix Prefix to set for pipe.
  393. *
  394. * @retval NRF_SUCCESS Call was successful.
  395. * @retval NRF_ERROR_BUSY Function failed because radio is busy.
  396. * @retval NRF_ERROR_INVALID_PARAM Invalid pipe number given.
  397. */
  398. uint32_t nrf_esb_update_prefix(uint8_t pipe, uint8_t prefix);
  399. /** @brief Function to set the channel to use for the radio.
  400. *
  401. * @note The module has to be in an idle state to call this function. As a PTX the
  402. * application has to wait for an idle state and as an PRX the application must stop RX
  403. * before changing the channel. After changing the channel operation can be resumed.
  404. *
  405. * @param[in] channel Channel to use for radio.
  406. *
  407. * @retval NRF_SUCCESS Call was successful.
  408. * @retval NRF_INVALID_STATE Module is not initialized.
  409. * @retval NRF_ERROR_BUSY Module was not in idle state.
  410. * @retval NRF_ERROR_INVALID_PARAM Channel is invalid (larger than 125).
  411. */
  412. uint32_t nrf_esb_set_rf_channel(uint32_t channel);
  413. /**@brief Function to get the current rf_channel.
  414. *
  415. * @param[in, out] p_channel Pointer to data channel data.
  416. *
  417. * @retval NRF_SUCCESS Call was successful.
  418. * @retval NRF_ERROR_NULL Required parameter was NULL.
  419. */
  420. uint32_t nrf_esb_rf_channel_get(uint32_t * p_channel);
  421. /**@brief Function to set the radio output power.
  422. *
  423. * @param[in] tx_output_power Output power.
  424. *
  425. * @retval NRF_SUCCESS Call was successful.
  426. * @retval NRF_ERROR_BUSY Function failed because radio is busy.
  427. */
  428. uint32_t nrf_esb_set_tx_power(nrf_esb_tx_power_t tx_output_power);
  429. /** @} */
  430. #endif