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 the TX power for the netstack, specified in dBm. Defaults to
95  * maximum available TX power setting for the specific PHY.
96  */
97 #ifndef RF_CONF_TXPOWER_DBM
98 #define RF_CONF_TXPOWER_DBM RF_TXPOWER_MAX_DBM
99 #endif
100 
101 /*
102  * Configure the TX power for the BLE beacon, specified in dBm.
103  * Defaults to maximum available TX power setting for the specific PHY.
104  */
105 #ifndef RF_CONF_BLE_TXPOWER_DBM
106 #define RF_CONF_BLE_TXPOWER_DBM RF_TXPOWER_MAX_DBM
107 #endif
108 
109 /*
110  * CC13xx only: Configure TX power to use boot mode, allowing to gain
111  * up to 14 dBm with the default PA. This will, however, increase power
112  * consumption.
113  */
114 #ifndef RF_CONF_TXPOWER_BOOST_MODE
115 #define RF_CONF_TXPOWER_BOOST_MODE 0
116 #endif
117 
118 /*
119  * Configure RF mode. That is, whether to run on Sub-1 GHz (Prop-mode) or
120  * 2.4 GHz (IEEE-mode).
121  */
122 #ifdef RF_CONF_MODE
123 /* Sanity check a valid configuration is provided. */
124 #if !(RF_CONF_MODE & RF_MODE_BM)
125 #error "Invalid RF_CONF_MODE provided"
126 #endif
127 
128 #define RF_MODE RF_CONF_MODE
129 #endif /* RF_CONF_MODE */
130 
131 /* Sub-1 GHz path front-end mode configuration */
132 #ifdef RF_SUB_1_GHZ_CONF_FRONT_END_MODE
133 #define RF_SUB_1_GHZ_FRONT_END_MODE RF_SUB_1_GHZ_CONF_FRONT_END_MODE
134 #else
135 #define RF_SUB_1_GHZ_FRONT_END_MODE RF_FRONT_END_MODE_DIFFERENTIAL
136 #endif
137 
138 #ifdef RF_SUB_1_GHZ_CONF_BIAS_MODE
139 #define RF_SUB_1_GHZ_BIAS_MODE RF_SUB_1_GHZ_CONF_BIAS_MODE
140 #else
141 #define RF_SUB_1_GHZ_BIAS_MODE RF_BIAS_MODE_INTERNAL
142 #endif
143 
144 /* 2.4 GHz path front-end mode configuration */
145 #ifdef RF_2_4_GHZ_CONF_FRONT_END_MODE
146 #define RF_2_4_GHZ_FRONT_END_MODE RF_2_4_GHZ_CONF_FRONT_END_MODE
147 #else
148 #define RF_2_4_GHZ_FRONT_END_MODE RF_FRONT_END_MODE_DIFFERENTIAL
149 #endif
150 
151 #ifdef RF_2_4_GHZ_CONF_BIAS_MODE
152 #define RF_2_4_GHZ_BIAS_MODE RF_2_4_GHZ_CONF_BIAS_MODE
153 #else
154 #define RF_2_4_GHZ_BIAS_MODE RF_BIAS_MODE_INTERNAL
155 #endif
156 
157 /* Number of RX buffers. */
158 #ifndef RF_CONF_RX_BUF_CNT
159 #define RF_CONF_RX_BUF_CNT 4
160 #endif
161 
162 /* Size of each RX buffer in bytes. */
163 #ifndef RF_CONF_RX_BUF_SIZE
164 #define RF_CONF_RX_BUF_SIZE 144
165 #endif
166 
167 /* Enable/disable BLE beacon. */
168 #ifndef RF_CONF_BLE_BEACON_ENABLE
169 #define RF_CONF_BLE_BEACON_ENABLE 0
170 #endif
171 
172 #if (RF_CONF_BLE_BEACON_ENABLE) && !(SUPPORTS_BLE_BEACON)
173 #error "Device does not support BLE for BLE beacon"
174 #endif
175 
176 /*----- CC13xx Device Line --------------------------------------------------*/
177 /* CC13xx supports both IEEE and Prop mode, depending on which device. */
178 #if defined(DEVICE_LINE_CC13XX)
179 
180 /* Default to Prop-mode for CC13xx devices if not configured. */
181 #ifndef RF_MODE
182 #define RF_MODE RF_MODE_SUB_1_GHZ
183 #endif
184 
185 /*----- CC13xx Prop-mode ----------------------------------------------------*/
186 #if (RF_MODE == RF_MODE_SUB_1_GHZ) && (SUPPORTS_PROP_MODE)
187 
188 /* Netstack configuration. */
189 #define NETSTACK_CONF_RADIO prop_mode_driver
190 
191 /* CSMA configuration. */
192 #define CSMA_CONF_ACK_WAIT_TIME (RTIMER_SECOND / 300)
193 #define CSMA_CONF_AFTER_ACK_DETECTED_WAIT_TIME (RTIMER_SECOND / 1000)
194 #define CSMA_CONF_SEND_SOFT_ACK 1
195 
196 /*----- CC13xx IEEE-mode ----------------------------------------------------*/
197 #elif (RF_MODE == RF_MODE_2_4_GHZ) && (SUPPORTS_IEEE_MODE)
198 
199 /* Netstack configuration. */
200 #define NETSTACK_CONF_RADIO ieee_mode_driver
201 
202 /* CSMA configuration. */
203 #define CSMA_CONF_SEND_SOFT_ACK 0
204 
205 #else
206 /*----- CC13xx Unsupported Mode ---------------------------------------------*/
207 #error "Invalid RF mode configuration of CC13xx device"
208 #endif /* CC13xx RF Mode configuration */
209 
210 /*----- CC26xx Device Line --------------------------------------------------*/
211 /* CC26xx only supports IEEE mode */
212 #elif defined(DEVICE_LINE_CC26XX)
213 
214 /* Default to IEEE-mode for CC26xx devices if not configured */
215 #ifndef RF_MODE
216 #define RF_MODE RF_MODE_2_4_GHZ
217 #endif
218 
219 /*----- CC26xx IEEE-mode ----------------------------------------------------*/
220 #if (RF_MODE == RF_MODE_2_4_GHZ) && (SUPPORTS_IEEE_MODE)
221 
222 /* Netstack configuration */
223 #define NETSTACK_CONF_RADIO ieee_mode_driver
224 
225 /* CSMA configuration */
226 #define CSMA_CONF_SEND_SOFT_ACK 0
227 
228 /* Frequncy band configuration */
229 #undef DOT_15_4G_FREQ_BAND_ID
230 #define DOT_15_4G_CONF_FREQ_BAND_ID DOT_15_4G_FREQ_BAND_2450
231 
232 #else
233 /*----- CC26xx Unsupported Mode ---------------------------------------------*/
234 #error "IEEE-mode only supported by CC26xx devices"
235 #endif /* CC26xx RF Mode configuration */
236 
237 /*----- Unsupported device line ---------------------------------------------*/
238 #else
239 #error "Unsupported Device Line defined"
240 #endif /* Unsupported device line */
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.