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 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 /* Platform name, type, and MCU clock rate */
47 #define PLATFORM_NAME "Raven"
48 #define PLATFORM_TYPE RAVEN_D
49 #ifndef F_CPU
50 #define F_CPU 8000000UL
51 #endif
52 
53 #include <avr/eeprom.h>
54 
55 /* Skip the last four bytes of the EEPROM, to leave room for things
56  * like the avrdude erase count and bootloader signaling. */
57 #define EEPROM_CONF_SIZE ((E2END + 1) - 4)
58 
59 /* MCU_CONF_LOW_WEAR will remove the signature and eeprom from the .elf file */
60 /* This reduces reprogramming wear during development */
61 //#define MCU_CONF_LOW_WEAR 1
62 
63 #include <stdint.h>
64 
65 /* The AVR tick interrupt usually is done with an 8 bit counter around 128 Hz.
66  * 125 Hz needs slightly more overhead during the interrupt, as does a 32 bit
67  * clock_time_t.
68  */
69 /* Clock ticks per second */
70 #define CLOCK_CONF_SECOND 128
71 #if 1
72 /* 16 bit counter overflows every ~10 minutes */
73 typedef unsigned short clock_time_t;
74 #define CLOCK_LT(a,b) ((signed short)((a)-(b)) < 0)
75 #define INFINITE_TIME 0xffff
76 #define RIME_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME INFINITE_TIME/CLOCK_CONF_SECOND /* Default uses 600 */
77 #define COLLECT_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME INFINITE_TIME/CLOCK_CONF_SECOND /* Default uses 600 */
78 #else
79 typedef unsigned long clock_time_t;
80 #define CLOCK_LT(a,b) ((signed long)((a)-(b)) < 0)
81 #define INFINITE_TIME 0xffffffff
82 #endif
83 /* These routines are not part of the contiki core but can be enabled in cpu/avr/clock.c */
84 void clock_delay_msec(uint16_t howlong);
85 void clock_adjust_ticks(clock_time_t howmany);
86 
87 /* The 1284p can use TIMER2 with the external 32768Hz crystal to keep time. Else TIMER0 is used. */
88 /* The sleep timer in raven-lcd.c also uses the crystal and adds a TIMER2 interrupt routine if not already define by clock.c */
89 /* If F_CPU is 0x800000 the clock tick interrupt routine will (attempt to) keep the cpu clock phase locked to the crystal. */
90 #define AVR_CONF_USE32KCRYSTAL 1
91 
92 /* Rtimer is implemented through the 16 bit Timer1, clocked at F_CPU through a 1024 prescaler. */
93 /* This gives 7812 counts per second, 128 microsecond precision and maximum interval 8.388 seconds. */
94 /* Change clock source and prescaler for greater precision and shorter maximum interval. */
95 /* 0 will disable the Rtimer code */
96 //#define RTIMER_ARCH_PRESCALER 256UL /*0, 1, 8, 64, 256, 1024 */
97 
98 /* COM port to be used for SLIP connection. Not tested on Raven */
99 #define SLIP_PORT RS232_PORT_0
100 
101 /* Pre-allocated memory for loadable modules heap space (in bytes)*/
102 /* Default is 4096. Currently used only when elfloader is present. Not tested on Raven */
103 //#define MMEM_CONF_SIZE 256
104 
105 /* Starting address for code received via the codeprop facility. Not tested on Raven */
106 typedef unsigned long off_t;
107 //#define EEPROMFS_ADDR_CODEPROP 0x8000
108 
109 /* RADIO_CONF_CALIBRATE_INTERVAL is used in rf230bb and clock.c. If nonzero a 256 second interval is used */
110 /* Calibration is automatic when the radio wakes so is not necessary when the radio periodically sleeps */
111 //#define RADIO_CONF_CALIBRATE_INTERVAL 256
112 
113 /* RADIOSTATS is used in rf230bb, clock.c and the webserver cgi to report radio usage */
114 #define RADIOSTATS 1
115 
116 /* More extensive stats */
117 #define ENERGEST_CONF_ON 1
118 
119 /* Packet statistics */
120 typedef unsigned short uip_stats_t;
121 #define UIP_STATISTICS 0
122 
123 
124 /* Possible watchdog timeouts depend on mcu. Default is WDTO_2S. -1 Disables the watchdog. */
125 /* AVR Studio simulator tends to reboot due to clocking the WD 8 times too fast */
126 //#define WATCHDOG_CONF_TIMEOUT -1
127 
128 /* Debugflow macro, useful for tracing path through mac and radio interrupts */
129 //#define DEBUGFLOWSIZE 128
130 
131 /* Define MAX_*X_POWER to reduce tx power and ignore weak rx packets for testing a miniature multihop network.
132  * Leave undefined for full power and sensitivity.
133  * tx=0 (3dbm, default) to 15 (-17.2dbm)
134  * RF230_CONF_AUTOACK sets the extended mode using the energy-detect register with rx=0 (-91dBm) to 84 (-7dBm)
135  * else the rssi register is used having range 0 (91dBm) to 28 (-10dBm)
136  * For simplicity RF230_MIN_RX_POWER is based on the energy-detect value and divided by 3 when autoack is not set.
137  * On the RF230 a reduced rx power threshold will not prevent autoack if enabled and requested.
138  * These numbers applied to both Raven and Jackdaw give a maximum communication distance of about 15 cm
139  * and a 10 meter range to a full-sensitivity RF230 sniffer.
140 #define RF230_MAX_TX_POWER 15
141 #define RF230_MIN_RX_POWER 30
142  */
143  /* The rf231 and atmega128rfa1 can use an rssi threshold for triggering rx_busy that saves 0.5ma in rx mode */
144 /* 1 - 15 maps into -90 to -48 dBm; the register is written with RF230_MIN_RX_POWER/6 + 1. Undefine for -100dBm sensitivity */
145 //#define RF230_MIN_RX_POWER 0
146 
147 /* Network setup. The new NETSTACK interface requires RF230BB (as does ip4) */
148 #if RF230BB
149 #undef PACKETBUF_CONF_HDR_SIZE //Use the packetbuf default for header size
150 /* TX routine passes the cca/ack result in the return parameter */
151 #define RDC_CONF_HARDWARE_ACK 1
152 /* TX routine does automatic cca and optional backoff */
153 #define RDC_CONF_HARDWARE_CSMA 1
154 /* Allow MCU sleeping between channel checks */
155 #define RDC_CONF_MCU_SLEEP 0
156 #else
157 #define PACKETBUF_CONF_HDR_SIZE 0 //RF230 combined driver/mac handles headers internally
158 #endif /*RF230BB */
159 
160 #if UIP_CONF_IPV6
161 
162 #define NETSTACK_CONF_NETWORK sicslowpan_driver
163 
164 #define LINKADDR_CONF_SIZE 8
165 
166 #define UIP_CONF_ICMP6 1
167 #define UIP_CONF_UDP 1
168 #define UIP_CONF_TCP 1
169 #define UIP_CONF_IPV6_RPL 0
170 #define SICSLOWPAN_CONF_COMPRESSION SICSLOWPAN_COMPRESSION_HC06
171 
172 #else
173 
174 /* ip4 should build but is largely untested */
175 #define NETSTACK_CONF_NETWORK rime_driver
176 
177 #define LINKADDR_CONF_SIZE 2
178 
179 #endif /* UIP_CONF_IPV6 */
180 
181 #define UIP_CONF_LL_802154 1
182 #define UIP_CONF_LLH_LEN 0
183 
184 /* 10 bytes per stateful address context - see sicslowpan.c */
185 /* Default is 1 context with prefix aaaa::/64 */
186 /* These must agree with all the other nodes or there will be a failure to communicate! */
187 #define SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS 1
188 #define SICSLOWPAN_CONF_ADDR_CONTEXT_0 {addr_contexts[0].prefix[0]=0xaa;addr_contexts[0].prefix[1]=0xaa;}
189 #define SICSLOWPAN_CONF_ADDR_CONTEXT_1 {addr_contexts[1].prefix[0]=0xbb;addr_contexts[1].prefix[1]=0xbb;}
190 #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;}
191 
192 /* See uip-ds6.h */
193 #define UIP_CONF_DS6_NBR_NBU 4
194 #define UIP_CONF_DS6_DEFRT_NBU 2
195 #define UIP_CONF_DS6_PREFIX_NBU 3
196 #define UIP_CONF_MAX_ROUTES 4
197 #define UIP_CONF_DS6_ADDR_NBU 3
198 #define UIP_CONF_DS6_MADDR_NBU 0
199 #define UIP_CONF_DS6_AADDR_NBU 0
200 
201 /* Take the default TCP maximum segment size for efficiency and simpler wireshark captures */
202 /* Use this to prevent 6LowPAN fragmentation (whether or not fragmentation is enabled) */
203 //#define UIP_CONF_TCP_MSS 48
204 
205 #define UIP_CONF_IP_FORWARD 0
206 #define UIP_CONF_FWCACHE_SIZE 0
207 
208 #define UIP_CONF_IPV6_CHECKS 1
209 #define UIP_CONF_IPV6_QUEUE_PKT 1
210 #define UIP_CONF_IPV6_REASSEMBLY 0
211 
212 #define UIP_CONF_UDP_CHECKSUMS 1
213 #define UIP_CONF_TCP_SPLIT 1
214 #define UIP_CONF_DHCP_LIGHT 1
215 
216 // --- common netstack config
217 
218 #ifndef NETSTACK_CONF_RADIO
219 #define NETSTACK_CONF_RADIO rf230_driver
220 #endif /* NETSTACK_CONF_RADIO */
221 
222 #ifndef NETSTACK_CONF_FRAMER
223 #define NETSTACK_CONF_FRAMER framer_802154
224 #endif /* NETSTACK_CONF_FRAMER */
225 
226 #ifndef NETSTACK_CONF_MAC
227 #define NETSTACK_CONF_MAC nullmac_driver
228 #endif /* NETSTACK_CONF_MAC */
229 
230 #ifndef NETSTACK_CONF_RDC
231 #define NETSTACK_CONF_RDC contikimac_driver
232 #endif /* NETSTACK_CONF_RDC */
233 
234 
235 /* -- Radio driver settings */
236 #define CHANNEL_802_15_4 26
237 #define RADIO_CONF_CALIBRATE_INTERVAL 256
238 /* AUTOACK receive mode gives better rssi measurements,
239  * even if ACK is never requested */
240 #define RF230_CONF_AUTOACK 1
241 /* Make nullrdc wait for the proper ACK before proceeding */
242 #define NULLRDC_CONF_802154_AUTOACK 1
243 /* Let the RF230 radio driver generate fake acknowledgements to make nullrdc happy */
244 #define RF320_CONF_INSERTACK 1
245 /* Number of CSMA attempts 0-7. 802.15.4 2003 standard max is 5. */
246 #define RF230_CONF_FRAME_RETRIES 5
247 /* CCA theshold energy -91 to -61 dBm (default -77).
248  * Set this smaller than the expected minimum rssi to avoid packet collisions */
249 /* The Jackdaw menu 'm' command is helpful for determining the smallest ever received rssi */
250 #define RF230_CONF_CCA_THRES -85
251 /* Default is one RAM buffer for received packets. More than one may benefit multiple TCP connections or ports */
252 #define RF230_CONF_RX_BUFFERS 3
253 
254 /* Default is two CCA separated by 500 usec */
255 #define NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE 8
256 /* Wireshark won't decode with the header, but padded packets will fail ipv6 checksum */
257 #define CONTIKIMAC_CONF_WITH_CONTIKIMAC_HEADER 0
258 /* So without the header this needed for RPL mesh to form */
259 #define CONTIKIMAC_CONF_SHORTEST_PACKET_SIZE 43-18 //multicast RPL DIS length
260 /* Not tested much yet */
261 #define WITH_PHASE_OPTIMIZATION 0
262 #define CONTIKIMAC_CONF_COMPOWER 1
263 #define RIMESTATS_CONF_ENABLED 1
264 /* The radio needs to interrupt during an rtimer interrupt */
265 #define RTIMER_CONF_NESTED_INTERRUPTS 1
266 /* A 0 here means cca but no retry, >1= for backoff retrys */
267 #define RF230_CONF_CSMA_RETRIES 1
268 #define SICSLOWPAN_CONF_FRAG 1
269 #define SICSLOWPAN_CONF_MAXAGE 3
270 /* 211 bytes per queue buffer. Contikimac burst mode needs 15 for a 1280 byte MTU */
271 #define QUEUEBUF_CONF_NUM 15
272 /* 54 bytes per queue ref buffer */
273 #define QUEUEBUF_CONF_REF_NUM 2
274 /* Allocate remaining RAM. Not much left due to queuebuf increase */
275 #define UIP_CONF_MAX_CONNECTIONS 2
276 #define UIP_CONF_MAX_LISTENPORTS 2
277 #define UIP_CONF_UDP_CONNS 4
278 
279 //Below gives 10% duty cycle, undef for default 5%
280 //#define CXMAC_CONF_ON_TIME (RTIMER_ARCH_SECOND / 80)
281 //Below gives 50% duty cycle
282 //#define CXMAC_CONF_ON_TIME (RTIMER_ARCH_SECOND / 16)
283 
284 /* ************************************************************************** */
285 //#pragma mark RPL Settings
286 /* ************************************************************************** */
287 #if UIP_CONF_IPV6_RPL
288 
289 #define UIP_CONF_ROUTER 1
290 #define UIP_CONF_ND6_SEND_RA 0
291 #define UIP_CONF_ND6_REACHABLE_TIME 600000
292 #define UIP_CONF_ND6_RETRANS_TIMER 10000
293 
294 #undef UIP_CONF_UDP_CONNS
295 #define UIP_CONF_UDP_CONNS 12
296 #undef UIP_CONF_FWCACHE_SIZE
297 #define UIP_CONF_FWCACHE_SIZE 30
298 #define UIP_CONF_BROADCAST 1
299 #define UIP_ARCH_IPCHKSUM 1
300 #define UIP_CONF_PINGADDRCONF 0
301 #define UIP_CONF_LOGGING 0
302 
303 #endif /* UIP_CONF_IPV6_RPL */
304 
305 
306 /* Logging adds 200 bytes to program size */
307 #define LOG_CONF_ENABLED 1
308 
309 #define CCIF
310 #define CLIF
311 #ifndef CC_CONF_INLINE
312 #define CC_CONF_INLINE inline
313 #endif
314 
315 /* include the project config */
316 /* PROJECT_CONF_H might be defined in the project Makefile */
317 #ifdef PROJECT_CONF_H
318 #include PROJECT_CONF_H
319 #endif /* PROJECT_CONF_H */
320 
321 #endif /* CONTIKI_CONF_H_ */