Contiki-NG
board.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012, Texas Instruments Incorporated - http://www.ti.com/
3 * Copyright (c) 2015, Zolertia
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 *
15 * 3. Neither the name of the copyright holder nor the names of its
16 * contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
30 * OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32/**
33 * \addtogroup zoul-platforms
34 * @{
35 *
36 * \defgroup firefly Firefly platform
37 *
38 * The Zolertia Firefly is the most down-to-core development platform, exposing
39 * the Zoul core functionalities and features, with a slick design to allow a
40 * flexible and easier user experience.
41 *
42 * Defines related to the Firefly platform: a Zoul-based breakout board
43 *
44 * This file provides connectivity information on LEDs, Buttons, UART and
45 * other peripherals
46 *
47 * This file can be used as the basis to configure other platforms using the
48 * cc2538 SoC.
49 * @{
50 *
51 * \file
52 * Header file with definitions related to the I/O connections on the Zolertia's
53 * Firefly platform, Zoul-based
54 *
55 * \note Do not include this file directly. It gets included by contiki-conf
56 * after all relevant directives have been set.
57 */
58#ifndef BOARD_H_
59#define BOARD_H_
60
61#include "dev/gpio.h"
62#include "dev/nvic.h"
63/*---------------------------------------------------------------------------*/
64/** \name Connector headers
65 *
66 * The Firefly features two 2.54 mm header rows over which exposes the following
67 * pins (facing up, Zolertia logo above and Micro-USB connector below):
68 * -----------------------------+---+---+--------------------------------------
69 * PIN_NAME |JP3|JP2| PIN_NAME
70 * -----------------------------+---+---+--------------------------------------
71 * PB5/CC1200.CS |-01|01-| LED1/PD5
72 * PB2/SPI0.SCLK/CC1200.SCLK |-02|02-| LED2/PD4
73 * PB1/SPIO0.MOSI/CC1200.MOSI |-03|03-| LED3/PD3
74 * PB3/SPIO0.MISO/CC1200.MISO |-04|04-| PD2
75 * PB3/CC1200.GPIO0 |-05|05-| PD1
76 * PC0/UART1.TX |-06|06-| PD0
77 * PC1/UART1.RX |-07|07-| AIN7/PA7
78 * PC2/I2C.SDA |-08|08-| AIN6/PA6
79 * PC3/I2C.SCL |-09|09-| ADC1/AIN5/PA5
80 * PC4/SPI1.SCLK |-10|10-| ADC2/AIN4/PA4
81 * PC5/SPI1.MOSI |-11|11-| BUTTON.USER/PA3
82 * PC6/SPI1.MISO |-12|12-| ADC3/AIN2/PA2
83 * USB.D+ |-13|13-| DGND
84 * USB.D- |-14|14-| D+3.3
85 * ---------------------------+-+---+---+-+------------------------------------
86 */
87/*---------------------------------------------------------------------------*/
88/** \name Firefly LED configuration
89 *
90 * LEDs on the Firefly are connected as follows:
91 * - LED1 (Red) -> PD5
92 * - LED2 (Green) -> PD4
93 * - LED3 (Blue) -> PD3
94 *
95 * LED1 pin exposed in JP2 connector
96 * LED2 pin exposed in JP2 connector
97 * LED3 pin exposed in JP2 connector
98 * @{
99 */
100/*---------------------------------------------------------------------------*/
101#define LEDS_ARCH_L1_PORT GPIO_D_NUM
102#define LEDS_ARCH_L1_PIN 5
103#define LEDS_ARCH_L2_PORT GPIO_D_NUM
104#define LEDS_ARCH_L2_PIN 4
105#define LEDS_ARCH_L3_PORT GPIO_D_NUM
106#define LEDS_ARCH_L3_PIN 3
107
108#define LEDS_CONF_RED 1
109#define LEDS_CONF_GREEN 2
110#define LEDS_CONF_BLUE 4
111
112#define LEDS_CONF_COUNT 3
113/** @} */
114/*---------------------------------------------------------------------------*/
115/** \name USB configuration
116 *
117 * The USB pullup is to be enabled by an external resistor, as it is not mapped
118 * to a GPIO.
119 * @{
120 */
121#ifdef USB_PULLUP_PORT
122#undef USB_PULLUP_PORT
123#endif
124#ifdef USB_PULLUP_PIN
125#undef USB_PULLUP_PIN
126#endif
127/** @} */
128/*---------------------------------------------------------------------------*/
129/** \name UART configuration
130 *
131 * On the Firefly, the UARTs are connected to the following ports/pins:
132 *
133 * - UART0:
134 * - RX: PA0, connected to CP2104 serial-to-usb converter TX pin
135 * - TX: PA1, connected to CP2104 serial-to-usb converter RX pin
136 * - UART1:
137 * - RX: PC1
138 * - TX: PC0
139 * - CTS: not used, one suggestion however is to use PD1
140 * - RTS: not used, one suggestion however is to use PD0
141 *
142 * We configure the port to use UART0 and UART1, CTS/RTS only for UART1,
143 * both without a HW pull-up resistor.
144 * UART0 is not exposed anywhere, UART1 pins are exposed over the JP3 connector.
145 * @{
146 */
147#define UART0_RX_PORT GPIO_A_NUM
148#define UART0_RX_PIN 0
149#define UART0_TX_PORT GPIO_A_NUM
150#define UART0_TX_PIN 1
151
152#define UART1_RX_PORT GPIO_C_NUM
153#define UART1_RX_PIN 1
154#define UART1_TX_PORT GPIO_C_NUM
155#define UART1_TX_PIN 0
156#define UART1_CTS_PORT (-1) /**< GPIO_D_NUM */
157#define UART1_CTS_PIN (-1) /**< 1 */
158#define UART1_RTS_PORT (-1) /**< GPIO_D_NUM */
159#define UART1_RTS_PIN (-1) /**< 0 */
160/** @} */
161/*---------------------------------------------------------------------------*/
162/**
163 * \name ADC configuration
164 *
165 * These values configure which CC2538 pins and ADC channels to use for the ADC
166 * inputs. There pins are suggested as they can be changed, but note that only
167 * pins from PA can be configured as ADC.
168 *
169 * - ADC1: up to 3.3V.
170 * - ADC2: up to 3.3V.
171 * - ADC3: up to 3.3V.
172 * - ADC4: up to 3.3V.
173 * - ADC5: up to 3.3V.
174 * - ADC6: up to 3.3V, shared with user button.
175 *
176 * Only ADC1 and ADC3 are enabled as default.
177 *
178 * The internal ADC reference is 1190mV, use either a voltage divider as input,
179 * or a different voltage reference, like AVDD5 or other externally (AIN7 or
180 * AIN6).
181 * @{
182 */
183#define ADC_SENSORS_PORT GPIO_A_NUM /**< ADC GPIO control port */
184
185#ifndef ADC_SENSORS_CONF_ADC1_PIN
186#define ADC_SENSORS_ADC1_PIN 5 /**< ADC1 to PA5 */
187#else
188#if ((ADC_SENSORS_CONF_ADC1_PIN != -1) && (ADC_SENSORS_CONF_ADC1_PIN != 5))
189#error "ADC1 channel should be mapped to PA5 or disabled with -1"
190#else
191#define ADC_SENSORS_ADC1_PIN ADC_SENSORS_CONF_ADC1_PIN
192#endif
193#endif
194
195#ifndef ADC_SENSORS_CONF_ADC2_PIN
196#define ADC_SENSORS_ADC2_PIN 4 /**< ADC2 to PA4 */
197#else
198#if ((ADC_SENSORS_CONF_ADC2_PIN != -1) && (ADC_SENSORS_CONF_ADC2_PIN != 4))
199#error "ADC2 channel should be mapped to PA4 or disabled with -1"
200#else
201#define ADC_SENSORS_ADC2_PIN ADC_SENSORS_CONF_ADC2_PIN
202#endif
203#endif
204
205#ifndef ADC_SENSORS_CONF_ADC3_PIN
206#define ADC_SENSORS_ADC3_PIN 2 /**< ADC3 to PA2 */
207#else
208#if ((ADC_SENSORS_CONF_ADC3_PIN != -1) && (ADC_SENSORS_CONF_ADC3_PIN != 2))
209#error "ADC3 channel should be mapped to PA2 or disabled with -1"
210#else
211#define ADC_SENSORS_ADC3_PIN ADC_SENSORS_CONF_ADC3_PIN
212#endif
213#endif
214
215#ifndef ADC_SENSORS_CONF_ADC4_PIN
216#define ADC_SENSORS_ADC4_PIN 6 /**< ADC4 to PA6 */
217#else
218#if ((ADC_SENSORS_CONF_ADC4_PIN != -1) && (ADC_SENSORS_CONF_ADC4_PIN != 6))
219#error "ADC4 channel should be mapped to PA6 or disabled with -1"
220#else
221#define ADC_SENSORS_ADC4_PIN ADC_SENSORS_CONF_ADC4_PIN
222#endif
223#endif
224
225#ifndef ADC_SENSORS_CONF_ADC5_PIN
226#define ADC_SENSORS_ADC5_PIN 7 /**< ADC5 to PA7 */
227#else
228#if ((ADC_SENSORS_CONF_ADC5_PIN != -1) && (ADC_SENSORS_CONF_ADC5_PIN != 7))
229#error "ADC5 channel should be mapped to PA7 or disabled with -1"
230#else
231#define ADC_SENSORS_ADC5_PIN ADC_SENSORS_CONF_ADC5_PIN
232#endif
233#endif
234
235#ifndef ADC_SENSORS_CONF_ADC6_PIN
236#define ADC_SENSORS_ADC6_PIN (-1) /**< ADC6 not declared */
237#else
238#define ADC_SENSORS_ADC6_PIN 3 /**< Hard-coded to PA3 */
239#endif
240
241#ifndef ADC_SENSORS_CONF_MAX
242#define ADC_SENSORS_MAX 5 /**< Maximum sensors */
243#else
244#define ADC_SENSORS_MAX ADC_SENSORS_CONF_MAX
245#endif
246/** @} */
247/*---------------------------------------------------------------------------*/
248/** \name Firefly Button configuration
249 *
250 * Buttons on the Firefly are connected as follows:
251 * - BUTTON_USER -> PA3, S1 user button, shared with bootloader
252 * - BUTTON_RESET -> RESET_N line
253 * @{
254 */
255/** BUTTON_USER -> PA3 */
256#define BUTTON_USER_PORT GPIO_A_NUM
257#define BUTTON_USER_PIN 3
258#define BUTTON_USER_VECTOR GPIO_A_IRQn
259
260/* Notify various examples that we have an user button.
261 * If ADC6 channel is used, then disable the user button
262 */
263#ifdef PLATFORM_CONF_WITH_BUTTON
264#if (PLATFORM_CONF_WITH_BUTTON && (ADC_SENSORS_ADC6_PIN == 3))
265#error "The ADC6 (PA3) and user button cannot be enabled at the same time"
266#else
267#define PLATFORM_HAS_BUTTON (PLATFORM_CONF_WITH_BUTTON && \
268 !(ADC_SENSORS_ADC6_PIN == 3))
269#endif /* (PLATFORM_CONF_WITH_BUTTON && (ADC_SENSORS_ADC6_PIN == 3)) */
270#else
271#define PLATFORM_HAS_BUTTON !(ADC_SENSORS_ADC6_PIN == 3)
272#endif /* PLATFORM_CONF_WITH_BUTTON */
273/** @} */
274/*---------------------------------------------------------------------------*/
275/**
276 * \name SPI (SSI0) configuration
277 *
278 * These values configure which CC2538 pins to use for the SPI (SSI0) lines,
279 * reserved exclusively for the CC1200 RF transceiver. These pins are exposed
280 * to the JP3 connector. To disable the CC1200 and use these pins, just
281 * remove the R10 resistor (0 ohm), which powers both the CC2538 and CC1200 to
282 * only power the SoC.
283 * TX -> MOSI, RX -> MISO
284 * @{
285 */
286#define SPI0_CLK_PORT GPIO_B_NUM
287#define SPI0_CLK_PIN 2
288#define SPI0_TX_PORT GPIO_B_NUM
289#define SPI0_TX_PIN 1
290#define SPI0_RX_PORT GPIO_B_NUM
291#define SPI0_RX_PIN 3
292/** @} */
293/*---------------------------------------------------------------------------*/
294/**
295 * \name SPI (SSI1) configuration
296 *
297 * These values configure which CC2538 pins to use for the SPI (SSI1) lines,
298 * exposed over JP3 connector.
299 * TX -> MOSI, RX -> MISO
300 * @{
301 */
302#define SPI1_CLK_PORT GPIO_C_NUM
303#define SPI1_CLK_PIN 4
304#define SPI1_TX_PORT GPIO_C_NUM
305#define SPI1_TX_PIN 5
306#define SPI1_RX_PORT GPIO_C_NUM
307#define SPI1_RX_PIN 6
308/** @} */
309/*---------------------------------------------------------------------------*/
310/**
311 * \name I2C configuration
312 *
313 * These values configure which CC2538 pins to use for the I2C lines, exposed
314 * over JP3 connector.
315 * @{
316 */
317#define I2C_SCL_PORT GPIO_C_NUM
318#define I2C_SCL_PIN 3
319#define I2C_SDA_PORT GPIO_C_NUM
320#define I2C_SDA_PIN 2
321#define I2C_INT_PORT GPIO_D_NUM
322#define I2C_INT_PIN 1
323#define I2C_INT_VECTOR GPIO_D_IRQn
324/** @} */
325/*---------------------------------------------------------------------------*/
326/**
327 * \name Dual RF interface support
328 *
329 * Enables support for dual band operation (both CC1200 and 2.4GHz enabled).
330 * Unlike the RE-Mote, the Firefly doesn't have a RF switch, so both interfaces
331 * should be always enabled if the R10 resistor is mounted. If only using the
332 * 2.4GHz RF interface, the resistor can be removed to power-off the CC1200.
333 * @{
334 */
335#ifndef REMOTE_DUAL_RF_ENABLED
336#define REMOTE_DUAL_RF_ENABLED 1
337#endif
338/** @} */
339/*---------------------------------------------------------------------------*/
340/**
341 * \name CC1200 configuration
342 *
343 * These values configure the required pins to drive the CC1200
344 * None of the following pins are exposed to any connector, kept for internal
345 * use only
346 * @{
347 */
348#define CC1200_SPI_INSTANCE 0
349#define CC1200_SPI_SCLK_PORT SPI0_CLK_PORT
350#define CC1200_SPI_SCLK_PIN SPI0_CLK_PIN
351#define CC1200_SPI_MOSI_PORT SPI0_TX_PORT
352#define CC1200_SPI_MOSI_PIN SPI0_TX_PIN
353#define CC1200_SPI_MISO_PORT SPI0_RX_PORT
354#define CC1200_SPI_MISO_PIN SPI0_RX_PIN
355#define CC1200_SPI_CSN_PORT GPIO_B_NUM
356#define CC1200_SPI_CSN_PIN 5
357#define CC1200_GDO0_PORT GPIO_B_NUM
358#define CC1200_GDO0_PIN 4
359#define CC1200_GDO2_PORT GPIO_B_NUM
360#define CC1200_GDO2_PIN 0
361#define CC1200_RESET_PORT GPIO_C_NUM
362#define CC1200_RESET_PIN 7
363#define CC1200_GPIOx_VECTOR GPIO_B_IRQn
364/** @} */
365/*---------------------------------------------------------------------------*/
366/**
367 * \name Device string used on startup
368 * @{
369 */
370#define BOARD_STRING "Zolertia Firefly platform"
371/** @} */
372
373#endif /* BOARD_H_ */
374
375/**
376 * @}
377 * @}
378 */
Header file with register and macro declarations for the cc2538 GPIO module.
Header file for the ARM Nested Vectored Interrupt Controller.