Contiki 2.5
contiki-conf.h
1 /* -*- C -*- */
2 /* @(#)$Id: contiki-conf.h,v 1.5 2010/06/22 06:39:44 joxe Exp $ */
3 
4 #ifndef CONTIKI_CONF_H
5 #define CONTIKI_CONF_H
6 
7 #include <avr/interrupt.h>
8 
9 #define HAVE_STDINT_H
10 #include "avrdef.h"
11 
12 /* #define CB_GATEWAY */
13 
14 #define CCIF
15 #define CLIF
16 
17 #define AODV_COMPLIANCE
18 #define AODV_NUM_RT_ENTRIES 32
19 
20 void clock_delay(unsigned int us2);
21 void clock_wait(int ms10);
22 void clock_set_seconds(unsigned long s);
23 unsigned long clock_seconds(void);
24 
25 #define WITH_UIP 1
26 #define WITH_ASCII 1
27 
28 #define PROCESS_CONF_FASTPOLL 4
29 
30 /* Our clock resolution, this is the same as Unix HZ. */
31 /* Fix clock.c XXX/bg */
32 #define CLOCK_CONF_SECOND 62
33 
34 /* CPU target speed in Hz */
35 #define F_CPU 8000000L
36 
37 /* The +1 and divide by 2 is to achieve rounding. */
38 #define BAUD2UBR(baud) ((u16_t)((F_CPU/baud/8uL + 1)/2 - 1))
39 
40 /* UART configs */
41 //#define MCU_MHZ 8
42 //#define MCU atmega128
43 //#define SLIP_PORT RS232_PORT_1
44 
45 
46 #define UIP_CONF_DHCP_LIGHT
47 #define UIP_CONF_LLH_LEN 0
48 #define UIP_CONF_BUFFER_SIZE 116
49 #define UIP_CONF_RECEIVE_WINDOW (UIP_CONF_BUFFER_SIZE - 40)
50 #define UIP_CONF_MAX_CONNECTIONS 4
51 #define UIP_CONF_MAX_LISTENPORTS 8
52 #define UIP_CONF_UDP_CONNS 12
53 #define UIP_CONF_FWCACHE_SIZE 30
54 #define UIP_CONF_BROADCAST 1
55 //#define UIP_ARCH_IPCHKSUM 1
56 #define UIP_CONF_UDP_CHECKSUMS 1
57 #define UIP_CONF_PINGADDRCONF 0
58 #define UIP_CONF_LOGGING 0
59 
60 /*
61  * Definitions below are dictated by the hardware and not really
62  * changeable!
63  */
64 
65 #ifdef CB_GATEWAY
66 /* LED port E */
67 #define LEDS_CONF_GREEN _BV(2) /* PE.2 - Output */
68 #define LEDS_CONF_YELLOW _BV(3) /* PE.3 - Output */
69 #else
70 #define LEDS_ORANGE 8
71 /* LED port B */
72 #define LEDS_CONF_ORANGE _BV(4) /* PB.4 - Output */
73 #define LEDS_CONF_GREEN _BV(7) /* PB.7 - Output */
74 /* LED port E */
75 #define LEDS_CONF_RED _BV(3) /* PE.3 - Output */
76 #define LEDS_CONF_YELLOW _BV(4) /* PE.4 - Output */
77 #endif
78 
79 typedef u16_t uip_stats_t;
80 typedef u16_t clock_time_t;
81 
82 typedef u32_t off_t;
83 #define ROM_ERASE_UNIT_SIZE SPM_PAGESIZE
84 #define XMEM_ERASE_UNIT_SIZE 8
85 
86 /* Use the first 64k of external flash for codeprop. */
87 #define EEPROMFS_ADDR_CODEPROP (128 * XMEM_ERASE_UNIT_SIZE)
88 
89 #define CC2420_RADIO
90 /* LOOP count for waiting 20 symbols in the CC2420 code */
91 #define CC2420_CONF_SYMBOL_LOOP_COUNT 500
92 /*
93  * SPI bus configuration for the CC2420DBK.
94  */
95 
96 /* SPI input/output registers. */
97 #define SPI_TXBUF SPDR
98 #define SPI_RXBUF SPDR
99 
100 #define BV(bitno) _BV(bitno)
101 
102 #define SPI_WAITFOREOTx() do { while (!(SPSR & BV(SPIF))); } while (0)
103 #define SPI_WAITFOREORx() do { while (!(SPSR & BV(SPIF))); } while (0)
104 
105 #define SCK 1 /* - Output: SPI Serial Clock (SCLK) */
106 #define MOSI 2 /* - Output: SPI Master out - slave in (MOSI) */
107 #define MISO 3 /* - Input: SPI Master in - slave out (MISO) */
108 
109 /*
110  * SPI bus - CC2420 pin configuration.
111  */
112 
113 #define FIFO_P 0 /* - Input: FIFOP from CC2420 */
114 #define FIFO 1 /* - Input: FIFO from CC2420 */
115 #define CCA 6 /* - Input: CCA from CC2420 */
116 
117 #define SFD 4 /* - Input: SFD from CC2420 */
118 #define CSN 0 /* - Output: SPI Chip Select (CS_N) */
119 #define VREG_EN 5 /* - Output: VREG_EN to CC2420 */
120 #define RESET_N 6 /* - Output: RESET_N to CC2420 */
121 
122 /* Pin status. */
123 
124 #define FIFO_IS_1 (!!(PIND & BV(FIFO)))
125 #define CCA_IS_1 (!!(PIND & BV(CCA) ))
126 #define RESET_IS_1 (!!(PINB & BV(RESET_N)))
127 #define VREG_IS_1 (!!(PINB & BV(VREG_EN)))
128 #define FIFOP_IS_1 (!!(PIND & BV(FIFO_P)))
129 #define SFD_IS_1 (!!(PIND & BV(SFD)))
130 
131 /* The CC2420 reset pin. */
132 #define SET_RESET_INACTIVE() ( PORTB |= BV(RESET_N) )
133 #define SET_RESET_ACTIVE() ( PORTB &= ~BV(RESET_N) )
134 
135 /* CC2420 voltage regulator enable pin. */
136 #define SET_VREG_ACTIVE() ( PORTB |= BV(VREG_EN) )
137 #define SET_VREG_INACTIVE() ( PORTB &= ~BV(VREG_EN) )
138 
139 /* CC2420 rising edge trigger for external interrupt 0 (FIFOP). */
140 #define FIFOP_INT_INIT() do {\
141  EICRA |= 0x03; \
142  CLEAR_FIFOP_INT(); \
143 } while (0)
144 
145 /* FIFOP on external interrupt 0. */
146 #define ENABLE_FIFOP_INT() do { EIMSK |= 0x01; } while (0)
147 #define DISABLE_FIFOP_INT() do { EIMSK &= ~0x01; } while (0)
148 #define CLEAR_FIFOP_INT() do { EIFR = 0x01; } while (0)
149 
150 /* Enables/disables CC2420 access to the SPI bus (not the bus).
151  *
152  * These guys should really be renamed but are compatible with the
153  * original Chipcon naming.
154  *
155  * SPI_CC2420_ENABLE/SPI_CC2420_DISABLE???
156  * CC2420_ENABLE_SPI/CC2420_DISABLE_SPI???
157  */
158 
159 #define SPI_ENABLE() ( PORTB &= ~BV(CSN) ) /* ENABLE CSn (active low) */
160 #define SPI_DISABLE() ( PORTB |= BV(CSN) ) /* DISABLE CSn (active low) */
161 
162 #endif /* CONTIKI_CONF_H */