Contiki 3.x
contiki-conf.h
Go to the documentation of this file.
1 /**
2  * \addtogroup cc2538
3  * @{
4  *
5  * \file
6  * Configuration for the cc2538dk platform
7  */
8 #ifndef CONTIKI_CONF_H_
9 #define CONTIKI_CONF_H_
10 
11 #include <stdint.h>
12 #include <string.h>
13 /*---------------------------------------------------------------------------*/
14 /* Include Project Specific conf */
15 #ifdef PROJECT_CONF_H
16 #include PROJECT_CONF_H
17 #endif /* PROJECT_CONF_H */
18 /*---------------------------------------------------------------------------*/
19 /**
20  * \name Compiler configuration and platform-specific type definitions
21  *
22  * Those values are not meant to be modified by the user
23  * @{
24  */
25 #define CLOCK_CONF_SECOND 128
26 
27 /* Compiler configurations */
28 #define CCIF
29 #define CLIF
30 
31 /* Platform typedefs */
32 typedef uint32_t clock_time_t;
33 typedef uint32_t uip_stats_t;
34 
35 /*
36  * rtimer.h typedefs rtimer_clock_t as unsigned short. We need to define
37  * RTIMER_CLOCK_LT to override this
38  */
39 typedef uint32_t rtimer_clock_t;
40 #define RTIMER_CLOCK_LT(a,b) ((int32_t)((a)-(b)) < 0)
41 /** @} */
42 /*---------------------------------------------------------------------------*/
43 /**
44  * \name Serial Boot Loader Backdoor configuration
45  *
46  * @{
47  */
48 #ifndef FLASH_CCA_CONF_BOOTLDR_BACKDOOR
49 #define FLASH_CCA_CONF_BOOTLDR_BACKDOOR 1 /**<Enable the boot loader backdoor */
50 #endif
51 
52 #ifndef FLASH_CCA_CONF_BOOTLDR_BACKDOOR_PORT_A_PIN
53 #define FLASH_CCA_CONF_BOOTLDR_BACKDOOR_PORT_A_PIN 3 /**< Pin PA_3 (Select button) activates the boot loader */
54 #endif
55 
56 #ifndef FLASH_CCA_CONF_BOOTLDR_BACKDOOR_ACTIVE_HIGH
57 #define FLASH_CCA_CONF_BOOTLDR_BACKDOOR_ACTIVE_HIGH 0 /**< A logic low level activates the boot loader */
58 #endif
59 /** @} */
60 
61 /*---------------------------------------------------------------------------*/
62 /**
63  * \name Flash Memory configuration
64  *
65  * @{
66  */
67 #ifndef FLASH_CONF_ORIGIN
68 #define FLASH_CONF_ORIGIN 0x00200000
69 #endif
70 
71 #ifndef FLASH_CONF_SIZE
72 #define FLASH_CONF_SIZE 0x00080000 /* 512 KiB */
73 #endif
74 /** @} */
75 /*---------------------------------------------------------------------------*/
76 /**
77  * \name Watchdog Timer configuration
78  *
79  * @{
80  */
81 #ifndef WATCHDOG_CONF_ENABLE
82 #define WATCHDOG_CONF_ENABLE 1 /**< Enable the watchdog timer */
83 #endif
84 /** @} */
85 /*---------------------------------------------------------------------------*/
86 /**
87  * \name USB 'core' configuration
88  *
89  * Those values are not meant to be modified by the user, except where stated
90  * otherwise
91  * @{
92  */
93 #define CTRL_EP_SIZE 8
94 #define USB_EP1_SIZE 32
95 #define USB_EP2_SIZE 64
96 #define USB_EP3_SIZE 64
97 #define USB_ARCH_WRITE_NOTIFY 0
98 
99 #ifndef USB_ARCH_CONF_DMA
100 #define USB_ARCH_CONF_DMA 1 /**< Change to Enable/Disable USB DMA */
101 
102 #endif
103 /** @} */
104 /*---------------------------------------------------------------------------*/
105 /**
106  * \name Generic Configuration directives
107  *
108  * @{
109  */
110 #ifndef ENERGEST_CONF_ON
111 #define ENERGEST_CONF_ON 0 /**< Energest Module */
112 #endif
113 
114 #ifndef STARTUP_CONF_VERBOSE
115 #define STARTUP_CONF_VERBOSE 1 /**< Set to 0 to decrease startup verbosity */
116 #endif
117 /** @} */
118 /*---------------------------------------------------------------------------*/
119 /**
120  * \name uDMA Configuration and channel allocations
121  *
122  * @{
123  */
124 #define USB_ARCH_CONF_RX_DMA_CHAN 0 /**< USB -> RAM DMA channel */
125 #define USB_ARCH_CONF_TX_DMA_CHAN 1 /**< RAM -> USB DMA channel */
126 #define CC2538_RF_CONF_TX_DMA_CHAN 2 /**< RF -> RAM DMA channel */
127 #define CC2538_RF_CONF_RX_DMA_CHAN 3 /**< RAM -> RF DMA channel */
128 #define UDMA_CONF_MAX_CHANNEL CC2538_RF_CONF_RX_DMA_CHAN
129 /** @} */
130 /*---------------------------------------------------------------------------*/
131 /**
132  * \name Character I/O Configuration
133  *
134  * @{
135  */
136 #ifndef UART_CONF_ENABLE
137 #define UART_CONF_ENABLE 1 /**< Enable/Disable UART I/O */
138 #endif
139 
140 #ifndef UART0_CONF_BAUD_RATE
141 #define UART0_CONF_BAUD_RATE 115200 /**< Default UART0 baud rate */
142 #endif
143 
144 #ifndef UART1_CONF_BAUD_RATE
145 #define UART1_CONF_BAUD_RATE 115200 /**< Default UART1 baud rate */
146 #endif
147 
148 #ifndef SLIP_ARCH_CONF_USB
149 #define SLIP_ARCH_CONF_USB 0 /**< SLIP over UART by default */
150 #endif
151 
152 #ifndef CC2538_RF_CONF_SNIFFER_USB
153 #define CC2538_RF_CONF_SNIFFER_USB 0 /**< Sniffer out over UART by default */
154 #endif
155 
156 #ifndef DBG_CONF_USB
157 #define DBG_CONF_USB 0 /**< All debugging over UART by default */
158 #endif
159 
160 #ifndef SERIAL_LINE_CONF_UART
161 #define SERIAL_LINE_CONF_UART 0 /**< UART to use with serial line */
162 #endif
163 
164 #if !SLIP_ARCH_CONF_USB
165 #ifndef SLIP_ARCH_CONF_UART
166 #define SLIP_ARCH_CONF_UART 0 /**< UART to use with SLIP */
167 #endif
168 #endif
169 
170 #if !CC2538_RF_CONF_SNIFFER_USB
171 #ifndef CC2538_RF_CONF_SNIFFER_UART
172 #define CC2538_RF_CONF_SNIFFER_UART 0 /**< UART to use with sniffer */
173 #endif
174 #endif
175 
176 #if !DBG_CONF_USB
177 #ifndef DBG_CONF_UART
178 #define DBG_CONF_UART 0 /**< UART to use for debugging */
179 #endif
180 #endif
181 
182 #ifndef UART1_CONF_UART
183 #define UART1_CONF_UART 0 /**< UART to use for examples relying on
184  the uart1_* API */
185 #endif
186 
187 /* Turn off example-provided putchars */
188 #define SLIP_BRIDGE_CONF_NO_PUTCHAR 1
189 #define SLIP_RADIO_CONF_NO_PUTCHAR 1
190 
191 #ifndef SLIP_ARCH_CONF_ENABLED
192 /*
193  * Determine whether we need SLIP
194  * This will keep working while UIP_FALLBACK_INTERFACE and CMD_CONF_OUTPUT
195  * keep using SLIP
196  */
197 #if defined (UIP_FALLBACK_INTERFACE) || defined (CMD_CONF_OUTPUT)
198 #define SLIP_ARCH_CONF_ENABLED 1
199 #endif
200 #endif
201 
202 /*
203  * When set, the radio turns off address filtering and sends all captured
204  * frames down a peripheral (UART or USB, depending on the value of
205  * CC2538_RF_CONF_SNIFFER_USB)
206  */
207 #ifndef CC2538_RF_CONF_SNIFFER
208 #define CC2538_RF_CONF_SNIFFER 0
209 #endif
210 
211 /**
212  * \brief Define this as 1 to build a headless node.
213  *
214  * The UART will not be initialised its clock will be gated, offering some
215  * energy savings. The USB will not be initialised either
216  */
217 #ifndef CC2538_CONF_QUIET
218 #define CC2538_CONF_QUIET 0
219 #endif
220 
221 /* CC2538_CONF_QUIET is hard and overrides all other related defines */
222 #if CC2538_CONF_QUIET
223 #undef USB_SERIAL_CONF_ENABLE
224 #define USB_SERIAL_CONF_ENABLE 0
225 
226 #undef UART_CONF_ENABLE
227 #define UART_CONF_ENABLE 0
228 
229 #undef STARTUP_CONF_VERBOSE
230 #define STARTUP_CONF_VERBOSE 0
231 
232 /* Little sanity check: We can't have quiet sniffers */
233 #if CC2538_RF_CONF_SNIFFER
234 #error "CC2538_RF_CONF_SNIFFER == 1 and CC2538_CONF_QUIET == 1"
235 #error "These values are conflicting. Please set either to 0"
236 #endif
237 #endif /* CC2538_CONF_QUIET */
238 
239 /**
240  * \brief Enable the USB core only if we need it
241  */
242 #ifndef USB_SERIAL_CONF_ENABLE
243 #define USB_SERIAL_CONF_ENABLE \
244  ((SLIP_ARCH_CONF_USB & SLIP_ARCH_CONF_ENABLED) | \
245  DBG_CONF_USB | \
246  (CC2538_RF_CONF_SNIFFER & CC2538_RF_CONF_SNIFFER_USB))
247 #endif
248 
249 /*
250  * If debugging and SLIP use the same peripheral, this will be 1. Don't modify
251  * this
252  */
253 #if SLIP_ARCH_CONF_ENABLED
254 #define DBG_CONF_SLIP_MUX (SLIP_ARCH_CONF_USB == DBG_CONF_USB && \
255  (SLIP_ARCH_CONF_USB || \
256  SLIP_ARCH_CONF_UART == DBG_CONF_UART))
257 #endif
258 
259 /*
260  * Automatic detection of whether a specific UART is in use
261  */
262 #define UART_IN_USE_BY_SERIAL_LINE(u) (SERIAL_LINE_CONF_UART == (u))
263 #define UART_IN_USE_BY_SLIP(u) (SLIP_ARCH_CONF_ENABLED && \
264  !SLIP_ARCH_CONF_USB && \
265  SLIP_ARCH_CONF_UART == (u))
266 #define UART_IN_USE_BY_RF_SNIFFER(u) (CC2538_RF_CONF_SNIFFER && \
267  !CC2538_RF_CONF_SNIFFER_USB && \
268  CC2538_RF_CONF_SNIFFER_UART == (u))
269 #define UART_IN_USE_BY_DBG(u) (!DBG_CONF_USB && DBG_CONF_UART == (u))
270 #define UART_IN_USE_BY_UART1(u) (UART1_CONF_UART == (u))
271 
272 #define UART_IN_USE(u) ( \
273  UART_CONF_ENABLE && \
274  (UART_IN_USE_BY_SERIAL_LINE(u) || \
275  UART_IN_USE_BY_SLIP(u) || \
276  UART_IN_USE_BY_RF_SNIFFER(u) || \
277  UART_IN_USE_BY_DBG(u) || \
278  UART_IN_USE_BY_UART1(u)) \
279 )
280 /** @} */
281 /*---------------------------------------------------------------------------*/
282 /* board.h assumes that basic configuration is done */
283 #include "board.h"
284 /*---------------------------------------------------------------------------*/
285 /**
286  * \name Network Stack Configuration
287  *
288  * @{
289  */
290 #ifndef NETSTACK_CONF_NETWORK
291 #if UIP_CONF_IPV6
292 #define NETSTACK_CONF_NETWORK sicslowpan_driver
293 #else
294 #define NETSTACK_CONF_NETWORK rime_driver
295 #endif /* UIP_CONF_IPV6 */
296 #endif /* NETSTACK_CONF_NETWORK */
297 
298 #ifndef NETSTACK_CONF_MAC
299 #define NETSTACK_CONF_MAC csma_driver
300 #endif
301 
302 #ifndef NETSTACK_CONF_RDC
303 #define NETSTACK_CONF_RDC contikimac_driver
304 #endif
305 
306 /* Configure NullRDC for when it's selected */
307 #define NULLRDC_802154_AUTOACK 1
308 #define NULLRDC_802154_AUTOACK_HW 1
309 
310 /* Configure ContikiMAC for when it's selected */
311 #define CONTIKIMAC_CONF_WITH_PHASE_OPTIMIZATION 0
312 #define WITH_FAST_SLEEP 1
313 
314 #ifndef NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE
315 #define NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE 8
316 #endif
317 
318 #ifndef NETSTACK_CONF_FRAMER
319 #define NETSTACK_CONF_FRAMER framer_802154
320 #endif
321 
322 #define NETSTACK_CONF_RADIO cc2538_rf_driver
323 /** @} */
324 /*---------------------------------------------------------------------------*/
325 /**
326  * \name LPM configuration
327  * @{
328  */
329 #ifndef LPM_CONF_ENABLE
330 #define LPM_CONF_ENABLE 1 /**< Set to 0 to disable LPM entirely */
331 #endif
332 
333 /**
334  * \brief Maximum PM
335  *
336  * The SoC will never drop to a Power Mode deeper than the one specified here.
337  * 0 for PM0, 1 for PM1 and 2 for PM2
338  */
339 #ifndef LPM_CONF_MAX_PM
340 #define LPM_CONF_MAX_PM 1
341 #endif
342 
343 #ifndef LPM_CONF_STATS
344 #define LPM_CONF_STATS 0 /**< Set to 1 to enable LPM-related stats */
345 #endif
346 /** @} */
347 /*---------------------------------------------------------------------------*/
348 /**
349  * \name IEEE address configuration
350  *
351  * Used to generate our RIME & IPv6 address
352  * @{
353  */
354 /**
355  * \brief Location of the IEEE address
356  * 0 => Read from InfoPage,
357  * 1 => Use a hardcoded address, configured by IEEE_ADDR_CONF_ADDRESS
358  */
359 #ifndef IEEE_ADDR_CONF_HARDCODED
360 #define IEEE_ADDR_CONF_HARDCODED 0
361 #endif
362 
363 /**
364  * \brief The hardcoded IEEE address to be used when IEEE_ADDR_CONF_HARDCODED
365  * is defined as 1
366  */
367 #ifndef IEEE_ADDR_CONF_ADDRESS
368 #define IEEE_ADDR_CONF_ADDRESS { 0x00, 0x12, 0x4B, 0x00, 0x89, 0xAB, 0xCD, 0xEF }
369 #endif
370 
371 /**
372  * \brief Location of the IEEE address in the InfoPage when
373  * IEEE_ADDR_CONF_HARDCODED is defined as 0
374  * 0 => Use the primary address location
375  * 1 => Use the secondary address location
376  */
377 #ifndef IEEE_ADDR_CONF_USE_SECONDARY_LOCATION
378 #define IEEE_ADDR_CONF_USE_SECONDARY_LOCATION 0
379 #endif
380 /** @} */
381 /*---------------------------------------------------------------------------*/
382 /**
383  * \name RF configuration
384  *
385  * @{
386  */
387 /* RF Config */
388 #ifndef IEEE802154_CONF_PANID
389 #define IEEE802154_CONF_PANID 0x5449 /**< Default PAN ID: TI */
390 #endif
391 
392 #ifndef CC2538_RF_CONF_CHANNEL
393 #define CC2538_RF_CONF_CHANNEL 25
394 #endif /* CC2538_RF_CONF_CHANNEL */
395 
396 #ifndef CC2538_RF_CONF_AUTOACK
397 #define CC2538_RF_CONF_AUTOACK 1 /**< RF H/W generates ACKs */
398 #endif /* CC2538_CONF_AUTOACK */
399 
400 #ifndef CC2538_RF_CONF_TX_USE_DMA
401 #define CC2538_RF_CONF_TX_USE_DMA 1 /**< RF TX over DMA */
402 #endif
403 
404 #ifndef CC2538_RF_CONF_RX_USE_DMA
405 #define CC2538_RF_CONF_RX_USE_DMA 1 /**< RF RX over DMA */
406 #endif
407 /** @} */
408 /*---------------------------------------------------------------------------*/
409 /**
410  * \name IPv6, RIME and network buffer configuration
411  *
412  * @{
413  */
414 
415 /* Don't let contiki-default-conf.h decide if we are an IPv6 build */
416 #ifndef UIP_CONF_IPV6
417 #define UIP_CONF_IPV6 0
418 #endif
419 
420 #if UIP_CONF_IPV6
421 /* Addresses, Sizes and Interfaces */
422 /* 8-byte addresses here, 2 otherwise */
423 #define LINKADDR_CONF_SIZE 8
424 #define UIP_CONF_LL_802154 1
425 #define UIP_CONF_LLH_LEN 0
426 #define UIP_CONF_NETIF_MAX_ADDRESSES 3
427 
428 /* TCP, UDP, ICMP */
429 #ifndef UIP_CONF_TCP
430 #define UIP_CONF_TCP 1
431 #endif
432 #ifndef UIP_CONF_TCP_MSS
433 #define UIP_CONF_TCP_MSS 64
434 #endif
435 #define UIP_CONF_UDP 1
436 #define UIP_CONF_UDP_CHECKSUMS 1
437 #define UIP_CONF_ICMP6 1
438 
439 /* ND and Routing */
440 #ifndef UIP_CONF_ROUTER
441 #define UIP_CONF_ROUTER 1
442 #endif
443 
444 #ifndef UIP_CONF_IPV6_RPL
445 #define UIP_CONF_IPV6_RPL 1
446 #endif
447 
448 #define UIP_CONF_ND6_SEND_RA 0
449 #define UIP_CONF_IP_FORWARD 0
450 #define RPL_CONF_STATS 0
451 #define RPL_CONF_MAX_DAG_ENTRIES 1
452 #ifndef RPL_CONF_OF
453 #define RPL_CONF_OF rpl_mrhof
454 #endif
455 
456 #define UIP_CONF_ND6_REACHABLE_TIME 600000
457 #define UIP_CONF_ND6_RETRANS_TIMER 10000
458 
459 #ifndef NBR_TABLE_CONF_MAX_NEIGHBORS
460 #define NBR_TABLE_CONF_MAX_NEIGHBORS 20
461 #endif
462 #ifndef UIP_CONF_MAX_ROUTES
463 #define UIP_CONF_MAX_ROUTES 20
464 #endif
465 
466 /* uIP */
467 #ifndef UIP_CONF_BUFFER_SIZE
468 #define UIP_CONF_BUFFER_SIZE 1300
469 #endif
470 
471 #define UIP_CONF_IPV6_QUEUE_PKT 0
472 #define UIP_CONF_IPV6_CHECKS 1
473 #define UIP_CONF_IPV6_REASSEMBLY 0
474 #define UIP_CONF_MAX_LISTENPORTS 8
475 
476 /* 6lowpan */
477 #define SICSLOWPAN_CONF_COMPRESSION SICSLOWPAN_COMPRESSION_HC06
478 #ifndef SICSLOWPAN_CONF_COMPRESSION_THRESHOLD
479 #define SICSLOWPAN_CONF_COMPRESSION_THRESHOLD 63
480 #endif
481 #ifndef SICSLOWPAN_CONF_FRAG
482 #define SICSLOWPAN_CONF_FRAG 1
483 #endif
484 #define SICSLOWPAN_CONF_MAXAGE 8
485 
486 /* Define our IPv6 prefixes/contexts here */
487 #define SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS 1
488 #ifndef SICSLOWPAN_CONF_ADDR_CONTEXT_0
489 #define SICSLOWPAN_CONF_ADDR_CONTEXT_0 { \
490  addr_contexts[0].prefix[0] = 0xaa; \
491  addr_contexts[0].prefix[1] = 0xaa; \
492 }
493 #endif
494 
495 #define MAC_CONF_CHANNEL_CHECK_RATE 8
496 
497 #ifndef QUEUEBUF_CONF_NUM
498 #define QUEUEBUF_CONF_NUM 8
499 #endif
500 /*---------------------------------------------------------------------------*/
501 #else /* UIP_CONF_IPV6 */
502 /* Network setup for non-IPv6 (rime). */
503 #define UIP_CONF_IP_FORWARD 1
504 
505 #ifndef UIP_CONF_BUFFER_SIZE
506 #define UIP_CONF_BUFFER_SIZE 108
507 #endif
508 
509 #define RIME_CONF_NO_POLITE_ANNOUCEMENTS 0
510 
511 #ifndef QUEUEBUF_CONF_NUM
512 #define QUEUEBUF_CONF_NUM 8
513 #endif
514 
515 #endif /* UIP_CONF_IPV6 */
516 /** @} */
517 /*---------------------------------------------------------------------------*/
518 
519 #endif /* CONTIKI_CONF_H_ */
520 
521 /** @} */