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