nrf_radio.h 53 KB

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