Contiki-NG
Loading...
Searching...
No Matches
at86rf215-conf.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023, ComLab, Jozef Stefan Institute - https://e6.ijs.si/
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/*---------------------------------------------------------------------------*/
31/**
32 * \file
33 * Configuration file for the AT86RF215 radio drivers.
34 * \author
35 * Grega Morano <grega.morano@ijs.si>
36 */
37/*---------------------------------------------------------------------------*/
38#ifndef AT86RF215_CONF_H_
39#define AT86RF215_CONF_H_
40
42
43
44/*---------------------------------------------------------------------------*/
45/* Radio configuration according to selected frequency band */
46/*---------------------------------------------------------------------------*/
47/**
48 * Current radio driver enables the selection of and frequency band only
49 * before compiling. In future we could reconfigure the drivers to support both
50 */
51#define FREQ_BAND_SUBGHZ (0)
52#define FREQ_BAND_24GHZ (1)
53
54/**
55 * Select the Frequency band to use: 0 = Sub-GHz, 1 = 2.4 GHz
56 *
57 * NOTE: Current driver is designed for only one RF band at the time!
58 */
59#ifndef AT86RF215_CONF_FREQUENCY_BAND
60#define AT86RF215_FREQUENCY_BAND (FREQ_BAND_24GHZ)
61#else
62#define AT86RF215_FREQUENCY_BAND (AT86RF215_CONF_FREQUENCY_BAND)
63#endif
64
65
66
67
68/*---------------------------------------------------------------------------*/
69/* Radio configuration according to selected modulation */
70/*---------------------------------------------------------------------------*/
71
72/*---------------------------------------------------------------------------*/
73/* O-QPSK modulation */
74#if AT86RF215_FREQUENCY_BAND == FREQ_BAND_24GHZ
75
76 /* Defined and depends on the band and regulation (Europe, US, Japan)
77 * and modulation type
78 */
79 #define OQPSK_CHANNEL_SPACING 5000000 // Hz
80 #define OQPSK_CHANNEL_CENTER_FREQ 2405000000 // Hz
81
82 /* Set the channel spacing (example: 5 MHz / 25 kHz resolution) */
83 #define OQPSK_CS (uint8_t) (OQPSK_CHANNEL_SPACING / 25000)
84
85 /* Set the center frequency (example: (2405 MHz - 1.5 MHz offset) / 25 kHz) */
86 #define OQPSK_CF_H (uint8_t) ((((OQPSK_CHANNEL_CENTER_FREQ - 1500000000) / 25000) & 0xFF00) >> 8)
87 #define OQPSK_CF_L (uint8_t) (((OQPSK_CHANNEL_CENTER_FREQ - 1500000000) / 25000) & 0x00FF)
88
89#else
90 #warning "SUB GHZ band not tested yet!"
91#endif
92
93
94/**
95 * Legacy O-QPSK (IEEE 802.15.4-2011)
96 * - 250 kbit/s
97 * - currently only 2.4 GHZ band
98 */
99static const at86rf215_radio_config_t radio_config_oqpsk_250kbps[] =
100{
101 /* Enable BBC */
102 {RG_BBC1_PC, 0x1F}, // CTX disabled, disable RX FCS filter, autogenerate TX FCS, 16-bit FCS, enable BBC, modulation: O-QPSK
103
104 /* TX config */
105 {RG_RF24_TXDFE, 0x81}, // TX cut-off freq. 1*fs/2 (default is 0.25*fs/2), TX sample rate 4000 kHz
106 {RG_RF24_TXCUTC, 0x0B}, // AMP ramp up = 4us, LP cut-off freq. = 1000 KHz
107 {RG_RF24_PAC, 0xFF}, // No current reduction, Max output power (0x1F)
108
109 /* RX config */
110 {RG_RF24_RXBWC, 0x0B}, // Rx filter BW 2000 kHz, IF 2000 kHz, no IF inversion or shift
111 {RG_RF24_RXDFE, 0x41}, // RX cut-off freq. 0.5*fs/2 (default is 0.25*fs/2), RX sampling rate 4000 kHz
112 {RG_RF24_EDC, 0x00}, // Automatic energy detection
113 {RG_RF24_EDD, 0x13}, // averaging time T = DF * DTB --> DTB=128us, DF = 4 --> T = 512us
114 {RG_RF24_AGCC, 0x01}, // Enable automatic gain control
115 {RG_RF24_AGCS, 0x77}, // AGC target level = -30dBm
116
117 /* PLL config */
118 {RG_RF24_CS, OQPSK_CS},
119 {RG_RF24_CCF0L, OQPSK_CF_L},
120 {RG_RF24_CCF0H, OQPSK_CF_H},
121
122 /* Baseband core config */
123 {RG_BBC1_OQPSKPHRTX, 0x09}, // QPSK - legacy
124 {RG_BBC1_OQPSKC0, 0x03}, // Chip freq.: 2000 kchips/s
125 {RG_BBC1_OQPSKC1, 0x47}, // rx-override enabled, MINIMUM preamble-detection sensitivities,
126 {RG_BBC1_OQPSKC2, 0x05}, // listen frames of legacy OQPSK, FCS is 16bit, power saving is off
127 {RG_BBC1_OQPSKC3, 0x00}, // legacy OQPSK, search for SFD_1 only
128};
129
130/**
131 * Option left to change the modulation parameters (e.g. 1Mbit/s)
132 */
133//static const at86rf215_radio_config_t radio_config_oqpsk_1Mbps[] = {};
134
135/*---------------------------------------------------------------------------*/
136/* FSK modulation */
137#if AT86RF215_FREQUENCY_BAND == FREQ_BAND_24GHZ
138
139 /* Defined and depends on the band and regulation (Europe, US, Japan)
140 * and modulation type
141 */
142 #define FSK_CHANNEL_SPACING 5000000 // Hz
143 #define FSK_CHANNEL_CENTER_FREQ 2405000000 // Hz
144
145 /* Set the channel spacing (example: 5 MHz / 25 kHz resolution) */
146 #define FSK_CS (uint8_t) (FSK_CHANNEL_SPACING / 25000)
147
148 /* Set the center frequency (example: (2405 MHz - 1.5 MHz offset) / 25 kHz) */
149 #define FSK_CF_H (uint8_t) ((((FSK_CHANNEL_CENTER_FREQ - 1500000000) / 25000) & 0xFF00) >> 8)
150 #define FSK_CF_L (uint8_t) (((FSK_CHANNEL_CENTER_FREQ - 1500000000) / 25000) & 0x00FF)
151
152#else
153 #warning "SUB GHZ band not tested yet!"
154#endif
155
156/**
157 * FSK modulation (not tested yet)
158 */
159static const at86rf215_radio_config_t radio_config_fsk_test[] =
160{
161 /* Enable BBC */
162 {RG_BBC1_PC, 0x1D}, // CTX disabled, disable RX FCS filter, autogenerate TX FCS, 16-bit FCS, enable BBC, modulation: FSK
163
164 /* TX config */
165 {RG_RF24_TXDFE, 0x98},
166 {RG_RF24_TXCUTC, 0xC0},
167 {RG_RF24_PAC, 0xFF}, // No current reduction, Max output power (0x1F)
168
169 /* RX config */
170 {RG_RF24_RXBWC, 0x00},
171 {RG_RF24_RXDFE, 0x2A},
172 {RG_RF24_EDC, 0x00},
173 {RG_RF24_EDD, 0x7A},
174 {RG_RF24_AGCC, 0x01},
175 {RG_RF24_AGCS, 0x37},
176
177 /* PLL config */
178 {RG_RF24_CS, FSK_CS},
179 {RG_RF24_CCF0L, FSK_CF_L},
180 {RG_RF24_CCF0H, FSK_CF_H},
181
182 /* Baseband core config */
183 {RG_BBC1_FSKDM, 0x01},
184 {RG_BBC1_FSKC0, 0xD6},
185 {RG_BBC1_FSKC1, 0x00},
186 {RG_BBC1_FSKC2, 0x00},
187 {RG_BBC1_FSKC3, 0x85},
188 {RG_BBC1_FSKC4, 0x00},
189 {RG_BBC1_FSKPE0, 0x02},
190 {RG_BBC1_FSKPE1, 0x03},
191 {RG_BBC1_FSKPE2, 0xFC},
192 {RG_BBC1_FSKPHRTX, 0x08}
193
194};
195
196/*---------------------------------------------------------------------------*/
197/* OFDM modulation */
198
199// TODO
200
201/*---------------------------------------------------------------------------*/
202
203/* Legacy OQPSK uses 16-bit CRC */
204#define AT86RF215_CONF_CRC_16BIT (1)
205#define AT86RF215_CONF_CCA_THRESHOLD (-90) // dBm
206
207#define AT86RF215_RADIO_CONFIGURATION radio_config_oqpsk_250kbps
208
209
210/*---------------------------------------------------------------------------*/
211/* Radio configuration according to selected MAC mode */
212/*---------------------------------------------------------------------------*/
213/**
214 * If driver is used for CSMA (default)
215 */
216#if MAC_CONF_WITH_CSMA
217
218 #define AT86RF215_CONF_FRAME_FILTER (0) // Required for AACK, no need otherwise?
219 #define AT86RF215_CONF_SEND_ON_CCA (0)
220 #define AT86RF215_CONF_POLL_MODE (0)
221 #define AT86RF215_CONF_AUTO_ACK (0) // Doesn't work, use SW ACK
222
223 #define CSMA_CONF_SEND_SOFT_ACK (1)
224 #define CSMA_CONF_ACK_WAIT_TIME (RTIMER_SECOND / 100)
225 #define CSMA_CONF_AFTER_ACK_DETECTED_WAIT_TIME (RTIMER_SECOND / 1000)
226
227 #define AT86RF215_CONF_AUTO_CRC (1)
228
229#endif /* MAC_CONF_WITH_CSMA */
230
231
232/**
233 * If driver is used for TSCH
234 */
235#if MAC_CONF_WITH_TSCH
236
237 #define AT86RF215_CONF_AUTO_ACK (0)
238 #define AT86RF215_CONF_FRAME_FILTER (0)
239 #define AT86RF215_CONF_SEND_ON_CCA (0)
240 #define AT86RF215_CONF_POLL_MODE (1)
241
242 #define AT86RF215_CONF_AUTO_CRC (1)
243
244#endif /* MAC_CONF_WITH_TSCH */
245
246
247
248/*---------------------------------------------------------------------------*/
249/* Radio module configuration */
250/*---------------------------------------------------------------------------*/
251/**
252 * Enable/disable auto-acknowledgement, where radio automatically sends
253 * an ACK frame after receiving a frame with the ACK request bit set
254 */
255#ifndef AT86RF215_CONF_AUTO_ACK
256#define AT86RF215_AUTO_ACK (0)
257#else
258#define AT86RF215_AUTO_ACK (AT86RF215_CONF_AUTO_ACK)
259#endif
260
261/**
262 * Enable/disable address filter mode, where radio only accepts frames
263 * with matching address
264 */
265#ifndef AT86RF215_CONF_FRAME_FILTER
266#define AT86RF215_FRAME_FILTER (0)
267#else
268#define AT86RF215_FRAME_FILTER (AT86RF215_CONF_FRAME_FILTER)
269#endif
270
271/**
272 * Do a CCA manually before sending a packet
273 */
274#ifndef AT86RF215_CONF_SEND_ON_CCA
275#define AT86RF215_SEND_ON_CCA (0)
276#else
277#define AT86RF215_SEND_ON_CCA (AT86RF215_CONF_SEND_ON_CCA)
278#endif
279
280/**
281 * Radio does a CCA automaticaly before sending a packet
282 *
283 * TODO: Not implemented yet!
284 * (No need, only if we want to offload the operation to the radio)
285 */
286#ifndef AT86RF215_CONF_AUTO_CCATX
287#define AT86RF215_AUTO_CCATX (0)
288#else
289#define AT86RF215_AUTO_CCATX (AT86RF215_CONF_AUTO_CCATX)
290#endif
291
292/**
293 * CCA threshold in dBm
294 */
295#ifndef AT86RF215_CONF_CCA_THRESHOLD
296#define AT86RF215_CCA_THRESHOLD (-70)
297#else
298#define AT86RF215_CCA_THRESHOLD (AT86RF215_CONF_CCA_THRESHOLD)
299#endif
300
301/**
302 * Radio poll mode - should disable interrupts and enable upper levels
303 * to poll the radio for events.
304 */
305#ifndef AT86RF215_CONF_POLL_MODE
306#define AT86RF215_POLL_MODE (1)
307#else
308#define AT86RF215_POLL_MODE (AT86RF215_CONF_POLL_MODE)
309#endif
310
311/**
312 * Enable/disable auto-CRC generation
313 * Radio will automatically append CRC to outgoing frames
314 */
315#ifndef AT86RF215_CONF_AUTO_CRC
316#define AT86RF215_AUTO_CRC (1)
317#else
318#define AT86RF215_AUTO_CRC (AT86RF215_CONF_AUTO_CRC)
319#endif
320
321/**
322 * Select either 16-bit (1) or 32-bit (0) CRC
323*/
324#ifndef AT86RF215_CONF_CRC_16BIT
325#define AT86RF215_CRC_16BIT (1)
326#else
327#define AT86RF215_CRC_16BIT (AT86RF215_CONF_CRC_16BIT)
328#endif
329
330/**
331 * Enable the automatic transition to RX state after a packet is sent.
332 *
333 * TODO: Not implemented yet (No need?)
334 */
335#ifndef AT86RF215_CONF_AUTO_TX2RX
336#define AT86RF215_AUTO_TX2RX (0)
337#else
338#define AT86RF215_AUTO_TX2RX (AT86RF215_CONF_AUTO_TX2RX)
339#endif
340
341/**
342 * Debug driver operation with GPIO pins (development purpose only)
343 */
344#ifndef AT86RF215_CONF_GPIO_DEBUG_TSCH
345#define AT86RF215_DEBUG_GPIO_TSCH (0)
346#else
347#define AT86RF215_DEBUG_GPIO_TSCH (AT86RF215_CONF_GPIO_DEBUG_TSCH)
348#endif
349
350/**
351 * Logging level for the AT86RF215 driver.
352 */
353#ifndef LOG_CONF_LEVEL_AT86RF215
354#define AT86RF215_LOG_LEVEL (LOG_LEVEL_WARN)
355#else
356#define AT86RF215_LOG_LEVEL (LOG_CONF_LEVEL_AT86RF215)
357#endif
358
359
360#endif /* AT86RF215_CONF_H_ */
static const at86rf215_radio_config_t radio_config_oqpsk_250kbps[]
Legacy O-QPSK (IEEE 802.15.4-2011)
static const at86rf215_radio_config_t radio_config_fsk_test[]
FSK modulation (not tested yet)
Registermap for the AT86RF215.