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