Contiki-NG
cc13xx-cc26xx-conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018, Texas Instruments Incorporated - http://www.ti.com/
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  * \addtogroup cc13xx-cc26xx-cpu
32  * @{
33  *
34  * \file
35  * Header with configuration defines common to the CC13xx/CC26xx
36  * platform.
37  * \author
38  * Edvard Pettersen <e.pettersen@ti.com>
39  */
40 /*---------------------------------------------------------------------------*/
41 #ifndef CC13XX_CC26XX_CONF_H_
42 #define CC13XX_CC26XX_CONF_H_
43 /*---------------------------------------------------------------------------*/
44 #include "cc13xx-cc26xx-def.h"
45 
46 #include "rf/rf.h"
47 /*---------------------------------------------------------------------------*/
48 /**
49  * \name Board Configuration.
50  *
51  * @{
52  */
53 
54 /* Configure that a board has sensors for the dev/sensors.h API. */
55 #ifndef BOARD_CONF_HAS_SENSORS
56 #define BOARD_CONF_HAS_SENSORS 0
57 #endif
58 
59 /* Enable/disable the dev/sensors.h API for the given board. */
60 #ifndef BOARD_CONF_SENSORS_DISABLE
61 #define BOARD_CONF_SENSORS_DISABLE 0
62 #endif
63 /*---------------------------------------------------------------------------*/
64 /**
65  * \name Watchdog Configuration.
66  *
67  * @{
68  */
69 #ifndef WATCHDOG_CONF_DISABLE
70 #define WATCHDOG_CONF_DISABLE 0
71 #endif
72 
73 #ifndef WATCHDOG_CONF_TIMEOUT_MS
74 #define WATCHDOG_CONF_TIMEOUT_MS 1000
75 #endif
76 /** @} */
77 /*---------------------------------------------------------------------------*/
78 /**
79  * \name RF configuration.
80  *
81  * @{
82  */
83 
84 /*
85  * Set the inactivity timeout period for the RF driver. This determines how
86  * long the RF driver will wait when inactive until turning off the RF Core.
87  * Specified in microseconds.
88  */
89 #ifndef RF_CONF_INACTIVITY_TIMEOUT
90 #define RF_CONF_INACTIVITY_TIMEOUT 2000 /**< 2 ms */
91 #endif
92 
93 /*
94  * Configure TX power to either default PA or High PA, defaults to
95  * default PA.
96  */
97 #ifndef RF_CONF_TXPOWER_HIGH_PA
98 #define RF_CONF_TXPOWER_HIGH_PA 0
99 #endif
100 
101 #if (RF_CONF_TXPOWER_HIGH_PA) && !(SUPPORTS_HIGH_PA)
102 #error "Device does not support High PA"
103 #endif
104 
105 /*
106  * CC13xx only: Configure TX power to use boot mode, allowing to gain
107  * up to 14 dBm with the default PA. This will, however, increase power
108  * consumption.
109  */
110 #ifndef RF_CONF_TXPOWER_BOOST_MODE
111 #define RF_CONF_TXPOWER_BOOST_MODE 0
112 #endif
113 
114 /*
115  * Configure RF mode. That is, whether to run on Sub-1 GHz (Prop-mode) or
116  * 2.4 GHz (IEEE-mode).
117  */
118 #ifdef RF_CONF_MODE
119 /* Sanity check a valid configuration is provided. */
120 #if !(RF_CONF_MODE & RF_MODE_BM)
121 #error "Invalid RF_CONF_MODE provided"
122 #endif
123 
124 #define RF_MODE RF_CONF_MODE
125 #endif /* RF_CONF_MODE */
126 
127 /* Sub-1 GHz path front-end mode configuration */
128 #ifdef RF_SUB_1_GHZ_CONF_FRONT_END_MODE
129 #define RF_SUB_1_GHZ_FRONT_END_MODE RF_SUB_1_GHZ_CONF_FRONT_END_MODE
130 #else
131 #define RF_SUB_1_GHZ_FRONT_END_MODE RF_FRONT_END_MODE_DIFFERENTIAL
132 #endif
133 
134 #ifdef RF_SUB_1_GHZ_CONF_BIAS_MODE
135 #define RF_SUB_1_GHZ_BIAS_MODE RF_SUB_1_GHZ_CONF_BIAS_MODE
136 #else
137 #define RF_SUB_1_GHZ_BIAS_MODE RF_BIAS_MODE_INTERNAL
138 #endif
139 
140 /* 2.4 GHz path front-end mode configuration */
141 #ifdef RF_2_4_GHZ_CONF_FRONT_END_MODE
142 #define RF_2_4_GHZ_FRONT_END_MODE RF_2_4_GHZ_CONF_FRONT_END_MODE
143 #else
144 #define RF_2_4_GHZ_FRONT_END_MODE RF_FRONT_END_MODE_DIFFERENTIAL
145 #endif
146 
147 #ifdef RF_2_4_GHZ_CONF_BIAS_MODE
148 #define RF_2_4_GHZ_BIAS_MODE RF_2_4_GHZ_CONF_BIAS_MODE
149 #else
150 #define RF_2_4_GHZ_BIAS_MODE RF_BIAS_MODE_INTERNAL
151 #endif
152 
153 /* Number of RX buffers. */
154 #ifndef RF_CONF_RX_BUF_CNT
155 #define RF_CONF_RX_BUF_CNT 4
156 #endif
157 
158 /* Size of each RX buffer in bytes. */
159 #ifndef RF_CONF_RX_BUF_SIZE
160 #define RF_CONF_RX_BUF_SIZE 144
161 #endif
162 
163 /* Enable/disable BLE beacon. */
164 #ifndef RF_CONF_BLE_BEACON_ENABLE
165 #define RF_CONF_BLE_BEACON_ENABLE 0
166 #endif
167 
168 #if (RF_CONF_BLE_BEACON_ENABLE) && !(SUPPORTS_BLE_BEACON)
169 #error "Device does not support BLE for BLE beacon"
170 #endif
171 
172 /*----- CC13xx Device Line --------------------------------------------------*/
173 /* CC13xx supports both IEEE and Prop mode, depending on which device. */
174 #if defined(DEVICE_LINE_CC13XX)
175 
176 /* Default to Prop-mode for CC13xx devices if not configured. */
177 #ifndef RF_MODE
178 #define RF_MODE RF_MODE_SUB_1_GHZ
179 #endif
180 
181 /*----- CC13xx Prop-mode ----------------------------------------------------*/
182 #if (RF_MODE == RF_MODE_SUB_1_GHZ) && (SUPPORTS_PROP_MODE)
183 
184 /* Netstack configuration. */
185 #define NETSTACK_CONF_RADIO prop_mode_driver
186 
187 /* CSMA configuration. */
188 #define CSMA_CONF_ACK_WAIT_TIME (RTIMER_SECOND / 300)
189 #define CSMA_CONF_AFTER_ACK_DETECTED_WAIT_TIME (RTIMER_SECOND / 1000)
190 #define CSMA_CONF_SEND_SOFT_ACK 1
191 
192 /*----- CC13xx IEEE-mode ----------------------------------------------------*/
193 #elif (RF_MODE == RF_MODE_2_4_GHZ) && (SUPPORTS_IEEE_MODE)
194 
195 /* Netstack configuration. */
196 #define NETSTACK_CONF_RADIO ieee_mode_driver
197 
198 /* CSMA configuration. */
199 #define CSMA_CONF_SEND_SOFT_ACK 0
200 
201 #else
202 /*----- CC13xx Unsupported Mode ---------------------------------------------*/
203 #error "Invalid RF mode configuration of CC13xx device"
204 #endif /* CC13xx RF Mode configuration */
205 
206 /*----- CC26xx Device Line --------------------------------------------------*/
207 /* CC26xx only supports IEEE mode */
208 #elif defined(DEVICE_LINE_CC26XX)
209 
210 /* Default to IEEE-mode for CC26xx devices if not configured */
211 #ifndef RF_MODE
212 #define RF_MODE RF_MODE_2_4_GHZ
213 #endif
214 
215 /*----- CC26xx IEEE-mode ----------------------------------------------------*/
216 #if (RF_MODE == RF_MODE_2_4_GHZ) && (SUPPORTS_IEEE_MODE)
217 
218 /* Netstack configuration */
219 #define NETSTACK_CONF_RADIO ieee_mode_driver
220 
221 /* CSMA configuration */
222 #define CSMA_CONF_SEND_SOFT_ACK 0
223 
224 /* Frequncy band configuration */
225 #undef DOT_15_4G_FREQ_BAND_ID
226 #define DOT_15_4G_CONF_FREQ_BAND_ID DOT_15_4G_FREQ_BAND_2450
227 
228 #else
229 /*----- CC26xx Unsupported Mode ---------------------------------------------*/
230 #error "IEEE-mode only supported by CC26xx devices"
231 #endif /* CC26xx RF Mode configuration */
232 
233 /*----- Unsupported device line ---------------------------------------------*/
234 #else
235 #error "Unsupported Device Line defined"
236 #endif /* Unsupported device line */
237 
238 #define prop_mode_driver_max_payload_len 125
239 #define ieee_mode_driver_max_payload_len 125
240 
241 /** @} */
242 /*---------------------------------------------------------------------------*/
243 /**
244  * \name IEEE address configuration. Used to generate our link-local and
245  * global IPv6 addresses.
246  * @{
247  */
248 
249 /**
250  * \brief Location of the IEEE address.
251  * 0 => Read from InfoPage.
252  * 1 => Use a hardcoded address, configured by IEEE_ADDR_CONF_ADDRESS.
253  */
254 #ifndef IEEE_ADDR_CONF_HARDCODED
255 #define IEEE_ADDR_CONF_HARDCODED 0
256 #endif
257 
258 /**
259  * \brief The hardcoded IEEE address to be used when IEEE_ADDR_CONF_HARDCODED
260  * is defined as 1. Must be a byte array of size 8.
261  */
262 #ifndef IEEE_ADDR_CONF_ADDRESS
263 #define IEEE_ADDR_CONF_ADDRESS { 0x00, 0x12, 0x4B, 0x00, 0x89, 0xAB, 0xCD, 0xEF }
264 #endif
265 /** @} */
266 /*---------------------------------------------------------------------------*/
267 /**
268  * \name IEEE-mode configuration.
269  *
270  * @{
271  */
272 
273 /**
274  * \brief Configuration to enable/disable auto ACKs in IEEE-mode.
275  * 0 => ACK generated by software
276  * 1 => ACK generated by the radio.
277  */
278 #ifndef IEEE_MODE_CONF_AUTOACK
279 #define IEEE_MODE_CONF_AUTOACK 1
280 #endif
281 
282 /**
283  * \brief Configuration to enable/disable frame filtering in IEEE-mode.
284  * 0 => Disable promiscous mode.
285  * 1 => Enable promiscous mode.
286  */
287 #ifndef IEEE_MODE_CONF_PROMISCOUS
288 #define IEEE_MODE_CONF_PROMISCOUS 0
289 #endif
290 
291 /**
292  * \brief Configuration to set the RSSI threshold in dBm in IEEE-mode.
293  * Defaults to -90 dBm.
294  */
295 #ifndef IEEE_MODE_CONF_CCA_RSSI_THRESHOLD
296 #define IEEE_MODE_CONF_CCA_RSSI_THRESHOLD 0xA6
297 #endif
298 /** @} */
299 /*---------------------------------------------------------------------------*/
300 /**
301  * \name Prop-mode configuration.
302  *
303  * @{
304  */
305 
306 /**
307  * \brief Configuration to set whitener in Prop-mode.
308  * 0 => No whitener
309  * 1 => Whitener.
310  */
311 #ifndef PROP_MODE_CONF_DW
312 #define PROP_MODE_CONF_DW 0
313 #endif
314 
315 /**
316  * \brief Use 16-bit or 32-bit CRC in Prop-mode.
317  * 0 => 32-bit CRC.
318  * 1 => 16-bit CRC.
319  */
320 #ifndef PROP_MODE_CONF_USE_CRC16
321 #define PROP_MODE_CONF_USE_CRC16 0
322 #endif
323 
324 /**
325  * \brief Configuration to set the RSSI threshold in dBm in Prop-mode.
326  * Defaults to -90 dBm.
327  */
328 #ifndef PROP_MODE_CONF_CCA_RSSI_THRESHOLD
329 #define PROP_MODE_CONF_CCA_RSSI_THRESHOLD 0xA6
330 #endif
331 /** @} */
332 /*---------------------------------------------------------------------------*/
333 /**
334  * \name TI Drivers Configuration.
335  *
336  * @{
337  */
338 
339 /**
340  * \brief Enable or disable UART driver.
341  */
342 #ifndef TI_UART_CONF_ENABLE
343 #define TI_UART_CONF_ENABLE 1
344 #endif
345 
346 /**
347  * \brief Enable or disable UART0 peripheral.
348  */
349 #ifndef TI_UART_CONF_UART0_ENABLE
350 #define TI_UART_CONF_UART0_ENABLE TI_UART_CONF_ENABLE
351 #endif
352 
353 /**
354  * \brief Enable or disable UART1 peripheral.
355  */
356 #ifndef TI_UART_CONF_UART1_ENABLE
357 #define TI_UART_CONF_UART1_ENABLE 0
358 #endif
359 
360 /**
361  * \brief UART driver baud rate configuration.
362  */
363 #ifndef TI_UART_CONF_BAUD_RATE
364 #define TI_UART_CONF_BAUD_RATE 115200
365 #endif
366 
367 /**
368  * \brief Enable or disable SPI driver.
369  */
370 #ifndef TI_SPI_CONF_ENABLE
371 #define TI_SPI_CONF_ENABLE 1
372 #endif
373 
374 /**
375  * \brief Enable or disable SPI0 peripheral.
376  */
377 #ifndef TI_SPI_CONF_SPI0_ENABLE
378 #define TI_SPI_CONF_SPI0_ENABLE TI_SPI_CONF_ENABLE
379 #endif
380 
381 /**
382  * \brief Enable or disable SPI1 peripheral.
383  */
384 #ifndef TI_SPI_CONF_SPI1_ENABLE
385 #define TI_SPI_CONF_SPI1_ENABLE 0
386 #endif
387 
388 /**
389  * \brief Enable or disable I2C driver.
390  */
391 #ifndef TI_I2C_CONF_ENABLE
392 #define TI_I2C_CONF_ENABLE 1
393 #endif
394 
395 /**
396  * \brief Enable or disable I2C0 peripheral.
397  */
398 #ifndef TI_I2C_CONF_I2C0_ENABLE
399 #define TI_I2C_CONF_I2C0_ENABLE TI_I2C_CONF_ENABLE
400 #endif
401 
402 /**
403  * \brief Enable or disable Non-Volatile Storage (NVS) driver.
404  */
405 #ifndef TI_NVS_CONF_ENABLE
406 #define TI_NVS_CONF_ENABLE 0
407 #endif
408 
409 /**
410  * \brief Enable or disable internal flash storage.
411  */
412 #ifndef TI_NVS_CONF_NVS_INTERNAL_ENABLE
413 #define TI_NVS_CONF_NVS_INTERNAL_ENABLE TI_NVS_CONF_ENABLE
414 #endif
415 
416 /**
417  * \brief Enable or disable external flash storage.
418  */
419 #ifndef TI_NVS_CONF_NVS_EXTERNAL_ENABLE
420 #define TI_NVS_CONF_NVS_EXTERNAL_ENABLE TI_NVS_CONF_ENABLE
421 #endif
422 
423 /**
424  * \brief Enable or disable SD driver.
425  */
426 #ifndef TI_SD_CONF_ENABLE
427 #define TI_SD_CONF_ENABLE 0
428 #endif
429 /** @} */
430 /*---------------------------------------------------------------------------*/
431 /**
432  * \name SPI HAL configuration.
433  *
434  * CC13x0/CC26x0 has one SPI interface, while CC13x2/CC26x2 has two
435  * SPI interfaces. Some additional checks has to be made for the
436  * SPI_CONF_CONTROLLER_COUNT configuration, as this relies on whether the
437  * available SPI interfaces are enabled or not, as well as if the SPI driver
438  * is enabled at all.
439  *
440  * @{
441  */
442 #if TI_SPI_CONF_ENABLE
443 /*
444  * The SPI driver is enabled. Therefore, the number of SPI interfaces depends
445  * on which Device family parent the device falls under and if any of its
446  * corresponding SPI interfaces are enabled or not.
447  */
448 
449 #define SPI0_IS_ENABLED ((TI_SPI_CONF_SPI0_ENABLE) ? 1 : 0)
450 #define SPI1_IS_ENABLED ((TI_SPI_CONF_SPI1_ENABLE) ? 1 : 0)
451 
452 #if (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X0_CC26X0)
453 
454 /* CC13x0/CC26x0 only has one SPI interface: SPI0. */
455 #define SPI_CONF_CONTROLLER_COUNT (SPI0_IS_ENABLED)
456 
457 #elif (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X2_CC26X2)
458 
459 /* CC13x0/CC26x0 only has two SPI interface: SPI0 and SPI1. */
460 #define SPI_CONF_CONTROLLER_COUNT (SPI0_IS_ENABLED + SPI1_IS_ENABLED)
461 
462 #endif /* DeviceFamily_PARENT */
463 
464 #else /* TI_SPI_CONF_ENABLE */
465 /*
466  * If the SPI driver is disabled then there are 0 available
467  * SPI interfaces. */
468 #define SPI_CONF_CONTROLLER_COUNT 0
469 #endif /* TI_SPI_CONF_ENABLE */
470 /** @} */
471 /*---------------------------------------------------------------------------*/
472 /**
473  * \name Slip configuration
474  *
475  * @{
476  */
477 #ifndef SLIP_ARCH_CONF_ENABLED
478 /*
479  * Determine whether we need SLIP
480  * This will keep working while UIP_FALLBACK_INTERFACE and CMD_CONF_OUTPUT
481  * keep using SLIP
482  */
483 #if defined(UIP_FALLBACK_INTERFACE) || defined(CMD_CONF_OUTPUT)
484 #define SLIP_ARCH_CONF_ENABLED 1
485 #endif
486 
487 #endif /* SLIP_ARCH_CONF_ENABLED */
488 /** @} */
489 /*---------------------------------------------------------------------------*/
490 #endif /* CC13XX_CC26XX_CONF_H_ */
491 /*---------------------------------------------------------------------------*/
492 /** @} */
Header file of common CC13xx/CC26xx RF functionality.