contiki-conf.h

00001 /* -*- C -*- */
00002 /* @(#)$Id: contiki-conf.h,v 1.5 2010/06/22 06:39:44 joxe Exp $ */
00003 
00004 #ifndef CONTIKI_CONF_H
00005 #define CONTIKI_CONF_H
00006 
00007 #include <avr/interrupt.h>
00008 
00009 #define HAVE_STDINT_H
00010 #include "avrdef.h"
00011 
00012 /* #define CB_GATEWAY */
00013 
00014 #define CCIF
00015 #define CLIF
00016 
00017 #define AODV_COMPLIANCE
00018 #define AODV_NUM_RT_ENTRIES 32
00019 
00020 void clock_delay(unsigned int us2);
00021 void clock_wait(int ms10);
00022 void clock_set_seconds(unsigned long s);
00023 unsigned long clock_seconds(void);
00024 
00025 #define WITH_UIP 1
00026 #define WITH_ASCII 1
00027 
00028 #define PROCESS_CONF_FASTPOLL    4
00029 
00030 /* Our clock resolution, this is the same as Unix HZ. */
00031 /* Fix clock.c XXX/bg */
00032 #define CLOCK_CONF_SECOND 62
00033 
00034 /* CPU target speed in Hz */
00035 #define F_CPU 8000000L
00036 
00037 /* The +1 and divide by 2 is to achieve rounding. */
00038 #define BAUD2UBR(baud) ((u16_t)((F_CPU/baud/8uL + 1)/2 - 1))
00039 
00040 /* UART configs */
00041 //#define MCU_MHZ 8
00042 //#define MCU atmega128
00043 //#define SLIP_PORT RS232_PORT_1
00044 
00045 
00046 #define UIP_CONF_DHCP_LIGHT
00047 #define UIP_CONF_LLH_LEN         0
00048 #define UIP_CONF_BUFFER_SIZE     116
00049 #define UIP_CONF_RECEIVE_WINDOW  (UIP_CONF_BUFFER_SIZE - 40)
00050 #define UIP_CONF_MAX_CONNECTIONS 4
00051 #define UIP_CONF_MAX_LISTENPORTS 8
00052 #define UIP_CONF_UDP_CONNS       12
00053 #define UIP_CONF_FWCACHE_SIZE    30
00054 #define UIP_CONF_BROADCAST       1
00055 //#define UIP_ARCH_IPCHKSUM        1
00056 #define UIP_CONF_UDP_CHECKSUMS   1
00057 #define UIP_CONF_PINGADDRCONF    0
00058 #define UIP_CONF_LOGGING         0
00059 
00060 /*
00061  * Definitions below are dictated by the hardware and not really
00062  * changeable!
00063  */
00064 
00065 #ifdef CB_GATEWAY
00066 /* LED port E */
00067 #define LEDS_CONF_GREEN  _BV(2) /* PE.2 - Output */
00068 #define LEDS_CONF_YELLOW _BV(3) /* PE.3 - Output */
00069 #else
00070 #define LEDS_ORANGE 8
00071 /* LED port B */
00072 #define LEDS_CONF_ORANGE _BV(4) /* PB.4 - Output */
00073 #define LEDS_CONF_GREEN  _BV(7) /* PB.7 - Output */
00074 /* LED port E */
00075 #define LEDS_CONF_RED    _BV(3) /* PE.3 - Output */
00076 #define LEDS_CONF_YELLOW _BV(4) /* PE.4 - Output */
00077 #endif
00078 
00079 typedef u16_t uip_stats_t;
00080 typedef u16_t clock_time_t;
00081 
00082 typedef u32_t off_t;
00083 #define ROM_ERASE_UNIT_SIZE  SPM_PAGESIZE
00084 #define XMEM_ERASE_UNIT_SIZE 8
00085 
00086 /* Use the first 64k of external flash for codeprop. */
00087 #define EEPROMFS_ADDR_CODEPROP  (128 * XMEM_ERASE_UNIT_SIZE)
00088 
00089 #define CC2420_RADIO
00090 /* LOOP count for waiting 20 symbols in the CC2420 code */
00091 #define CC2420_CONF_SYMBOL_LOOP_COUNT 500
00092 /*
00093  * SPI bus configuration for the CC2420DBK.
00094  */
00095 
00096 /* SPI input/output registers. */
00097 #define SPI_TXBUF SPDR
00098 #define SPI_RXBUF SPDR
00099 
00100 #define BV(bitno) _BV(bitno)
00101 
00102 #define SPI_WAITFOREOTx() do { while (!(SPSR & BV(SPIF))); } while (0)
00103 #define SPI_WAITFOREORx() do { while (!(SPSR & BV(SPIF))); } while (0)
00104 
00105 #define SCK            1  /* - Output: SPI Serial Clock (SCLK) */
00106 #define MOSI           2  /* - Output: SPI Master out - slave in (MOSI) */
00107 #define MISO           3  /* - Input:  SPI Master in - slave out (MISO) */
00108 
00109 /*
00110  * SPI bus - CC2420 pin configuration.
00111  */
00112 
00113 #define FIFO_P         0  /* - Input: FIFOP from CC2420 */
00114 #define FIFO           1  /* - Input: FIFO from CC2420 */
00115 #define CCA            6  /* - Input: CCA from CC2420 */
00116 
00117 #define SFD            4  /* - Input:  SFD from CC2420 */
00118 #define CSN            0  /* - Output: SPI Chip Select (CS_N) */
00119 #define VREG_EN        5  /* - Output: VREG_EN to CC2420 */
00120 #define RESET_N        6  /* - Output: RESET_N to CC2420 */
00121 
00122 /* Pin status. */
00123 
00124 #define FIFO_IS_1       (!!(PIND & BV(FIFO)))
00125 #define CCA_IS_1        (!!(PIND & BV(CCA) ))
00126 #define RESET_IS_1      (!!(PINB & BV(RESET_N)))
00127 #define VREG_IS_1       (!!(PINB & BV(VREG_EN)))
00128 #define FIFOP_IS_1      (!!(PIND & BV(FIFO_P)))
00129 #define SFD_IS_1        (!!(PIND & BV(SFD)))
00130 
00131 /* The CC2420 reset pin. */
00132 #define SET_RESET_INACTIVE()    ( PORTB |= BV(RESET_N) )    
00133 #define SET_RESET_ACTIVE()      ( PORTB &= ~BV(RESET_N) )
00134 
00135 /* CC2420 voltage regulator enable pin. */
00136 #define SET_VREG_ACTIVE()       ( PORTB |= BV(VREG_EN) )
00137 #define SET_VREG_INACTIVE()     ( PORTB &= ~BV(VREG_EN) )
00138 
00139 /* CC2420 rising edge trigger for external interrupt 0 (FIFOP). */
00140 #define FIFOP_INT_INIT() do {\
00141   EICRA |= 0x03; \
00142   CLEAR_FIFOP_INT(); \
00143 } while (0)
00144 
00145 /* FIFOP on external interrupt 0. */
00146 #define ENABLE_FIFOP_INT()          do { EIMSK |= 0x01; } while (0)
00147 #define DISABLE_FIFOP_INT()         do { EIMSK &= ~0x01; } while (0)
00148 #define CLEAR_FIFOP_INT()           do { EIFR = 0x01; } while (0)
00149 
00150 /* Enables/disables CC2420 access to the SPI bus (not the bus).
00151  *
00152  * These guys should really be renamed but are compatible with the
00153  * original Chipcon naming.
00154  *
00155  * SPI_CC2420_ENABLE/SPI_CC2420_DISABLE???
00156  * CC2420_ENABLE_SPI/CC2420_DISABLE_SPI???
00157  */
00158 
00159 #define SPI_ENABLE()    ( PORTB &= ~BV(CSN) ) /* ENABLE CSn (active low) */
00160 #define SPI_DISABLE()   ( PORTB |=  BV(CSN) ) /* DISABLE CSn (active low) */
00161 
00162 #endif /* CONTIKI_CONF_H */

Generated on Mon Apr 11 14:23:41 2011 for Contiki 2.5 by  doxygen 1.6.1