1 /* 2 * Copyright (c) 2019 - 2023, Nordic Semiconductor ASA 3 * All rights reserved. 4 * 5 * SPDX-License-Identifier: BSD-3-Clause 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions are met: 9 * 10 * 1. Redistributions of source code must retain the above copyright notice, this 11 * list of conditions and the following disclaimer. 12 * 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 17 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its 18 * contributors may be used to endorse or promote products derived from this 19 * software without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 * POSSIBILITY OF SUCH DAMAGE. 32 * 33 */ 34 35 /** 36 * @brief Module that defines the 802.15.4 driver peripheral usage for nRF52 family. 37 * 38 */ 39 40 #ifndef NRF_802154_PERIPHERALS_NRF52_H__ 41 #define NRF_802154_PERIPHERALS_NRF52_H__ 42 43 #include <nrfx.h> 44 #include "nrf_802154_config.h" 45 #include "nrf_802154_debug.h" 46 #include "hal/nrf_ppi.h" 47 48 #ifdef __cplusplus 49 extern "C" { 50 #endif 51 52 /** 53 * @def NRF_802154_EGU_INSTANCE_NO 54 * 55 * Number of the EGU instance used by the driver to synchronize PPIs and for requests and 56 * notifications if SWI is in use. 57 * 58 */ 59 #ifndef NRF_802154_EGU_INSTANCE_NO 60 61 #define NRF_802154_EGU_INSTANCE_NO 3 62 63 #endif // NRF_802154_EGU_INSTANCE_NO 64 65 /** 66 * @def NRF_802154_EGU_INSTANCE 67 * 68 * The EGU instance used by the driver to synchronize PPIs and for requests and notifications if 69 * SWI is in use. 70 * 71 * @note This option is used by the core module regardless of the driver configuration. 72 * 73 */ 74 #define NRF_802154_EGU_INSTANCE NRFX_CONCAT_2(NRF_EGU, NRF_802154_EGU_INSTANCE_NO) 75 76 /** 77 * @def NRF_802154_EGU_IRQ_HANDLER 78 * 79 * The SWI EGU IRQ handler used by the driver for requests and notifications if SWI is in use. 80 * 81 * @note This option is used when the driver uses SWI to process requests and notifications. 82 * 83 */ 84 #define NRF_802154_EGU_IRQ_HANDLER \ 85 NRFX_CONCAT_3(NRFX_CONCAT_3(SWI, NRF_802154_EGU_INSTANCE_NO, _EGU), \ 86 NRF_802154_EGU_INSTANCE_NO, \ 87 _IRQHandler) 88 89 /** 90 * @def NRF_802154_EGU_IRQN 91 * 92 * The SWI EGU IRQ number used by the driver for requests and notifications if SWI is in use. 93 * 94 * @note This option is used when the driver uses SWI to process requests and notifications. 95 * 96 */ 97 #define NRF_802154_EGU_IRQN \ 98 NRFX_CONCAT_3(NRFX_CONCAT_3(SWI, NRF_802154_EGU_INSTANCE_NO, _EGU), \ 99 NRF_802154_EGU_INSTANCE_NO, \ 100 _IRQn) 101 102 /** 103 * @def NRF_802154_RTC_INSTANCE_NO 104 * 105 * Number of the RTC instance used in the standalone timer driver implementation. 106 * 107 */ 108 #ifndef NRF_802154_RTC_INSTANCE_NO 109 110 #define NRF_802154_RTC_INSTANCE_NO 2 111 112 #endif // NRF_802154_RTC_INSTANCE_NO 113 114 /** 115 * @def NRF_802154_PPI_RADIO_RAMP_UP_TRIGG 116 * 117 * The PPI channel that connects ramp up triggering event to EGU task. 118 * 119 * @note The peripheral is shared with @ref NRF_802154_PPI_RADIO_DISABLED_TO_EGU in such a way 120 * that a receive or transmit request causes that ppi to be configured for ramp up 121 * triggering purpose, while in the EVENT_READY isr the ppi is reconfigured to follow the 122 * @ref NRF_802154_PPI_RADIO_DISABLED_TO_EGU description. 123 * 124 * @note This option is used regardless of the driver configuration. 125 * 126 */ 127 #ifndef NRF_802154_PPI_RADIO_RAMP_UP_TRIGG 128 #define NRF_802154_PPI_RADIO_RAMP_UP_TRIGG NRF_PPI_CHANNEL6 129 #endif 130 131 /** 132 * @def NRF_802154_PPI_RADIO_DISABLED_TO_EGU 133 * 134 * The PPI channel that connects RADIO_DISABLED event to EGU task. 135 * 136 * @note This option is used by the core module regardless of the driver configuration. 137 * The peripheral is shared with @ref NRF_802154_PPI_RADIO_RAMP_UP_TRIGG. 138 * 139 */ 140 #ifndef NRF_802154_PPI_RADIO_DISABLED_TO_EGU 141 #define NRF_802154_PPI_RADIO_DISABLED_TO_EGU NRF_PPI_CHANNEL6 142 #endif 143 144 /** 145 * @def NRF_802154_PPI_EGU_TO_RADIO_RAMP_UP 146 * 147 * The PPI channel that connects EGU event to RADIO_TXEN or RADIO_RXEN task. 148 * 149 * @note This option is used by the core module regardless of the driver configuration. 150 * 151 */ 152 #ifndef NRF_802154_PPI_EGU_TO_RADIO_RAMP_UP 153 #define NRF_802154_PPI_EGU_TO_RADIO_RAMP_UP NRF_PPI_CHANNEL7 154 #endif 155 156 /** 157 * @def NRF_802154_PPI_EGU_TO_TIMER_START 158 * 159 * The PPI channel that connects EGU event to TIMER_START task. 160 * 161 * @note This option is used by the core module regardless of the driver configuration. 162 * 163 */ 164 #ifndef NRF_802154_PPI_EGU_TO_TIMER_START 165 #define NRF_802154_PPI_EGU_TO_TIMER_START NRF_PPI_CHANNEL8 166 #endif 167 168 /** 169 * @def NRF_802154_PPI_RADIO_CRCERROR_TO_TIMER_CLEAR 170 * 171 * The PPI channel that connects RADIO_CRCERROR event to TIMER_CLEAR task. 172 * 173 * @note This option is used by the core module regardless of the driver configuration. 174 * The peripheral is shared with @ref NRF_802154_PPI_RADIO_CCAIDLE_TO_FEM_GPIOTE 175 * and @ref NRF_802154_PPI_TIMER_COMPARE_TO_RADIO_TXEN. 176 * 177 */ 178 #ifndef NRF_802154_PPI_RADIO_CRCERROR_TO_TIMER_CLEAR 179 #define NRF_802154_PPI_RADIO_CRCERROR_TO_TIMER_CLEAR NRF_PPI_CHANNEL9 180 #endif 181 182 /** 183 * @def NRF_802154_PPI_RADIO_CCAIDLE_TO_FEM_GPIOTE 184 * 185 * The PPI channel that connects RADIO_CCAIDLE event to the GPIOTE tasks used by the Frontend. 186 * 187 * @note This option is used by the core module regardless of the driver configuration. 188 * The peripheral is shared with @ref NRF_802154_PPI_RADIO_CRCERROR_TO_TIMER_CLEAR 189 * and @ref NRF_802154_PPI_TIMER_COMPARE_TO_RADIO_TXEN. 190 * 191 */ 192 #ifndef NRF_802154_PPI_RADIO_CCAIDLE_TO_FEM_GPIOTE 193 #define NRF_802154_PPI_RADIO_CCAIDLE_TO_FEM_GPIOTE NRF_PPI_CHANNEL9 194 #endif 195 196 /** 197 * @def NRF_802154_PPI_TIMER_COMPARE_TO_RADIO_TXEN 198 * 199 * The PPI channel that connects TIMER_COMPARE event to RADIO_TXEN task. 200 * 201 * @note This option is used by the core module regardless of the driver configuration. 202 * The peripheral is shared with @ref NRF_802154_PPI_RADIO_CRCERROR_TO_TIMER_CLEAR 203 * and @ref NRF_802154_PPI_RADIO_CCAIDLE_TO_FEM_GPIOTE. 204 * 205 */ 206 #ifndef NRF_802154_PPI_TIMER_COMPARE_TO_RADIO_TXEN 207 #define NRF_802154_PPI_TIMER_COMPARE_TO_RADIO_TXEN NRF_PPI_CHANNEL9 208 #endif 209 210 /** 211 * @def NRF_802154_PPI_RADIO_CRCOK_TO_PPI_GRP_DISABLE 212 * 213 * The PPI channel that connects RADIO_CRCOK event with the task that disables the whole PPI group. 214 * 215 * @note This option is used by the core module regardless of the driver configuration. 216 * 217 */ 218 #ifndef NRF_802154_PPI_RADIO_CRCOK_TO_PPI_GRP_DISABLE 219 #define NRF_802154_PPI_RADIO_CRCOK_TO_PPI_GRP_DISABLE NRF_PPI_CHANNEL10 220 #endif 221 222 /** 223 * @def NRF_802154_PPI_RADIO_SYNC_TO_EGU_SYNC 224 * 225 * The PPI channel that connects RADIO_SYNC event to EGU_SYNC task. 226 * EGU_SYNC task belongs to one of EGU channels 227 * 228 */ 229 #ifndef NRF_802154_PPI_RADIO_SYNC_TO_EGU_SYNC 230 #define NRF_802154_PPI_RADIO_SYNC_TO_EGU_SYNC NRF_PPI_CHANNEL11 231 #endif 232 233 #define NRF_802154_DISABLE_BCC_MATCHING_PPI_CHANNELS_USED_MASK \ 234 (1 << NRF_802154_PPI_RADIO_SYNC_TO_EGU_SYNC) 235 236 #ifdef NRF_802154_FRAME_TIMESTAMP_ENABLED 237 238 /** 239 * @def NRF_802154_PPI_RTC_COMPARE_TO_TIMER_CAPTURE 240 * 241 * The PPI channel that connects LP timer's COMPARE event to HP timer's TIMER_CAPTURE task. 242 * 243 * @note This option is used only when the timestamping feature is enabled 244 * (see @ref NRF_802154_FRAME_TIMESTAMP_ENABLED). 245 * 246 */ 247 #ifndef NRF_802154_PPI_RTC_COMPARE_TO_TIMER_CAPTURE 248 #define NRF_802154_PPI_RTC_COMPARE_TO_TIMER_CAPTURE NRF_PPI_CHANNEL13 249 #endif 250 251 /** 252 * @def NRF_802154_PPI_TIMESTAMP_EVENT_TO_TIMER_CAPTURE 253 * 254 * The PPI channel that connects provided event to HP timer's TIMER_CAPTURE task. 255 * 256 * @note This option is used only when the timestamping feature is enabled 257 * (see @ref NRF_802154_FRAME_TIMESTAMP_ENABLED). 258 * 259 */ 260 #ifndef NRF_802154_PPI_TIMESTAMP_EVENT_TO_TIMER_CAPTURE 261 #define NRF_802154_PPI_TIMESTAMP_EVENT_TO_TIMER_CAPTURE NRF_PPI_CHANNEL14 262 #endif 263 264 /** 265 * @def NRF_802154_TIMESTAMP_PPI_CHANNELS_USED_MASK 266 * 267 * Helper bit mask of PPI channels used by the 802.15.4 driver for timestamping. 268 */ 269 #define NRF_802154_TIMESTAMP_PPI_CHANNELS_USED_MASK \ 270 ((1 << NRF_802154_PPI_RTC_COMPARE_TO_TIMER_CAPTURE) | \ 271 (1 << NRF_802154_PPI_TIMESTAMP_EVENT_TO_TIMER_CAPTURE)) 272 273 #else // NRF_802154_FRAME_TIMESTAMP_ENABLED 274 275 #define NRF_802154_TIMESTAMP_PPI_CHANNELS_USED_MASK 0 276 277 #endif // NRF_802154_FRAME_TIMESTAMP_ENABLED 278 279 /** 280 * @def NRF_802154_PPI_CORE_GROUP 281 * 282 * The PPI channel group used to disable self-disabling PPIs used by the core module. 283 * 284 * @note This option is used by the core module regardless of the driver configuration. 285 * 286 */ 287 #ifndef NRF_802154_PPI_CORE_GROUP 288 #define NRF_802154_PPI_CORE_GROUP NRF_PPI_CHANNEL_GROUP0 289 #endif 290 291 /** 292 * @def NRF_802154_PPI_ABORT_GROUP 293 * 294 * The PPI channel group used to break PPI connections related with FEM, when the abort condition occurs. 295 * 296 */ 297 #ifndef NRF_802154_PPI_ABORT_GROUP 298 #define NRF_802154_PPI_ABORT_GROUP NRF_PPI_CHANNEL_GROUP1 299 #endif 300 301 /** 302 * @def NRF_802154_EGU_USED_MASK 303 * 304 * Bit mask of instances of SWI/EGU peripherals used by the 802.15.4 driver. 305 */ 306 #ifndef NRF_802154_EGU_USED_MASK 307 #define NRF_802154_EGU_USED_MASK (1 << NRF_802154_EGU_INSTANCE_NO) 308 #endif 309 310 /** 311 * @def NRF_802154_PPI_CHANNELS_USED_MASK 312 * 313 * Bit mask of PPI channels used by the 802.15.4 driver. 314 */ 315 #ifndef NRF_802154_PPI_CHANNELS_USED_MASK 316 #define NRF_802154_PPI_CHANNELS_USED_MASK ((1 << NRF_802154_PPI_RADIO_DISABLED_TO_EGU) | \ 317 (1 << NRF_802154_PPI_RADIO_RAMP_UP_TRIGG) | \ 318 (1 << NRF_802154_PPI_EGU_TO_RADIO_RAMP_UP) | \ 319 (1 << NRF_802154_PPI_EGU_TO_TIMER_START) | \ 320 (1 << NRF_802154_PPI_RADIO_CRCERROR_TO_TIMER_CLEAR) | \ 321 (1 << NRF_802154_PPI_RADIO_CCAIDLE_TO_FEM_GPIOTE) | \ 322 (1 << NRF_802154_PPI_TIMER_COMPARE_TO_RADIO_TXEN) | \ 323 (1 << NRF_802154_PPI_RADIO_CRCOK_TO_PPI_GRP_DISABLE) | \ 324 NRF_802154_DISABLE_BCC_MATCHING_PPI_CHANNELS_USED_MASK | \ 325 NRF_802154_TIMESTAMP_PPI_CHANNELS_USED_MASK | \ 326 NRF_802154_DEBUG_PPI_CHANNELS_USED_MASK) 327 #endif // NRF_802154_PPI_CHANNELS_USED_MASK 328 329 /** 330 * @def NRF_802154_PPI_GROUPS_USED_MASK 331 * 332 * Bit mask of PPI groups identifiers used by the 802.15.4 driver. 333 */ 334 #ifndef NRF_802154_PPI_GROUPS_USED_MASK 335 #define NRF_802154_PPI_GROUPS_USED_MASK ((1 << NRF_802154_PPI_CORE_GROUP) | \ 336 (1 << NRF_802154_PPI_ABORT_GROUP) ) 337 #endif // NRF_802154_PPI_GROUPS_USED_MASK 338 339 #ifdef __cplusplus 340 } 341 #endif 342 343 #endif // NRF_802154_PERIPHERALS_NRF52_H__ 344