Contiki-Inga 3.x
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 ATmega128rfa1
37  * \author
38  * David Kopf <dak664@embarqmail.com>
39  */
40 
41 #ifndef CONTIKI_CONF_H_
42 #define CONTIKI_CONF_H_
43 
44 /* Platform name, type, and MCU clock rate */
45 #define PLATFORM_NAME "RFA1"
46 #define PLATFORM_TYPE ATMEGA128RFA1
47 #ifndef F_CPU
48 #define F_CPU 8000000UL
49 #endif
50 
51 #include <stdint.h>
52 
53 /* The AVR tick interrupt usually is done with an 8 bit counter around 128 Hz.
54  * 125 Hz needs slightly more overhead during the interrupt, as does a 32 bit
55  * clock_time_t.
56  */
57  /* Clock ticks per second */
58 #define CLOCK_CONF_SECOND 128
59 #if 1
60 /* 16 bit counter overflows every ~10 minutes */
61 typedef unsigned short clock_time_t;
62 #define CLOCK_LT(a,b) ((signed short)((a)-(b)) < 0)
63 #define INFINITE_TIME 0xffff
64 #define RIME_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME INFINITE_TIME/CLOCK_CONF_SECOND /* Default uses 600 */
65 #define COLLECT_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME INFINITE_TIME/CLOCK_CONF_SECOND /* Default uses 600 */
66 #else
67 typedef unsigned long clock_time_t;
68 #define CLOCK_LT(a,b) ((signed long)((a)-(b)) < 0)
69 #define INFINITE_TIME 0xffffffff
70 #endif
71 /* These routines are not part of the contiki core but can be enabled in cpu/avr/clock.c */
72 void clock_delay_msec(uint16_t howlong);
73 void clock_adjust_ticks(clock_time_t howmany);
74 
75 /* Michael Hartman's atmega128rfa1 board has an external 32768Hz crystal connected to TOSC1 and 2 pins similar to the Raven 1284p */
76 /* and theoretically can use TIMER2 with it to keep time. Else TIMER0 is used. */
77 /* The sleep timer requires the crystal and adds a TIMER2 interrupt routine if not already define by clock.c */
78 #define AVR_CONF_USE32KCRYSTAL 0
79 
80 /* Michael Hartman's protobyte board has LED on PORTE1, used for radio on indication */
81 /* However this results in disabling UART0. */
82 #define RF230BB_CONF_LEDONPORTE1 0
83 
84 /* COM port to be used for SLIP connection. This is usually UART0, but see above */
85 #if RF230BB_CONF_LEDONPORTE1
86 #define SLIP_PORT RS232_PORT_1
87 #else
88 #define SLIP_PORT RS232_PORT_0
89 #endif
90 
91 /* Pre-allocated memory for loadable modules heap space (in bytes)*/
92 /* Default is 4096. Currently used only when elfloader is present. Not tested on Raven */
93 //#define MMEM_CONF_SIZE 256
94 
95 /* Starting address for code received via the codeprop facility. Not tested. */
96 typedef unsigned long off_t;
97 //#define EEPROMFS_ADDR_CODEPROP 0x8000
98 
99 /* Logging adds 200 bytes to program size. RS232 output slows down webserver. */
100 //#define LOG_CONF_ENABLED 1
101 
102 /* RADIOSTATS is used in rf230bb, clock.c and the webserver cgi to report radio usage */
103 /* It has less overhead than ENERGEST */
104 #define RADIOSTATS 1
105 
106 /* More extensive stats, via main loop printfs or webserver status pages */
107 #define ENERGEST_CONF_ON 1
108 
109 /* Packet statistics */
110 typedef unsigned short uip_stats_t;
111 #define UIP_STATISTICS 0
112 
113 /* Available watchdog timeouts depend on mcu. Default is WDTO_2S. -1 Disables the watchdog. */
114 /* AVR Studio simulator tends to reboot due to clocking the WD 8 times too fast */
115 //#define WATCHDOG_CONF_TIMEOUT -1
116 
117 /* Debugflow macro, useful for tracing path through mac and radio interrupts */
118 //#define DEBUGFLOWSIZE 128
119 
120 
121 /* Define MAX_*X_POWER to reduce tx power and ignore weak rx packets for testing a miniature multihop network.
122  * Leave undefined for full power and sensitivity.
123  * tx=0 (3dbm, default) to 15 (-17.2dbm)
124  * RF230_CONF_AUTOACK sets the extended mode using the energy-detect register with rx=0 (-91dBm) to 84 (-7dBm)
125  * else the rssi register is used having range 0 (91dBm) to 28 (-10dBm)
126  * For simplicity RF230_MIN_RX_POWER is based on the energy-detect value and divided by 3 when autoack is not set.
127  * On the RF230 a reduced rx power threshold will not prevent autoack if enabled and requested.
128  * These numbers applied to both Raven and Jackdaw give a maximum communication distance of about 15 cm
129  * and a 10 meter range to a full-sensitivity RF230 sniffer.
130 #define RF230_MAX_TX_POWER 15
131 #define RF230_MIN_RX_POWER 30
132  */
133  /* The rf231 and atmega128rfa1 can use an rssi threshold for triggering rx_busy that saves 0.5ma in rx mode */
134 /* 1 - 15 maps into -90 to -48 dBm; the register is written with RF230_MIN_RX_POWER/6 + 1. Undefine for -100dBm sensitivity */
135 //#define RF230_MIN_RX_POWER 0
136 
137 /* Network setup */
138 /* TX routine passes the cca/ack result in the return parameter */
139 #define RDC_CONF_HARDWARE_ACK 1
140 /* TX routine does automatic cca and optional backoffs */
141 #define RDC_CONF_HARDWARE_CSMA 1
142 /* Allow MCU sleeping between channel checks */
143 /* Not for COOJA yet! */
144 #define RDC_CONF_MCU_SLEEP 0
145 
146 #if UIP_CONF_IPV6
147 #define LINKADDR_CONF_SIZE 8
148 #define UIP_CONF_ICMP6 1
149 #define UIP_CONF_UDP 1
150 #define UIP_CONF_TCP 1
151 #define NETSTACK_CONF_NETWORK sicslowpan_driver
152 #define SICSLOWPAN_CONF_COMPRESSION SICSLOWPAN_COMPRESSION_HC06
153 #else
154 /* ip4 should build but is largely untested */
155 #define LINKADDR_CONF_SIZE 2
156 #define NETSTACK_CONF_NETWORK rime_driver
157 #endif
158 
159 #define UIP_CONF_LL_802154 1
160 #define UIP_CONF_LLH_LEN 0
161 
162 /* 10 bytes per stateful address context - see sicslowpan.c */
163 /* Default is 1 context with prefix aaaa::/64 */
164 /* These must agree with all the other nodes or there will be a failure to communicate! */
165 #define SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS 1
166 #define SICSLOWPAN_CONF_ADDR_CONTEXT_0 {addr_contexts[0].prefix[0]=0xaa;addr_contexts[0].prefix[1]=0xaa;}
167 #define SICSLOWPAN_CONF_ADDR_CONTEXT_1 {addr_contexts[1].prefix[0]=0xbb;addr_contexts[1].prefix[1]=0xbb;}
168 #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;}
169 
170 /* Take the default TCP maximum segment size for efficiency and simpler wireshark captures */
171 /* Use this to prevent 6LowPAN fragmentation (whether or not fragmentation is enabled) */
172 //#define UIP_CONF_TCP_MSS 48
173 
174 #define UIP_CONF_IP_FORWARD 0
175 #define UIP_CONF_FWCACHE_SIZE 0
176 
177 #define UIP_CONF_IPV6_CHECKS 1
178 #define UIP_CONF_IPV6_QUEUE_PKT 1
179 #define UIP_CONF_IPV6_REASSEMBLY 0
180 
181 #define UIP_CONF_UDP_CHECKSUMS 1
182 #define UIP_CONF_TCP_SPLIT 1
183 #define UIP_CONF_DHCP_LIGHT 1
184 
185 
186 #if 0 /* No radio cycling */
187 
188 #define NETSTACK_CONF_MAC nullmac_driver
189 #define NETSTACK_CONF_RDC sicslowmac_driver
190 #define NETSTACK_CONF_FRAMER framer_802154
191 #define NETSTACK_CONF_RADIO rf230_driver
192 #define CHANNEL_802_15_4 26
193 /* AUTOACK receive mode gives better rssi measurements, even if ACK is never requested */
194 #define RF230_CONF_AUTOACK 1
195 /* Request 802.15.4 ACK on all packets sent (else autoretry). This is primarily for testing. */
196 #define SICSLOWPAN_CONF_ACK_ALL 0
197 /* 1 + Number of auto retry attempts 0-15 (0 implies don't use extended TX_ARET_ON mode) */
198 #define RF230_CONF_FRAME_RETRIES 2
199 /* Number of csma retry attempts 0-5 in extended tx mode (7 does immediate tx with no csma) */
200 #define RF230_CONF_CSMA_RETRIES 5
201 /* Default is one RAM buffer for received packets. More than one may benefit multiple TCP connections or ports */
202 #define RF230_CONF_RX_BUFFERS 3
203 #define SICSLOWPAN_CONF_FRAG 1
204 /* Most browsers reissue GETs after 3 seconds which stops fragment reassembly so a longer MAXAGE does no good */
205 #define SICSLOWPAN_CONF_MAXAGE 3
206 /* How long to wait before terminating an idle TCP connection. Smaller to allow faster sleep. Default is 120 seconds */
207 /* If wait is too short the connection can be reset as a result of multiple fragment reassembly timeouts */
208 #define UIP_CONF_WAIT_TIMEOUT 20
209 /* 211 bytes per queue buffer */
210 #define QUEUEBUF_CONF_NUM 8
211 /* 54 bytes per queue ref buffer */
212 #define QUEUEBUF_CONF_REF_NUM 2
213 /* Allocate remaining RAM as desired */
214 /* 30 bytes per TCP connection */
215 /* 6LoWPAN does not do well with concurrent TCP streams, as new browser GETs collide with packets coming */
216 /* from previous GETs, causing decreased throughput, retransmissions, and timeouts. Increase to study this. */
217 /* ACKs to other ports become interleaved with computation-intensive GETs, so ACKs are particularly missed. */
218 /* Increasing the number of packet receive buffers in RAM helps to keep ACKs from being lost */
219 #define UIP_CONF_MAX_CONNECTIONS 4
220 /* 2 bytes per TCP listening port */
221 #define UIP_CONF_MAX_LISTENPORTS 4
222 /* 25 bytes per UDP connection */
223 #define UIP_CONF_UDP_CONNS 10
224 /* See uip-ds6.h */
225 #define NBR_TABLE_CONF_MAX_NEIGHBORS 20
226 #define UIP_CONF_DS6_DEFRT_NBU 2
227 #define UIP_CONF_DS6_PREFIX_NBU 3
228 #define UIP_CONF_MAX_ROUTES 20
229 #define UIP_CONF_DS6_ADDR_NBU 3
230 #define UIP_CONF_DS6_MADDR_NBU 0
231 #define UIP_CONF_DS6_AADDR_NBU 0
232 
233 
234 #elif 1 /* Contiki-mac radio cycling */
235 //#define NETSTACK_CONF_MAC nullmac_driver
236 /* csma needed for burst mode at present. Webserver won't work without it */
237 #define NETSTACK_CONF_MAC csma_driver
238 #define NETSTACK_CONF_RDC contikimac_driver
239 /* Default is two CCA separated by 500 usec */
240 #define NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE 8
241 /* Wireshark won't decode with the header, but padded packets will fail ipv6 checksum */
242 #define CONTIKIMAC_CONF_WITH_CONTIKIMAC_HEADER 0
243 /* So without the header this needed for RPL mesh to form */
244 #define CONTIKIMAC_CONF_SHORTEST_PACKET_SIZE 43-18 //multicast RPL DIS length
245 /* Not tested much yet */
246 #define WITH_PHASE_OPTIMIZATION 0
247 #define CONTIKIMAC_CONF_COMPOWER 1
248 #define RIMESTATS_CONF_ENABLED 1
249 #define NETSTACK_CONF_FRAMER framer_802154
250 #define NETSTACK_CONF_RADIO rf230_driver
251 #define CHANNEL_802_15_4 26
252 /* The radio needs to interrupt during an rtimer interrupt */
253 #define RTIMER_CONF_NESTED_INTERRUPTS 1
254 #define RF230_CONF_AUTOACK 1
255 /* A 0 here means non-extended mode; 1 means extended mode with no retry, >1 for retrys */
256 /* Contikimac strobes on its own, but hardware retries are faster */
257 #define RF230_CONF_FRAME_RETRIES 1
258 /* Long csma backoffs will compromise radio cycling; set to 0 for 1 csma */
259 #define RF230_CONF_CSMA_RETRIES 0
260 #define SICSLOWPAN_CONF_FRAG 1
261 #define SICSLOWPAN_CONF_MAXAGE 3
262 /* 211 bytes per queue buffer. Contikimac burst mode needs 15 for a 1280 byte MTU */
263 #define QUEUEBUF_CONF_NUM 15
264 /* 54 bytes per queue ref buffer */
265 #define QUEUEBUF_CONF_REF_NUM 2
266 /* Allocate remaining RAM. Not much left due to queuebuf increase */
267 #define UIP_CONF_MAX_CONNECTIONS 2
268 #define UIP_CONF_MAX_LISTENPORTS 4
269 #define UIP_CONF_UDP_CONNS 5
270 #define NBR_TABLE_CONF_MAX_NEIGHBORS 20
271 #define UIP_CONF_DS6_DEFRT_NBU 2
272 #define UIP_CONF_DS6_PREFIX_NBU 3
273 #define UIP_CONF_MAX_ROUTES 4
274 #define UIP_CONF_DS6_ADDR_NBU 3
275 #define UIP_CONF_DS6_MADDR_NBU 0
276 #define UIP_CONF_DS6_AADDR_NBU 0
277 
278 
279 #elif 1 /* cx-mac radio cycling */
280 /* RF230 does clear-channel assessment in extended mode (autoretries>0) */
281 /* These values are guesses */
282 #define RF230_CONF_FRAME_RETRIES 10
283 #define RF230_CONF_CSMA_RETRIES 2
284 #if RF230_CONF_CSMA_RETRIES
285 #define NETSTACK_CONF_MAC nullmac_driver
286 #else
287 #define NETSTACK_CONF_MAC csma_driver
288 #endif
289 #define NETSTACK_CONF_RDC cxmac_driver
290 #define NETSTACK_CONF_FRAMER framer_802154
291 #define NETSTACK_CONF_RADIO rf230_driver
292 #define CHANNEL_802_15_4 26
293 #define RF230_CONF_AUTOACK 1
294 #define SICSLOWPAN_CONF_FRAG 1
295 #define SICSLOWPAN_CONF_MAXAGE 3
296 #define CXMAC_CONF_ANNOUNCEMENTS 0
297 #define NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE 8
298 /* 211 bytes per queue buffer. Burst mode will need 15 for a 1280 byte MTU */
299 #define QUEUEBUF_CONF_NUM 15
300 /* 54 bytes per queue ref buffer */
301 #define QUEUEBUF_CONF_REF_NUM 2
302 /* Allocate remaining RAM. Not much left due to queuebuf increase */
303 #define UIP_CONF_MAX_CONNECTIONS 2
304 #define UIP_CONF_MAX_LISTENPORTS 4
305 #define UIP_CONF_UDP_CONNS 5
306 #define NBR_TABLE_CONF_MAX_NEIGHBORS 4
307 #define UIP_CONF_DS6_DEFRT_NBU 2
308 #define UIP_CONF_DS6_PREFIX_NBU 3
309 #define UIP_CONF_MAX_ROUTES 4
310 #define UIP_CONF_DS6_ADDR_NBU 3
311 #define UIP_CONF_DS6_MADDR_NBU 0
312 #define UIP_CONF_DS6_AADDR_NBU 0
313 //Below gives 10% duty cycle, undef for default 5%
314 //#define CXMAC_CONF_ON_TIME (RTIMER_ARCH_SECOND / 80)
315 //Below gives 50% duty cycle
316 //#define CXMAC_CONF_ON_TIME (RTIMER_ARCH_SECOND / 16)
317 
318 #else
319 #error Network configuration not specified!
320 #endif /* Network setup */
321 
322 /* ************************************************************************** */
323 //#pragma mark RPL Settings
324 /* ************************************************************************** */
325 #if UIP_CONF_IPV6_RPL
326 
327 #define UIP_CONF_ROUTER 1
328 #define UIP_CONF_ND6_SEND_RA 0
329 #define UIP_CONF_ND6_REACHABLE_TIME 600000
330 #define UIP_CONF_ND6_RETRANS_TIMER 10000
331 
332 /* For slow slip connections, to prevent buffer overruns */
333 //#define UIP_CONF_RECEIVE_WINDOW 300
334 #undef UIP_CONF_FWCACHE_SIZE
335 #define UIP_CONF_FWCACHE_SIZE 30
336 #define UIP_CONF_BROADCAST 1
337 #define UIP_ARCH_IPCHKSUM 1
338 #define UIP_CONF_PINGADDRCONF 0
339 #define UIP_CONF_LOGGING 0
340 
341 #endif /* RPL */
342 
343 #define CCIF
344 #define CLIF
345 #ifndef CC_CONF_INLINE
346 #define CC_CONF_INLINE inline
347 #endif
348 
349 /* include the project config */
350 /* PROJECT_CONF_H might be defined in the project Makefile */
351 #ifdef PROJECT_CONF_H
352 #include PROJECT_CONF_H
353 #endif
354 
355 #endif /* CONTIKI_CONF_H_ */