Contiki 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 #define LINKADDR_CONF_SIZE 8
162 #define UIP_CONF_ICMP6 1
163 #define UIP_CONF_UDP 1
164 #define UIP_CONF_TCP 1
165 //#define UIP_CONF_IPV6_RPL 0
166 #define NETSTACK_CONF_NETWORK sicslowpan_driver
167 #define SICSLOWPAN_CONF_COMPRESSION SICSLOWPAN_COMPRESSION_HC06
168 #else
169 /* ip4 should build but is largely untested */
170 #define LINKADDR_CONF_SIZE 2
171 #define NETSTACK_CONF_NETWORK rime_driver
172 #endif /* UIP_CONF_IPV6 */
173 
174 #define UIP_CONF_LL_802154 1
175 #define UIP_CONF_LLH_LEN 0
176 
177 /* 10 bytes per stateful address context - see sicslowpan.c */
178 /* Default is 1 context with prefix aaaa::/64 */
179 /* These must agree with all the other nodes or there will be a failure to communicate! */
180 #define SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS 1
181 #define SICSLOWPAN_CONF_ADDR_CONTEXT_0 {addr_contexts[0].prefix[0]=0xaa;addr_contexts[0].prefix[1]=0xaa;}
182 #define SICSLOWPAN_CONF_ADDR_CONTEXT_1 {addr_contexts[1].prefix[0]=0xbb;addr_contexts[1].prefix[1]=0xbb;}
183 #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;}
184 
185 /* Take the default TCP maximum segment size for efficiency and simpler wireshark captures */
186 /* Use this to prevent 6LowPAN fragmentation (whether or not fragmentation is enabled) */
187 //#define UIP_CONF_TCP_MSS 48
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 #if 1 /* No radio cycling */
201 
202 #define NETSTACK_CONF_MAC nullmac_driver
203 #define NETSTACK_CONF_RDC sicslowmac_driver
204 #define NETSTACK_CONF_FRAMER framer_802154
205 #define NETSTACK_CONF_RADIO rf230_driver
206 #define CHANNEL_802_15_4 26
207 #define RADIO_CONF_CALIBRATE_INTERVAL 256
208 /* AUTOACK receive mode gives better rssi measurements, even if ACK is never requested */
209 #define RF230_CONF_AUTOACK 1
210 /* Request 802.15.4 ACK on all packets sent (else autoretry). This is primarily for testing. */
211 #define SICSLOWPAN_CONF_ACK_ALL 0
212 /* Number of auto retry attempts+1, 1-16. Set zero to disable extended TX_ARET_ON mode with CCA) */
213 #define RF230_CONF_FRAME_RETRIES 3
214 /* Number of CSMA attempts 0-7. 802.15.4 2003 standard max is 5. */
215 #define RF230_CONF_CSMA_RETRIES 5
216 /* CCA theshold energy -91 to -61 dBm (default -77). Set this smaller than the expected minimum rssi to avoid packet collisions */
217 /* The Jackdaw menu 'm' command is helpful for determining the smallest ever received rssi */
218 #define RF230_CONF_CCA_THRES -85
219 /* Allow 6lowpan fragments (needed for large TCP maximum segment size) */
220 #define SICSLOWPAN_CONF_FRAG 1
221 /* Most browsers reissue GETs after 3 seconds which stops fragment reassembly so a longer MAXAGE does no good */
222 #define SICSLOWPAN_CONF_MAXAGE 3
223 /* How long to wait before terminating an idle TCP connection. Smaller to allow faster sleep. Default is 120 seconds */
224 #define UIP_CONF_WAIT_TIMEOUT 5
225 /* 211 bytes per queue buffer */
226 #define QUEUEBUF_CONF_NUM 8
227 /* 54 bytes per queue ref buffer */
228 #define QUEUEBUF_CONF_REF_NUM 2
229 /* Allocate remaining RAM as desired */
230 /* 30 bytes per TCP connection */
231 /* 6LoWPAN does not do well with concurrent TCP streams, as new browser GETs collide with packets coming */
232 /* from previous GETs, causing decreased throughput, retransmissions, and timeouts. Increase to study this. */
233 /* ACKs to other ports become interleaved with computation-intensive GETs, so ACKs are particularly missed. */
234 /* Increasing the number of packet receive buffers in RAM helps to keep ACKs from being lost */
235 #define UIP_CONF_MAX_CONNECTIONS 4
236 /* 2 bytes per TCP listening port */
237 #define UIP_CONF_MAX_LISTENPORTS 4
238 /* 25 bytes per UDP connection */
239 #define UIP_CONF_UDP_CONNS 10
240 /* See uip-ds6.h */
241 #define NBR_TABLE_CONF_MAX_NEIGHBORS 20
242 #define UIP_CONF_DS6_DEFRT_NBU 2
243 #define UIP_CONF_DS6_PREFIX_NBU 3
244 #define UIP_CONF_MAX_ROUTES 20
245 #define UIP_CONF_DS6_ADDR_NBU 3
246 #define UIP_CONF_DS6_MADDR_NBU 0
247 #define UIP_CONF_DS6_AADDR_NBU 0
248 
249 #elif 1 /* Contiki-mac radio cycling */
250 //#define NETSTACK_CONF_MAC nullmac_driver
251 /* csma needed for burst mode at present. Webserver won't work without it */
252 #define NETSTACK_CONF_MAC csma_driver
253 #define NETSTACK_CONF_RDC contikimac_driver
254 /* Default is two CCA separated by 500 usec */
255 #define NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE 8
256 /* So without the header this needed for RPL mesh to form */
257 #define CONTIKIMAC_FRAMER_CONF_SHORTEST_PACKET_SIZE 43-18 //multicast RPL DIS length
258 /* Not tested much yet */
259 #define WITH_PHASE_OPTIMIZATION 0
260 #define CONTIKIMAC_CONF_COMPOWER 1
261 #define RIMESTATS_CONF_ENABLED 1
262 #define NETSTACK_CONF_FRAMER framer_802154
263 #define NETSTACK_CONF_RADIO rf230_driver
264 #define CHANNEL_802_15_4 26
265 /* The radio needs to interrupt during an rtimer interrupt */
266 #define RTIMER_CONF_NESTED_INTERRUPTS 1
267 #define RF230_CONF_AUTOACK 1
268 /* A 0 here means non-extended mode; 1 means extended mode with no retry, >1 for retrys */
269 #define RF230_CONF_FRAME_RETRIES 1
270 /* A 0 here means cca but no retry, >1= for backoff retrys */
271 #define RF230_CONF_CSMA_RETRIES 1
272 #define SICSLOWPAN_CONF_FRAG 1
273 #define SICSLOWPAN_CONF_MAXAGE 3
274 /* 211 bytes per queue buffer. Contikimac burst mode needs 15 for a 1280 byte MTU */
275 #define QUEUEBUF_CONF_NUM 15
276 /* 54 bytes per queue ref buffer */
277 #define QUEUEBUF_CONF_REF_NUM 2
278 /* Allocate remaining RAM. Not much left due to queuebuf increase */
279 #define UIP_CONF_MAX_CONNECTIONS 2
280 #define UIP_CONF_MAX_LISTENPORTS 2
281 #define UIP_CONF_UDP_CONNS 4
282 #define NBR_TABLE_CONF_MAX_NEIGHBORS 10
283 #define UIP_CONF_DS6_DEFRT_NBU 2
284 #define UIP_CONF_DS6_PREFIX_NBU 2
285 #define UIP_CONF_MAX_ROUTES 4
286 #define UIP_CONF_DS6_ADDR_NBU 3
287 #define UIP_CONF_DS6_MADDR_NBU 0
288 #define UIP_CONF_DS6_AADDR_NBU 0
289 
290 #elif 1 /* cx-mac radio cycling */
291 /* RF230 does clear-channel assessment in extended mode (frame retries>0) */
292 #define RF230_CONF_FRAME_RETRIES 1
293 #if RF230_CONF_FRAME_RETRIES
294 #define NETSTACK_CONF_MAC nullmac_driver
295 #else
296 #define NETSTACK_CONF_MAC csma_driver
297 #endif
298 #define NETSTACK_CONF_RDC cxmac_driver
299 #define NETSTACK_CONF_FRAMER framer_802154
300 #define NETSTACK_CONF_RADIO rf230_driver
301 #define CHANNEL_802_15_4 26
302 #define RF230_CONF_AUTOACK 1
303 #define SICSLOWPAN_CONF_FRAG 1
304 #define SICSLOWPAN_CONF_MAXAGE 3
305 #define CXMAC_CONF_ANNOUNCEMENTS 0
306 #define NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE 8
307 /* 211 bytes per queue buffer. Burst mode will need 15 for a 1280 byte MTU */
308 #define QUEUEBUF_CONF_NUM 15
309 /* 54 bytes per queue ref buffer */
310 #define QUEUEBUF_CONF_REF_NUM 2
311 /* Allocate remaining RAM. Not much left due to queuebuf increase */
312 #define UIP_CONF_MAX_CONNECTIONS 2
313 #define UIP_CONF_MAX_LISTENPORTS 4
314 #define UIP_CONF_UDP_CONNS 5
315 #define NBR_TABLE_CONF_MAX_NEIGHBORS 4
316 #define UIP_CONF_DS6_DEFRT_NBU 2
317 #define UIP_CONF_DS6_PREFIX_NBU 3
318 #define UIP_CONF_MAX_ROUTES 4
319 #define UIP_CONF_DS6_ADDR_NBU 3
320 #define UIP_CONF_DS6_MADDR_NBU 0
321 #define UIP_CONF_DS6_AADDR_NBU 0
322 //Below gives 10% duty cycle, undef for default 5%
323 //#define CXMAC_CONF_ON_TIME (RTIMER_ARCH_SECOND / 80)
324 //Below gives 50% duty cycle
325 //#define CXMAC_CONF_ON_TIME (RTIMER_ARCH_SECOND / 16)
326 
327 
328 #else
329 #error Network configuration not specified!
330 #endif /* Network setup */
331 
332 /* Logging adds 200 bytes to program size */
333 #define LOG_CONF_ENABLED 1
334 
335 /* ************************************************************************** */
336 //#pragma mark RPL Settings
337 /* ************************************************************************** */
338 #if UIP_CONF_IPV6_RPL
339 
340 #define UIP_CONF_ROUTER 1
341 #define UIP_CONF_ND6_SEND_RA 0
342 #define UIP_CONF_ND6_REACHABLE_TIME 600000
343 #define UIP_CONF_ND6_RETRANS_TIMER 10000
344 /* For slow slip connections, to prevent buffer overruns */
345 //#define UIP_CONF_RECEIVE_WINDOW 300
346 #undef UIP_CONF_FWCACHE_SIZE
347 #define UIP_CONF_FWCACHE_SIZE 30
348 #define UIP_CONF_BROADCAST 1
349 #define UIP_ARCH_IPCHKSUM 1
350 #define UIP_CONF_PINGADDRCONF 0
351 #define UIP_CONF_LOGGING 0
352 
353 #endif /* RPL */
354 
355 #define CCIF
356 #define CLIF
357 #ifndef CC_CONF_INLINE
358 #define CC_CONF_INLINE inline
359 #endif
360 
361 /* include the project config */
362 /* PROJECT_CONF_H might be defined in the project Makefile */
363 #ifdef PROJECT_CONF_H
364 #include PROJECT_CONF_H
365 #endif /* PROJECT_CONF_H */
366 
367 #endif /* CONTIKI_CONF_H_ */
void clock_delay_msec(uint16_t howlong)
Delay up to 65535 milliseconds.
Definition: clock.c:260
void clock_adjust_ticks(clock_time_t howmany)
Adjust the system current clock time.
Definition: clock.c:289