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