nrf_radio.h 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404
  1. /**
  2. * Copyright (c) 2018 - 2020, Nordic Semiconductor ASA
  3. *
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without modification,
  7. * are permitted provided that the following conditions are met:
  8. *
  9. * 1. Redistributions of source code must retain the above copyright notice, this
  10. * list of conditions and the following disclaimer.
  11. *
  12. * 2. Redistributions in binary form, except as embedded into a Nordic
  13. * Semiconductor ASA integrated circuit in a product or a software update for
  14. * such product, must reproduce the above copyright notice, this list of
  15. * conditions and the following disclaimer in the documentation and/or other
  16. * materials provided with the distribution.
  17. *
  18. * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * 4. This software, with or without modification, must only be used with a
  23. * Nordic Semiconductor ASA integrated circuit.
  24. *
  25. * 5. Any software provided in binary form under this license must not be reverse
  26. * engineered, decompiled, modified and/or disassembled.
  27. *
  28. * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
  29. * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  30. * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
  31. * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
  32. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  33. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  34. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  35. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  36. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  37. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  38. *
  39. */
  40. #ifndef NRF_RADIO_H__
  41. #define NRF_RADIO_H__
  42. #include <nrfx.h>
  43. #ifdef __cplusplus
  44. extern "C" {
  45. #endif
  46. /**
  47. * @defgroup nrf_radio_hal RADIO HAL
  48. * @{
  49. * @ingroup nrf_radio
  50. * @brief Hardware access layer for managing the RADIO peripheral.
  51. */
  52. /** @brief RADIO tasks. */
  53. typedef enum
  54. {
  55. NRF_RADIO_TASK_TXEN = offsetof(NRF_RADIO_Type, TASKS_TXEN), /**< Enable RADIO in TX mode. */
  56. NRF_RADIO_TASK_RXEN = offsetof(NRF_RADIO_Type, TASKS_RXEN), /**< Enable RADIO in RX mode. */
  57. NRF_RADIO_TASK_START = offsetof(NRF_RADIO_Type, TASKS_START), /**< Start RADIO. */
  58. NRF_RADIO_TASK_STOP = offsetof(NRF_RADIO_Type, TASKS_STOP), /**< Stop RADIO. */
  59. NRF_RADIO_TASK_DISABLE = offsetof(NRF_RADIO_Type, TASKS_DISABLE), /**< Disable RADIO. */
  60. NRF_RADIO_TASK_RSSISTART = offsetof(NRF_RADIO_Type, TASKS_RSSISTART), /**< Start the RSSI and take one single sample of the receive signal strength. */
  61. NRF_RADIO_TASK_RSSISTOP = offsetof(NRF_RADIO_Type, TASKS_RSSISTOP), /**< Stop the RSSI measurement. */
  62. NRF_RADIO_TASK_BCSTART = offsetof(NRF_RADIO_Type, TASKS_BCSTART), /**< Start the bit counter. */
  63. NRF_RADIO_TASK_BCSTOP = offsetof(NRF_RADIO_Type, TASKS_BCSTOP), /**< Stop the bit counter. */
  64. #if defined(RADIO_TASKS_EDSTART_TASKS_EDSTART_Msk) || defined(__NRFX_DOXYGEN__)
  65. NRF_RADIO_TASK_EDSTART = offsetof(NRF_RADIO_Type, TASKS_EDSTART), /**< Start the Energy Detect measurement used in IEEE 802.15.4 mode. */
  66. #endif
  67. #if defined(RADIO_TASKS_EDSTOP_TASKS_EDSTOP_Msk) || defined(__NRFX_DOXYGEN__)
  68. NRF_RADIO_TASK_EDSTOP = offsetof(NRF_RADIO_Type, TASKS_EDSTOP), /**< Stop the Energy Detect measurement. */
  69. #endif
  70. #if defined(RADIO_TASKS_CCASTART_TASKS_CCASTART_Msk) || defined(__NRFX_DOXYGEN__)
  71. NRF_RADIO_TASK_CCASTART = offsetof(NRF_RADIO_Type, TASKS_CCASTART), /**< Start the Clear Channel Assessment used in IEEE 802.15.4 mode. */
  72. #endif
  73. #if defined(RADIO_TASKS_CCASTOP_TASKS_CCASTOP_Msk) || defined(__NRFX_DOXYGEN__)
  74. NRF_RADIO_TASK_CCASTOP = offsetof(NRF_RADIO_Type, TASKS_CCASTOP), /**< Stop the Clear Channel Assessment. */
  75. #endif
  76. } nrf_radio_task_t;
  77. /** @brief RADIO events. */
  78. typedef enum
  79. {
  80. NRF_RADIO_EVENT_READY = offsetof(NRF_RADIO_Type, EVENTS_READY), /**< Radio has ramped up and is ready to be started. */
  81. NRF_RADIO_EVENT_ADDRESS = offsetof(NRF_RADIO_Type, EVENTS_ADDRESS), /**< Address sent or received. */
  82. NRF_RADIO_EVENT_PAYLOAD = offsetof(NRF_RADIO_Type, EVENTS_PAYLOAD), /**< Packet payload sent or received. */
  83. NRF_RADIO_EVENT_END = offsetof(NRF_RADIO_Type, EVENTS_END), /**< Packet transmitted or received. */
  84. NRF_RADIO_EVENT_DISABLED = offsetof(NRF_RADIO_Type, EVENTS_DISABLED), /**< RADIO has been disabled. */
  85. NRF_RADIO_EVENT_DEVMATCH = offsetof(NRF_RADIO_Type, EVENTS_DEVMATCH), /**< A device address match occurred on the last received packet. */
  86. NRF_RADIO_EVENT_DEVMISS = offsetof(NRF_RADIO_Type, EVENTS_DEVMISS), /**< No device address match occurred on the last received packet. */
  87. NRF_RADIO_EVENT_RSSIEND = offsetof(NRF_RADIO_Type, EVENTS_RSSIEND), /**< Sampling of receive signal strength complete. */
  88. NRF_RADIO_EVENT_BCMATCH = offsetof(NRF_RADIO_Type, EVENTS_BCMATCH), /**< Bit counter reached bit count value. */
  89. #if defined(RADIO_INTENSET_CRCOK_Msk) || defined(__NRFX_DOXYGEN__)
  90. NRF_RADIO_EVENT_CRCOK = offsetof(NRF_RADIO_Type, EVENTS_CRCOK), /**< Packet received with correct CRC. */
  91. #endif
  92. #if defined(RADIO_INTENSET_CRCERROR_Msk) || defined(__NRFX_DOXYGEN__)
  93. NRF_RADIO_EVENT_CRCERROR = offsetof(NRF_RADIO_Type, EVENTS_CRCERROR), /**< Packet received with incorrect CRC. */
  94. #endif
  95. #if defined(RADIO_INTENSET_FRAMESTART_Msk) || defined(__NRFX_DOXYGEN__)
  96. NRF_RADIO_EVENT_FRAMESTART = offsetof(NRF_RADIO_Type, EVENTS_FRAMESTART), /**< IEEE 802.15.4 length field received. */
  97. #endif
  98. #if defined(RADIO_INTENSET_EDEND_Msk) || defined(__NRFX_DOXYGEN__)
  99. NRF_RADIO_EVENT_EDEND = offsetof(NRF_RADIO_Type, EVENTS_EDEND), /**< Energy Detection procedure ended. */
  100. #endif
  101. #if defined(RADIO_INTENSET_EDSTOPPED_Msk) || defined(__NRFX_DOXYGEN__)
  102. NRF_RADIO_EVENT_EDSTOPPED = offsetof(NRF_RADIO_Type, EVENTS_EDSTOPPED), /**< The sampling of Energy Detection has stopped. */
  103. #endif
  104. #if defined(RADIO_INTENSET_CCAIDLE_Msk) || defined(__NRFX_DOXYGEN__)
  105. NRF_RADIO_EVENT_CCAIDLE = offsetof(NRF_RADIO_Type, EVENTS_CCAIDLE), /**< Wireless medium in idle - clear to send. */
  106. #endif
  107. #if defined(RADIO_INTENSET_CCABUSY_Msk) || defined(__NRFX_DOXYGEN__)
  108. NRF_RADIO_EVENT_CCABUSY = offsetof(NRF_RADIO_Type, EVENTS_CCABUSY), /**< Wireless medium busy - do not send. */
  109. #endif
  110. #if defined(RADIO_INTENSET_CCASTOPPED_Msk) || defined(__NRFX_DOXYGEN__)
  111. NRF_RADIO_EVENT_CCASTOPPED = offsetof(NRF_RADIO_Type, EVENTS_CCASTOPPED), /**< The CCA has stopped. */
  112. #endif
  113. #if defined(RADIO_INTENSET_RATEBOOST_Msk) || defined(__NRFX_DOXYGEN__)
  114. NRF_RADIO_EVENT_RATEBOOST = offsetof(NRF_RADIO_Type, EVENTS_RATEBOOST), /**< Ble_LR CI field received, receive mode is changed from Ble_LR125Kbit to Ble_LR500Kbit. */
  115. #endif
  116. #if defined(RADIO_INTENSET_TXREADY_Msk) || defined(__NRFX_DOXYGEN__)
  117. NRF_RADIO_EVENT_TXREADY = offsetof(NRF_RADIO_Type, EVENTS_TXREADY), /**< RADIO has ramped up and is ready to be started TX path. */
  118. #endif
  119. #if defined(RADIO_INTENSET_RXREADY_Msk) || defined(__NRFX_DOXYGEN__)
  120. NRF_RADIO_EVENT_RXREADY = offsetof(NRF_RADIO_Type, EVENTS_RXREADY), /**< RADIO has ramped up and is ready to be started RX path. */
  121. #endif
  122. #if defined(RADIO_INTENSET_MHRMATCH_Msk) || defined(__NRFX_DOXYGEN__)
  123. NRF_RADIO_EVENT_MHRMATCH = offsetof(NRF_RADIO_Type, EVENTS_MHRMATCH), /**< MAC Header match found. */
  124. #endif
  125. #if defined(RADIO_INTENSET_PHYEND_Msk) || defined(__NRFX_DOXYGEN__)
  126. NRF_RADIO_EVENT_PHYEND = offsetof(NRF_RADIO_Type, EVENTS_PHYEND), /**< Generated in Ble_LR125Kbit, Ble_LR500Kbit
  127. and BleIeee802154_250Kbit modes when last
  128. bit is sent on the air. */
  129. #endif
  130. } nrf_radio_event_t;
  131. /** @brief RADIO interrupts. */
  132. typedef enum
  133. {
  134. NRF_RADIO_INT_READY_MASK = RADIO_INTENSET_READY_Msk, /**< Interrupt on READY event. */
  135. NRF_RADIO_INT_ADDRESS_MASK = RADIO_INTENSET_ADDRESS_Msk, /**< Interrupt on ADDRESS event. */
  136. NRF_RADIO_INT_PAYLOAD_MASK = RADIO_INTENSET_PAYLOAD_Msk, /**< Interrupt on PAYLOAD event. */
  137. NRF_RADIO_INT_END_MASK = RADIO_INTENSET_END_Msk, /**< Interrupt on END event. */
  138. NRF_RADIO_INT_DISABLED_MASK = RADIO_INTENSET_DISABLED_Msk, /**< Interrupt on DISABLED event. */
  139. NRF_RADIO_INT_DEVMATCH_MASK = RADIO_INTENSET_DEVMATCH_Msk, /**< Interrupt on DEVMATCH event. */
  140. NRF_RADIO_INT_DEVMISS_MASK = RADIO_INTENSET_DEVMISS_Msk, /**< Interrupt on DEVMISS event. */
  141. NRF_RADIO_INT_RSSIEND_MASK = RADIO_INTENSET_RSSIEND_Msk, /**< Interrupt on RSSIEND event. */
  142. NRF_RADIO_INT_BCMATCH_MASK = RADIO_INTENSET_BCMATCH_Msk, /**< Interrupt on BCMATCH event. */
  143. #if defined(RADIO_INTENSET_CRCOK_Msk) || defined(__NRFX_DOXYGEN__)
  144. NRF_RADIO_INT_CRCOK_MASK = RADIO_INTENSET_CRCOK_Msk, /**< Interrupt on CRCOK event. */
  145. #endif
  146. #if defined(RADIO_INTENSET_CRCERROR_Msk) || defined(__NRFX_DOXYGEN__)
  147. NRF_RADIO_INT_CRCERROR_MASK = RADIO_INTENSET_CRCERROR_Msk, /**< Interrupt on CRCERROR event. */
  148. #endif
  149. #if defined(RADIO_INTENSET_FRAMESTART_Msk) || defined(__NRFX_DOXYGEN__)
  150. NRF_RADIO_INT_FRAMESTART_MASK = RADIO_INTENSET_FRAMESTART_Msk, /**< Interrupt on FRAMESTART event. */
  151. #endif
  152. #if defined(RADIO_INTENSET_EDEND_Msk) || defined(__NRFX_DOXYGEN__)
  153. NRF_RADIO_INT_EDEND_MASK = RADIO_INTENSET_EDEND_Msk, /**< Interrupt on EDEND event. */
  154. #endif
  155. #if defined(RADIO_INTENSET_EDSTOPPED_Msk) || defined(__NRFX_DOXYGEN__)
  156. NRF_RADIO_INT_EDSTOPPED_MASK = RADIO_INTENSET_EDSTOPPED_Msk, /**< Interrupt on EDSTOPPED event. */
  157. #endif
  158. #if defined(RADIO_INTENSET_CCAIDLE_Msk) || defined(__NRFX_DOXYGEN__)
  159. NRF_RADIO_INT_CCAIDLE_MASK = RADIO_INTENSET_CCAIDLE_Msk, /**< Interrupt on CCAIDLE event. */
  160. #endif
  161. #if defined(RADIO_INTENSET_CCABUSY_Msk) || defined(__NRFX_DOXYGEN__)
  162. NRF_RADIO_INT_CCABUSY_MASK = RADIO_INTENSET_CCABUSY_Msk, /**< Interrupt on CCABUSY event. */
  163. #endif
  164. #if defined(RADIO_INTENSET_CCASTOPPED_Msk) || defined(__NRFX_DOXYGEN__)
  165. NRF_RADIO_INT_CCASTOPPED_MASK = RADIO_INTENSET_CCASTOPPED_Msk, /**< Interrupt on CCASTOPPED event. */
  166. #endif
  167. #if defined(RADIO_INTENSET_RATEBOOST_Msk) || defined(__NRFX_DOXYGEN__)
  168. NRF_RADIO_INT_RATEBOOST_MASK = RADIO_INTENSET_RATEBOOST_Msk, /**< Interrupt on RATEBOOST event. */
  169. #endif
  170. #if defined(RADIO_INTENSET_TXREADY_Msk) || defined(__NRFX_DOXYGEN__)
  171. NRF_RADIO_INT_TXREADY_MASK = RADIO_INTENSET_TXREADY_Msk, /**< Interrupt on TXREADY event. */
  172. #endif
  173. #if defined(RADIO_INTENSET_RXREADY_Msk) || defined(__NRFX_DOXYGEN__)
  174. NRF_RADIO_INT_RXREADY_MASK = RADIO_INTENSET_RXREADY_Msk, /**< Interrupt on RXREADY event. */
  175. #endif
  176. #if defined(RADIO_INTENSET_MHRMATCH_Msk) || defined(__NRFX_DOXYGEN__)
  177. NRF_RADIO_INT_MHRMATCH_MASK = RADIO_INTENSET_MHRMATCH_Msk, /**< Interrupt on MHRMATCH event. */
  178. #endif
  179. #if defined(RADIO_INTENSET_PHYEND_Msk) || defined(__NRFX_DOXYGEN__)
  180. NRF_RADIO_INT_PHYEND_MASK = RADIO_INTENSET_PHYEND_Msk, /**< Interrupt on PHYEND event. */
  181. #endif
  182. } nrf_radio_int_mask_t;
  183. /** @brief RADIO shortcuts. */
  184. typedef enum
  185. {
  186. NRF_RADIO_SHORT_READY_START_MASK = RADIO_SHORTS_READY_START_Msk, /**< Shortcut between READY event and START task. */
  187. NRF_RADIO_SHORT_END_DISABLE_MASK = RADIO_SHORTS_END_DISABLE_Msk, /**< Shortcut between END event and DISABLE task. */
  188. NRF_RADIO_SHORT_DISABLED_TXEN_MASK = RADIO_SHORTS_DISABLED_TXEN_Msk, /**< Shortcut between DISABLED event and TXEN task. */
  189. NRF_RADIO_SHORT_DISABLED_RXEN_MASK = RADIO_SHORTS_DISABLED_RXEN_Msk, /**< Shortcut between DISABLED event and RXEN task. */
  190. NRF_RADIO_SHORT_ADDRESS_RSSISTART_MASK = RADIO_SHORTS_ADDRESS_RSSISTART_Msk, /**< Shortcut between ADDRESS event and RSSISTART task. */
  191. NRF_RADIO_SHORT_END_START_MASK = RADIO_SHORTS_END_START_Msk, /**< Shortcut between END event and START task. */
  192. NRF_RADIO_SHORT_ADDRESS_BCSTART_MASK = RADIO_SHORTS_ADDRESS_BCSTART_Msk, /**< Shortcut between ADDRESS event and BCSTART task. */
  193. NRF_RADIO_SHORT_DISABLED_RSSISTOP_MASK = RADIO_SHORTS_DISABLED_RSSISTOP_Msk, /**< Shortcut between DISABLED event and RSSISTOP task. */
  194. #if defined(RADIO_SHORTS_RXREADY_CCASTART_Msk) || defined(__NRFX_DOXYGEN__)
  195. NRF_RADIO_SHORT_RXREADY_CCASTART_MASK = RADIO_SHORTS_RXREADY_CCASTART_Msk, /**< Shortcut between RXREADY event and CCASTART task. */
  196. #endif
  197. #if defined(RADIO_SHORTS_CCAIDLE_TXEN_Msk) || defined(__NRFX_DOXYGEN__)
  198. NRF_RADIO_SHORT_CCAIDLE_TXEN_MASK = RADIO_SHORTS_CCAIDLE_TXEN_Msk, /**< Shortcut between CCAIDLE event and TXEN task. */
  199. #endif
  200. #if defined(RADIO_SHORTS_CCABUSY_DISABLE_Msk) || defined(__NRFX_DOXYGEN__)
  201. NRF_RADIO_SHORT_CCABUSY_DISABLE_MASK = RADIO_SHORTS_CCABUSY_DISABLE_Msk, /**< Shortcut between CCABUSY event and DISABLE task. */
  202. #endif
  203. #if defined(RADIO_SHORTS_FRAMESTART_BCSTART_Msk) || defined(__NRFX_DOXYGEN__)
  204. NRF_RADIO_SHORT_FRAMESTART_BCSTART_MASK = RADIO_SHORTS_FRAMESTART_BCSTART_Msk, /**< Shortcut between FRAMESTART event and BCSTART task. */
  205. #endif
  206. #if defined(RADIO_SHORTS_READY_EDSTART_Msk) || defined(__NRFX_DOXYGEN__)
  207. NRF_RADIO_SHORT_READY_EDSTART_MASK = RADIO_SHORTS_READY_EDSTART_Msk, /**< Shortcut between READY event and EDSTART task. */
  208. #endif
  209. #if defined(RADIO_SHORTS_EDEND_DISABLE_Msk) || defined(__NRFX_DOXYGEN__)
  210. NRF_RADIO_SHORT_EDEND_DISABLE_MASK = RADIO_SHORTS_EDEND_DISABLE_Msk, /**< Shortcut between EDEND event and DISABLE task. */
  211. #endif
  212. #if defined(RADIO_SHORTS_CCAIDLE_STOP_Msk) || defined(__NRFX_DOXYGEN__)
  213. NRF_RADIO_SHORT_CCAIDLE_STOP_MASK = RADIO_SHORTS_CCAIDLE_STOP_Msk, /**< Shortcut between CCAIDLE event and STOP task. */
  214. #endif
  215. #if defined(RADIO_SHORTS_TXREADY_START_Msk) || defined(__NRFX_DOXYGEN__)
  216. NRF_RADIO_SHORT_TXREADY_START_MASK = RADIO_SHORTS_TXREADY_START_Msk, /**< Shortcut between TXREADY event and START task. */
  217. #endif
  218. #if defined(RADIO_SHORTS_RXREADY_START_Msk) || defined(__NRFX_DOXYGEN__)
  219. NRF_RADIO_SHORT_RXREADY_START_MASK = RADIO_SHORTS_RXREADY_START_Msk, /**< Shortcut between RXREADY event and START task. */
  220. #endif
  221. #if defined(RADIO_SHORTS_PHYEND_DISABLE_Msk) || defined(__NRFX_DOXYGEN__)
  222. NRF_RADIO_SHORT_PHYEND_DISABLE_MASK = RADIO_SHORTS_PHYEND_DISABLE_Msk, /**< Shortcut between PHYEND event and DISABLE task. */
  223. #endif
  224. #if defined(RADIO_SHORTS_PHYEND_START_Msk) || defined(__NRFX_DOXYGEN__)
  225. NRF_RADIO_SHORT_PHYEND_START_MASK = RADIO_SHORTS_PHYEND_START_Msk, /**< Shortcut between PHYEND event and START task. */
  226. #endif
  227. } nrf_radio_short_mask_t;
  228. #if defined(RADIO_CCACTRL_CCAMODE_Msk) || defined(__NRFX_DOXYGEN__)
  229. /** @brief RADIO Clear Channel Assessment modes. */
  230. typedef enum
  231. {
  232. NRF_RADIO_CCA_MODE_ED = RADIO_CCACTRL_CCAMODE_EdMode, /**< Energy Above Threshold. Will report busy whenever energy is detected above set threshold. */
  233. NRF_RADIO_CCA_MODE_CARRIER = RADIO_CCACTRL_CCAMODE_CarrierMode, /**< Carrier Seen. Will report busy whenever compliant IEEE 802.15.4 signal is seen. */
  234. NRF_RADIO_CCA_MODE_CARRIER_AND_ED = RADIO_CCACTRL_CCAMODE_CarrierAndEdMode, /**< Energy Above Threshold AND Carrier Seen. */
  235. NRF_RADIO_CCA_MODE_CARRIER_OR_ED = RADIO_CCACTRL_CCAMODE_CarrierOrEdMode, /**< Energy Above Threshold OR Carrier Seen. */
  236. NRF_RADIO_CCA_MODE_ED_TEST1 = RADIO_CCACTRL_CCAMODE_EdModeTest1, /**< Energy Above Threshold test mode that will abort when first ED measurement over threshold is seen. No averaging. */
  237. } nrf_radio_cca_mode_t;
  238. #endif // defined(RADIO_CCACTRL_CCAMODE_Msk) || defined(__NRFX_DOXYGEN__)
  239. /** @brief Types of RADIO states. */
  240. typedef enum
  241. {
  242. NRF_RADIO_STATE_DISABLED = RADIO_STATE_STATE_Disabled, /**< No operations are going on inside the radio and the power consumption is at a minimum. */
  243. NRF_RADIO_STATE_RXRU = RADIO_STATE_STATE_RxRu, /**< The radio is ramping up and preparing for reception. */
  244. NRF_RADIO_STATE_RXIDLE = RADIO_STATE_STATE_RxIdle, /**< The radio is ready for reception to start. */
  245. NRF_RADIO_STATE_RX = RADIO_STATE_STATE_Rx, /**< Reception has been started. */
  246. NRF_RADIO_STATE_RXDISABLE = RADIO_STATE_STATE_RxDisable, /**< The radio is disabling the receiver. */
  247. NRF_RADIO_STATE_TXRU = RADIO_STATE_STATE_TxRu, /**< The radio is ramping up and preparing for transmission. */
  248. NRF_RADIO_STATE_TXIDLE = RADIO_STATE_STATE_TxIdle, /**< The radio is ready for transmission to start. */
  249. NRF_RADIO_STATE_TX = RADIO_STATE_STATE_Tx, /**< The radio is transmitting a packet. */
  250. NRF_RADIO_STATE_TXDISABLE = RADIO_STATE_STATE_TxDisable, /**< The radio is disabling the transmitter. */
  251. } nrf_radio_state_t;
  252. /** @brief Types of RADIO TX power. */
  253. typedef enum
  254. {
  255. #if defined(RADIO_TXPOWER_TXPOWER_Pos8dBm) || defined(__NRFX_DOXYGEN__)
  256. NRF_RADIO_TXPOWER_POS8DBM = RADIO_TXPOWER_TXPOWER_Pos8dBm, /**< 8 dBm. */
  257. #endif
  258. #if defined(RADIO_TXPOWER_TXPOWER_Pos7dBm) || defined(__NRFX_DOXYGEN__)
  259. NRF_RADIO_TXPOWER_POS7DBM = RADIO_TXPOWER_TXPOWER_Pos7dBm, /**< 7 dBm. */
  260. #endif
  261. #if defined(RADIO_TXPOWER_TXPOWER_Pos6dBm) || defined(__NRFX_DOXYGEN__)
  262. NRF_RADIO_TXPOWER_POS6DBM = RADIO_TXPOWER_TXPOWER_Pos6dBm, /**< 6 dBm. */
  263. #endif
  264. #if defined(RADIO_TXPOWER_TXPOWER_Pos5dBm) || defined(__NRFX_DOXYGEN__)
  265. NRF_RADIO_TXPOWER_POS5DBM = RADIO_TXPOWER_TXPOWER_Pos5dBm, /**< 5 dBm. */
  266. #endif
  267. NRF_RADIO_TXPOWER_POS4DBM = RADIO_TXPOWER_TXPOWER_Pos4dBm, /**< 4 dBm. */
  268. #if defined(RADIO_TXPOWER_TXPOWER_Pos3dBm) || defined(__NRFX_DOXYGEN__)
  269. NRF_RADIO_TXPOWER_POS3DBM = RADIO_TXPOWER_TXPOWER_Pos3dBm, /**< 3 dBm. */
  270. #endif
  271. #if defined(RADIO_TXPOWER_TXPOWER_Pos2dBm) || defined(__NRFX_DOXYGEN__)
  272. NRF_RADIO_TXPOWER_POS2DBM = RADIO_TXPOWER_TXPOWER_Pos2dBm, /**< 2 dBm. */
  273. #endif
  274. NRF_RADIO_TXPOWER_0DBM = RADIO_TXPOWER_TXPOWER_0dBm, /**< 0 dBm. */
  275. NRF_RADIO_TXPOWER_NEG4DBM = RADIO_TXPOWER_TXPOWER_Neg4dBm, /**< -4 dBm. */
  276. NRF_RADIO_TXPOWER_NEG8DBM = RADIO_TXPOWER_TXPOWER_Neg8dBm, /**< -8 dBm. */
  277. NRF_RADIO_TXPOWER_NEG12DBM = RADIO_TXPOWER_TXPOWER_Neg12dBm, /**< -12 dBm. */
  278. NRF_RADIO_TXPOWER_NEG16DBM = RADIO_TXPOWER_TXPOWER_Neg16dBm, /**< -16 dBm. */
  279. NRF_RADIO_TXPOWER_NEG20DBM = RADIO_TXPOWER_TXPOWER_Neg20dBm, /**< -20 dBm. */
  280. NRF_RADIO_TXPOWER_NEG30DBM = RADIO_TXPOWER_TXPOWER_Neg30dBm, /**< -30 dBm. */
  281. #if defined(RADIO_TXPOWER_TXPOWER_Neg40dBm) || defined(__NRFX_DOXYGEN__)
  282. NRF_RADIO_TXPOWER_NEG40DBM = RADIO_TXPOWER_TXPOWER_Neg40dBm, /**< -40 dBm. */
  283. #endif
  284. } nrf_radio_txpower_t;
  285. /** @brief Types of RADIO modes (data rate and modulation). */
  286. typedef enum
  287. {
  288. NRF_RADIO_MODE_NRF_1MBIT = RADIO_MODE_MODE_Nrf_1Mbit, /**< 1Mbit/s Nordic proprietary radio mode. */
  289. NRF_RADIO_MODE_NRF_2MBIT = RADIO_MODE_MODE_Nrf_2Mbit, /**< 2Mbit/s Nordic proprietary radio mode. */
  290. #if defined(RADIO_MODE_MODE_Nrf_250Kbit) || defined(__NRFX_DOXYGEN__)
  291. NRF_RADIO_MODE_NRF_250KBIT = RADIO_MODE_MODE_Nrf_250Kbit, /**< 250Kbit/s Nordic proprietary radio mode. */
  292. #endif
  293. NRF_RADIO_MODE_BLE_1MBIT = RADIO_MODE_MODE_Ble_1Mbit, /**< 1 Mbit/s Bluetooth Low Energy. */
  294. #if defined(RADIO_MODE_MODE_Ble_2Mbit) || defined(__NRFX_DOXYGEN__)
  295. NRF_RADIO_MODE_BLE_2MBIT = RADIO_MODE_MODE_Ble_2Mbit, /**< 2 Mbit/s Bluetooth Low Energy. */
  296. #endif
  297. #if defined(RADIO_MODE_MODE_Ble_LR125Kbit) || defined(__NRFX_DOXYGEN__)
  298. NRF_RADIO_MODE_BLE_LR125KBIT = RADIO_MODE_MODE_Ble_LR125Kbit, /*!< Bluetooth Low Energy Long range 125 kbit/s TX, 125 kbit/s and 500 kbit/s RX */
  299. #endif
  300. #if defined(RADIO_MODE_MODE_Ble_LR500Kbit) || defined(__NRFX_DOXYGEN__)
  301. NRF_RADIO_MODE_BLE_LR500KBIT = RADIO_MODE_MODE_Ble_LR500Kbit, /*!< Bluetooth Low Energy Long range 500 kbit/s TX, 125 kbit/s and 500 kbit/s RX */
  302. #endif
  303. #if defined(RADIO_MODE_MODE_Ieee802154_250Kbit) || defined(__NRFX_DOXYGEN__)
  304. NRF_RADIO_MODE_IEEE802154_250KBIT = RADIO_MODE_MODE_Ieee802154_250Kbit, /**< IEEE 802.15.4-2006 250 kbit/s. */
  305. #endif
  306. } nrf_radio_mode_t;
  307. #if defined(RADIO_PCNF0_PLEN_Msk) || defined(__NRFX_DOXYGEN__)
  308. /** @brief Types of preamble length. */
  309. typedef enum
  310. {
  311. NRF_RADIO_PREAMBLE_LENGTH_8BIT = RADIO_PCNF0_PLEN_8bit, /**< 8-bit preamble. */
  312. NRF_RADIO_PREAMBLE_LENGTH_16BIT = RADIO_PCNF0_PLEN_16bit, /**< 16-bit preamble. */
  313. #if defined(RADIO_PCNF0_PLEN_32bitZero) || defined(__NRFX_DOXYGEN__)
  314. NRF_RADIO_PREAMBLE_LENGTH_32BIT_ZERO = RADIO_PCNF0_PLEN_32bitZero, /**< 32-bit zero preamble used for IEEE 802.15.4. */
  315. #endif
  316. #if defined(RADIO_PCNF0_PLEN_LongRange) || defined(__NRFX_DOXYGEN__)
  317. NRF_RADIO_PREAMBLE_LENGTH_LONG_RANGE = RADIO_PCNF0_PLEN_LongRange, /**< Preamble - used for BTLE Long Range. */
  318. #endif
  319. } nrf_radio_preamble_length_t;
  320. #endif // defined(RADIO_PCNF0_PLEN_Msk) || defined(__NRFX_DOXYGEN__)
  321. /** @brief Types of CRC calculatons regarding address. */
  322. typedef enum
  323. {
  324. NRF_RADIO_CRC_ADDR_INCLUDE = RADIO_CRCCNF_SKIPADDR_Include, /**< CRC calculation includes address field. */
  325. NRF_RADIO_CRC_ADDR_SKIP = RADIO_CRCCNF_SKIPADDR_Skip, /**< CRC calculation does not include address field. */
  326. #if defined(RADIO_CRCCNF_SKIPADDR_Ieee802154) || defined(__NRFX_DOXYGEN__)
  327. NRF_RADIO_CRC_ADDR_IEEE802154 = RADIO_CRCCNF_SKIPADDR_Ieee802154, /**< CRC calculation as per 802.15.4 standard. */
  328. #endif
  329. } nrf_radio_crc_addr_t;
  330. /** @brief Packet configuration. */
  331. typedef struct
  332. {
  333. uint8_t lflen; /**< Length on air of LENGTH field in number of bits. */
  334. uint8_t s0len; /**< Length on air of S0 field in number of bytes. */
  335. uint8_t s1len; /**< Length on air of S1 field in number of bits. */
  336. #if defined(RADIO_PCNF0_S1INCL_Msk) || defined(__NRFX_DOXYGEN__)
  337. bool s1incl; /**< Include or exclude S1 field in RAM. */
  338. #endif
  339. #if defined(RADIO_PCNF0_CILEN_Msk) || defined(__NRFX_DOXYGEN__)
  340. uint8_t cilen; /**< Length of code indicator - long range. */
  341. #endif
  342. #if defined(RADIO_PCNF0_PLEN_Msk) || defined(__NRFX_DOXYGEN__)
  343. nrf_radio_preamble_length_t plen; /**< Length of preamble on air. Decision point: TASKS_START task. */
  344. #endif
  345. #if defined(RADIO_PCNF0_CRCINC_Msk) || defined(__NRFX_DOXYGEN__)
  346. bool crcinc; /**< Indicates if LENGTH field contains CRC or not. */
  347. #endif
  348. #if defined(RADIO_PCNF0_TERMLEN_Msk) || defined(__NRFX_DOXYGEN__)
  349. uint8_t termlen; /**< Length of TERM field in Long Range operation. */
  350. #endif
  351. uint8_t maxlen; /**< Maximum length of packet payload. */
  352. uint8_t statlen; /**< Static length in number of bytes. */
  353. uint8_t balen; /**< Base address length in number of bytes. */
  354. bool big_endian; /**< On air endianness of packet. */
  355. bool whiteen; /**< Enable or disable packet whitening. */
  356. } nrf_radio_packet_conf_t;
  357. /**
  358. * @brief Function for activating a specific RADIO task.
  359. *
  360. * @param[in] task Task to be activated.
  361. */
  362. __STATIC_INLINE void nrf_radio_task_trigger(nrf_radio_task_t task);
  363. /**
  364. * @brief Function for getting the address of a specific RADIO task register.
  365. *
  366. * This function can be used by the PPI module.
  367. *
  368. * @param[in] task Requested task.
  369. *
  370. * @return Address of the specified task register.
  371. */
  372. __STATIC_INLINE uint32_t nrf_radio_task_address_get(nrf_radio_task_t task);
  373. /**
  374. * @brief Function for clearing a specific RADIO event.
  375. *
  376. * @param[in] event Event to clean.
  377. */
  378. __STATIC_INLINE void nrf_radio_event_clear(nrf_radio_event_t event);
  379. /**
  380. * @brief Function for retrieving the state of the RADIO event.
  381. *
  382. * @param[in] event Event to be checked.
  383. *
  384. * @retval true The event has been generated.
  385. * @retval false The event has not been generated.
  386. */
  387. __STATIC_INLINE bool nrf_radio_event_check(nrf_radio_event_t event);
  388. /**
  389. * @brief Function for getting the address of a specific RADIO event register.
  390. *
  391. * This function can be used by the PPI module.
  392. *
  393. * @param[in] event Requested Event.
  394. *
  395. * @return Address of the specified event register.
  396. */
  397. __STATIC_INLINE uint32_t nrf_radio_event_address_get(nrf_radio_event_t event);
  398. /**
  399. * @brief Function for enabling specified RADIO shortcuts.
  400. *
  401. * @param[in] shorts_mask Mask of shortcuts.
  402. */
  403. __STATIC_INLINE void nrf_radio_shorts_enable(uint32_t shorts_mask);
  404. /**
  405. * @brief Function for disabling specified RADIO shortcuts.
  406. *
  407. * @param[in] shorts_mask Mask of shortcuts.
  408. */
  409. __STATIC_INLINE void nrf_radio_shorts_disable(uint32_t shorts_mask);
  410. /**
  411. * @brief Function for setting the configuration of RADIO shortcuts.
  412. *
  413. * @param[in] shorts_mask Shortcuts configuration to set.
  414. */
  415. __STATIC_INLINE void nrf_radio_shorts_set(uint32_t shorts_mask);
  416. /**
  417. * @brief Function for getting the configuration of RADIO shortcuts.
  418. *
  419. * @return Mask of currently enabled shortcuts.
  420. */
  421. __STATIC_INLINE uint32_t nrf_radio_shorts_get(void);
  422. /**
  423. * @brief Function for enabling specified RADIO interrupts.
  424. *
  425. * @param[in] int_mask Mask of interrupts.
  426. */
  427. __STATIC_INLINE void nrf_radio_int_enable(uint32_t int_mask);
  428. /**
  429. * @brief Function for disabling specified RADIO interrupts.
  430. *
  431. * @param[in] int_mask Mask of interrupts.
  432. */
  433. __STATIC_INLINE void nrf_radio_int_disable(uint32_t int_mask);
  434. /**
  435. * @brief Function for getting the state of a specific interrupt.
  436. *
  437. * @param[in] int_mask Interrupt to be checked.
  438. *
  439. * @retval true The interrupt is enabled.
  440. * @retval false The interrupt is not enabled.
  441. */
  442. __STATIC_INLINE bool nrf_radio_int_enable_check(nrf_radio_int_mask_t int_mask);
  443. /**
  444. * @brief Function for getting CRC status of last received packet.
  445. *
  446. * @retval true The packet was received without CRC error.
  447. * @retval false The packet was received with CRC error.
  448. */
  449. __STATIC_INLINE bool nrf_radio_crc_status_check(void);
  450. /**
  451. * @brief Function for getting the received address.
  452. *
  453. * @return Received address.
  454. */
  455. __STATIC_INLINE uint8_t nrf_radio_rxmatch_get(void);
  456. /**
  457. * @brief Function for getting CRC field of the last received packet.
  458. *
  459. * @return CRC field of previously received packet.
  460. */
  461. __STATIC_INLINE uint32_t nrf_radio_rxcrc_get(void);
  462. /**
  463. * @brief Function for getting the device address match index.
  464. *
  465. * @return Device adress match index.
  466. */
  467. __STATIC_INLINE uint8_t nrf_radio_dai_get(void);
  468. #if defined(RADIO_PDUSTAT_PDUSTAT_Msk) || defined(__NRFX_DOXYGEN__)
  469. /**
  470. * @brief Function for getting status on payload length.
  471. *
  472. * @retval 0 The payload is lesser than PCNF1.MAXLEN.
  473. * @retval 1 The payload is greater than PCNF1.MAXLEN.
  474. */
  475. __STATIC_INLINE uint8_t nrf_radio_pdustat_get(void);
  476. /**
  477. * @brief Function for getting status on what rate packet is received with in Long Range.
  478. *
  479. * @retval 0 The frame is received at 125kbps.
  480. * @retval 1 The frame is received at 500kbps.
  481. */
  482. __STATIC_INLINE uint8_t nrf_radio_cistat_get(void);
  483. #endif // defined(RADIO_PDUSTAT_PDUSTAT_Msk) || defined(__NRFX_DOXYGEN__)
  484. /**
  485. * @brief Function for setting packet pointer to given location in memory.
  486. *
  487. * @param[in] p_packet Packet pointer.
  488. */
  489. __STATIC_INLINE void nrf_radio_packetptr_set(const void * p_packet);
  490. /**
  491. * @brief Function for getting packet pointer.
  492. *
  493. * @return Pointer to tx or rx packet buffer.
  494. */
  495. __STATIC_INLINE void * nrf_radio_packetptr_get(void);
  496. /**
  497. * @brief Function for setting the radio frequency.
  498. *
  499. * @param[in] radio_frequency Frequency in MHz.
  500. */
  501. __STATIC_INLINE void nrf_radio_frequency_set(uint16_t radio_frequency);
  502. /**
  503. * @brief Function for getting the radio frequency.
  504. *
  505. * @return Frequency in MHz.
  506. */
  507. __STATIC_INLINE uint16_t nrf_radio_frequency_get(void);
  508. /**
  509. * @brief Function for setting the radio transmit power.
  510. *
  511. * @param[in] tx_power Transmit power of the radio [dBm].
  512. */
  513. __STATIC_INLINE void nrf_radio_txpower_set(nrf_radio_txpower_t tx_power);
  514. /**
  515. * @brief Function for getting the radio transmit power.
  516. *
  517. * @return Transmit power of the radio.
  518. */
  519. __STATIC_INLINE nrf_radio_txpower_t nrf_radio_txpower_get(void);
  520. /**
  521. * @brief Function for setting the radio data rate and modulation settings.
  522. *
  523. * @param[in] radio_mode Radio data rate and modulation.
  524. */
  525. __STATIC_INLINE void nrf_radio_mode_set(nrf_radio_mode_t radio_mode);
  526. /**
  527. * @brief Function for getting Radio data rate and modulation settings.
  528. *
  529. * @return Radio data rate and modulation.
  530. */
  531. __STATIC_INLINE nrf_radio_mode_t nrf_radio_mode_get(void);
  532. /**
  533. * @brief Function for setting the packet configuration.
  534. *
  535. * @param[in] p_config Pointer to the structure with packet configuration.
  536. */
  537. __STATIC_INLINE void nrf_radio_packet_configure(const nrf_radio_packet_conf_t * p_config);
  538. /**
  539. * @brief Function for setting the base address 0.
  540. *
  541. * @param address Base address 0 value.
  542. */
  543. __STATIC_INLINE void nrf_radio_base0_set(uint32_t address);
  544. /**
  545. * @brief Function for getting the base address 0.
  546. *
  547. * @return Base address 0.
  548. */
  549. __STATIC_INLINE uint32_t nrf_radio_base0_get(void);
  550. /**
  551. * @brief Function for setting Base address 1.
  552. *
  553. * @param address Base address 1 value.
  554. */
  555. __STATIC_INLINE void nrf_radio_base1_set(uint32_t address);
  556. /**
  557. * @brief Function for getting base address 1.
  558. *
  559. * @return Base address 1.
  560. */
  561. __STATIC_INLINE uint32_t nrf_radio_base1_get(void);
  562. /**
  563. * @brief Function for setting prefixes bytes for logical addresses 0-3.
  564. *
  565. * @param prefixes Prefixes bytes for logical addresses 0-3.
  566. */
  567. __STATIC_INLINE void nrf_radio_prefix0_set(uint32_t prefixes);
  568. /**
  569. * @brief Function for getting prefixes bytes for logical addresses 0-3
  570. *
  571. * @return Prefixes bytes for logical addresses 0-3
  572. */
  573. __STATIC_INLINE uint32_t nrf_radio_prefix0_get(void);
  574. /**
  575. * @brief Function for setting prefixes bytes for logical addresses 4-7.
  576. *
  577. * @param prefixes Prefixes bytes for logical addresses 4-7.
  578. */
  579. __STATIC_INLINE void nrf_radio_prefix1_set(uint32_t prefixes);
  580. /**
  581. * @brief Function for getting prefixes bytes for logical addresses 4-7
  582. *
  583. * @return Prefixes bytes for logical addresses 4-7
  584. */
  585. __STATIC_INLINE uint32_t nrf_radio_prefix1_get(void);
  586. /**
  587. * @brief Function for setting the transmit address.
  588. *
  589. * @param txaddress Logical address to be used when transmitting a packet.
  590. */
  591. __STATIC_INLINE void nrf_radio_txaddress_set(uint8_t txaddress);
  592. /**
  593. * @brief Function for getting the transmit address select.
  594. *
  595. * @return Logical address to be used when transmitting a packet.
  596. */
  597. __STATIC_INLINE uint8_t nrf_radio_txaddress_get(void);
  598. /**
  599. * @brief Function for for selecting the receive addresses.
  600. *
  601. * @param rxaddresses Enable or disable reception on logical address i.
  602. * Read more in the Product Specification.
  603. */
  604. __STATIC_INLINE void nrf_radio_rxaddresses_set(uint8_t rxaddresses);
  605. /**
  606. * @brief Function for getting receive address select.
  607. *
  608. * @return Receive address select.
  609. */
  610. __STATIC_INLINE uint8_t nrf_radio_rxaddresses_get(void);
  611. /**
  612. * @brief Function for configure CRC.
  613. *
  614. * @param[in] crc_length CRC length in number of bytes [0-3].
  615. * @param[in] crc_address Include or exclude packet address field out of CRC.
  616. * @param[in] crc_polynominal CRC polynominal to set.
  617. */
  618. __STATIC_INLINE void nrf_radio_crc_configure(uint8_t crc_length,
  619. nrf_radio_crc_addr_t crc_address,
  620. uint32_t crc_polynominal);
  621. /**
  622. * @brief Function for setting CRC initial value.
  623. *
  624. * @param crc_init_value CRC initial value
  625. */
  626. __STATIC_INLINE void nrf_radio_crcinit_set(uint32_t crc_init_value);
  627. /**
  628. * @brief Function for getting CRC initial value.
  629. *
  630. * @return CRC initial value.
  631. */
  632. __STATIC_INLINE uint32_t nrf_radio_crcinit_get(void);
  633. /**
  634. * @brief Function for setting Inter Frame Spacing interval.
  635. *
  636. * @param[in] radio_ifs Inter frame spacing interval [us].
  637. */
  638. __STATIC_INLINE void nrf_radio_ifs_set(uint32_t radio_ifs);
  639. /**
  640. * @brief Function for getting Inter Frame Spacing interval.
  641. *
  642. * @return Inter frame spacing interval [us].
  643. */
  644. __STATIC_INLINE uint32_t nrf_radio_ifs_get(void);
  645. /**
  646. * @brief Function for getting RSSI sample result.
  647. *
  648. * @note The read value is a positive value while the actual received signal
  649. * is a negative value. Actual received signal strength is therefore as follows:
  650. * received signal strength = - read_value dBm .
  651. *
  652. * @return RSSI sample result.
  653. */
  654. __STATIC_INLINE uint8_t nrf_radio_rssi_sample_get(void);
  655. /**
  656. * @brief Function for getting the current state of the radio module.
  657. *
  658. * @return Current radio state.
  659. */
  660. __STATIC_INLINE nrf_radio_state_t nrf_radio_state_get(void);
  661. /**
  662. * @brief Function for setting the data whitening initial value.
  663. *
  664. * @param datawhiteiv Data whitening initial value.
  665. */
  666. __STATIC_INLINE void nrf_radio_datawhiteiv_set(uint8_t datawhiteiv);
  667. /**
  668. * @brief Function for getting the data whitening initial value.
  669. *
  670. * @return Data whitening initial value.
  671. */
  672. __STATIC_INLINE uint8_t nrf_radio_datawhiteiv_get(void);
  673. /**
  674. * @brief Function for setting Bit counter compare.
  675. *
  676. * @param[in] radio_bcc Bit counter compare [bits].
  677. */
  678. __STATIC_INLINE void nrf_radio_bcc_set(uint32_t radio_bcc);
  679. /**
  680. * @brief Function for getting Bit counter compare.
  681. *
  682. * @return Bit counter compare.
  683. */
  684. __STATIC_INLINE uint32_t nrf_radio_bcc_get(void);
  685. /**
  686. * @brief Function for setting Device address base segment.
  687. *
  688. * @param dab_value Particular base segment value.
  689. * @param segment Index of the particular Device address base segment register.
  690. */
  691. __STATIC_INLINE void nrf_radio_dab_set(uint32_t dab_value, uint8_t segment);
  692. /**
  693. * @brief Function for getting Device address base segment.
  694. *
  695. * @param segment Number of the Device address base segment.
  696. *
  697. * @return Particular segment of the Device address base.
  698. */
  699. __STATIC_INLINE uint32_t nrf_radio_dab_get(uint8_t segment);
  700. /**
  701. * @brief Function for setting device address prefix.
  702. *
  703. * @param dap_value Particular device address prefix value.
  704. * @param prefix_index Index of the particular device address prefix register.
  705. */
  706. __STATIC_INLINE void nrf_radio_dap_set(uint16_t dap_value, uint8_t prefix_index);
  707. /**
  708. * @brief Function for getting Device address prefix.
  709. *
  710. * @param prefix_index Number of the Device address prefix segment.
  711. *
  712. * @return Particular segment of the Device address prefix.
  713. */
  714. __STATIC_INLINE uint32_t nrf_radio_dap_get(uint8_t prefix_index);
  715. /**
  716. * @brief Function for setting device address match configuration.
  717. *
  718. * @note Read more about configuring device address match in the Product Specification.
  719. *
  720. * @param ena Device address matching bitmask.
  721. * @param txadd TxAdd bitmask.
  722. */
  723. __STATIC_INLINE void nrf_radio_dacnf_set(uint8_t ena, uint8_t txadd);
  724. /**
  725. * @brief Function for getting ENA field of the Device address match configuration register.
  726. *
  727. * @return ENA field of the Device address match configuration register.
  728. */
  729. __STATIC_INLINE uint8_t nrf_radio_dacnf_ena_get(void);
  730. /**
  731. * @brief Function for getting TXADD field of the Device address match configuration register.
  732. *
  733. * @return TXADD field of the Device address match configuration register.
  734. */
  735. __STATIC_INLINE uint8_t nrf_radio_dacnf_txadd_get(void);
  736. #if defined(RADIO_INTENSET_MHRMATCH_Msk) || defined(__NRFX_DOXYGEN__)
  737. /**
  738. * @brief Function for setting MAC Header Match Unit search pattern configuration.
  739. *
  740. * @param[in] radio_mhmu_search_pattern Search Pattern Configuration.
  741. */
  742. __STATIC_INLINE void nrf_radio_mhmu_search_pattern_set(uint32_t radio_mhmu_search_pattern);
  743. /**
  744. * @brief Function for getting MAC Header Match Unit search pattern configuration.
  745. *
  746. * @return Search Pattern Configuration.
  747. */
  748. __STATIC_INLINE uint32_t nrf_radio_mhmu_search_pattern_get(void);
  749. /**
  750. * @brief Function for setting MAC Header Match Unit pattern mask configuration.
  751. *
  752. * @param[in] radio_mhmu_pattern_mask Pattern mask.
  753. */
  754. __STATIC_INLINE void nrf_radio_mhmu_pattern_mask_set(uint32_t radio_mhmu_pattern_mask);
  755. /**
  756. * @brief Function for getting MAC Header Match Unit pattern mask configuration.
  757. *
  758. * @return Pattern mask.
  759. */
  760. __STATIC_INLINE uint32_t nrf_radio_mhmu_pattern_mask_get(void);
  761. #endif // defined(RADIO_INTENSET_MHRMATCH_Msk) || defined(__NRFX_DOXYGEN__)
  762. #if defined(RADIO_MODECNF0_RU_Msk) || defined(__NRFX_DOXYGEN__)
  763. /**
  764. * @brief Function for setting Radio mode configuration register 0.
  765. *
  766. * @param fast_ramp_up Use fast radio ramp-up time
  767. * @param default_tx Default TX value during inactivity.
  768. */
  769. __STATIC_INLINE void nrf_radio_modecnf0_set(bool fast_ramp_up, uint8_t default_tx);
  770. /**
  771. * @brief Function for getting ramp-up time configuration of the Radio mode configuration register 0.
  772. *
  773. * @retval true If the ramp-up time is set to fast.
  774. * @retval false If the ramp-up time is set to default.
  775. */
  776. __STATIC_INLINE bool nrf_radio_modecnf0_ru_get(void);
  777. /**
  778. * @brief Function for getting default TX value of the Radio mode configuration register 0.
  779. *
  780. * @return Default TX value.
  781. */
  782. __STATIC_INLINE uint8_t nrf_radio_modecnf0_dtx_get(void);
  783. #endif // defined(RADIO_MODECNF0_RU_Msk) || defined(__NRFX_DOXYGEN__)
  784. #if defined(RADIO_SFD_SFD_Msk) || defined(__NRFX_DOXYGEN__)
  785. /**
  786. * @brief Function for setting IEEE 802.15.4 start of frame delimiter.
  787. *
  788. * @param sfd IEEE 802.15.4 start of frame delimiter.
  789. */
  790. __STATIC_INLINE void nrf_radio_sfd_set(uint8_t sfd);
  791. /**
  792. * @brief Function for getting IEEE 802.15.4 start of frame delimiter.
  793. *
  794. * @return IEEE 802.15.4 start of frame delimiter.
  795. */
  796. __STATIC_INLINE uint8_t nrf_radio_sfd_get(void);
  797. #endif // defined(RADIO_SFD_SFD_Msk) || defined(__NRFX_DOXYGEN__)
  798. #if defined(RADIO_EDCNT_EDCNT_Msk) || defined(__NRFX_DOXYGEN__)
  799. /**
  800. * @brief Function for setting number of iterations to perform ED scan.
  801. *
  802. * @param[in] ed_loop_count Number of iterations during ED procedure.
  803. */
  804. __STATIC_INLINE void nrf_radio_ed_loop_count_set(uint32_t ed_loop_count);
  805. #endif // defined(RADIO_EDCNT_EDCNT_Msk) || defined(__NRFX_DOXYGEN__)
  806. #if defined(RADIO_EDSAMPLE_EDLVL_Msk) || defined(__NRFX_DOXYGEN__)
  807. /**
  808. * @brief Function for getting Energy Detection level.
  809. *
  810. * @return IEEE 802.15.4 energy detect level.
  811. */
  812. __STATIC_INLINE uint8_t nrf_radio_ed_sample_get(void);
  813. #endif // defined(RADIO_EDSAMPLE_EDLVL_Msk) || defined(__NRFX_DOXYGEN__)
  814. #if defined(RADIO_CCACTRL_CCAMODE_Msk) || defined(__NRFX_DOXYGEN__)
  815. /**
  816. * @brief Function for configuring the IEEE 802.15.4 clear channel assessment.
  817. *
  818. * @param cca_mode Mode of CCA.
  819. * @param cca_ed_threshold Energy Detection threshold value.
  820. * @param cca_corr_threshold Correlator Busy Threshold.
  821. * @param cca_corr_cnt Limit of occurances above Correlator Threshold.
  822. * When not equal to zero the correlator based
  823. * signal detect is enabled.
  824. */
  825. __STATIC_INLINE void nrf_radio_cca_configure(nrf_radio_cca_mode_t cca_mode,
  826. uint8_t cca_ed_threshold,
  827. uint8_t cca_corr_threshold,
  828. uint8_t cca_corr_cnt);
  829. #endif // defined(RADIO_CCACTRL_CCAMODE_Msk) || defined(__NRFX_DOXYGEN__)
  830. /**
  831. * @brief Function for setting power mode of the radio peripheral.
  832. *
  833. * @param[in] radio_power If radio should be powered on.
  834. */
  835. __STATIC_INLINE void nrf_radio_power_set(bool radio_power);
  836. #ifndef SUPPRESS_INLINE_IMPLEMENTATION
  837. __STATIC_INLINE void nrf_radio_task_trigger(nrf_radio_task_t task)
  838. {
  839. *((volatile uint32_t *)((uint8_t *)NRF_RADIO + (uint32_t)task)) = 0x1UL;
  840. }
  841. __STATIC_INLINE uint32_t nrf_radio_task_address_get(nrf_radio_task_t task)
  842. {
  843. return ((uint32_t)NRF_RADIO + (uint32_t)task);
  844. }
  845. __STATIC_INLINE void nrf_radio_event_clear(nrf_radio_event_t event)
  846. {
  847. *((volatile uint32_t *)((uint8_t *)NRF_RADIO + (uint32_t)event)) = 0x0UL;
  848. #if __CORTEX_M == 0x04
  849. volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)NRF_RADIO + (uint32_t)event));
  850. (void)dummy;
  851. #endif
  852. }
  853. __STATIC_INLINE bool nrf_radio_event_check(nrf_radio_event_t event)
  854. {
  855. return (bool) *((volatile uint32_t *)((uint8_t *)NRF_RADIO + (uint32_t)event));
  856. }
  857. __STATIC_INLINE uint32_t nrf_radio_event_address_get(nrf_radio_event_t event)
  858. {
  859. return ((uint32_t)NRF_RADIO + (uint32_t)event);
  860. }
  861. __STATIC_INLINE void nrf_radio_shorts_enable(uint32_t shorts_mask)
  862. {
  863. NRF_RADIO->SHORTS |= shorts_mask;
  864. }
  865. __STATIC_INLINE void nrf_radio_shorts_disable(uint32_t shorts_mask)
  866. {
  867. NRF_RADIO->SHORTS &= ~shorts_mask;
  868. }
  869. __STATIC_INLINE void nrf_radio_shorts_set(uint32_t shorts_mask)
  870. {
  871. NRF_RADIO->SHORTS = shorts_mask;
  872. }
  873. __STATIC_INLINE uint32_t nrf_radio_shorts_get(void)
  874. {
  875. return NRF_RADIO->SHORTS;
  876. }
  877. __STATIC_INLINE void nrf_radio_int_enable(uint32_t int_mask)
  878. {
  879. NRF_RADIO->INTENSET = int_mask;
  880. }
  881. __STATIC_INLINE void nrf_radio_int_disable(uint32_t int_mask)
  882. {
  883. NRF_RADIO->INTENCLR = int_mask;
  884. }
  885. __STATIC_INLINE bool nrf_radio_int_enable_check(nrf_radio_int_mask_t int_mask)
  886. {
  887. return (bool)(NRF_RADIO->INTENSET & int_mask);
  888. }
  889. __STATIC_INLINE bool nrf_radio_crc_status_check(void)
  890. {
  891. return ((NRF_RADIO->CRCSTATUS & RADIO_CRCSTATUS_CRCSTATUS_Msk) >> RADIO_CRCSTATUS_CRCSTATUS_Pos)
  892. == RADIO_CRCSTATUS_CRCSTATUS_CRCOk ;
  893. }
  894. __STATIC_INLINE uint8_t nrf_radio_rxmatch_get(void)
  895. {
  896. return (uint8_t)NRF_RADIO->RXMATCH;
  897. }
  898. __STATIC_INLINE uint32_t nrf_radio_rxcrc_get(void)
  899. {
  900. return NRF_RADIO->RXCRC;
  901. }
  902. __STATIC_INLINE uint8_t nrf_radio_dai_get(void)
  903. {
  904. return (uint8_t)NRF_RADIO->DAI;
  905. }
  906. #if defined(RADIO_PDUSTAT_PDUSTAT_Msk)
  907. __STATIC_INLINE uint8_t nrf_radio_pdustat_get(void)
  908. {
  909. return (uint8_t)(NRF_RADIO->PDUSTAT & RADIO_PDUSTAT_PDUSTAT_Msk);
  910. }
  911. __STATIC_INLINE uint8_t nrf_radio_cistat_get(void)
  912. {
  913. return (uint8_t)((NRF_RADIO->PDUSTAT & RADIO_PDUSTAT_CISTAT_Msk) >> RADIO_PDUSTAT_CISTAT_Pos);
  914. }
  915. #endif // defined(RADIO_PDUSTAT_PDUSTAT_Msk)
  916. __STATIC_INLINE void nrf_radio_packetptr_set(const void * p_packet)
  917. {
  918. NRF_RADIO->PACKETPTR = (uint32_t)p_packet;
  919. }
  920. __STATIC_INLINE void * nrf_radio_packetptr_get(void)
  921. {
  922. return (void *)NRF_RADIO->PACKETPTR;
  923. }
  924. __STATIC_INLINE void nrf_radio_frequency_set(uint16_t radio_frequency)
  925. {
  926. NRFX_ASSERT(radio_frequency <= 2500);
  927. #if defined(RADIO_FREQUENCY_MAP_Msk)
  928. NRFX_ASSERT(radio_frequency >= 2360);
  929. uint32_t delta;
  930. if (radio_frequency < 2400)
  931. {
  932. delta = ((uint32_t)(radio_frequency - 2360)) |
  933. (RADIO_FREQUENCY_MAP_Low << RADIO_FREQUENCY_MAP_Pos);
  934. }
  935. else
  936. {
  937. delta = ((uint32_t)(radio_frequency - 2400)) |
  938. (RADIO_FREQUENCY_MAP_Default << RADIO_FREQUENCY_MAP_Pos);
  939. }
  940. NRF_RADIO->FREQUENCY = delta;
  941. #else
  942. NRFX_ASSERT(radio_frequency >= 2400);
  943. NRF_RADIO->FREQUENCY = (uint32_t)(radio_frequency - 2400);
  944. #endif //defined(RADIO_FREQUENCY_MAP_Msk)
  945. }
  946. __STATIC_INLINE uint16_t nrf_radio_frequency_get(void)
  947. {
  948. uint32_t freq;
  949. #if defined(RADIO_FREQUENCY_MAP_Msk)
  950. if (((NRF_RADIO->FREQUENCY & RADIO_FREQUENCY_MAP_Msk) >> RADIO_FREQUENCY_MAP_Pos) ==
  951. RADIO_FREQUENCY_MAP_Low)
  952. {
  953. freq = 2360;
  954. }
  955. else
  956. #endif
  957. {
  958. freq = 2400;
  959. }
  960. freq += NRF_RADIO->FREQUENCY & RADIO_FREQUENCY_FREQUENCY_Msk;
  961. return freq;
  962. }
  963. __STATIC_INLINE void nrf_radio_txpower_set(nrf_radio_txpower_t tx_power)
  964. {
  965. NRF_RADIO->TXPOWER = (((uint32_t)tx_power) << RADIO_TXPOWER_TXPOWER_Pos);
  966. }
  967. __STATIC_INLINE nrf_radio_txpower_t nrf_radio_txpower_get(void)
  968. {
  969. return (nrf_radio_txpower_t)(NRF_RADIO->TXPOWER >> RADIO_TXPOWER_TXPOWER_Pos);
  970. }
  971. __STATIC_INLINE void nrf_radio_mode_set(nrf_radio_mode_t radio_mode)
  972. {
  973. NRF_RADIO->MODE = ((uint32_t) radio_mode << RADIO_MODE_MODE_Pos);
  974. }
  975. __STATIC_INLINE nrf_radio_mode_t nrf_radio_mode_get(void)
  976. {
  977. return (nrf_radio_mode_t)((NRF_RADIO->MODE & RADIO_MODE_MODE_Msk) >> RADIO_MODE_MODE_Pos);
  978. }
  979. __STATIC_INLINE void nrf_radio_packet_configure(const nrf_radio_packet_conf_t * p_config)
  980. {
  981. NRF_RADIO->PCNF0 = (((uint32_t)p_config->lflen << RADIO_PCNF0_LFLEN_Pos) |
  982. ((uint32_t)p_config->s0len << RADIO_PCNF0_S0LEN_Pos) |
  983. ((uint32_t)p_config->s1len << RADIO_PCNF0_S1LEN_Pos) |
  984. #if defined(RADIO_PCNF0_S1INCL_Msk)
  985. (p_config->s1incl ?
  986. (RADIO_PCNF0_S1INCL_Include << RADIO_PCNF0_S1INCL_Pos) :
  987. (RADIO_PCNF0_S1INCL_Automatic << RADIO_PCNF0_S1INCL_Pos) ) |
  988. #endif
  989. #if defined(RADIO_PCNF0_CILEN_Msk)
  990. ((uint32_t)p_config->cilen << RADIO_PCNF0_CILEN_Pos) |
  991. #endif
  992. #if defined(RADIO_PCNF0_PLEN_Msk)
  993. ((uint32_t)p_config->plen << RADIO_PCNF0_PLEN_Pos) |
  994. #endif
  995. #if defined(RADIO_PCNF0_CRCINC_Msk)
  996. (p_config->crcinc ?
  997. (RADIO_PCNF0_CRCINC_Include << RADIO_PCNF0_CRCINC_Pos) :
  998. (RADIO_PCNF0_CRCINC_Exclude << RADIO_PCNF0_CRCINC_Pos) ) |
  999. #endif
  1000. #if defined(RADIO_PCNF0_TERMLEN_Msk)
  1001. ((uint32_t)p_config->termlen << RADIO_PCNF0_TERMLEN_Pos) |
  1002. #endif
  1003. 0);
  1004. NRF_RADIO->PCNF1 = (((uint32_t)p_config->maxlen << RADIO_PCNF1_MAXLEN_Pos) |
  1005. ((uint32_t)p_config->statlen << RADIO_PCNF1_STATLEN_Pos) |
  1006. ((uint32_t)p_config->balen << RADIO_PCNF1_BALEN_Pos) |
  1007. (p_config->big_endian ?
  1008. (RADIO_PCNF1_ENDIAN_Big << RADIO_PCNF1_ENDIAN_Pos) :
  1009. (RADIO_PCNF1_ENDIAN_Little << RADIO_PCNF1_ENDIAN_Pos) ) |
  1010. (p_config->whiteen ?
  1011. (RADIO_PCNF1_WHITEEN_Enabled << RADIO_PCNF1_WHITEEN_Pos) :
  1012. (RADIO_PCNF1_WHITEEN_Disabled << RADIO_PCNF1_WHITEEN_Pos) ));
  1013. }
  1014. __STATIC_INLINE void nrf_radio_base0_set(uint32_t address)
  1015. {
  1016. NRF_RADIO->BASE0 = address;
  1017. }
  1018. __STATIC_INLINE uint32_t nrf_radio_base0_get(void)
  1019. {
  1020. return NRF_RADIO->BASE0;
  1021. }
  1022. __STATIC_INLINE void nrf_radio_base1_set(uint32_t address)
  1023. {
  1024. NRF_RADIO->BASE1 = address;
  1025. }
  1026. __STATIC_INLINE uint32_t nrf_radio_base1_get(void)
  1027. {
  1028. return NRF_RADIO->BASE1;
  1029. }
  1030. __STATIC_INLINE void nrf_radio_prefix0_set(uint32_t prefix0_value)
  1031. {
  1032. NRF_RADIO->PREFIX0 = prefix0_value;
  1033. }
  1034. __STATIC_INLINE uint32_t nrf_radio_prefix0_get(void)
  1035. {
  1036. return NRF_RADIO->PREFIX0;
  1037. }
  1038. __STATIC_INLINE void nrf_radio_prefix1_set(uint32_t prefix1_value)
  1039. {
  1040. NRF_RADIO->PREFIX1 = prefix1_value;
  1041. }
  1042. __STATIC_INLINE uint32_t nrf_radio_prefix1_get(void)
  1043. {
  1044. return NRF_RADIO->PREFIX1;
  1045. }
  1046. __STATIC_INLINE void nrf_radio_txaddress_set(uint8_t txaddress)
  1047. {
  1048. NRF_RADIO->TXADDRESS = ((uint32_t)txaddress) << RADIO_TXADDRESS_TXADDRESS_Pos;
  1049. }
  1050. __STATIC_INLINE uint8_t nrf_radio_txaddress_get(void)
  1051. {
  1052. return (uint8_t)((NRF_RADIO->TXADDRESS & RADIO_TXADDRESS_TXADDRESS_Msk) >>
  1053. RADIO_TXADDRESS_TXADDRESS_Pos);
  1054. }
  1055. __STATIC_INLINE void nrf_radio_rxaddresses_set(uint8_t rxaddresses)
  1056. {
  1057. NRF_RADIO->RXADDRESSES = (uint32_t)(rxaddresses);
  1058. }
  1059. __STATIC_INLINE uint8_t nrf_radio_rxaddresses_get(void)
  1060. {
  1061. return (uint8_t)(NRF_RADIO->RXADDRESSES);
  1062. }
  1063. __STATIC_INLINE void nrf_radio_crc_configure(uint8_t crc_length,
  1064. nrf_radio_crc_addr_t crc_address,
  1065. uint32_t crc_polynominal)
  1066. {
  1067. NRF_RADIO->CRCCNF = ((uint32_t)crc_length << RADIO_CRCCNF_LEN_Pos) |
  1068. ((uint32_t)crc_address << RADIO_CRCCNF_SKIPADDR_Pos);
  1069. NRF_RADIO->CRCPOLY = (crc_polynominal << RADIO_CRCPOLY_CRCPOLY_Pos);
  1070. }
  1071. __STATIC_INLINE void nrf_radio_crcinit_set(uint32_t crc_init_value)
  1072. {
  1073. NRF_RADIO->CRCINIT = crc_init_value;
  1074. }
  1075. __STATIC_INLINE uint32_t nrf_radio_crcinit_get(void)
  1076. {
  1077. return NRF_RADIO->CRCINIT;
  1078. }
  1079. __STATIC_INLINE void nrf_radio_ifs_set(uint32_t radio_ifs)
  1080. {
  1081. NRF_RADIO->TIFS = radio_ifs;
  1082. }
  1083. __STATIC_INLINE uint32_t nrf_radio_ifs_get(void)
  1084. {
  1085. return NRF_RADIO->TIFS;
  1086. }
  1087. __STATIC_INLINE uint8_t nrf_radio_rssi_sample_get(void)
  1088. {
  1089. return (uint8_t)((NRF_RADIO->RSSISAMPLE & RADIO_RSSISAMPLE_RSSISAMPLE_Msk) >>
  1090. RADIO_RSSISAMPLE_RSSISAMPLE_Pos);
  1091. }
  1092. __STATIC_INLINE nrf_radio_state_t nrf_radio_state_get(void)
  1093. {
  1094. return (nrf_radio_state_t) NRF_RADIO->STATE;
  1095. }
  1096. __STATIC_INLINE void nrf_radio_datawhiteiv_set(uint8_t datawhiteiv)
  1097. {
  1098. NRF_RADIO->DATAWHITEIV = (((uint32_t)datawhiteiv) & RADIO_DATAWHITEIV_DATAWHITEIV_Msk);
  1099. }
  1100. __STATIC_INLINE uint8_t nrf_radio_datawhiteiv_get(void)
  1101. {
  1102. return (uint8_t)(NRF_RADIO->DATAWHITEIV & RADIO_DATAWHITEIV_DATAWHITEIV_Msk);
  1103. }
  1104. __STATIC_INLINE void nrf_radio_bcc_set(uint32_t radio_bcc)
  1105. {
  1106. NRF_RADIO->BCC = radio_bcc;
  1107. }
  1108. __STATIC_INLINE uint32_t nrf_radio_bcc_get(void)
  1109. {
  1110. return NRF_RADIO->BCC;
  1111. }
  1112. __STATIC_INLINE void nrf_radio_dab_set(uint32_t dab_value, uint8_t segment)
  1113. {
  1114. NRFX_ASSERT(segment < 8);
  1115. NRF_RADIO->DAB[segment] = dab_value;
  1116. }
  1117. __STATIC_INLINE uint32_t nrf_radio_dab_get(uint8_t segment)
  1118. {
  1119. NRFX_ASSERT(segment < 8);
  1120. return NRF_RADIO->DAB[segment];
  1121. }
  1122. __STATIC_INLINE void nrf_radio_dap_set(uint16_t dap_value, uint8_t prefix_index)
  1123. {
  1124. NRFX_ASSERT(prefix_index < 8);
  1125. NRF_RADIO->DAP[prefix_index] = (uint32_t)dap_value;
  1126. }
  1127. __STATIC_INLINE uint32_t nrf_radio_dap_get(uint8_t prefix_index)
  1128. {
  1129. NRFX_ASSERT(prefix_index < 8);
  1130. return NRF_RADIO->DAP[prefix_index];
  1131. }
  1132. __STATIC_INLINE void nrf_radio_dacnf_set(uint8_t ena, uint8_t txadd)
  1133. {
  1134. NRF_RADIO->DACNF = (((uint32_t)ena << RADIO_DACNF_ENA0_Pos) |
  1135. ((uint32_t)txadd << RADIO_DACNF_TXADD0_Pos));
  1136. }
  1137. __STATIC_INLINE uint8_t nrf_radio_dacnf_ena_get(void)
  1138. {
  1139. return (NRF_RADIO->DACNF & (RADIO_DACNF_ENA0_Msk |
  1140. RADIO_DACNF_ENA1_Msk |
  1141. RADIO_DACNF_ENA2_Msk |
  1142. RADIO_DACNF_ENA3_Msk |
  1143. RADIO_DACNF_ENA4_Msk |
  1144. RADIO_DACNF_ENA5_Msk |
  1145. RADIO_DACNF_ENA6_Msk |
  1146. RADIO_DACNF_ENA7_Msk)) >> RADIO_DACNF_ENA0_Pos;
  1147. }
  1148. __STATIC_INLINE uint8_t nrf_radio_dacnf_txadd_get(void)
  1149. {
  1150. return (NRF_RADIO->DACNF & (RADIO_DACNF_TXADD0_Msk |
  1151. RADIO_DACNF_TXADD1_Msk |
  1152. RADIO_DACNF_TXADD2_Msk |
  1153. RADIO_DACNF_TXADD3_Msk |
  1154. RADIO_DACNF_TXADD4_Msk |
  1155. RADIO_DACNF_TXADD5_Msk |
  1156. RADIO_DACNF_TXADD6_Msk |
  1157. RADIO_DACNF_TXADD7_Msk)) >> RADIO_DACNF_TXADD0_Pos;
  1158. }
  1159. #if defined(RADIO_INTENSET_MHRMATCH_Msk)
  1160. __STATIC_INLINE void nrf_radio_mhmu_search_pattern_set(uint32_t radio_mhmu_search_pattern)
  1161. {
  1162. NRF_RADIO->MHRMATCHCONF = radio_mhmu_search_pattern;
  1163. }
  1164. __STATIC_INLINE uint32_t nrf_radio_mhmu_search_pattern_get(void)
  1165. {
  1166. return NRF_RADIO->MHRMATCHCONF;
  1167. }
  1168. __STATIC_INLINE void nrf_radio_mhmu_pattern_mask_set(uint32_t radio_mhmu_pattern_mask)
  1169. {
  1170. NRF_RADIO->MHRMATCHMAS = radio_mhmu_pattern_mask;
  1171. }
  1172. __STATIC_INLINE uint32_t nrf_radio_mhmu_pattern_mask_get(void)
  1173. {
  1174. return NRF_RADIO->MHRMATCHMAS;
  1175. }
  1176. #endif // defined(RADIO_INTENSET_MHRMATCH_Msk)
  1177. #if defined(RADIO_MODECNF0_RU_Msk)
  1178. __STATIC_INLINE void nrf_radio_modecnf0_set(bool fast_ramp_up, uint8_t default_tx)
  1179. {
  1180. NRF_RADIO->MODECNF0 = (fast_ramp_up ? (RADIO_MODECNF0_RU_Fast << RADIO_MODECNF0_RU_Pos) :
  1181. (RADIO_MODECNF0_RU_Default << RADIO_MODECNF0_RU_Pos) ) |
  1182. (((uint32_t)default_tx) << RADIO_MODECNF0_DTX_Pos);
  1183. }
  1184. __STATIC_INLINE bool nrf_radio_modecnf0_ru_get(void)
  1185. {
  1186. return ((NRF_RADIO->MODECNF0 & RADIO_MODECNF0_RU_Msk) >> RADIO_MODECNF0_RU_Pos) ==
  1187. RADIO_MODECNF0_RU_Fast;
  1188. }
  1189. __STATIC_INLINE uint8_t nrf_radio_modecnf0_dtx_get(void)
  1190. {
  1191. return (uint8_t)((NRF_RADIO->MODECNF0 & RADIO_MODECNF0_DTX_Msk) >> RADIO_MODECNF0_DTX_Pos);
  1192. }
  1193. #endif // defined(RADIO_MODECNF0_RU_Msk)
  1194. #if defined(RADIO_SFD_SFD_Msk)
  1195. __STATIC_INLINE void nrf_radio_sfd_set(uint8_t sfd)
  1196. {
  1197. NRF_RADIO->SFD = ((uint32_t)sfd) << RADIO_SFD_SFD_Pos;
  1198. }
  1199. __STATIC_INLINE uint8_t nrf_radio_sfd_get(void)
  1200. {
  1201. return (uint8_t)((NRF_RADIO->SFD & RADIO_SFD_SFD_Msk) >> RADIO_SFD_SFD_Pos);
  1202. }
  1203. #endif // defined(RADIO_SFD_SFD_Msk)
  1204. #if defined(RADIO_EDCNT_EDCNT_Msk)
  1205. __STATIC_INLINE void nrf_radio_ed_loop_count_set(uint32_t ed_loop_count)
  1206. {
  1207. NRF_RADIO->EDCNT = (ed_loop_count & RADIO_EDCNT_EDCNT_Msk);
  1208. }
  1209. #endif
  1210. #if defined(RADIO_EDSAMPLE_EDLVL_Msk)
  1211. __STATIC_INLINE uint8_t nrf_radio_ed_sample_get(void)
  1212. {
  1213. return (uint8_t) NRF_RADIO->EDSAMPLE;
  1214. }
  1215. #endif
  1216. #if defined(RADIO_CCACTRL_CCAMODE_Msk)
  1217. __STATIC_INLINE void nrf_radio_cca_configure(nrf_radio_cca_mode_t cca_mode,
  1218. uint8_t cca_ed_threshold,
  1219. uint8_t cca_corr_threshold,
  1220. uint8_t cca_corr_cnt)
  1221. {
  1222. NRF_RADIO->CCACTRL = (((uint32_t)cca_mode << RADIO_CCACTRL_CCAMODE_Pos) |
  1223. ((uint32_t)cca_ed_threshold << RADIO_CCACTRL_CCAEDTHRES_Pos) |
  1224. ((uint32_t)cca_corr_threshold << RADIO_CCACTRL_CCACORRTHRES_Pos) |
  1225. ((uint32_t)cca_corr_cnt << RADIO_CCACTRL_CCACORRCNT_Pos));
  1226. }
  1227. #endif
  1228. __STATIC_INLINE void nrf_radio_power_set(bool radio_power)
  1229. {
  1230. NRF_RADIO->POWER = (uint32_t) radio_power;
  1231. }
  1232. #endif
  1233. /** @} */
  1234. #ifdef __cplusplus
  1235. }
  1236. #endif
  1237. #endif // NRF_RADIO_H__