Contiki 2.6

contiki-conf.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2006, Technical University of Munich
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  * 3. Neither the name of the Institute nor the names of its contributors
00014  *    may be used to endorse or promote products derived from this software
00015  *    without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
00018  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
00021  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00022  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00023  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00024  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00025  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00026  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00027  * SUCH DAMAGE.
00028  *
00029  * This file is part of the Contiki operating system.
00030  *
00031  * @(#)$$
00032  */
00033 
00034 /**
00035  * \file
00036  *         Configuration for Atmel ATmega128rfa1
00037  * \author
00038  *         David Kopf <dak664@embarqmail.com>
00039  */
00040 
00041 #ifndef __CONTIKI_CONF_H__
00042 #define __CONTIKI_CONF_H__
00043 
00044 /* Platform name, type, and MCU clock rate */
00045 #define PLATFORM_NAME  "RFA1"
00046 #define PLATFORM_TYPE  ATMEGA128RFA1
00047 #ifndef F_CPU
00048 #define F_CPU          8000000UL
00049 #endif
00050 
00051 #include <stdint.h>
00052 
00053 /* The AVR tick interrupt usually is done with an 8 bit counter around 128 Hz.
00054  * 125 Hz needs slightly more overhead during the interrupt, as does a 32 bit
00055  * clock_time_t.
00056  */
00057  /* Clock ticks per second */
00058 #define CLOCK_CONF_SECOND 128
00059 #if 1
00060 /* 16 bit counter overflows every ~10 minutes */
00061 typedef unsigned short clock_time_t;
00062 #define CLOCK_LT(a,b)  ((signed short)((a)-(b)) < 0)
00063 #define INFINITE_TIME 0xffff
00064 #define RIME_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME INFINITE_TIME/CLOCK_CONF_SECOND /* Default uses 600 */
00065 #define COLLECT_CONF_BROADCAST_ANNOUNCEMENT_MAX_TIME INFINITE_TIME/CLOCK_CONF_SECOND /* Default uses 600 */
00066 #else
00067 typedef unsigned long clock_time_t;
00068 #define CLOCK_LT(a,b)  ((signed long)((a)-(b)) < 0)
00069 #define INFINITE_TIME 0xffffffff
00070 #endif
00071 /* These routines are not part of the contiki core but can be enabled in cpu/avr/clock.c */
00072 void clock_delay_msec(uint16_t howlong);
00073 void clock_adjust_ticks(clock_time_t howmany);
00074 
00075 /* Michael Hartman's atmega128rfa1 board has an external 32768Hz crystal connected to TOSC1 and 2 pins similar to the Raven 1284p */
00076 /* and theoretically can use TIMER2 with it to keep time. Else TIMER0 is used. */
00077 /* The sleep timer requires the crystal and adds a TIMER2 interrupt routine if not already define by clock.c */
00078 #define AVR_CONF_USE32KCRYSTAL 0
00079 
00080 /* Michael Hartman's protobyte board has LED on PORTE1, used for radio on indication */
00081 /* However this results in disabling UART0. */
00082 #define RF230BB_CONF_LEDONPORTE1  0
00083 
00084 /* COM port to be used for SLIP connection. This is usually UART0, but see above */
00085 #if RF230BB_CONF_LEDONPORTE1
00086 #define SLIP_PORT RS232_PORT_1
00087 #else
00088 #define SLIP_PORT RS232_PORT_0
00089 #endif
00090 
00091 /* Pre-allocated memory for loadable modules heap space (in bytes)*/
00092 /* Default is 4096. Currently used only when elfloader is present. Not tested on Raven */
00093 //#define MMEM_CONF_SIZE 256
00094 
00095 /* Starting address for code received via the codeprop facility. Not tested. */
00096 typedef unsigned long off_t;
00097 //#define EEPROMFS_ADDR_CODEPROP 0x8000
00098 
00099 /* Logging adds 200 bytes to program size. RS232 output slows down webserver. */
00100 //#define LOG_CONF_ENABLED         1
00101 
00102 /* RADIOSTATS is used in rf230bb, clock.c and the webserver cgi to report radio usage */
00103 /* It has less overhead than ENERGEST */
00104 #define RADIOSTATS                1
00105 
00106 /* More extensive stats, via main loop printfs or webserver status pages */
00107 #define ENERGEST_CONF_ON          1
00108 
00109 /* Packet statistics */
00110 typedef unsigned short uip_stats_t;
00111 #define UIP_STATISTICS            0
00112 
00113 /* Available watchdog timeouts depend on mcu. Default is WDTO_2S. -1 Disables the watchdog. */
00114 /* AVR Studio simulator tends to reboot due to clocking the WD 8 times too fast */
00115 //#define WATCHDOG_CONF_TIMEOUT -1
00116 
00117 /* Debugflow macro, useful for tracing path through mac and radio interrupts */
00118 //#define DEBUGFLOWSIZE 128
00119 
00120 
00121 /* Define MAX_*X_POWER to reduce tx power and ignore weak rx packets for testing a miniature multihop network.
00122  * Leave undefined for full power and sensitivity.
00123  * tx=0 (3dbm, default) to 15 (-17.2dbm)
00124  * RF230_CONF_AUTOACK sets the extended mode using the energy-detect register with rx=0 (-91dBm) to 84 (-7dBm)
00125  *   else the rssi register is used having range 0 (91dBm) to 28 (-10dBm)
00126  *   For simplicity RF230_MIN_RX_POWER is based on the energy-detect value and divided by 3 when autoack is not set.
00127  * On the RF230 a reduced rx power threshold will not prevent autoack if enabled and requested.
00128  * These numbers applied to both Raven and Jackdaw give a maximum communication distance of about 15 cm
00129  * and a 10 meter range to a full-sensitivity RF230 sniffer.
00130 #define RF230_MAX_TX_POWER 15
00131 #define RF230_MIN_RX_POWER 30
00132  */
00133   /* The rf231 and atmega128rfa1 can use an rssi threshold for triggering rx_busy that saves 0.5ma in rx mode */
00134 /* 1 - 15 maps into -90 to -48 dBm; the register is written with RF230_MIN_RX_POWER/6 + 1. Undefine for -100dBm sensitivity */
00135 //#define RF230_MIN_RX_POWER        0
00136 
00137 /* Network setup */
00138 /* TX routine passes the cca/ack result in the return parameter */
00139 #define RDC_CONF_HARDWARE_ACK    1
00140 /* TX routine does automatic cca and optional backoff */
00141 #define RDC_CONF_HARDWARE_CSMA   1
00142 /* Allow MCU sleeping between channel checks */
00143 #define RDC_CONF_MCU_SLEEP         1
00144 
00145 #if UIP_CONF_IPV6
00146 #define RIMEADDR_CONF_SIZE        8
00147 #define UIP_CONF_ICMP6            1
00148 #define UIP_CONF_UDP              1
00149 #define UIP_CONF_TCP              1
00150 #define NETSTACK_CONF_NETWORK     sicslowpan_driver
00151 #define SICSLOWPAN_CONF_COMPRESSION SICSLOWPAN_COMPRESSION_HC06
00152 #else
00153 /* ip4 should build but is largely untested */
00154 #define RIMEADDR_CONF_SIZE        2
00155 #define NETSTACK_CONF_NETWORK     rime_driver
00156 #endif
00157 
00158 #define UIP_CONF_LL_802154        1
00159 #define UIP_CONF_LLH_LEN          0
00160 
00161 /* 10 bytes per stateful address context - see sicslowpan.c */
00162 /* Default is 1 context with prefix aaaa::/64 */
00163 /* These must agree with all the other nodes or there will be a failure to communicate! */
00164 #define SICSLOWPAN_CONF_MAX_ADDR_CONTEXTS 1
00165 #define SICSLOWPAN_CONF_ADDR_CONTEXT_0 {addr_contexts[0].prefix[0]=0xaa;addr_contexts[0].prefix[1]=0xaa;}
00166 #define SICSLOWPAN_CONF_ADDR_CONTEXT_1 {addr_contexts[1].prefix[0]=0xbb;addr_contexts[1].prefix[1]=0xbb;}
00167 #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;}
00168 
00169 /* Take the default TCP maximum segment size for efficiency and simpler wireshark captures */
00170 /* Use this to prevent 6LowPAN fragmentation (whether or not fragmentation is enabled) */
00171 //#define UIP_CONF_TCP_MSS       48
00172 
00173 #define UIP_CONF_IP_FORWARD      0
00174 #define UIP_CONF_FWCACHE_SIZE    0
00175 
00176 #define UIP_CONF_IPV6_CHECKS     1
00177 #define UIP_CONF_IPV6_QUEUE_PKT  1
00178 #define UIP_CONF_IPV6_REASSEMBLY 0
00179 
00180 #define UIP_CONF_UDP_CHECKSUMS   1
00181 #define UIP_CONF_TCP_SPLIT       1
00182 #define UIP_CONF_DHCP_LIGHT      1
00183 
00184 
00185 #if 1 /* No radio cycling */
00186 
00187 #define NETSTACK_CONF_MAC         nullmac_driver
00188 #define NETSTACK_CONF_RDC         sicslowmac_driver
00189 #define NETSTACK_CONF_FRAMER      framer_802154
00190 #define NETSTACK_CONF_RADIO       rf230_driver
00191 #define CHANNEL_802_15_4          26
00192 /* AUTOACK receive mode gives better rssi measurements, even if ACK is never requested */
00193 #define RF230_CONF_AUTOACK        1
00194 /* Request 802.15.4 ACK on all packets sent (else autoretry). This is primarily for testing. */
00195 #define SICSLOWPAN_CONF_ACK_ALL   0
00196 /* Number of auto retry attempts 0-15 (0 implies don't use extended TX_ARET_ON mode with CCA) */
00197 #define RF230_CONF_AUTORETRIES    2
00198 /* Default is one RAM buffer for received packets. More than one may benefit multiple TCP connections or ports */
00199 #define RF230_CONF_RX_BUFFERS     3
00200 #define SICSLOWPAN_CONF_FRAG      1
00201 /* Most browsers reissue GETs after 3 seconds which stops fragment reassembly so a longer MAXAGE does no good */
00202 #define SICSLOWPAN_CONF_MAXAGE    3
00203 /* How long to wait before terminating an idle TCP connection. Smaller to allow faster sleep. Default is 120 seconds */
00204 /* If wait is too short the connection can be reset as a result of multiple fragment reassembly timeouts */
00205 #define UIP_CONF_WAIT_TIMEOUT    20
00206 /* 211 bytes per queue buffer */
00207 #define QUEUEBUF_CONF_NUM         8
00208 /* 54 bytes per queue ref buffer */
00209 #define QUEUEBUF_CONF_REF_NUM     2
00210 /* Allocate remaining RAM as desired */
00211 /* 30 bytes per TCP connection */
00212 /* 6LoWPAN does not do well with concurrent TCP streams, as new browser GETs collide with packets coming */
00213 /* from previous GETs, causing decreased throughput, retransmissions, and timeouts. Increase to study this. */
00214 /* ACKs to other ports become interleaved with computation-intensive GETs, so ACKs are particularly missed. */
00215 /* Increasing the number of packet receive buffers in RAM helps to keep ACKs from being lost */
00216 #define UIP_CONF_MAX_CONNECTIONS  4
00217 /* 2 bytes per TCP listening port */
00218 #define UIP_CONF_MAX_LISTENPORTS  4
00219 /* 25 bytes per UDP connection */
00220 #define UIP_CONF_UDP_CONNS       10
00221 /* See uip-ds6.h */
00222 #define UIP_CONF_DS6_NBR_NBU      20
00223 #define UIP_CONF_DS6_DEFRT_NBU    2
00224 #define UIP_CONF_DS6_PREFIX_NBU   3
00225 #define UIP_CONF_DS6_ROUTE_NBU    20
00226 #define UIP_CONF_DS6_ADDR_NBU     3
00227 #define UIP_CONF_DS6_MADDR_NBU    0
00228 #define UIP_CONF_DS6_AADDR_NBU    0
00229 
00230 
00231 #elif 1  /* Contiki-mac radio cycling */
00232 //#define NETSTACK_CONF_MAC         nullmac_driver
00233 /* csma needed for burst mode at present. Webserver won't work without it */
00234 #define NETSTACK_CONF_MAC         csma_driver
00235 #define NETSTACK_CONF_RDC         contikimac_driver
00236 /* Default is two CCA separated by 500 usec */
00237 #define NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE   8
00238 /* Wireshark won't decode with the header, but padded packets will fail ipv6 checksum */
00239 #define CONTIKIMAC_CONF_WITH_CONTIKIMAC_HEADER 0
00240 /* So without the header this needed for RPL mesh to form */
00241 #define CONTIKIMAC_CONF_SHORTEST_PACKET_SIZE   43-18  //multicast RPL DIS length
00242 /* Not tested much yet */
00243 #define WITH_PHASE_OPTIMIZATION                0
00244 #define CONTIKIMAC_CONF_COMPOWER               1
00245 #define RIMESTATS_CONF_ON                      1
00246 #define NETSTACK_CONF_FRAMER      framer_802154
00247 #define NETSTACK_CONF_RADIO       rf230_driver
00248 #define CHANNEL_802_15_4          26
00249 /* The radio needs to interrupt during an rtimer interrupt */
00250 #define RTIMER_CONF_NESTED_INTERRUPTS 1
00251 #define RF230_CONF_AUTOACK        1
00252 /* A 0 here means non-extended mode; 1 means extended mode with no retry, >1 for retrys */
00253 #define RF230_CONF_AUTORETRIES    1
00254 /* A 0 here means no cca; 1 means extended mode with cca but no retry, >1 for backoff retrys */
00255 #define RF230_CONF_CSMARETRIES    1
00256 #define SICSLOWPAN_CONF_FRAG      1
00257 #define SICSLOWPAN_CONF_MAXAGE    3
00258 /* 211 bytes per queue buffer. Contikimac burst mode needs 15 for a 1280 byte MTU */
00259 #define QUEUEBUF_CONF_NUM         15
00260 /* 54 bytes per queue ref buffer */
00261 #define QUEUEBUF_CONF_REF_NUM     2
00262 /* Allocate remaining RAM. Not much left due to queuebuf increase  */
00263 #define UIP_CONF_MAX_CONNECTIONS  2
00264 #define UIP_CONF_MAX_LISTENPORTS  4
00265 #define UIP_CONF_UDP_CONNS        5
00266 #define UIP_CONF_DS6_NBR_NBU      4
00267 #define UIP_CONF_DS6_DEFRT_NBU    2
00268 #define UIP_CONF_DS6_PREFIX_NBU   3
00269 #define UIP_CONF_DS6_ROUTE_NBU    4
00270 #define UIP_CONF_DS6_ADDR_NBU     3
00271 #define UIP_CONF_DS6_MADDR_NBU    0
00272 #define UIP_CONF_DS6_AADDR_NBU    0
00273 
00274 
00275 #elif 1  /* cx-mac radio cycling */
00276 /* RF230 does clear-channel assessment in extended mode (autoretries>0) */
00277 #define RF230_CONF_AUTORETRIES    1
00278 #if RF230_CONF_AUTORETRIES
00279 #define NETSTACK_CONF_MAC         nullmac_driver
00280 #else
00281 #define NETSTACK_CONF_MAC         csma_driver
00282 #endif
00283 #define NETSTACK_CONF_RDC         cxmac_driver
00284 #define NETSTACK_CONF_FRAMER      framer_802154
00285 #define NETSTACK_CONF_RADIO       rf230_driver
00286 #define CHANNEL_802_15_4          26
00287 #define RF230_CONF_AUTOACK        1
00288 #define SICSLOWPAN_CONF_FRAG      1
00289 #define SICSLOWPAN_CONF_MAXAGE    3
00290 #define CXMAC_CONF_ANNOUNCEMENTS  0
00291 #define NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE 8
00292 /* 211 bytes per queue buffer. Burst mode will need 15 for a 1280 byte MTU */
00293 #define QUEUEBUF_CONF_NUM         15
00294 /* 54 bytes per queue ref buffer */
00295 #define QUEUEBUF_CONF_REF_NUM     2
00296 /* Allocate remaining RAM. Not much left due to queuebuf increase  */
00297 #define UIP_CONF_MAX_CONNECTIONS  2
00298 #define UIP_CONF_MAX_LISTENPORTS  4
00299 #define UIP_CONF_UDP_CONNS        5
00300 #define UIP_CONF_DS6_NBR_NBU      4
00301 #define UIP_CONF_DS6_DEFRT_NBU    2
00302 #define UIP_CONF_DS6_PREFIX_NBU   3
00303 #define UIP_CONF_DS6_ROUTE_NBU    4
00304 #define UIP_CONF_DS6_ADDR_NBU     3
00305 #define UIP_CONF_DS6_MADDR_NBU    0
00306 #define UIP_CONF_DS6_AADDR_NBU    0
00307 //Below gives 10% duty cycle, undef for default 5%
00308 //#define CXMAC_CONF_ON_TIME (RTIMER_ARCH_SECOND / 80)
00309 //Below gives 50% duty cycle
00310 //#define CXMAC_CONF_ON_TIME (RTIMER_ARCH_SECOND / 16)
00311 
00312 #else
00313 #error Network configuration not specified!
00314 #endif   /* Network setup */
00315 
00316 /* ************************************************************************** */
00317 //#pragma mark RPL Settings
00318 /* ************************************************************************** */
00319 #if UIP_CONF_IPV6_RPL
00320 
00321 #define UIP_CONF_ROUTER                 1
00322 #define UIP_CONF_ND6_SEND_RA                0
00323 #define UIP_CONF_ND6_REACHABLE_TIME     600000
00324 #define UIP_CONF_ND6_RETRANS_TIMER      10000
00325 
00326 /* For slow slip connections, to prevent buffer overruns */
00327 //#define UIP_CONF_RECEIVE_WINDOW 300
00328 #undef UIP_CONF_FWCACHE_SIZE
00329 #define UIP_CONF_FWCACHE_SIZE    30
00330 #define UIP_CONF_BROADCAST       1
00331 #define UIP_ARCH_IPCHKSUM        1
00332 #define UIP_CONF_PINGADDRCONF    0
00333 #define UIP_CONF_LOGGING         0
00334 
00335 #endif /* RPL */
00336 
00337 #define CCIF
00338 #define CLIF
00339 
00340 /* include the project config */
00341 /* PROJECT_CONF_H might be defined in the project Makefile */
00342 #ifdef PROJECT_CONF_H
00343 #include PROJECT_CONF_H
00344 #endif
00345 
00346 #endif /* __CONTIKI_CONF_H__ */