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