Contiki-NG
Toggle main menu visibility
Loading...
Searching...
No Matches
z1-def.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 Z1 platform
33
* \author
34
* Joakim Eriksson <joakime@sics.se>
35
*/
36
37
#ifndef Z1_DEF_H_
38
#define Z1_DEF_H_
39
40
#include <iomacros.h>
41
42
/*
43
* Definitions below are dictated by the hardware and not really
44
* changeable!
45
*/
46
47
#define ZOLERTIA_Z1 1
/* Enric */
48
49
/* 1 len byte, 2 bytes CRC */
50
#define RADIO_PHY_OVERHEAD 3
51
/* 250kbps data rate. One byte = 32us */
52
#define RADIO_BYTE_AIR_TIME 32
53
/* Delay between GO signal and SFD: radio fixed delay + 4Bytes preample + 1B SFD -- 1Byte time is 32us
54
* ~327us + 129preample = 456 us */
55
#define RADIO_DELAY_BEFORE_TX ((unsigned)US_TO_RTIMERTICKS(456))
56
/* Delay between GO signal and start listening
57
* ~50us delay + 129preample + ?? = 183 us */
58
#define RADIO_DELAY_BEFORE_RX ((unsigned)US_TO_RTIMERTICKS(183))
59
/* Delay between the SFD finishes arriving and it is detected in software */
60
#define RADIO_DELAY_BEFORE_DETECT 0
61
62
#define PLATFORM_HAS_LEDS 1
63
#define PLATFORM_HAS_BUTTON 1
64
#define PLATFORM_HAS_RADIO 1
65
#define PLATFORM_HAS_BATTERY 1
66
67
/* CPU target speed in Hz */
68
#define F_CPU 8000000uL
/* 8MHz by default */
69
70
/* the low-level radio driver */
71
#define NETSTACK_CONF_RADIO cc2420_driver
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
/*
97
* Definitions below are dictated by the hardware and not really
98
* changeable!
99
*/
100
101
/* LED ports */
102
#ifdef Z1_IS_Z1SP
103
#define LEDS_PxDIR P4DIR
104
#define LEDS_PxOUT P4OUT
105
#define LEDS_CONF_RED 0x04
106
#define LEDS_CONF_GREEN 0x01
107
#define LEDS_CONF_YELLOW 0x80
108
#else
109
#define LEDS_PxDIR P5DIR
110
#define LEDS_PxOUT P5OUT
111
#define LEDS_CONF_RED 0x10
112
#define LEDS_CONF_GREEN 0x40
113
#define LEDS_CONF_YELLOW 0x20
114
#endif
/* Z1_IS_Z1SP */
115
116
#define LEDS_CONF_ALL ((LEDS_CONF_RED) | (LEDS_CONF_GREEN) | (LEDS_CONF_YELLOW))
117
#define LEDS_CONF_LEGACY_API 1
118
119
/* DCO speed resynchronization for more robust UART, etc. */
120
#ifndef DCOSYNCH_CONF_ENABLED
121
#define DCOSYNCH_CONF_ENABLED (!(MAC_CONF_WITH_TSCH))
/* TSCH needs timerB
122
for SFD timestamping */
123
#endif
/* DCOSYNCH_CONF_ENABLED */
124
125
#ifndef CC2420_CONF_SFD_TIMESTAMPS
126
#define CC2420_CONF_SFD_TIMESTAMPS (MAC_CONF_WITH_TSCH)
/* TSCH needs SFD timestamping */
127
#endif
/* CC2420_CONF_SFD_TIMESTAMPS */
128
129
#ifndef DCOSYNCH_CONF_PERIOD
130
#define DCOSYNCH_CONF_PERIOD 30
131
#endif
/* DCOSYNCH_CONF_PERIOD */
132
133
#define ROM_ERASE_UNIT_SIZE 512
134
#define XMEM_ERASE_UNIT_SIZE (64 * 1024L)
135
136
#define CFS_CONF_OFFSET_TYPE long
137
138
/* Use the first 64k of external flash for node configuration */
139
#define NODE_ID_XMEM_OFFSET (0 * XMEM_ERASE_UNIT_SIZE)
140
141
/* Use the second 64k of external flash for codeprop. */
142
#define EEPROMFS_ADDR_CODEPROP (1 * XMEM_ERASE_UNIT_SIZE)
143
144
#define CFS_XMEM_CONF_OFFSET (2 * XMEM_ERASE_UNIT_SIZE)
145
#define CFS_XMEM_CONF_SIZE (1 * XMEM_ERASE_UNIT_SIZE)
146
147
#define CFS_RAM_CONF_SIZE 4096
148
149
/*
150
* SPI bus configuration for the Z1 mote.
151
*/
152
153
/* SPI input/output registers. */
154
#define SPI_TXBUF UCB0TXBUF
155
#define SPI_RXBUF UCB0RXBUF
156
157
/* USART0 Tx ready? */
158
#define SPI_WAITFOREOTx() while((UCB0STAT & UCBUSY) != 0)
159
/* USART0 Rx ready? */
160
#define SPI_WAITFOREORx() while((IFG2 & UCB0RXIFG) == 0)
161
/* USART0 Tx buffer ready? */
162
#define SPI_WAITFORTxREADY() while((IFG2 & UCB0TXIFG) == 0)
163
164
#define MOSI 1
/* P3.1 - Output: SPI Master out - slave in (MOSI) */
165
#define MISO 2
/* P3.2 - Input: SPI Master in - slave out (MISO) */
166
#define SCK 3
/* P3.3 - Output: SPI Serial Clock (SCLK) */
167
168
/*
169
* SPI bus - M25P80 external flash configuration.
170
*/
171
/* FLASH_PWR P4.3 Output ALWAYS POWERED ON Z1 */
172
#define FLASH_CS 4
/* P4.4 Output */
173
#define FLASH_HOLD 7
/* P5.7 Output */
174
175
/* Enable/disable flash access to the SPI bus (active low). */
176
177
#define SPI_FLASH_ENABLE() (P4OUT &= ~BV(FLASH_CS))
178
#define SPI_FLASH_DISABLE() (P4OUT |= BV(FLASH_CS))
179
180
#define SPI_FLASH_HOLD() (P5OUT &= ~BV(FLASH_HOLD))
181
#define SPI_FLASH_UNHOLD() (P5OUT |= BV(FLASH_HOLD))
182
183
/*
184
* SPI bus - CC2420 pin configuration.
185
*/
186
187
#define CC2420_CONF_SYMBOL_LOOP_COUNT 1302
/* 326us msp430X @ 8MHz */
188
189
/* P1.2 - Input: FIFOP from CC2420 */
190
#define CC2420_FIFOP_PORT(type) P1##type
191
#define CC2420_FIFOP_PIN 2
192
/* P1.3 - Input: FIFO from CC2420 */
193
#define CC2420_FIFO_PORT(type) P1##type
194
#define CC2420_FIFO_PIN 3
195
/* P1.4 - Input: CCA from CC2420 */
196
#define CC2420_CCA_PORT(type) P1##type
197
#define CC2420_CCA_PIN 4
198
/* P4.1 - Input: SFD from CC2420 */
199
#define CC2420_SFD_PORT(type) P4##type
200
#define CC2420_SFD_PIN 1
201
/* P3.0 - Output: SPI Chip Select (CS_N) */
202
#define CC2420_CSN_PORT(type) P3##type
203
#define CC2420_CSN_PIN 0
204
/* P4.5 - Output: VREG_EN to CC2420 */
205
#define CC2420_VREG_PORT(type) P4##type
206
#define CC2420_VREG_PIN 5
207
/* P4.6 - Output: RESET_N to CC2420 */
208
#define CC2420_RESET_PORT(type) P4##type
209
#define CC2420_RESET_PIN 6
210
211
#define CC2420_IRQ_VECTOR PORT1_VECTOR
212
213
/* Pin status. */
214
#define CC2420_FIFOP_IS_1 (!!(CC2420_FIFOP_PORT(IN) & BV(CC2420_FIFOP_PIN)))
215
#define CC2420_FIFO_IS_1 (!!(CC2420_FIFO_PORT(IN) & BV(CC2420_FIFO_PIN)))
216
#define CC2420_CCA_IS_1 (!!(CC2420_CCA_PORT(IN) & BV(CC2420_CCA_PIN)))
217
#define CC2420_SFD_IS_1 (!!(CC2420_SFD_PORT(IN) & BV(CC2420_SFD_PIN)))
218
219
/* The CC2420 reset pin. */
220
#define SET_RESET_INACTIVE() (CC2420_RESET_PORT(OUT) |= BV(CC2420_RESET_PIN))
221
#define SET_RESET_ACTIVE() (CC2420_RESET_PORT(OUT) &= ~BV(CC2420_RESET_PIN))
222
223
/* CC2420 voltage regulator enable pin. */
224
#define SET_VREG_ACTIVE() (CC2420_VREG_PORT(OUT) |= BV(CC2420_VREG_PIN))
225
#define SET_VREG_INACTIVE() (CC2420_VREG_PORT(OUT) &= ~BV(CC2420_VREG_PIN))
226
227
/* CC2420 rising edge trigger for external interrupt 0 (FIFOP). */
228
#define CC2420_FIFOP_INT_INIT() do { \
229
CC2420_FIFOP_PORT(IES) &= ~BV(CC2420_FIFOP_PIN); \
230
CC2420_CLEAR_FIFOP_INT(); \
231
} while(0)
232
233
/* FIFOP on external interrupt 0. */
234
#define CC2420_ENABLE_FIFOP_INT() do { CC2420_FIFOP_PORT(IE) |= BV(CC2420_FIFOP_PIN); } while(0)
235
#define CC2420_DISABLE_FIFOP_INT() do { CC2420_FIFOP_PORT(IE) &= ~BV(CC2420_FIFOP_PIN); } while(0)
236
#define CC2420_CLEAR_FIFOP_INT() do { CC2420_FIFOP_PORT(IFG) &= ~BV(CC2420_FIFOP_PIN); } while(0)
237
238
/*
239
* Enables/disables CC2420 access to the SPI bus (not the bus).
240
* (Chip Select)
241
*/
242
243
/* ENABLE CSn (active low) */
244
#define CC2420_SPI_ENABLE() (CC2420_CSN_PORT(OUT) &= ~BV(CC2420_CSN_PIN))
245
/* DISABLE CSn (active low) */
246
#define CC2420_SPI_DISABLE() (CC2420_CSN_PORT(OUT) |= BV(CC2420_CSN_PIN))
247
#define CC2420_SPI_IS_ENABLED() ((CC2420_CSN_PORT(OUT) & BV(CC2420_CSN_PIN)) != BV(CC2420_CSN_PIN))
248
249
/*
250
* I2C configuration
251
*/
252
253
#define I2C_PxDIR P5DIR
254
#define I2C_PxIN P5IN
255
#define I2C_PxOUT P5OUT
256
#define I2C_PxSEL P5SEL
257
#define I2C_PxSEL2 P5SEL2
258
#define I2C_PxREN P5REN
259
260
#define I2C_SDA (1 << 1)
/* SDA == P5.1 */
261
#define I2C_SCL (1 << 2)
/* SCL == P5.2 */
262
#define I2C_PRESC_1KHZ_LSB 0x00
263
#define I2C_PRESC_1KHZ_MSB 0x20
264
#define I2C_PRESC_100KHZ_LSB 0x50
265
#define I2C_PRESC_100KHZ_MSB 0x00
266
#define I2C_PRESC_400KHZ_LSB 0x14
267
#define I2C_PRESC_400KHZ_MSB 0x00
268
269
/* Set rate as high as possible by default */
270
#ifndef I2C_PRESC_Z1_LSB
271
#define I2C_PRESC_Z1_LSB I2C_PRESC_400KHZ_LSB
272
#endif
273
274
#ifndef I2C_PRESC_Z1_MSB
275
#define I2C_PRESC_Z1_MSB I2C_PRESC_400KHZ_MSB
276
#endif
277
278
/* I2C configuration with RX interrupts */
279
#ifdef I2C_CONF_RX_WITH_INTERRUPT
280
#define I2C_RX_WITH_INTERRUPT I2C_CONF_RX_WITH_INTERRUPT
281
#else
/* I2C_CONF_RX_WITH_INTERRUPT */
282
#define I2C_RX_WITH_INTERRUPT 1
283
#endif
/* I2C_CONF_RX_WITH_INTERRUPT */
284
285
/* Platform-specific define for the end of the stack region */
286
#define STACK_CONF_ORIGIN ((void *)0x3100)
287
288
#endif
/* PLATFORM_CONF_H_ */
arch
platform
z1
z1-def.h
Generated on
for Contiki-NG by
1.17.0