Contiki-NG
Loading...
Searching...
No Matches
nrf_802154_project_config.h
1/*
2 * Copyright (c) 2026, RISE Research Institutes of Sweden AB
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
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the copyright holder nor the names of its
14 * contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28 * OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
30 * nrf_802154 library configuration for the Contiki-NG nRF5340
31 * network-core radio port. Adapted from the nRF54L15 port
32 * (arch/cpu/nrf/nrf54l15/nrf_802154_project_config.h).
33 *
34 * Peripheral instances are chosen to avoid the ones Contiki-NG already
35 * claims on the net core:
36 * - System clock -> RTC0 (clock-arch.c, NRF_CLOCK_CONF_RTC_INSTANCE=0)
37 * - rtimer -> TIMER0 (rtimer-arch.c, TIMER_INSTANCE default 0)
38 * - IPC transport -> IPC peripheral + IPC_IRQ (no EGU/DPPI)
39 *
40 * The nrf_802154 nRF53 defaults (nrf_802154_peripherals_nrf53.h +
41 * nrf_802154_peripherals.h) are: EGU0, RTC2, DPPIC, TIMER0. RTC2 and
42 * EGU0 are free, but the library's TIMER0 collides with rtimer, so the
43 * radio TIMER is moved below. (Alternatively, relocate rtimer instead
44 * via NRF_RTIMER_CONF_TIMER_INSTANCE in the example's project-conf.h.)
45 */
46
47#ifndef NRF_802154_PROJECT_CONFIG_H_
48#define NRF_802154_PROJECT_CONFIG_H_
49
50/* ---- Peripheral instance assignments (avoid Contiki-NG's) ------------- */
51
52/* Radio fine-timing / ACK-IFS timer. Default is TIMER0 (used by rtimer),
53 * so move the library to TIMER1. */
54#define NRF_802154_TIMER_INSTANCE_NO 1
55/* High-precision (timestamp) timer; unused while timestamping is off, but
56 * reserve TIMER2 so NRF_802154_TIMERS_USED_MASK stays off TIMER0. */
57#define NRF_802154_HIGH_PRECISION_TIMER_INSTANCE_NO 2
58
59/* The nRF5340 NETWORK core has only RTC0 and RTC1 -- there is no RTC2, so
60 * the nrf53 header default (RTC_INSTANCE_NO=2) does not exist here. RTC0 is
61 * the Contiki-NG system clock, so the low-power timer backend uses RTC1.
62 * (Build must NOT enable NRFX_RTC1 so this file owns RTC1_IRQHandler.) */
63#define NRF_802154_RTC_INSTANCE_NO 1
64
65/* EGU0 (library default) is unused by Contiki-NG on the net core. The
66 * library's DPPIC channels are likewise free: the only other nrfx_gppi
67 * user on this core, the legacy nrf-ieee-driver-arch.c, is excluded from
68 * the build when NRF_802154=1 (see nrf802154.mk). */
69
70/* ---- IRQ ownership ---------------------------------------------------- */
71
72/* The library owns the net core's RADIO IRQ directly. Use direct (non-SWI)
73 * notification/request as the nRF54L15 port does, to avoid wiring an EGU
74 * IRQ handler in the platform layer. */
75#define NRF_802154_INTERNAL_RADIO_IRQ_HANDLING 1
76#define NRF_802154_INTERNAL_SWI_IRQ_HANDLING 0
77#define NRF_802154_NOTIFICATION_IMPL NRF_802154_NOTIFICATION_IMPL_DIRECT
78#define NRF_802154_REQUEST_IMPL NRF_802154_REQUEST_IMPL_DIRECT
79
80/* ---- Feature set ------------------------------------------------------ */
81
82/* Auto-ACK is what this port is for: the wrapper calls
83 * nrf_802154_auto_ack_set(true); the library generates the immediate ACK
84 * in hardware within the 802.15.4 ACK window (fixing the CC2538 interop).
85 * Contiki-NG CSMA on the app core still does TX backoff, so disable the
86 * library's own CSMA. Keep TX-side ACK timeout. */
87#define NRF_802154_CSMA_CA_ENABLED 0
88#define NRF_802154_ACK_TIMEOUT_ENABLED 1
89#define NRF_802154_IFS_ENABLED 0
90#define NRF_802154_DELAYED_TRX_ENABLED 0 /* no TSCH yet */
91
92/* Open-source SL feature trim (matches the nRF54L15 port). */
93#define NRF_802154_ENCRYPTION_ENABLED 0
94#define NRF_802154_IE_WRITER_ENABLED 0
95#define NRF_802154_SECURITY_WRITER_ENABLED 0
96#define NRF_802154_CARRIER_FUNCTIONS_ENABLED 0
97#define NRF_802154_TEST_MODES_ENABLED 0
98#define NRF_802154_FRAME_TIMESTAMP_ENABLED 0
99#define NRF_802154_NOTIFY_CRCERROR 0
100#define NRF_802154_SERIALIZATION_HOST 0
101
102/* ---- CCA / buffers (nRF54L15 values; re-tune on nRF53 hardware) ------- */
103#define NRF_802154_CCA_MODE_DEFAULT NRF_RADIO_CCA_MODE_ED
104#define NRF_802154_CCA_ED_THRESHOLD_DBM_DEFAULT (-75)
105#define NRF_802154_CCA_CORR_THRESHOLD_DEFAULT 45
106#define NRF_802154_CCA_CORR_LIMIT_DEFAULT 2
107#define NRF_802154_PENDING_SHORT_ADDRESSES 16
108#define NRF_802154_PENDING_EXTENDED_ADDRESSES 16
109#define NRF_802154_RX_BUFFERS 20
110
111/* Extra ACK turnaround slack for the bare-metal Contiki-NG timer backend.
112 * Start at 0 on nRF53 and only raise if RX-side ACKs land late. */
113#define NRF_802154_ACK_IFS_EXTRA_TIME_US 0U
114
115/* No closed-source SL: must remain undefined, not 0. */
116#ifdef NRF_802154_USE_INTERNAL_INCLUDES
117#undef NRF_802154_USE_INTERNAL_INCLUDES
118#endif
119
120#endif /* NRF_802154_PROJECT_CONFIG_H_ */