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