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 
72 typedef uint32_t clock_time_t;
73 #define CLOCK_LT(a,b) ((int32_t)((a)-(b)) < 0)
74 
75 /* These routines are not part of the contiki core but can be enabled in cpu/avr/clock.c */
76 void clock_delay_msec(uint16_t howlong);
77 void clock_adjust_ticks(clock_time_t howmany);
78 
79 /* The 1284p can use TIMER2 with the external 32768Hz crystal to keep time. Else TIMER0 is used. */
80 /* The sleep timer in raven-lcd.c also uses the crystal and adds a TIMER2 interrupt routine if not already define by clock.c */
81 /* If F_CPU is 0x800000 the clock tick interrupt routine will (attempt to) keep the cpu clock phase locked to the crystal. */
82 #define AVR_CONF_USE32KCRYSTAL 1
83 
84 /* Rtimer is implemented through the 16 bit Timer1, clocked at F_CPU through a 1024 prescaler. */
85 /* This gives 7812 counts per second, 128 microsecond precision and maximum interval 8.388 seconds. */
86 /* Change clock source and prescaler for greater precision and shorter maximum interval. */
87 /* 0 will disable the Rtimer code */
88 //#define RTIMER_ARCH_PRESCALER 256UL /*0, 1, 8, 64, 256, 1024 */
89 
90 /* COM port to be used for SLIP connection. Not tested on Raven */
91 #define SLIP_PORT RS232_PORT_0
92 
93 /* Pre-allocated memory for loadable modules heap space (in bytes)*/
94 /* Default is 4096. Currently used only when elfloader is present. Not tested on Raven */
95 //#define MMEM_CONF_SIZE 256
96 
97 /* Starting address for code received via the codeprop facility. Not tested on Raven */
98 typedef unsigned long off_t;
99 //#define EEPROMFS_ADDR_CODEPROP 0x8000
100 
101 /* RADIO_CONF_CALIBRATE_INTERVAL is used in rf230bb and clock.c. If nonzero a 256 second interval is used */
102 /* Calibration is automatic when the radio wakes so is not necessary when the radio periodically sleeps */
103 //#define RADIO_CONF_CALIBRATE_INTERVAL 256
104 
105 /* RADIOSTATS is used in rf230bb, clock.c and the webserver cgi to report radio usage */
106 #define RADIOSTATS 1
107 
108 /* More extensive stats */
109 #define ENERGEST_CONF_ON 1
110 
111 /* Packet statistics */
112 typedef unsigned short uip_stats_t;
113 #define UIP_STATISTICS 0
114 
115 
116 /* Possible watchdog timeouts depend on mcu. Default is WDTO_2S. -1 Disables the watchdog. */
117 /* AVR Studio simulator tends to reboot due to clocking the WD 8 times too fast */
118 //#define WATCHDOG_CONF_TIMEOUT -1
119 
120 /* Debugflow macro, useful for tracing path through mac and radio interrupts */
121 //#define DEBUGFLOWSIZE 128
122 
123 /* Define MAX_*X_POWER to reduce tx power and ignore weak rx packets for testing a miniature multihop network.
124  * Leave undefined for full power and sensitivity.
125  * tx=0 (3dbm, default) to 15 (-17.2dbm)
126  * RF230_CONF_AUTOACK sets the extended mode using the energy-detect register with rx=0 (-91dBm) to 84 (-7dBm)
127  * else the rssi register is used having range 0 (91dBm) to 28 (-10dBm)
128  * For simplicity RF230_MIN_RX_POWER is based on the energy-detect value and divided by 3 when autoack is not set.
129  * On the RF230 a reduced rx power threshold will not prevent autoack if enabled and requested.
130  * These numbers applied to both Raven and Jackdaw give a maximum communication distance of about 15 cm
131  * and a 10 meter range to a full-sensitivity RF230 sniffer.
132 #define RF230_MAX_TX_POWER 15
133 #define RF230_MIN_RX_POWER 30
134  */
135  /* The rf231 and atmega128rfa1 can use an rssi threshold for triggering rx_busy that saves 0.5ma in rx mode */
136 /* 1 - 15 maps into -90 to -48 dBm; the register is written with RF230_MIN_RX_POWER/6 + 1. Undefine for -100dBm sensitivity */
137 //#define RF230_MIN_RX_POWER 0
138 
139 /* Network setup. The new NETSTACK interface requires RF230BB (as does ip4) */
140 #if RF230BB
141 /* TX routine passes the cca/ack result in the return parameter */
142 #define RDC_CONF_HARDWARE_ACK 1
143 /* TX routine does automatic cca and optional backoff */
144 #define RDC_CONF_HARDWARE_CSMA 1
145 /* Allow MCU sleeping between channel checks */
146 #define RDC_CONF_MCU_SLEEP 0
147 #endif /*RF230BB */
148 
149 #if NETSTACK_CONF_WITH_IPV6
150 #define LINKADDR_CONF_SIZE 8
151 #define UIP_CONF_ICMP6 1
152 #define UIP_CONF_UDP 1
153 #define UIP_CONF_TCP 1
154 #define UIP_CONF_BUFFER_SIZE 1300
155 #define NETSTACK_CONF_NETWORK sicslowpan_driver
156 #define SICSLOWPAN_CONF_COMPRESSION SICSLOWPAN_COMPRESSION_HC06
157 #else
158 /* ip4 should build but is largely untested */
159 #define LINKADDR_CONF_SIZE 2
160 #define NETSTACK_CONF_NETWORK rime_driver
161 #endif /* NETSTACK_CONF_WITH_IPV6 */
162 
163 #define UIP_CONF_LL_802154 1
164 #define UIP_CONF_LLH_LEN 0
165 
166 /* 10 bytes per stateful address context - see sicslowpan.c */
167 /* Default is 1 context with prefix fd00::/64 */
168 /* These must agree with all the other nodes or there will be a failure to communicate! */
169 #define SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS 1
170 #define SICSLOWPAN_CONF_ADDR_CONTEXT_0 {addr_contexts[0].prefix[0]=UIP_DS6_DEFAULT_PREFIX_0;addr_contexts[0].prefix[1]=UIP_DS6_DEFAULT_PREFIX_1;}
171 #define SICSLOWPAN_CONF_ADDR_CONTEXT_1 {addr_contexts[1].prefix[0]=0xbb;addr_contexts[1].prefix[1]=0xbb;}
172 #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;}
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 #define UIP_CONF_IP_FORWARD 0
179 #define UIP_CONF_FWCACHE_SIZE 0
180 
181 #define UIP_CONF_IPV6_CHECKS 1
182 #define UIP_CONF_IPV6_QUEUE_PKT 1
183 #define UIP_CONF_IPV6_REASSEMBLY 0
184 
185 #define UIP_CONF_UDP_CHECKSUMS 1
186 #define UIP_CONF_TCP_SPLIT 1
187 #define UIP_CONF_DHCP_LIGHT 1
188 
189 #if 1 /* No radio cycling */
190 
191 #define NETSTACK_CONF_MAC nullmac_driver
192 #define NETSTACK_CONF_RDC sicslowmac_driver
193 #define NETSTACK_CONF_FRAMER framer_802154
194 #define NETSTACK_CONF_RADIO rf230_driver
195 #define CHANNEL_802_15_4 26
196 #define RADIO_CONF_CALIBRATE_INTERVAL 256
197 /* AUTOACK receive mode gives better rssi measurements, even if ACK is never requested */
198 #define RF230_CONF_AUTOACK 1
199 /* Number of auto retry attempts+1, 1-16. Set zero to disable extended TX_ARET_ON mode with CCA) */
200 #define RF230_CONF_FRAME_RETRIES 3
201 /* Number of CSMA attempts 0-7. 802.15.4 2003 standard max is 5. */
202 #define RF230_CONF_CSMA_RETRIES 5
203 /* CCA theshold energy -91 to -61 dBm (default -77). Set this smaller than the expected minimum rssi to avoid packet collisions */
204 /* The Jackdaw menu 'm' command is helpful for determining the smallest ever received rssi */
205 #define RF230_CONF_CCA_THRES -85
206 /* Allow 6lowpan fragments (needed for large TCP maximum segment size) */
207 #define SICSLOWPAN_CONF_FRAG 1
208 /* Most browsers reissue GETs after 3 seconds which stops fragment reassembly so a longer MAXAGE does no good */
209 #define SICSLOWPAN_CONF_MAXAGE 3
210 /* How long to wait before terminating an idle TCP connection. Smaller to allow faster sleep. Default is 120 seconds */
211 #define UIP_CONF_WAIT_TIMEOUT 5
212 /* 211 bytes per queue buffer */
213 #define QUEUEBUF_CONF_NUM 8
214 /* 54 bytes per queue ref buffer */
215 #define QUEUEBUF_CONF_REF_NUM 2
216 /* Allocate remaining RAM as desired */
217 /* 30 bytes per TCP connection */
218 /* 6LoWPAN does not do well with concurrent TCP streams, as new browser GETs collide with packets coming */
219 /* from previous GETs, causing decreased throughput, retransmissions, and timeouts. Increase to study this. */
220 /* ACKs to other ports become interleaved with computation-intensive GETs, so ACKs are particularly missed. */
221 /* Increasing the number of packet receive buffers in RAM helps to keep ACKs from being lost */
222 #define UIP_CONF_MAX_CONNECTIONS 4
223 /* 2 bytes per TCP listening port */
224 #define UIP_CONF_MAX_LISTENPORTS 4
225 /* 25 bytes per UDP connection */
226 #define UIP_CONF_UDP_CONNS 10
227 /* See uip-ds6.h */
228 #define NBR_TABLE_CONF_MAX_NEIGHBORS 20
229 #define UIP_CONF_DS6_DEFRT_NBU 2
230 #define UIP_CONF_DS6_PREFIX_NBU 3
231 #define UIP_CONF_MAX_ROUTES 20
232 #define UIP_CONF_DS6_ADDR_NBU 3
233 #define UIP_CONF_DS6_MADDR_NBU 0
234 #define UIP_CONF_DS6_AADDR_NBU 0
235 
236 #elif 1 /* Contiki-mac radio cycling */
237 //#define NETSTACK_CONF_MAC nullmac_driver
238 /* csma needed for burst mode at present. Webserver won't work without it */
239 #define NETSTACK_CONF_MAC csma_driver
240 #define NETSTACK_CONF_RDC contikimac_driver
241 /* Default is two CCA separated by 500 usec */
242 #define NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE 8
243 /* So without the header this needed for RPL mesh to form */
244 #define CONTIKIMAC_FRAMER_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 
250 #if NETSTACK_CONF_WITH_IPV6
251 #define NETSTACK_CONF_FRAMER framer802154
252 #else /* NETSTACK_CONF_WITH_IPV6 */
253 #define NETSTACK_CONF_FRAMER contikimac_framer
254 #endif /* NETSTACK_CONF_WITH_IPV6 */
255 
256 #define NETSTACK_CONF_RADIO rf230_driver
257 #define CHANNEL_802_15_4 26
258 /* The radio needs to interrupt during an rtimer interrupt */
259 #define RTIMER_CONF_NESTED_INTERRUPTS 1
260 #define RF230_CONF_AUTOACK 1
261 /* A 0 here means non-extended mode; 1 means extended mode with no retry, >1 for retrys */
262 #define RF230_CONF_FRAME_RETRIES 1
263 /* A 0 here means cca but no retry, >1= for backoff retrys */
264 #define RF230_CONF_CSMA_RETRIES 1
265 #define SICSLOWPAN_CONF_FRAG 1
266 #define SICSLOWPAN_CONF_MAXAGE 3
267 /* 211 bytes per queue buffer. Contikimac burst mode needs 15 for a 1280 byte MTU */
268 #define QUEUEBUF_CONF_NUM 15
269 /* 54 bytes per queue ref buffer */
270 #define QUEUEBUF_CONF_REF_NUM 2
271 /* Allocate remaining RAM. Not much left due to queuebuf increase */
272 #define UIP_CONF_MAX_CONNECTIONS 2
273 #define UIP_CONF_MAX_LISTENPORTS 2
274 #define UIP_CONF_UDP_CONNS 4
275 #define NBR_TABLE_CONF_MAX_NEIGHBORS 10
276 #define UIP_CONF_DS6_DEFRT_NBU 2
277 #define UIP_CONF_DS6_PREFIX_NBU 2
278 #define UIP_CONF_MAX_ROUTES 4
279 #define UIP_CONF_DS6_ADDR_NBU 3
280 #define UIP_CONF_DS6_MADDR_NBU 0
281 #define UIP_CONF_DS6_AADDR_NBU 0
282 
283 #elif 1 /* cx-mac radio cycling */
284 /* RF230 does clear-channel assessment in extended mode (frame retries>0) */
285 #define RF230_CONF_FRAME_RETRIES 1
286 #if RF230_CONF_FRAME_RETRIES
287 #define NETSTACK_CONF_MAC nullmac_driver
288 #else
289 #define NETSTACK_CONF_MAC csma_driver
290 #endif
291 #define NETSTACK_CONF_RDC cxmac_driver
292 #define NETSTACK_CONF_FRAMER framer_802154
293 #define NETSTACK_CONF_RADIO rf230_driver
294 #define CHANNEL_802_15_4 26
295 #define RF230_CONF_AUTOACK 1
296 #define SICSLOWPAN_CONF_FRAG 1
297 #define SICSLOWPAN_CONF_MAXAGE 3
298 #define CXMAC_CONF_ANNOUNCEMENTS 0
299 #define NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE 8
300 /* 211 bytes per queue buffer. Burst mode will need 15 for a 1280 byte MTU */
301 #define QUEUEBUF_CONF_NUM 15
302 /* 54 bytes per queue ref buffer */
303 #define QUEUEBUF_CONF_REF_NUM 2
304 /* Allocate remaining RAM. Not much left due to queuebuf increase */
305 #define UIP_CONF_MAX_CONNECTIONS 2
306 #define UIP_CONF_MAX_LISTENPORTS 4
307 #define UIP_CONF_UDP_CONNS 5
308 #define NBR_TABLE_CONF_MAX_NEIGHBORS 4
309 #define UIP_CONF_DS6_DEFRT_NBU 2
310 #define UIP_CONF_DS6_PREFIX_NBU 3
311 #define UIP_CONF_MAX_ROUTES 4
312 #define UIP_CONF_DS6_ADDR_NBU 3
313 #define UIP_CONF_DS6_MADDR_NBU 0
314 #define UIP_CONF_DS6_AADDR_NBU 0
315 //Below gives 10% duty cycle, undef for default 5%
316 //#define CXMAC_CONF_ON_TIME (RTIMER_ARCH_SECOND / 80)
317 //Below gives 50% duty cycle
318 //#define CXMAC_CONF_ON_TIME (RTIMER_ARCH_SECOND / 16)
319 
320 
321 #else
322 #error Network configuration not specified!
323 #endif /* Network setup */
324 
325 /* Logging adds 200 bytes to program size */
326 #define LOG_CONF_ENABLED 1
327 
328 /* ************************************************************************** */
329 //#pragma mark RPL Settings
330 /* ************************************************************************** */
331 #if UIP_CONF_IPV6_RPL
332 
333 #define UIP_CONF_ROUTER 1
334 #define UIP_CONF_ND6_SEND_RA 0
335 #define UIP_CONF_ND6_REACHABLE_TIME 600000
336 #define UIP_CONF_ND6_RETRANS_TIMER 10000
337 /* For slow slip connections, to prevent buffer overruns */
338 //#define UIP_CONF_RECEIVE_WINDOW 300
339 #undef UIP_CONF_FWCACHE_SIZE
340 #define UIP_CONF_FWCACHE_SIZE 30
341 #define UIP_CONF_BROADCAST 1
342 #define UIP_ARCH_IPCHKSUM 1
343 #define UIP_CONF_PINGADDRCONF 0
344 #define UIP_CONF_LOGGING 0
345 
346 #endif /* RPL */
347 
348 #define CCIF
349 #define CLIF
350 #ifndef CC_CONF_INLINE
351 #define CC_CONF_INLINE inline
352 #endif
353 
354 /* include the project config */
355 /* PROJECT_CONF_H might be defined in the project Makefile */
356 #ifdef PROJECT_CONF_H
357 #include PROJECT_CONF_H
358 #endif /* PROJECT_CONF_H */
359 
360 #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