forked from hubertmis/nRF-IEEE-802.15.4-radio-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nrf_802154_config.h
547 lines (485 loc) · 13.9 KB
/
nrf_802154_config.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
/* Copyright (c) 2017 - 2018, Nordic Semiconductor ASA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef NRF_802154_CONFIG_H__
#define NRF_802154_CONFIG_H__
#ifdef NRF_802154_PROJECT_CONFIG
#include NRF_802154_PROJECT_CONFIG
#endif
#include <nrf.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup nrf_802154_config 802.15.4 driver configuration
* @{
* @ingroup nrf_802154
* @brief Configuration of the 802.15.4 radio driver for nRF SoCs.
*/
/**
* @defgroup nrf_802154_config_radio Radio driver configuration
* @{
*/
/**
* @def NRF_802154_CCA_MODE_DEFAULT
*
* CCA mode used by the driver.
*
*/
#ifndef NRF_802154_CCA_MODE_DEFAULT
#define NRF_802154_CCA_MODE_DEFAULT NRF_RADIO_CCA_MODE_ED
#endif
/**
* @def NRF_802154_CCA_ED_THRESHOLD_DEFAULT
*
* Energy detection threshold used in the CCA procedure.
*
*/
#ifndef NRF_802154_CCA_ED_THRESHOLD_DEFAULT
#define NRF_802154_CCA_ED_THRESHOLD_DEFAULT 0x14
#endif
/**
* @def NRF_802154_CCA_CORR_THRESHOLD_DEFAULT
*
* Correlator threshold used in the CCA procedure.
*
*/
#ifndef NRF_802154_CCA_CORR_THRESHOLD_DEFAULT
#define NRF_802154_CCA_CORR_THRESHOLD_DEFAULT 0x14
#endif
/**
* @def NRF_802154_CCA_CORR_LIMIT_DEFAULT
*
* Correlator limit used in the CCA procedure.
*
*/
#ifndef NRF_802154_CCA_CORR_LIMIT_DEFAULT
#define NRF_802154_CCA_CORR_LIMIT_DEFAULT 0x02
#endif
/**
* @def NRF_802154_INTERNAL_RADIO_IRQ_HANDLING
*
* If the driver is expected to internally handle the RADIO IRQ.
* If the driver is used in an OS, the RADIO IRQ can be handled by the OS and passed to
* the driver by @ref nrf_802154_radio_irq_handler.
* In this case, the internal handling must be disabled.
*
*/
#ifndef NRF_802154_INTERNAL_RADIO_IRQ_HANDLING
#if RAAL_SOFTDEVICE || RAAL_REM
#define NRF_802154_INTERNAL_RADIO_IRQ_HANDLING 0
#else // RAAL_SOFTDEVICE || RAAL_REM
#define NRF_802154_INTERNAL_RADIO_IRQ_HANDLING 1
#endif // RAAL_SOFTDEVICE || RAAL_REM
#endif // NRF_802154_INTERNAL_RADIO_IRQ_HANDLING
/**
* @def NRF_802154_IRQ_PRIORITY
*
* Interrupt priority for RADIO peripheral.
* Keep the IRQ priority high (low number) to prevent losing frames due to preemption.
*
*/
#ifndef NRF_802154_IRQ_PRIORITY
#define NRF_802154_IRQ_PRIORITY 0
#endif
/**
* @def NRF_802154_TIMER_INSTANCE
*
* The timer instance used both by the driver for ACK IFS and by the FEM module.
*
*/
#ifndef NRF_802154_TIMER_INSTANCE
#define NRF_802154_TIMER_INSTANCE NRF_TIMER1
#endif
/**
* @def NRF_802154_COUNTER_TIMER_INSTANCE
*
* The timer instance used by the driver for detecting when PSDU is being received.
*
* @note This configuration is used only when the NRF_RADIO_EVENT_BCMATCH event handling is disabled
* (see @ref NRF_802154_DISABLE_BCC_MATCHING).
*/
#ifndef NRF_802154_COUNTER_TIMER_INSTANCE
#define NRF_802154_COUNTER_TIMER_INSTANCE NRF_TIMER2
#endif
/**
* @def NRF_802154_SWI_EGU_INSTANCE
*
* The SWI EGU instance used by the driver to synchronize PPIs and for requests and notifications if
* SWI is in use.
*
* @note This option is used by the core module regardless of the driver configuration.
*
*/
#ifndef NRF_802154_SWI_EGU_INSTANCE
#ifdef NRF52811_XXAA
#define NRF_802154_SWI_EGU_INSTANCE NRF_EGU0
#else
#define NRF_802154_SWI_EGU_INSTANCE NRF_EGU3
#endif
#endif
/**
* @def NRF_802154_SWI_IRQ_HANDLER
*
* The SWI EGU IRQ handler used by the driver for requests and notifications if SWI is in use.
*
* @note This option is used when the driver uses SWI to process requests and notifications.
*
*/
#ifndef NRF_802154_SWI_IRQ_HANDLER
#define NRF_802154_SWI_IRQ_HANDLER SWI3_EGU3_IRQHandler
#endif
/**
* @def NRF_802154_SWI_IRQN
*
* The SWI EGU IRQ number used by the driver for requests and notifications if SWI is in use.
*
* @note This option is used when the driver uses SWI to process requests and notifications.
*
*/
#ifndef NRF_802154_SWI_IRQN
#define NRF_802154_SWI_IRQN SWI3_EGU3_IRQn
#endif
/**
* @def NRF_802154_SWI_PRIORITY
*
* The priority of software interrupt used for requests and notifications.
*
*/
#ifndef NRF_802154_SWI_PRIORITY
#define NRF_802154_SWI_PRIORITY 5
#endif
/**
* @def NRF_802154_USE_RAW_API
*
* When this flag is set, the RAW API is available for the MAC layer. It is recommended to use
* the RAW API because it provides more optimized functions.
*
* @note If the RAW API is not available for the MAC layer, only less optimized functions performing
* copy are available.
*
*/
#ifndef NRF_802154_USE_RAW_API
#define NRF_802154_USE_RAW_API 1
#endif
/**
* @def NRF_802154_PENDING_SHORT_ADDRESSES
*
* The number of slots containing short addresses of nodes for which the pending data is stored.
*
*/
#ifndef NRF_802154_PENDING_SHORT_ADDRESSES
#define NRF_802154_PENDING_SHORT_ADDRESSES 10
#endif
/**
* @def NRF_802154_PENDING_EXTENDED_ADDRESSES
*
* The number of slots containing extended addresses of nodes for which the pending data is stored.
*
*/
#ifndef NRF_802154_PENDING_EXTENDED_ADDRESSES
#define NRF_802154_PENDING_EXTENDED_ADDRESSES 10
#endif
/**
* @def NRF_802154_RX_BUFFERS
*
* The number of buffers in the receive queue.
*
*/
#ifndef NRF_802154_RX_BUFFERS
#define NRF_802154_RX_BUFFERS 16
#endif
/**
* @def NRF_802154_DISABLE_BCC_MATCHING
*
* Setting this flag disables NRF_RADIO_EVENT_BCMATCH handling, and therefore the address filtering
* during the frame reception. With this flag set to 1, the address filtering is done after
* receiving a frame, during NRF_RADIO_EVENT_END handling.
*
*/
#ifndef NRF_802154_DISABLE_BCC_MATCHING
#define NRF_802154_DISABLE_BCC_MATCHING 0
#endif
/**
* @def NRF_802154_NOTIFY_CRCERROR
*
* With this flag set to 1, the CRC errors are notified to upper layers. This requires an interrupt
* handler to be used.
*
*/
#ifndef NRF_802154_NOTIFY_CRCERROR
#define NRF_802154_NOTIFY_CRCERROR 1
#endif
/**
* @def NRF_802154_FRAME_TIMESTAMP_ENABLED
*
* If timestamps are to be added to the frames received.
* Enabling this feature enables the functions @ref nrf_802154_received_timsestamp_raw,
* @ref nrf_802154_received_timestamp, @ref nrf_802154_transmitted_timestamp_raw, and
* @ref nrf_802154_transmitted_timestamp, which add timestamps to the frames received.
*
*/
#ifndef NRF_802154_FRAME_TIMESTAMP_ENABLED
#define NRF_802154_FRAME_TIMESTAMP_ENABLED 1
#endif
/**
* @def NRF_802154_DELAYED_TRX_ENABLED
*
* If the delayed transmission and the receive window features are available.
*
*/
#ifndef NRF_802154_DELAYED_TRX_ENABLED
#define NRF_802154_DELAYED_TRX_ENABLED 1
#endif
/**
* @}
* @defgroup nrf_802154_config_clock Clock driver configuration
* @{
*/
/**
* @def NRF_802154_CLOCK_IRQ_PRIORITY
*
* The priority of clock interrupt used in the standalone clock driver implementation.
*
* @note This configuration is only applicable for the Clock Abstraction Layer implementation
* in nrf_802154_clock_nodrv.c.
*
*/
#ifndef NRF_802154_CLOCK_IRQ_PRIORITY
#define NRF_802154_CLOCK_IRQ_PRIORITY 7
#endif
/**
* @def NRF_802154_CLOCK_LFCLK_SOURCE
*
* The low-frequency clock source used in the standalone clock driver implementation.
*
* @note This configuration is only applicable for the Clock Abstraction Layer implementation
* in nrf_802154_clock_nodrv.c.
*
*/
#ifndef NRF_802154_CLOCK_LFCLK_SOURCE
#define NRF_802154_CLOCK_LFCLK_SOURCE NRF_CLOCK_LFCLK_Xtal
#endif
/**
* @}
* @defgroup nrf_802154_config_rtc RTC driver configuration
* @{
*/
/**
* @def NRF_802154_RTC_IRQ_PRIORITY
*
* The priority of RTC interrupt used in the standalone timer driver implementation.
*
* @note This configuration is only applicable for the Low Power Timer Abstraction Layer
* implementation in nrf_802154_lp_timer_nodrv.c.
*
*/
#ifndef NRF_802154_RTC_IRQ_PRIORITY
#define NRF_802154_RTC_IRQ_PRIORITY 6
#endif
/**
* @def NRF_802154_RTC_INSTANCE
*
* The RTC instance used in the standalone timer driver implementation.
*
* @note This configuration is only applicable for the Low Power Timer Abstraction Layer
* implementation in nrf_802154_lp_timer_nodrv.c.
*
*/
#ifndef NRF_802154_RTC_INSTANCE
#ifdef NRF52811_XXAA
#define NRF_802154_RTC_INSTANCE NRF_RTC0
#else
#define NRF_802154_RTC_INSTANCE NRF_RTC2
#endif
#endif
/**
* @def NRF_802154_RTC_IRQ_HANDLER
*
* The RTC interrupt handler name used in the standalone timer driver implementation.
*
* @note This configuration is only applicable for Low Power Timer Abstraction Layer implementation
* in nrf_802154_lp_timer_nodrv.c.
*
*/
#ifndef NRF_802154_RTC_IRQ_HANDLER
#ifdef NRF52811_XXAA
#define NRF_802154_RTC_IRQ_HANDLER RTC0_IRQHandler
#else
#define NRF_802154_RTC_IRQ_HANDLER RTC2_IRQHandler
#endif
#endif
/**
* @def NRF_802154_RTC_IRQN
*
* The RTC Interrupt number used in the standalone timer driver implementation.
*
* @note This configuration is only applicable for the Low Power Timer Abstraction Layer implementation
* in nrf_802154_lp_timer_nodrv.c.
*
*/
#ifndef NRF_802154_RTC_IRQN
#ifdef NRF52811_XXAA
#define NRF_802154_RTC_IRQN RTC0_IRQn
#else
#define NRF_802154_RTC_IRQN RTC2_IRQn
#endif
#endif
/**
* @}
* @defgroup nrf_802154_config_csma CSMA/CA procedure configuration
* @{
*/
/**
* @def NRF_802154_CSMA_CA_ENABLED
*
* If CSMA-CA is to be enabled by the driver. Disabling CSMA-CA improves
* the driver performance.
*
*/
#ifndef NRF_802154_CSMA_CA_ENABLED
#define NRF_802154_CSMA_CA_ENABLED 1
#endif
/**
* @def NRF_802154_CSMA_CA_MIN_BE
*
* The minimum value of the backoff exponent (BE) in the CSMA-CA algorithm
* (see IEEE 802.15.4-2015: 6.2.5.1).
*
*/
#ifndef NRF_802154_CSMA_CA_MIN_BE
#define NRF_802154_CSMA_CA_MIN_BE 3
#endif
/**
* @def NRF_802154_CSMA_CA_MAX_BE
*
* The maximum value of the backoff exponent, BE, in the CSMA-CA algorithm
* (see IEEE 802.15.4-2015: 6.2.5.1).
*
*/
#ifndef NRF_802154_CSMA_CA_MAX_BE
#define NRF_802154_CSMA_CA_MAX_BE 5
#endif
/**
* @def NRF_802154_CSMA_CA_MAX_CSMA_BACKOFFS
*
* The maximum number of backoffs that the CSMA-CA algorithm will attempt before declaring a channel
* access failure.
*
*/
#ifndef NRF_802154_CSMA_CA_MAX_CSMA_BACKOFFS
#define NRF_802154_CSMA_CA_MAX_CSMA_BACKOFFS 4
#endif
/**
* @def NRF_802154_CSMA_CA_WAIT_FOR_TIMESLOT
*
* Indicates whether the CSMA-CA algorithm waits for an available timeslot before it performs
* the CCA procedure.
*
* @note When this option is enabled, the CSMA-CA procedure can be synchronized with timeslots of
* other protocols. This decreases the robustness of the CSMA-CA procedure. On the other hand,
* enabling this function increases the performance of multi-protocol applications, especially
* when protocols other than 802.15.4 use much of the radio time (like the BLE scanning
* operation).
*
*/
#ifndef NRF_802154_CSMA_CA_WAIT_FOR_TIMESLOT
#define NRF_802154_CSMA_CA_WAIT_FOR_TIMESLOT 1
#endif
/**
* @}
* @defgroup nrf_802154_config_timeout ACK timeout feature configuration
* @{
*/
/**
* @def NRF_802154_ACK_TIMEOUT_ENABLED
*
* Indicates whether the ACK timeout feature is to be enabled in the driver.
*
*/
#ifndef NRF_802154_ACK_TIMEOUT_ENABLED
#define NRF_802154_ACK_TIMEOUT_ENABLED 1
#endif
/**
* @def NRF_802154_ACK_TIMEOUT_DEFAULT_TIMEOUT
*
* The default timeout in microseconds (us) for the ACK timeout feature.
*
*/
#ifndef NRF_802154_ACK_TIMEOUT_DEFAULT_TIMEOUT
#define NRF_802154_ACK_TIMEOUT_DEFAULT_TIMEOUT 7000
#endif
/**
* @def NRF_802154_ACK_TIMEOUT_DEFAULT_TIMEOUT
*
* The default timeout in microseconds (us) for the precise ACK timeout feature.
*
*/
#ifndef NRF_802154_PRECISE_ACK_TIMEOUT_DEFAULT_TIMEOUT
#define NRF_802154_PRECISE_ACK_TIMEOUT_DEFAULT_TIMEOUT 210
#endif
/**
* @def NRF_802154_MAX_ACK_IE_SIZE
*
* The maximum supported size of the 802.15.4-2015 IE header and content fields in an Enh-Ack.
*
*/
#ifndef NRF_802154_MAX_ACK_IE_SIZE
#define NRF_802154_MAX_ACK_IE_SIZE 8
#endif
/**
* @}
* @defgroup nrf_802154_config_transmission Transmission start notification feature configuration
* @{
*/
/**
* @def NRF_802154_TX_STARTED_NOTIFY_ENABLED
*
* Indicates whether the notifications of the started transmissions are to be enabled in the driver.
*
* @note This feature is enabled by default if the ACK timeout feature or CSMA-CA is enabled.
* These features depend on the notifications of the transmission start.
*/
#ifndef NRF_802154_TX_STARTED_NOTIFY_ENABLED
#if NRF_802154_ACK_TIMEOUT_ENABLED || NRF_802154_CSMA_CA_ENABLED
#define NRF_802154_TX_STARTED_NOTIFY_ENABLED 1
#else
#define NRF_802154_TX_STARTED_NOTIFY_ENABLED 0
#endif
#endif // NRF_802154_TX_STARTED_NOTIFY_ENABLED
/**
*@}
**/
#ifdef __cplusplus
}
#endif
#endif // NRF_802154_CONFIG_H__
/**
*@}
**/