Contiki 2.5
contiki-conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2006, Technical University of Munich
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 Institute nor the names of its contributors
14  * may be used to endorse or promote products derived from this software
15  * without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * This file is part of the Contiki operating system.
30  *
31  * @(#)$$
32  */
33 
34 /**
35  * \file
36  * Configuration for Atmel Raven
37  *
38  * \author
39  * Simon Barner <barner@in.tum.de>
40  * David Kopf <dak664@embarqmail.com>
41  */
42 
43 #ifndef __CONTIKI_CONF_H__
44 #define __CONTIKI_CONF_H__
45 
46 /* MCU and clock rate */
47 #define PLATFORM PLATFORM_AVR
48 #define RAVEN_REVISION RAVEN_D
49 #ifndef F_CPU
50 #define F_CPU 8000000UL
51 #endif
52 #include <stdint.h>
53 
54 typedef int32_t s32_t;
55 typedef unsigned char u8_t;
56 typedef unsigned short u16_t;
57 typedef unsigned long u32_t;
58 typedef unsigned short clock_time_t;
59 typedef unsigned short uip_stats_t;
60 typedef unsigned long off_t;
61 
62 void clock_delay(unsigned int us2);
63 void clock_wait(int ms10);
64 void clock_set_seconds(unsigned long s);
65 unsigned long clock_seconds(void);
66 
67 /* Maximum timer interval for 16 bit clock_time_t */
68 #define INFINITE_TIME 0xffff
69 
70 /* Clock ticks per second */
71 #define CLOCK_CONF_SECOND 128
72 
73 /* Maximum tick interval is 0xffff/128 = 511 seconds */
74 #define RIME_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME INFINITE_TIME/CLOCK_CONF_SECOND /* Default uses 600 */
75 #define COLLECT_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME INFINITE_TIME/CLOCK_CONF_SECOND /* Default uses 600 */
76 
77 /* The 1284p can use TIMER2 with the external 32768Hz crystal to keep time. Else TIMER0 is used. */
78 /* The sleep timer in raven-lcd.c also uses the crystal and adds a TIMER2 interrupt routine if not already define by clock.c */
79 #define AVR_CONF_USE32KCRYSTAL 1
80 
81 /* Rtimer is implemented through the 16 bit Timer1, clocked at F_CPU through a 1024 prescaler. */
82 /* This gives 7812 counts per second, 128 microsecond precision and maximum interval 8.388 seconds. */
83 /* Change clock source and prescaler for greater precision and shorter maximum interval. */
84 /* 0 will disable the Rtimer code */
85 //#define RTIMER_ARCH_PRESCALER 256UL /*0, 1, 8, 64, 256, 1024 */
86 
87 /* COM port to be used for SLIP connection. Not tested on Raven */
88 #define SLIP_PORT RS232_PORT_0
89 
90 /* Pre-allocated memory for loadable modules heap space (in bytes)*/
91 /* Default is 4096. Currently used only when elfloader is present. Not tested on Raven */
92 //#define MMEM_CONF_SIZE 256
93 
94 /* Starting address for code received via the codeprop facility. Not tested on Raven */
95 //#define EEPROMFS_ADDR_CODEPROP 0x8000
96 
97 /* RADIO_CONF_CALIBRATE_INTERVAL is used in rf230bb and clock.c. If nonzero a 256 second interval is used */
98 /* Calibration is automatic when the radio wakes so is not necessary when the radio periodically sleeps */
99 //#define RADIO_CONF_CALIBRATE_INTERVAL 256
100 
101 /* RADIOSTATS is used in rf230bb, clock.c and the webserver cgi to report radio usage */
102 #define RADIOSTATS 1
103 
104 /* More extensive stats */
105 #define ENERGEST_CONF_ON 0
106 
107 /* Use settings manager to save configuration in EEPROM */
108 /* Adds ~1700 bytes to progmem */
109 #define CONTIKI_CONF_SETTINGS_MANAGER 1
110 
111 /* Possible watchdog timeouts depend on mcu. Default is WDTO_2S. -1 Disables the watchdog. */
112 /* AVR Studio simulator tends to reboot due to clocking the WD 8 times too fast */
113 //#define WATCHDOG_CONF_TIMEOUT -1
114 
115 /* Debugflow macro, useful for tracing path through mac and radio interrupts */
116 //#define DEBUGFLOWSIZE 128
117 
118 /* Network setup. The new NETSTACK interface requires RF230BB (as does ip4) */
119 #if RF230BB
120 #undef PACKETBUF_CONF_HDR_SIZE //Use the packetbuf default for header size
121 #else
122 #define PACKETBUF_CONF_HDR_SIZE 0 //RF230 combined driver/mac handles headers internally
123 #endif /*RF230BB */
124 
125 #if UIP_CONF_IPV6
126 #define RIMEADDR_CONF_SIZE 8
127 #define UIP_CONF_ICMP6 1
128 #define UIP_CONF_UDP 1
129 #define UIP_CONF_TCP 1
130 //#define UIP_CONF_IPV6_RPL 0
131 #define NETSTACK_CONF_NETWORK sicslowpan_driver
132 #define SICSLOWPAN_CONF_COMPRESSION SICSLOWPAN_COMPRESSION_HC06
133 
134 
135 
136 #elif WITH_DTN
137 #define NETSTACK_CONF_NETWORK dtn_network_driver
138 #define RIMEADDR_CONF_SIZE 2
139 
140 
141 
142 #else
143 /* ip4 should build but is largely untested */
144 #define RIMEADDR_CONF_SIZE 2
145 #define NETSTACK_CONF_NETWORK rime_driver
146 #endif /* UIP_CONF_IPV6 */
147 
148 /* See uip-ds6.h */
149 #define UIP_CONF_DS6_NBR_NBU 20
150 #define UIP_CONF_DS6_DEFRT_NBU 2
151 #define UIP_CONF_DS6_PREFIX_NBU 3
152 #define UIP_CONF_DS6_ROUTE_NBU 20
153 #define UIP_CONF_DS6_ADDR_NBU 3
154 #define UIP_CONF_DS6_MADDR_NBU 0
155 #define UIP_CONF_DS6_AADDR_NBU 0
156 
157 #define UIP_CONF_LL_802154 1
158 #define UIP_CONF_LLH_LEN 0
159 
160 /* 10 bytes per stateful address context - see sicslowpan.c */
161 /* Default is 1 context with prefix aaaa::/64 */
162 /* These must agree with all the other nodes or there will be a failure to communicate! */
163 #define SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS 1
164 #define SICSLOWPAN_CONF_ADDR_CONTEXT_0 {addr_contexts[0].prefix[0]=0xaa;addr_contexts[0].prefix[1]=0xaa;}
165 #define SICSLOWPAN_CONF_ADDR_CONTEXT_1 {addr_contexts[1].prefix[0]=0xbb;addr_contexts[1].prefix[1]=0xbb;}
166 #define SICSLOWPAN_CONF_ADDR_CONTEXT_2 {addr_contexts[2].prefix[0]=0x20;addr_contexts[2].prefix[1]=0x01;addr_contexts[2].prefix[2]=0x49;addr_contexts[2].prefix[3]=0x78,addr_contexts[2].prefix[4]=0x1d;addr_contexts[2].prefix[5]=0xb1;}
167 
168 /* 211 bytes per queue buffer */
169 #define QUEUEBUF_CONF_NUM 8
170 
171 /* 54 bytes per queue ref buffer */
172 #define QUEUEBUF_CONF_REF_NUM 2
173 
174 /* Take the default TCP maximum segment size for efficiency and simpler wireshark captures */
175 /* Use this to prevent 6LowPAN fragmentation (whether or not fragmentation is enabled) */
176 //#define UIP_CONF_TCP_MSS 48
177 
178 /* 30 bytes per TCP connection */
179 /* 6LoWPAN does not do well with concurrent TCP streams, as new browser GETs collide with packets coming */
180 /* from previous GETs, causing decreased throughput, retransmissions, and timeouts. Increase to study this. */
181 #define UIP_CONF_MAX_CONNECTIONS 1
182 
183 /* 2 bytes per TCP listening port */
184 #define UIP_CONF_MAX_LISTENPORTS 1
185 
186 /* 25 bytes per UDP connection */
187 #define UIP_CONF_UDP_CONNS 10
188 
189 #define UIP_CONF_IP_FORWARD 0
190 #define UIP_CONF_FWCACHE_SIZE 0
191 
192 #define UIP_CONF_IPV6_CHECKS 1
193 #define UIP_CONF_IPV6_QUEUE_PKT 1
194 #define UIP_CONF_IPV6_REASSEMBLY 0
195 
196 #define UIP_CONF_UDP_CHECKSUMS 1
197 #define UIP_CONF_TCP_SPLIT 1
198 #define UIP_CONF_DHCP_LIGHT 1
199 
200 
201 #if WITH_DTN
202 #define CHANNEL_802_15_4 24
203 #define NETSTACK_CONF_MAC csma_driver
204 #define NETSTACK_CONF_RDC nullrdc_driver
205 #define NETSTACK_CONF_FRAMER framer_802154
206 #define NETSTACK_CONF_RADIO rf230_driver
207 #define RF230_CONF_AUTOACK 1
208 #define SICSLOWPAN_CONF_ACK_ALL 0
209 #define RF230_CONF_AUTORETRIES 2
210 #ifndef QUEUEBUF_CONF_NUM
211 #define QUEUEBUF_CONF_NUM 16
212 
213 #endif
214 
215 #elif 1 /* No radio cycling */
216 #define NETSTACK_CONF_MAC nullmac_driver
217 #define NETSTACK_CONF_RDC nullrdc_driver
218 #define NETSTACK_CONF_FRAMER framer_802154
219 #define NETSTACK_CONF_RADIO rf230_driver
220 #define CHANNEL_802_15_4 26
221 #define RADIO_CONF_CALIBRATE_INTERVAL 256
222 /* AUTOACK receive mode gives better rssi measurements, even if ACK is never requested */
223 #define RF230_CONF_AUTOACK 1
224 /* Request 802.15.4 ACK on all packets sent (else autoretry). This is primarily for testing. */
225 #define SICSLOWPAN_CONF_ACK_ALL 0
226 /* Number of auto retry attempts+1, 1-16. Set zero to disable extended TX_ARET_ON mode with CCA) */
227 #define RF230_CONF_AUTORETRIES 3
228 /* Number of CSMA attempts 0-7. 802.15.4 2003 standard max is 5. */
229 #define RF230_CONF_CSMARETRIES 5
230 /* CCA theshold energy -91 to -61 dBm (default -77). Set this smaller than the expected minimum rssi to avoid packet collisions */
231 /* The Jackdaw menu 'm' command is helpful for determining the smallest ever received rssi */
232 #define RF230_CONF_CCA_THRES -85
233 /* Allow 6lowpan fragments (needed for large TCP maximum segment size) */
234 #define SICSLOWPAN_CONF_FRAG 1
235 /* Most browsers reissue GETs after 3 seconds which stops fragment reassembly so a longer MAXAGE does no good */
236 #define SICSLOWPAN_CONF_MAXAGE 3
237 /* How long to wait before terminating an idle TCP connection. Smaller to allow faster sleep. Default is 120 seconds */
238 #define UIP_CONF_WAIT_TIMEOUT 5
239 
240 #elif 1 /* Contiki-mac radio cycling */
241 #define NETSTACK_CONF_MAC nullmac_driver
242 //#define NETSTACK_CONF_MAC csma_driver
243 #define NETSTACK_CONF_RDC contikimac_driver
244 #define NETSTACK_CONF_FRAMER framer_802154
245 #define NETSTACK_CONF_RADIO rf230_driver
246 #define CHANNEL_802_15_4 26
247 /* The radio needs to interrupt during an rtimer interrupt */
248 #define RTIMER_CONF_NESTED_INTERRUPTS 1
249 #define RF230_CONF_AUTOACK 1
250 #define RF230_CONF_AUTORETRIES 1
251 #define RF230_CONF_CSMARETRIES 1
252 #define CONTIKIMAC_CONF_RADIO_ALWAYS_ON 0
253 #define SICSLOWPAN_CONF_FRAG 1
254 #define SICSLOWPAN_CONF_MAXAGE 3
255 #define NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE 8
256 
257 #elif 1 /* cx-mac radio cycling */
258 /* RF230 does clear-channel assessment in extended mode (autoretries>0) */
259 #define RF230_CONF_AUTORETRIES 1
260 #if RF230_CONF_AUTORETRIES
261 #define NETSTACK_CONF_MAC nullmac_driver
262 #else
263 #define NETSTACK_CONF_MAC csma_driver
264 #endif
265 #define NETSTACK_CONF_RDC cxmac_driver
266 #define NETSTACK_CONF_FRAMER framer_802154
267 #define NETSTACK_CONF_RADIO rf230_driver
268 #define CHANNEL_802_15_4 24
269 #define RF230_CONF_AUTOACK 1
270 #define SICSLOWPAN_CONF_FRAG 1
271 #define SICSLOWPAN_CONF_MAXAGE 3
272 #define CXMAC_CONF_ANNOUNCEMENTS 0
273 #define NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE 8
274 
275 //Below gives 10% duty cycle, undef for default 5%
276 //#define CXMAC_CONF_ON_TIME (RTIMER_ARCH_SECOND / 80)
277 //Below gives 50% duty cycle
278 //#define CXMAC_CONF_ON_TIME (RTIMER_ARCH_SECOND / 16)
279 
280 #else
281 #error Network configuration not specified!
282 #endif /* Network setup */
283 
284 /* Logging adds 200 bytes to program size */
285 #define LOG_CONF_ENABLED 1
286 
287 /* ************************************************************************** */
288 //#pragma mark RPL Settings
289 /* ************************************************************************** */
290 #if UIP_CONF_IPV6_RPL
291 
292 /* Define MAX_*X_POWER to reduce tx power and ignore weak rx packets for testing a miniature multihop network.
293  * Leave undefined for full power and sensitivity.
294  * tx=0 (3dbm, default) to 15 (-17.2dbm)
295  * RF230_CONF_AUTOACK sets the extended mode using the energy-detect register with rx=0 (-91dBm) to 84 (-7dBm)
296  * else the rssi register is used having range 0 (91dBm) to 28 (-10dBm)
297  * For simplicity RF230_MIN_RX_POWER is based on the energy-detect value and divided by 3 when autoack is not set.
298  * On the RF230 a reduced rx power threshold will not prevent autoack if enabled and requested.
299  * These numbers applied to both Raven and Jackdaw give a maximum communication distance of about 15 cm
300  * and a 10 meter range to a full-sensitivity RF230 sniffer.
301 #define RF230_MAX_TX_POWER 15
302 #define RF230_MIN_RX_POWER 30
303  */
304 
305 #define UIP_CONF_ROUTER 1
306 #define UIP_CONF_ND6_SEND_RA 0
307 #define UIP_CONF_ND6_REACHABLE_TIME 600000
308 #define UIP_CONF_ND6_RETRANS_TIMER 10000
309 
310 #undef UIP_CONF_UDP_CONNS
311 #define UIP_CONF_UDP_CONNS 12
312 #undef UIP_CONF_FWCACHE_SIZE
313 #define UIP_CONF_FWCACHE_SIZE 30
314 #define UIP_CONF_BROADCAST 1
315 #define UIP_ARCH_IPCHKSUM 1
316 #define UIP_CONF_PINGADDRCONF 0
317 #define UIP_CONF_LOGGING 0
318 
319 #endif /* RPL */
320 
321 #define CCIF
322 #define CLIF
323 
324 /* include the project config */
325 /* PROJECT_CONF_H might be defined in the project Makefile */
326 #ifdef PROJECT_CONF_H
327 #include PROJECT_CONF_H
328 #endif /* PROJECT_CONF_H */
329 
330 #endif /* __CONTIKI_CONF_H__ */