1 /*
2  * Copyright (c) 2019, 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 "nrf_802154_sl_periphs.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 0
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_RTC_INSTANCE_NO
91  *
92  * Number of the RTC instance used in the standalone timer driver implementation.
93  *
94  */
95 #ifndef NRF_802154_RTC_INSTANCE_NO
96 
97 #define NRF_802154_RTC_INSTANCE_NO 2
98 
99 #endif // NRF_802154_RTC_INSTANCE_NO
100 
101 /**
102  * @def NRF_802154_PPI_RADIO_RAMP_UP_TRIGG
103  *
104  * The PPI channel that connects ramp up triggering event to EGU task.
105  *
106  * @note The peripheral is shared with @ref NRF_802154_PPI_RADIO_DISABLED_TO_EGU in such a way
107  *       that a receive or transmit request causes that ppi to be configured for ramp up
108  *       triggering purpose, while in the EVENT_READY isr the ppi is reconfigured to follow the
109  *       @ref NRF_802154_PPI_RADIO_DISABLED_TO_EGU description.
110  *
111  * @note This option is used regardless of the driver configuration.
112  *
113  */
114 #ifndef NRF_802154_PPI_RADIO_RAMP_UP_TRIGG
115 #define NRF_802154_PPI_RADIO_RAMP_UP_TRIGG 6U
116 #endif
117 
118 /**
119  * @def NRF_802154_PPI_RADIO_DISABLED_TO_EGU
120  *
121  * The PPI channel that connects RADIO_DISABLED event to EGU task.
122  *
123  * @note This option is used by the core module regardless of the driver configuration.
124  *       The peripheral is shared with @ref NRF_802154_PPI_RADIO_RAMP_UP_TRIGG.
125  *
126  */
127 #ifndef NRF_802154_PPI_RADIO_DISABLED_TO_EGU
128 #define NRF_802154_PPI_RADIO_DISABLED_TO_EGU 6U
129 #endif
130 
131 /**
132  * @def NRF_802154_PPI_EGU_TO_RADIO_RAMP_UP
133  *
134  * The PPI channel that connects EGU event to RADIO_TXEN or RADIO_RXEN task.
135  *
136  * @note This option is used by the core module regardless of the driver configuration.
137  *
138  */
139 #ifndef NRF_802154_PPI_EGU_TO_RADIO_RAMP_UP
140 #define NRF_802154_PPI_EGU_TO_RADIO_RAMP_UP 7U
141 #endif
142 
143 /**
144  * @def NRF_802154_PPI_EGU_TO_TIMER_START
145  *
146  * The PPI channel that connects EGU event to TIMER_START task.
147  *
148  * @note This option is used by the core module regardless of the driver configuration.
149  *
150  */
151 #ifndef NRF_802154_PPI_EGU_TO_TIMER_START
152 #define NRF_802154_PPI_EGU_TO_TIMER_START 8U
153 #endif
154 
155 /**
156  * @def NRF_802154_PPI_RADIO_CRCERROR_TO_TIMER_CLEAR
157  *
158  * The PPI channel that connects RADIO_CRCERROR event to TIMER_CLEAR task.
159  *
160  * @note This option is used by the core module regardless of the driver configuration.
161  *       The peripheral is shared with @ref NRF_802154_PPI_RADIO_CCAIDLE_TO_FEM_GPIOTE
162  *       and @ref NRF_802154_PPI_TIMER_COMPARE_TO_RADIO_TXEN.
163  *
164  */
165 #ifndef NRF_802154_PPI_RADIO_CRCERROR_TO_TIMER_CLEAR
166 #define NRF_802154_PPI_RADIO_CRCERROR_TO_TIMER_CLEAR 9U
167 #endif
168 
169 /**
170  * @def NRF_802154_PPI_RADIO_CCAIDLE_TO_FEM_GPIOTE
171  *
172  * The PPI channel that connects RADIO_CCAIDLE event to the GPIOTE tasks used by the Frontend.
173  *
174  * @note This option is used by the core module regardless of the driver configuration.
175  *       The peripheral is shared with @ref NRF_802154_PPI_RADIO_CRCERROR_TO_TIMER_CLEAR
176  *       and @ref NRF_802154_PPI_TIMER_COMPARE_TO_RADIO_TXEN.
177  *
178  */
179 #ifndef NRF_802154_PPI_RADIO_CCAIDLE_TO_FEM_GPIOTE
180 #define NRF_802154_PPI_RADIO_CCAIDLE_TO_FEM_GPIOTE 9U
181 #endif
182 
183 /**
184  * @def NRF_802154_PPI_TIMER_COMPARE_TO_RADIO_TXEN
185  *
186  * The PPI channel that connects TIMER_COMPARE event to RADIO_TXEN task.
187  *
188  * @note This option is used by the core module regardless of the driver configuration.
189  *       The peripheral is shared with @ref NRF_802154_PPI_RADIO_CRCERROR_TO_TIMER_CLEAR
190  *       and @ref NRF_802154_PPI_RADIO_CCAIDLE_TO_FEM_GPIOTE.
191  *
192  */
193 #ifndef NRF_802154_PPI_TIMER_COMPARE_TO_RADIO_TXEN
194 #define NRF_802154_PPI_TIMER_COMPARE_TO_RADIO_TXEN 9U
195 #endif
196 
197 /**
198  * @def NRF_802154_PPI_RADIO_CCABUSY_TO_RADIO_CCASTART
199  *
200  * The PPI channel that connects RADIO_CCABUSY event to RADIO_CCASTART task. This PPI is used to
201  * perform multiple back-to-back CCA attempts before a transmission.
202  *
203  * @note This option is used by the core module regardless of the driver configuration.
204  *
205  */
206 #ifndef NRF_802154_PPI_RADIO_CCABUSY_TO_RADIO_CCASTART
207 #define NRF_802154_PPI_RADIO_CCABUSY_TO_RADIO_CCASTART 10U
208 #endif
209 
210 /**
211  * @def NRF_802154_PPI_RADIO_SYNC_TO_EGU_SYNC
212  *
213  * The PPI channel that connects RADIO_SYNC event to EGU_SYNC task.
214  * EGU_SYNC task belongs to one of EGU channels
215  *
216  */
217 #ifndef NRF_802154_PPI_RADIO_SYNC_TO_EGU_SYNC
218 #define NRF_802154_PPI_RADIO_SYNC_TO_EGU_SYNC 11U
219 #endif
220 
221 #define NRF_802154_DISABLE_BCC_MATCHING_PPI_CHANNELS_USED_MASK \
222     (1 << NRF_802154_PPI_RADIO_SYNC_TO_EGU_SYNC)
223 
224 /**
225  * @def NRF_802154_PPI_CORE_GROUP
226  *
227  * The PPI channel group used to disable self-disabling PPIs used by the core module.
228  *
229  * @note This option is used by the core module regardless of the driver configuration.
230  *
231  */
232 #ifndef NRF_802154_PPI_CORE_GROUP
233 #define NRF_802154_PPI_CORE_GROUP 0U
234 #endif
235 
236 /**
237  * @def NRF_802154_PPI_ABORT_GROUP
238  *
239  * The PPI channel group used to break PPI connections related with FEM, when the abort condition occurs.
240  *
241  */
242 #ifndef NRF_802154_PPI_ABORT_GROUP
243 #define NRF_802154_PPI_ABORT_GROUP 1U
244 #endif
245 
246 /**
247  * @def NRF_802154_EGU_USED_MASK
248  *
249  * Bit mask of instances of SWI/EGU peripherals used by the 802.15.4 driver.
250  */
251 #ifndef NRF_802154_EGU_USED_MASK
252 #define NRF_802154_EGU_USED_MASK (1 << NRF_802154_EGU_INSTANCE_NO)
253 #endif
254 
255 /**
256  * @def NRF_802154_PPI_CHANNELS_USED_MASK
257  *
258  * Bit mask of PPI channels used by the 802.15.4 driver.
259  */
260 #ifndef NRF_802154_PPI_CHANNELS_USED_MASK
261 #define NRF_802154_PPI_CHANNELS_USED_MASK ((1 << NRF_802154_PPI_RADIO_DISABLED_TO_EGU) |            \
262                                            (1 << NRF_802154_PPI_RADIO_RAMP_UP_TRIGG) |              \
263                                            (1 << NRF_802154_PPI_EGU_TO_RADIO_RAMP_UP) |             \
264                                            (1 << NRF_802154_PPI_EGU_TO_TIMER_START) |               \
265                                            (1 << NRF_802154_PPI_RADIO_CRCERROR_TO_TIMER_CLEAR) |    \
266                                            (1 << NRF_802154_PPI_RADIO_CCAIDLE_TO_FEM_GPIOTE) |      \
267                                            (1 << NRF_802154_PPI_TIMER_COMPARE_TO_RADIO_TXEN) |      \
268                                            (1 << NRF_802154_PPI_RADIO_CCABUSY_TO_RADIO_CCASTART) |  \
269                                            NRF_802154_DISABLE_BCC_MATCHING_PPI_CHANNELS_USED_MASK | \
270                                            NRF_802154_SL_PPI_CHANNELS_USED_MASK |                   \
271                                            NRF_802154_DEBUG_PPI_CHANNELS_USED_MASK)
272 #endif // NRF_802154_PPI_CHANNELS_USED_MASK
273 
274 /**
275  * @def NRF_802154_PPI_GROUPS_USED_MASK
276  *
277  * Bit mask of PPI groups identifiers used by the 802.15.4 driver.
278  */
279 #ifndef NRF_802154_PPI_GROUPS_USED_MASK
280 #define NRF_802154_PPI_GROUPS_USED_MASK ((1 << NRF_802154_PPI_CORE_GROUP) | \
281                                          (1 << NRF_802154_PPI_ABORT_GROUP)  )
282 #endif // NRF_802154_PPI_GROUPS_USED_MASK
283 
284 #ifdef __cplusplus
285 }
286 #endif
287 
288 #endif // NRF_802154_PERIPHERALS_NRF52_H__
289