Contiki 3.x
platform-conf.h
Go to the documentation of this file.
1 
2 /*
3  * Copyright (c) 2010, Swedish Institute of Computer Science.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  * 3. Neither the name of the Institute nor the names of its contributors
15  * may be used to endorse or promote products derived from this software
16  * without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  */
30 
31 /**
32  * \file
33  * Platform configuration for the Z1-feshie platform
34  * \author
35  * Joakim Eriksson <joakime@sics.se>
36  */
37 
38 #ifndef __PLATFORM_CONF_H__
39 #define __PLATFORM_CONF_H__
40 
41 #define SPI_LOCKING
42 //#define LOCKING_DEBUG
43 #ifdef LOCKING_DEBUG
44  #include <stdio.h>
45  #define LPRINT(...) printf(__VA_ARGS__)
46 #else
47  #define LPRINT(...)
48 #endif
49 /*
50  * Definitions below are dictated by the hardware and not really
51  * changeable!
52  */
53 #define ZOLERTIA_Z1 1 /* Enric */
54 
55 #define PLATFORM_HAS_LEDS 1
56 #define PLATFORM_HAS_BUTTON 1
57 
58 /* CPU target speed in Hz */
59 #define F_CPU 8000000uL /* 8MHz by default */
60 //Enric #define F_CPU 3900000uL /*2457600uL*/
61 
62 /* Our clock resolution, this is the same as Unix HZ. */
63 #define CLOCK_CONF_SECOND 128UL
64 
65 #define BAUD2UBR(baud) ((F_CPU/baud))
66 
67 #define CCIF
68 #define CLIF
69 
70 #define HAVE_STDINT_H
71 #include "msp430def.h"
72 
73 /* XXX Temporary place for defines that are lacking in mspgcc4's gpio.h */
74 #ifdef __IAR_SYSTEMS_ICC__
75 #ifndef P1SEL2_
76 #define P1SEL2_ (0x0041u) /* Port 1 Selection 2*/
77 DEFC( P1SEL2 , P1SEL2_)
78 #endif
79 #ifndef P5SEL2_
80 #define P5SEL2_ (0x0045u) /* Port 5 Selection 2*/
81 DEFC( P5SEL2 , P5SEL2_)
82 #endif
83 #else /* __IAR_SYSTEMS_ICC__ */
84 #ifdef __GNUC__
85 #ifndef P1SEL2_
86  #define P1SEL2_ 0x0041 /* Port 1 Selection 2*/
87  sfrb(P1SEL2, P1SEL2_);
88 #endif
89 #ifndef P5SEL2_
90  #define P5SEL2_ 0x0045 /* Port 5 Selection 2*/
91  sfrb(P5SEL2, P5SEL2_);
92 #endif
93 #endif /* __GNUC__ */
94 #endif /* __IAR_SYSTEMS_ICC__ */
95 
96 /* Types for clocks and uip_stats */
97 typedef unsigned short uip_stats_t;
98 typedef unsigned long clock_time_t;
99 typedef unsigned long off_t;
100 
101 /* the low-level radio driver */
102 //#define NETSTACK_CONF_RADIO cc1120_driver
103 
104 /*
105  * Definitions below are dictated by the hardware and not really
106  * changeable!
107  */
108 
109 /* LED ports */
110 #define LEDS_PxDIR P5DIR
111 #define LEDS_PxOUT P5OUT
112 #define LEDS_CONF_RED 0x10
113 #define LEDS_CONF_GREEN 0x40
114 #define LEDS_CONF_YELLOW 0x20
115 
116 /* DCO speed resynchronization for more robust UART, etc. */
117 #define DCOSYNCH_CONF_ENABLED 0
118 #define DCOSYNCH_CONF_PERIOD 30
119 
120 #define ROM_ERASE_UNIT_SIZE 512
121 #define XMEM_ERASE_UNIT_SIZE (64*1024L)
122 
123 
124 #define CFS_CONF_OFFSET_TYPE long
125 
126 /* Use the first 64k of external flash for node configuration */
127 #define NODE_ID_XMEM_OFFSET (0 * XMEM_ERASE_UNIT_SIZE)
128 #define RESET_COUNTER_XMEM_OFFSET (1 * XMEM_ERASE_UNIT_SIZE)
129 
130 /* Use the second 64k of external flash for codeprop. */
131 #define EEPROMFS_ADDR_CODEPROP (2 * XMEM_ERASE_UNIT_SIZE)
132 
133 #define CFS_XMEM_CONF_OFFSET (3 * XMEM_ERASE_UNIT_SIZE)
134 #define CFS_XMEM_CONF_SIZE (1 * XMEM_ERASE_UNIT_SIZE)
135 
136 #define CFS_RAM_CONF_SIZE 4096
137 
138 
139 
140 /* **************************************************************************** */
141 /* ------------------------------- SPI Related -------------------------------- */
142 /* **************************************************************************** */
143 #define SPI_TXBUF UCB0TXBUF
144 #define SPI_RXBUF UCB0RXBUF
145 
146 /* USART0 Tx ready? */
147 #define SPI_WAITFOREOTx() while ((UCB0STAT & UCBUSY) != 0)
148 
149 /* USART0 Rx ready? */
150 #define SPI_WAITFOREORx() while ((IFG2 & UCB0RXIFG) == 0)
151 
152 /* USART0 Tx buffer ready? */
153 #define SPI_WAITFORTxREADY() while ((IFG2 & UCB0TXIFG) == 0)
154 
155 #define MOSI 1 /* P3.1 - Output: SPI Master out - slave in (MOSI) */
156 #define MISO 2 /* P3.2 - Input: SPI Master in - slave out (MISO) */
157 #define SCK 3 /* P3.3 - Output: SPI Serial Clock (SCLK) */
158 
159 
160 
161 /* **************************************************************************** */
162 /* ------------------------------- MS1 Related -------------------------------- */
163 /* **************************************************************************** */
164 
165 #define SENSE_EN_PORT(type) P4##type /* Sense enable Pin. */
166 #define SENSE_EN_PIN 0
167 
168 #define RADIO_EN_PORT(type) P4##type /* Radio power enable Pin. */
169 #define RADIO_EN_PIN 2
170 
171 #define RS485_TXEN_PORT(type) P2##type /* TX Enable pin for RS485 Driver. */
172 #define RS485_TXEN_PIN 3
173 
174 #define UART1_RX_PORT(type) P3##type /* UART1 RX Pin. */
175 #define UART1_RX_PIN 7
176 
177 #define UART1_TX_PORT(type) P3##type /* UART1 TX Pin. */
178 #define UART1_TX_PIN 6
179 
180 
181 
182 /* **************************************************************************** */
183 /* --------------------------- M25P80 Flash Related --------------------------- */
184 /* **************************************************************************** */
185 #define FLASH_CS 4 /* P4.4 Output */
186 #define FLASH_HOLD 7 /* P5.7 Output */
187 
188 #define SPI_FLASH_ENABLE() ( P4OUT &= ~BV(FLASH_CS) )
189 #define SPI_FLASH_DISABLE() ( P4OUT |= BV(FLASH_CS) )
190 
191 #define SPI_FLASH_HOLD() ( P5OUT &= ~BV(FLASH_HOLD) )
192 #define SPI_FLASH_UNHOLD() ( P5OUT |= BV(FLASH_HOLD) )
193 
194 
195 /* **************************************************************************** */
196 /* ------------------------------ CC1120 Related ------------------------------ */
197 /* **************************************************************************** */
198 
199 //#define CC1120DEBUG 1
200 //#define CC1120TXDEBUG 1
201 #define CC1120TXERDEBUG 1
202 //#define CC1120RXDEBUG 1
203 #define CC1120RXERDEBUG 1
204 //#define CC1120INTDEBUG 1
205 //#define C1120PROCESSDEBUG 1
206 //#define CC1120ARCHDEBUG 1
207 //#define CC1120STATEDEBUG 1
208 
209 #define RF_CHANNEL 42
210 
211 #define CC1120_CS_THRESHOLD 0x9C /*-100dBm */
212 
213 /* Other possible sensible values:
214  * 0xC4 -60dBm.
215  * 0xBF -65dBm.
216  * 0xBA -70dBm.
217  * 0xB5 -75dBm.
218  * 0xB0 -80dBm.
219  * 0xAB -85dBm.
220  * 0xA6 -90dBm.
221  * 0xA5 -91dBm.
222  * 0xA4 -92dBm.
223  * 0xA3 -93dBm.
224  * 0xA2 -94dBm.
225  * 0xA1 -95dBm.
226  * 0xA0 -96dBm.
227  * 0x9F -97dBm.
228  * 0x9E -98dBm.
229  * 0x9D -99dBm.
230  * 0x9C -100dBm.
231  * 0x9B -101dBm.
232  * 0x9A -102dBm.
233  * 0x99 -103dBm
234  * 0x98 -104dBm.
235  * 0x97 -105dBm.
236  * 0x96 -106dBm.
237  * 0x95 -107dBm.
238  * 0x94 -108dBm.
239  * 0x93 -109dBm.
240  * 0x92 -110dBm.
241  */
242 //#define CC1120_RSSI_OFFSET 0x9A
243 
244 #define CC1120LEDS 1
245 
246 #define CC1120_LBT_TIMEOUT RTIMER_ARCH_SECOND //80
247 #define CC1120_ACK_WAIT RTIMER_ARCH_SECOND/667 /* ~1.5ms. */
248 
249 #define CC1120_INTER_PACKET_INTERVAL RTIMER_ARCH_SECOND/300 //275 //222
250 
251 #define CC1120_EN_TIMEOUT RTIMER_ARCH_SECOND/500
252 
253 #define CC1120_FHSS_ETSI_50 1
254 #define CC1120_FHSS_FCC_50 0
255 
256 #define CC1120_OFF_STATE CC1120_STATE_XOFF
257 
258 #define CC1120_GPIO_MODE 2
259 
260 #define CC1120_GPIO0_FUNC CC1120_GPIO_MCU_WAKEUP
261 //#define CC1120_GPIO0_FUNC (CC1120_GPIO_PKT_SYNC_RXTX| CC1120_GPIO_INV_MASK)
262 //#define CC1120_GPIO2_FUNC
263 //#define CC1120_GPIO3_FUNC CC1120_GPIO_RXFIFO_THR_PKT
264 #define CC1120_GPIO2_FUNC CC1120_GPIO_RX0TX1_CFG
265 #define CC1120_GPIO3_FUNC CC1120_GPIO_RX0TX1_CFG //CC1120_GPIO_MARC_2PIN_STATUS0 //(CC1120_GPIO_PKT_SYNC_RXTX| CC1120_GPIO_INV_MASK)
266 
267 
268 
269 
270 /* --------------------------- CC1120 Pin Mappings. --------------------------- */
271 #define CC1120_RESET_PORT(type) P2##type
272 #define CC1120_RESET_PIN 6
273 
274 #define CC1120_SPI_CSN_PORT(type) P2##type
275 #define CC1120_SPI_CSN_PIN 1
276 
277 #define CC1120_SPI_MOSI_PORT(type) P3##type
278 #define CC1120_SPI_MOSI_PIN 1
279 
280 #define CC1120_SPI_MISO_PORT(type) P3##type
281 #define CC1120_SPI_MISO_PIN 2
282 
283 #define CC1120_SPI_SCLK_PORT(type) P3##type
284 #define CC1120_SPI_SCLK_PIN 3
285 
286 #define CC1120_GDO0_PORT(type) P1##type
287 #define CC1120_GDO0_PIN 0
288 
289 //#ifdef CC1120_GPIO2_FUNC
290 //#define CC1120_GDO2_PORT(type) P1##type
291 //#define CC1120_GDO2_PIN 0
292 //#endif
293 
294 #ifdef CC1120_GPIO3_FUNC
295 #define CC1120_GDO3_PORT(type) P4##type
296 #define CC1120_GDO3_PIN 3
297 
298 #endif
299 
300 
301 
302 /* **************************************************************************** */
303 /* ------------------------------ CC2420 Related ------------------------------ */
304 /* **************************************************************************** */
305 
306 /* Pin Mappings. */
307 #define CC2420_CSN_PORT(type) P3##type
308 #define CC2420_CSN_PIN 0
309 
310 #define CC2420_PWR_PORT(type) P4##type
311 #define CC2420_PWR_PIN 4
312 
313 #define CC2420_RESET_PORT(type) P4##type
314 #define CC2420_RESET_PIN 6
315 
316 #endif /* __PLATFORM_CONF_H__ */