Contiki-NG
cc2538-conf.h
1 /*
2  * Copyright (c) 2017, George Oikonomou - http://www.spd.gr
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  *
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  * 3. Neither the name of the copyright holder nor the names of its
15  * contributors may be used to endorse or promote products derived
16  * from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
29  * OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 /*---------------------------------------------------------------------------*/
32 /**
33  * \addtogroup cc2538
34  * @{
35  */
36 /*---------------------------------------------------------------------------*/
37 #ifndef CC2538_CONF_H_
38 #define CC2538_CONF_H_
39 /*---------------------------------------------------------------------------*/
40 /**
41  * \name CFS configuration
42  *
43  * @{
44  */
45 #ifndef COFFEE_CONF_SIZE
46 #define COFFEE_CONF_SIZE (4 * COFFEE_SECTOR_SIZE)
47 #endif
48 /** @} */
49 /*---------------------------------------------------------------------------*/
50 /**
51  * \name CC2538 System Control configuration
52  *
53  * @{
54  */
55 #ifndef SYS_CTRL_CONF_OSC32K_USE_XTAL
56 #define SYS_CTRL_CONF_OSC32K_USE_XTAL 0 /**< Use the on-board 32.768-kHz crystal */
57 #endif
58 /** @} */
59 /*---------------------------------------------------------------------------*/
60 /**
61  * \name Watchdog Timer configuration
62  *
63  * @{
64  */
65 #ifndef WATCHDOG_CONF_ENABLE
66 #define WATCHDOG_CONF_ENABLE 1 /**< Enable the watchdog timer */
67 #endif
68 /** @} */
69 /*---------------------------------------------------------------------------*/
70 /**
71  * \name USB 'core' configuration
72  *
73  * Those values are not meant to be modified by the user, except where stated
74  * otherwise
75  * @{
76  */
77 #define CTRL_EP_SIZE 8
78 #define USB_EP1_SIZE 32
79 #define USB_EP2_SIZE 64
80 #define USB_EP3_SIZE 64
81 #define USB_ARCH_WRITE_NOTIFY 0
82 
83 #ifndef USB_ARCH_CONF_DMA
84 #define USB_ARCH_CONF_DMA 1 /**< Change to Enable/Disable USB DMA */
85 
86 #endif
87 /** @} */
88 /**
89  * \name uDMA Configuration and channel allocations
90  *
91  * @{
92  */
93 #define USB_ARCH_CONF_RX_DMA_CHAN 0 /**< USB -> RAM DMA channel */
94 #define USB_ARCH_CONF_TX_DMA_CHAN 1 /**< RAM -> USB DMA channel */
95 #define CC2538_RF_CONF_TX_DMA_CHAN 2 /**< RF -> RAM DMA channel */
96 #define CC2538_RF_CONF_RX_DMA_CHAN 3 /**< RAM -> RF DMA channel */
97 #define UDMA_CONF_MAX_CHANNEL CC2538_RF_CONF_RX_DMA_CHAN
98 /** @} */
99 /*---------------------------------------------------------------------------*/
100 /**
101  * \name Character I/O Configuration
102  *
103  * @{
104  */
105 #ifndef UART_CONF_ENABLE
106 #define UART_CONF_ENABLE 1 /**< Enable/Disable UART I/O */
107 #endif
108 
109 #ifndef UART0_CONF_BAUD_RATE
110 #define UART0_CONF_BAUD_RATE 115200 /**< Default UART0 baud rate */
111 #endif
112 
113 #ifndef UART1_CONF_BAUD_RATE
114 #define UART1_CONF_BAUD_RATE 115200 /**< Default UART1 baud rate */
115 #endif
116 
117 #ifndef SLIP_ARCH_CONF_USB
118 #define SLIP_ARCH_CONF_USB 0 /**< SLIP over UART by default */
119 #endif
120 
121 #ifndef DBG_CONF_USB
122 #define DBG_CONF_USB 0 /**< All debugging over UART by default */
123 #endif
124 
125 #ifndef SERIAL_LINE_CONF_UART
126 #define SERIAL_LINE_CONF_UART 0 /**< UART to use with serial line */
127 #endif
128 
129 #if !SLIP_ARCH_CONF_USB
130 #ifndef SLIP_ARCH_CONF_UART
131 #define SLIP_ARCH_CONF_UART 0 /**< UART to use with SLIP */
132 #endif
133 #endif
134 
135 #if !DBG_CONF_USB
136 #ifndef DBG_CONF_UART
137 #define DBG_CONF_UART 0 /**< UART to use for debugging */
138 #endif
139 #endif
140 
141 #ifndef UART1_CONF_UART
142 #define UART1_CONF_UART 0 /**< UART to use for examples relying on
143  the uart1_* API */
144 #endif
145 
146 #ifndef SLIP_ARCH_CONF_ENABLED
147 /*
148  * Determine whether we need SLIP
149  * This will keep working while UIP_FALLBACK_INTERFACE and CMD_CONF_OUTPUT
150  * keep using SLIP
151  */
152 #if defined(UIP_FALLBACK_INTERFACE) || defined(CMD_CONF_OUTPUT)
153 #define SLIP_ARCH_CONF_ENABLED 1
154 #endif
155 #endif
156 
157 /**
158  * \brief Define this as 1 to build a headless node.
159  *
160  * The UART will not be initialised its clock will be gated, offering some
161  * energy savings. The USB will not be initialised either
162  */
163 #ifndef CC2538_CONF_QUIET
164 #define CC2538_CONF_QUIET 0
165 #endif
166 
167 /* CC2538_CONF_QUIET is hard and overrides all other related defines */
168 #if CC2538_CONF_QUIET
169 #undef USB_SERIAL_CONF_ENABLE
170 #define USB_SERIAL_CONF_ENABLE 0
171 
172 #undef UART_CONF_ENABLE
173 #define UART_CONF_ENABLE 0
174 #endif /* CC2538_CONF_QUIET */
175 
176 /**
177  * \brief Enable the USB core only if we need it
178  */
179 #ifndef USB_SERIAL_CONF_ENABLE
180 #define USB_SERIAL_CONF_ENABLE \
181  ((SLIP_ARCH_CONF_USB && SLIP_ARCH_CONF_ENABLED) || \
182  (MAC_CONF_WITH_TSCH && (SLIP_ARCH_CONF_ENABLED || BUILD_WITH_SHELL)) || \
183  DBG_CONF_USB)
184 #endif
185 
186 /*
187  * If debugging and SLIP use the same peripheral, this will be 1. Don't modify
188  * this
189  */
190 #if SLIP_ARCH_CONF_ENABLED
191 #define DBG_CONF_SLIP_MUX (SLIP_ARCH_CONF_USB == DBG_CONF_USB && \
192  (SLIP_ARCH_CONF_USB || \
193  SLIP_ARCH_CONF_UART == DBG_CONF_UART))
194 #endif
195 
196 /*
197  * Automatic detection of whether a specific UART is in use
198  */
199 #define UART_IN_USE_BY_SERIAL_LINE(u) (SERIAL_LINE_CONF_UART == (u))
200 #define UART_IN_USE_BY_SLIP(u) (SLIP_ARCH_CONF_ENABLED && \
201  !SLIP_ARCH_CONF_USB && \
202  SLIP_ARCH_CONF_UART == (u))
203 #define UART_IN_USE_BY_DBG(u) (!DBG_CONF_USB && DBG_CONF_UART == (u))
204 #define UART_IN_USE_BY_UART1(u) (UART1_CONF_UART == (u))
205 
206 #define UART_IN_USE(u) ( \
207  UART_CONF_ENABLE && \
208  (UART_IN_USE_BY_SERIAL_LINE(u) || \
209  UART_IN_USE_BY_SLIP(u) || \
210  UART_IN_USE_BY_DBG(u) || \
211  UART_IN_USE_BY_UART1(u)) \
212 )
213 /** @} */
214 /*---------------------------------------------------------------------------*/
215 /**
216  * \name RF configuration
217  *
218  * @{
219  */
220 /* RF Config */
221 
222 #ifndef CC2538_RF_CONF_AUTOACK
223 #define CC2538_RF_CONF_AUTOACK 1 /**< RF H/W generates ACKs */
224 #endif /* CC2538_CONF_AUTOACK */
225 
226 #ifndef CC2538_RF_CONF_TX_USE_DMA
227 #define CC2538_RF_CONF_TX_USE_DMA 1 /**< RF TX over DMA */
228 #endif
229 
230 #ifndef CC2538_RF_CONF_RX_USE_DMA
231 #define CC2538_RF_CONF_RX_USE_DMA 1 /**< RF RX over DMA */
232 #endif
233 /** @} */
234 /*---------------------------------------------------------------------------*/
235 /**
236  * \name LPM configuration
237  * @{
238  */
239 #ifndef LPM_CONF_ENABLE
240 #define LPM_CONF_ENABLE 1 /**< Set to 0 to disable LPM entirely */
241 #endif
242 
243 /**
244  * \brief Maximum PM
245  *
246  * The SoC will never drop to a Power Mode deeper than the one specified here.
247  * 0 for PM0, 1 for PM1 and 2 for PM2
248  */
249 #ifndef LPM_CONF_MAX_PM
250 #define LPM_CONF_MAX_PM 1
251 #endif
252 
253 #ifndef LPM_CONF_STATS
254 #define LPM_CONF_STATS 0 /**< Set to 1 to enable LPM-related stats */
255 #endif
256 /** @} */
257 /*---------------------------------------------------------------------------*/
258 /**
259  * \name Radio Configuration
260  *
261  * @{
262  */
263 #ifndef NETSTACK_CONF_RADIO
264 #define NETSTACK_CONF_RADIO cc2538_rf_driver
265 #endif
266 /** @} */
267 /*---------------------------------------------------------------------------*/
268 /**
269  * \name IEEE address configuration
270  *
271  * Used to generate our link-layer & IPv6 address
272  * @{
273  */
274 /**
275  * \brief Location of the IEEE address
276  * 0 => Read from InfoPage,
277  * 1 => Use a hardcoded address, configured by IEEE_ADDR_CONF_ADDRESS
278  */
279 #ifndef IEEE_ADDR_CONF_HARDCODED
280 #define IEEE_ADDR_CONF_HARDCODED 0
281 #endif
282 
283 /**
284  * \brief The hardcoded IEEE address to be used when IEEE_ADDR_CONF_HARDCODED
285  * is defined as 1
286  */
287 #ifndef IEEE_ADDR_CONF_ADDRESS
288 #define IEEE_ADDR_CONF_ADDRESS { 0x00, 0x12, 0x4B, 0x00, 0x89, 0xAB, 0xCD, 0xEF }
289 #endif
290 
291 /**
292  * \brief Location of the IEEE address in the InfoPage when
293  * IEEE_ADDR_CONF_HARDCODED is defined as 0
294  * 0 => Use the primary address location
295  * 1 => Use the secondary address location
296  */
297 #ifndef IEEE_ADDR_CONF_USE_SECONDARY_LOCATION
298 #define IEEE_ADDR_CONF_USE_SECONDARY_LOCATION 0
299 #endif
300 /** @} */
301 /*---------------------------------------------------------------------------*/
302 /**
303  * \name Security
304  *
305  * @{
306  */
307 #ifndef CRYPTO_CONF_INIT
308 #define CRYPTO_CONF_INIT 1 /**< Whether to init cryptoprocessor */
309 #endif
310 
311 #ifndef AES_128_CONF
312 #define AES_128_CONF cc2538_aes_128_driver /**< AES-128 driver */
313 #endif
314 
315 #ifndef CCM_STAR_CONF
316 #define CCM_STAR_CONF cc2538_ccm_star_driver /**< AES-CCM* driver */
317 #endif
318 /** @} */
319 /*---------------------------------------------------------------------------*/
320 #endif /* CC2538_CONF_H_ */
321 /*---------------------------------------------------------------------------*/
322 /** @} */