Contiki 3.x
platform-conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010, Swedish Institute of Computer Science.
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  */
30 
31 /**
32  * \file
33  * A brief description of what this file is
34  * \author
35  * Joakim Eriksson <joakime@sics.se>
36  */
37 
38 #ifndef PLATFORM_CONF_H_
39 #define PLATFORM_CONF_H_
40 
41 /*
42  * Definitions below are dictated by the hardware and not really
43  * changeable
44  */
45 
46 #ifndef WITH_LCD
47 #define WITH_LCD 0
48 #endif /* 0 */
49 
50 /* CPU target speed in Hz */
51 #define F_CPU 8000000uL // 8MHz by default
52 
53 /* Our clock resolution, this is the same as Unix HZ. */
54 #define CLOCK_CONF_SECOND 128UL
55 
56 #define BAUD2UBR(baud) ((F_CPU/baud))
57 
58 #define CCIF
59 #define CLIF
60 
61 #define HAVE_STDINT_H
62 #define MSP430_MEMCPY_WORKAROUND 1
63 #include "msp430def.h"
64 
65 
66 /* Types for clocks and uip_stats */
67 typedef unsigned short uip_stats_t;
68 typedef unsigned long clock_time_t;
69 typedef unsigned long off_t;
70 
71 /* the low-level radio driver */
72 #define NETSTACK_CONF_RADIO cc2420_driver
73 
74 /*
75  * Definitions below are dictated by the hardware and not really
76  * changeable!
77  */
78 
79 /* DCO speed resynchronization for more robust UART, etc. */
80 /* Not needed from MSP430x5xx since it make use of the FLL */
81 #define DCOSYNCH_CONF_ENABLED 0
82 #define DCOSYNCH_CONF_PERIOD 30
83 
84 #define ROM_ERASE_UNIT_SIZE 512
85 #define XMEM_ERASE_UNIT_SIZE (64*1024L)
86 
87 #define CFS_CONF_OFFSET_TYPE long
88 
89 /* Use the first 64k of external flash for node configuration */
90 #define NODE_ID_XMEM_OFFSET (0 * XMEM_ERASE_UNIT_SIZE)
91 
92 /* Use the second 64k of external flash for codeprop. */
93 #define EEPROMFS_ADDR_CODEPROP (1 * XMEM_ERASE_UNIT_SIZE)
94 
95 #define CFS_XMEM_CONF_OFFSET (2 * XMEM_ERASE_UNIT_SIZE)
96 #define CFS_XMEM_CONF_SIZE (1 * XMEM_ERASE_UNIT_SIZE)
97 
98 #define CFS_RAM_CONF_SIZE 4096
99 
100 /*
101  * SPI bus configuration for the TMote Sky.
102  */
103 
104 /* SPI input/output registers. */
105 #define SPI_TXBUF UCB0TXBUF
106 #define SPI_RXBUF UCB0RXBUF
107 
108  /* USART0 Tx ready? */
109 #define SPI_WAITFOREOTx() while ((UCB0STAT & UCBUSY) != 0)
110  /* USART0 Rx ready? */
111 #define SPI_WAITFOREORx() while ((UCB0IFG & UCRXIFG) == 0)
112  /* USART0 Tx buffer ready? */
113 #define SPI_WAITFORTxREADY() while ((UCB0IFG & UCTXIFG) == 0)
114 
115 #define MOSI 1 /* P3.1 - Output: SPI Master out - slave in (MOSI) */
116 #define MISO 2 /* P3.2 - Input: SPI Master in - slave out (MISO) */
117 #define SCK 3 /* P3.3 - Output: SPI Serial Clock (SCLK) */
118 
119 /*
120  * SPI bus - M25P80 external flash configuration.
121  */
122 //#define FLASH_PWR 3 /* P4.3 Output */ ALWAYS POWERED ON Z1
123 #define FLASH_CS 4 /* P4.4 Output */
124 #define FLASH_HOLD 7 /* P5.7 Output */
125 
126 /* Enable/disable flash access to the SPI bus (active low). */
127 
128 #define SPI_FLASH_ENABLE() ( P4OUT &= ~BV(FLASH_CS) )
129 #define SPI_FLASH_DISABLE() ( P4OUT |= BV(FLASH_CS) )
130 
131 #define SPI_FLASH_HOLD() ( P5OUT &= ~BV(FLASH_HOLD) )
132 #define SPI_FLASH_UNHOLD() ( P5OUT |= BV(FLASH_HOLD) )
133 
134 
135 /*
136  * SPI bus - CC2420 pin configuration.
137  */
138 
139 #define CC2420_CONF_SYMBOL_LOOP_COUNT 1302 /* 326us msp430X @ 8MHz */
140 
141 /* P1.2 - Input: FIFOP from CC2420 */
142 #define CC2420_FIFOP_PORT(type) P1##type
143 #define CC2420_FIFOP_PIN 6
144 /* P1.3 - Input: FIFO from CC2420 */
145 #define CC2420_FIFO_PORT(type) P1##type
146 #define CC2420_FIFO_PIN 5
147 /* P1.4 - Input: CCA from CC2420 */
148 #define CC2420_CCA_PORT(type) P1##type
149 #define CC2420_CCA_PIN 7
150 /* P4.1 - Input: SFD from CC2420 */
151 #define CC2420_SFD_PORT(type) P1##type
152 #define CC2420_SFD_PIN 3
153  /* P3.0 - Output: SPI Chip Select (CS_N) */
154 #define CC2420_CSN_PORT(type) P3##type
155 #define CC2420_CSN_PIN 0
156 /* P4.5 - Output: VREG_EN to CC2420 */
157 #define CC2420_VREG_PORT(type) P1##type
158 #define CC2420_VREG_PIN 4
159 /* P4.6 - Output: RESET_N to CC2420 */
160 #define CC2420_RESET_PORT(type) P1##type
161 #define CC2420_RESET_PIN 2
162 
163 
164 #define CC2420_IRQ_VECTOR PORT1_VECTOR
165 
166 /* Pin status. */
167 #define CC2420_FIFOP_IS_1 (!!(CC2420_FIFOP_PORT(IN) & BV(CC2420_FIFOP_PIN)))
168 #define CC2420_FIFO_IS_1 (!!(CC2420_FIFO_PORT(IN) & BV(CC2420_FIFO_PIN)))
169 #define CC2420_CCA_IS_1 (!!(CC2420_CCA_PORT(IN) & BV(CC2420_CCA_PIN)))
170 #define CC2420_SFD_IS_1 (!!(CC2420_SFD_PORT(IN) & BV(CC2420_SFD_PIN)))
171 
172 /* The CC2420 reset pin. */
173 #define SET_RESET_INACTIVE() (CC2420_RESET_PORT(OUT) |= BV(CC2420_RESET_PIN))
174 #define SET_RESET_ACTIVE() (CC2420_RESET_PORT(OUT) &= ~BV(CC2420_RESET_PIN))
175 
176 /* CC2420 voltage regulator enable pin. */
177 #define SET_VREG_ACTIVE() (CC2420_VREG_PORT(OUT) |= BV(CC2420_VREG_PIN))
178 #define SET_VREG_INACTIVE() (CC2420_VREG_PORT(OUT) &= ~BV(CC2420_VREG_PIN))
179 
180 /* CC2420 rising edge trigger for external interrupt (FIFOP). */
181 #define CC2420_FIFOP_INT_INIT() do { \
182  CC2420_FIFOP_PORT(IES) &= ~BV(CC2420_FIFOP_PIN); \
183  CC2420_CLEAR_FIFOP_INT(); \
184  } while(0)
185 
186 /* FIFOP on external interrupt 0. */
187 #define CC2420_ENABLE_FIFOP_INT() do {CC2420_FIFOP_PORT(IE) |= BV(CC2420_FIFOP_PIN);} while(0)
188 #define CC2420_DISABLE_FIFOP_INT() do {CC2420_FIFOP_PORT(IE) &= ~BV(CC2420_FIFOP_PIN);} while(0)
189 #define CC2420_CLEAR_FIFOP_INT() do {CC2420_FIFOP_PORT(IFG) &= ~BV(CC2420_FIFOP_PIN);} while(0)
190 
191 
192 /*
193  * Enables/disables CC2420 access to the SPI bus (not the bus).
194  * (Chip Select)
195  */
196 
197  /* ENABLE CSn (active low) */
198 #define CC2420_SPI_ENABLE() (CC2420_CSN_PORT(OUT) &= ~BV(CC2420_CSN_PIN))
199  /* DISABLE CSn (active low) */
200 #define CC2420_SPI_DISABLE() (CC2420_CSN_PORT(OUT) |= BV(CC2420_CSN_PIN))
201 #define CC2420_SPI_IS_ENABLED() ((CC2420_CSN_PORT(OUT) & BV(CC2420_CSN_PIN)) != BV(CC2420_CSN_PIN))
202 
203 #endif /* PLATFORM_CONF_H_ */