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 #ifdef USB_PULLUP_PORT
121 #undef USB_PULLUP_PORT
122 #endif
123 #ifdef USB_PULLUP_PIN
124 #undef USB_PULLUP_PIN
125 #endif
126 /** @} */
127 /*---------------------------------------------------------------------------*/
128 /** \name UART configuration
129  *
130  * On the Firefly, the UARTs are connected to the following ports/pins:
131  *
132  * - UART0:
133  * - RX: PA0, connected to CP2104 serial-to-usb converter TX pin
134  * - TX: PA1, connected to CP2104 serial-to-usb converter RX pin
135  * - UART1:
136  * - RX: PC1
137  * - TX: PC0
138  * - CTS: not used, one suggestion however is to use PD1
139  * - RTS: not used, one suggestion however is to use PD0
140  *
141  * We configure the port to use UART0 and UART1, CTS/RTS only for UART1,
142  * both without a HW pull-up resistor.
143  * UART0 is not exposed anywhere, UART1 pins are exposed over the JP3 connector.
144  * @{
145  */
146 #define UART0_RX_PORT GPIO_A_NUM
147 #define UART0_RX_PIN 0
148 #define UART0_TX_PORT GPIO_A_NUM
149 #define UART0_TX_PIN 1
150 
151 #define UART1_RX_PORT GPIO_C_NUM
152 #define UART1_RX_PIN 1
153 #define UART1_TX_PORT GPIO_C_NUM
154 #define UART1_TX_PIN 0
155 #define UART1_CTS_PORT (-1) /**< GPIO_D_NUM */
156 #define UART1_CTS_PIN (-1) /**< 1 */
157 #define UART1_RTS_PORT (-1) /**< GPIO_D_NUM */
158 #define UART1_RTS_PIN (-1) /**< 0 */
159 /** @} */
160 /*---------------------------------------------------------------------------*/
161 /**
162  * \name ADC configuration
163  *
164  * These values configure which CC2538 pins and ADC channels to use for the ADC
165  * inputs. There pins are suggested as they can be changed, but note that only
166  * pins from PA can be configured as ADC.
167  *
168  * - ADC1: up to 3.3V.
169  * - ADC2: up to 3.3V.
170  * - ADC3: up to 3.3V.
171  * - ADC4: up to 3.3V.
172  * - ADC5: up to 3.3V.
173  * - ADC6: up to 3.3V, shared with user button.
174  *
175  * Only ADC1 and ADC3 are enabled as default.
176  *
177  * The internal ADC reference is 1190mV, use either a voltage divider as input,
178  * or a different voltage reference, like AVDD5 or other externally (AIN7 or
179  * AIN6).
180  * @{
181  */
182 #define ADC_SENSORS_PORT GPIO_A_NUM /**< ADC GPIO control port */
183 
184 #ifndef ADC_SENSORS_CONF_ADC1_PIN
185 #define ADC_SENSORS_ADC1_PIN 5 /**< ADC1 to PA5 */
186 #else
187 #if ((ADC_SENSORS_CONF_ADC1_PIN != -1) && (ADC_SENSORS_CONF_ADC1_PIN != 5))
188 #error "ADC1 channel should be mapped to PA5 or disabled with -1"
189 #else
190 #define ADC_SENSORS_ADC1_PIN ADC_SENSORS_CONF_ADC1_PIN
191 #endif
192 #endif
193 
194 #ifndef ADC_SENSORS_CONF_ADC2_PIN
195 #define ADC_SENSORS_ADC2_PIN 4 /**< ADC2 to PA4 */
196 #else
197 #if ((ADC_SENSORS_CONF_ADC2_PIN != -1) && (ADC_SENSORS_CONF_ADC2_PIN != 4))
198 #error "ADC2 channel should be mapped to PA4 or disabled with -1"
199 #else
200 #define ADC_SENSORS_ADC2_PIN ADC_SENSORS_CONF_ADC2_PIN
201 #endif
202 #endif
203 
204 #ifndef ADC_SENSORS_CONF_ADC3_PIN
205 #define ADC_SENSORS_ADC3_PIN 2 /**< ADC3 to PA2 */
206 #else
207 #if ((ADC_SENSORS_CONF_ADC3_PIN != -1) && (ADC_SENSORS_CONF_ADC3_PIN != 2))
208 #error "ADC3 channel should be mapped to PA2 or disabled with -1"
209 #else
210 #define ADC_SENSORS_ADC3_PIN ADC_SENSORS_CONF_ADC3_PIN
211 #endif
212 #endif
213 
214 #ifndef ADC_SENSORS_CONF_ADC4_PIN
215 #define ADC_SENSORS_ADC4_PIN 6 /**< ADC4 to PA6 */
216 #else
217 #if ((ADC_SENSORS_CONF_ADC4_PIN != -1) && (ADC_SENSORS_CONF_ADC4_PIN != 6))
218 #error "ADC4 channel should be mapped to PA6 or disabled with -1"
219 #else
220 #define ADC_SENSORS_ADC4_PIN ADC_SENSORS_CONF_ADC4_PIN
221 #endif
222 #endif
223 
224 #ifndef ADC_SENSORS_CONF_ADC5_PIN
225 #define ADC_SENSORS_ADC5_PIN 7 /**< ADC5 to PA7 */
226 #else
227 #if ((ADC_SENSORS_CONF_ADC5_PIN != -1) && (ADC_SENSORS_CONF_ADC5_PIN != 7))
228 #error "ADC5 channel should be mapped to PA7 or disabled with -1"
229 #else
230 #define ADC_SENSORS_ADC5_PIN ADC_SENSORS_CONF_ADC5_PIN
231 #endif
232 #endif
233 
234 #ifndef ADC_SENSORS_CONF_ADC6_PIN
235 #define ADC_SENSORS_ADC6_PIN (-1) /**< ADC6 not declared */
236 #else
237 #define ADC_SENSORS_ADC6_PIN 3 /**< Hard-coded to PA3 */
238 #endif
239 
240 #ifndef ADC_SENSORS_CONF_MAX
241 #define ADC_SENSORS_MAX 5 /**< Maximum sensors */
242 #else
243 #define ADC_SENSORS_MAX ADC_SENSORS_CONF_MAX
244 #endif
245 /** @} */
246 /*---------------------------------------------------------------------------*/
247 /** \name Firefly Button configuration
248  *
249  * Buttons on the Firefly are connected as follows:
250  * - BUTTON_USER -> PA3, S1 user button, shared with bootloader
251  * - BUTTON_RESET -> RESET_N line
252  * @{
253  */
254 /** BUTTON_USER -> PA3 */
255 #define BUTTON_USER_PORT GPIO_A_NUM
256 #define BUTTON_USER_PIN 3
257 #define BUTTON_USER_VECTOR GPIO_A_IRQn
258 
259 /* Notify various examples that we have an user button.
260  * If ADC6 channel is used, then disable the user button
261  */
262 #ifdef PLATFORM_CONF_WITH_BUTTON
263 #if (PLATFORM_CONF_WITH_BUTTON && (ADC_SENSORS_ADC6_PIN == 3))
264 #error "The ADC6 (PA3) and user button cannot be enabled at the same time"
265 #else
266 #define PLATFORM_HAS_BUTTON (PLATFORM_CONF_WITH_BUTTON && \
267  !(ADC_SENSORS_ADC6_PIN == 3))
268 #endif /* (PLATFORM_CONF_WITH_BUTTON && (ADC_SENSORS_ADC6_PIN == 3)) */
269 #else
270 #define PLATFORM_HAS_BUTTON !(ADC_SENSORS_ADC6_PIN == 3)
271 #endif /* PLATFORM_CONF_WITH_BUTTON */
272 /** @} */
273 /*---------------------------------------------------------------------------*/
274 /**
275  * \name SPI (SSI0) configuration
276  *
277  * These values configure which CC2538 pins to use for the SPI (SSI0) lines,
278  * reserved exclusively for the CC1200 RF transceiver. These pins are exposed
279  * to the JP3 connector. To disable the CC1200 and use these pins, just
280  * remove the R10 resistor (0 ohm), which powers both the CC2538 and CC1200 to
281  * only power the SoC.
282  * TX -> MOSI, RX -> MISO
283  * @{
284  */
285 #define SPI0_CLK_PORT GPIO_B_NUM
286 #define SPI0_CLK_PIN 2
287 #define SPI0_TX_PORT GPIO_B_NUM
288 #define SPI0_TX_PIN 1
289 #define SPI0_RX_PORT GPIO_B_NUM
290 #define SPI0_RX_PIN 3
291 /** @} */
292 /*---------------------------------------------------------------------------*/
293 /**
294  * \name SPI (SSI1) configuration
295  *
296  * These values configure which CC2538 pins to use for the SPI (SSI1) lines,
297  * exposed over JP3 connector.
298  * TX -> MOSI, RX -> MISO
299  * @{
300  */
301 #define SPI1_CLK_PORT GPIO_C_NUM
302 #define SPI1_CLK_PIN 4
303 #define SPI1_TX_PORT GPIO_C_NUM
304 #define SPI1_TX_PIN 5
305 #define SPI1_RX_PORT GPIO_C_NUM
306 #define SPI1_RX_PIN 6
307 /** @} */
308 /*---------------------------------------------------------------------------*/
309 /**
310  * \name I2C configuration
311  *
312  * These values configure which CC2538 pins to use for the I2C lines, exposed
313  * over JP3 connector.
314  * @{
315  */
316 #define I2C_SCL_PORT GPIO_C_NUM
317 #define I2C_SCL_PIN 3
318 #define I2C_SDA_PORT GPIO_C_NUM
319 #define I2C_SDA_PIN 2
320 #define I2C_INT_PORT GPIO_D_NUM
321 #define I2C_INT_PIN 1
322 #define I2C_INT_VECTOR GPIO_D_IRQn
323 /** @} */
324 /*---------------------------------------------------------------------------*/
325 /**
326  * \name Dual RF interface support
327  *
328  * Enables support for dual band operation (both CC1200 and 2.4GHz enabled).
329  * Unlike the RE-Mote, the Firefly doesn't have a RF switch, so both interfaces
330  * should be always enabled if the R10 resistor is mounted. If only using the
331  * 2.4GHz RF interface, the resistor can be removed to power-off the CC1200.
332  * @{
333  */
334 #define REMOTE_DUAL_RF_ENABLED 1
335 /** @} */
336 /*---------------------------------------------------------------------------*/
337 /**
338  * \name CC1200 configuration
339  *
340  * These values configure the required pins to drive the CC1200
341  * None of the following pins are exposed to any connector, kept for internal
342  * use only
343  * @{
344  */
345 #define CC1200_SPI_INSTANCE 0
346 #define CC1200_SPI_SCLK_PORT SPI0_CLK_PORT
347 #define CC1200_SPI_SCLK_PIN SPI0_CLK_PIN
348 #define CC1200_SPI_MOSI_PORT SPI0_TX_PORT
349 #define CC1200_SPI_MOSI_PIN SPI0_TX_PIN
350 #define CC1200_SPI_MISO_PORT SPI0_RX_PORT
351 #define CC1200_SPI_MISO_PIN SPI0_RX_PIN
352 #define CC1200_SPI_CSN_PORT GPIO_B_NUM
353 #define CC1200_SPI_CSN_PIN 5
354 #define CC1200_GDO0_PORT GPIO_B_NUM
355 #define CC1200_GDO0_PIN 4
356 #define CC1200_GDO2_PORT GPIO_B_NUM
357 #define CC1200_GDO2_PIN 0
358 #define CC1200_RESET_PORT GPIO_C_NUM
359 #define CC1200_RESET_PIN 7
360 #define CC1200_GPIOx_VECTOR GPIO_B_IRQn
361 /** @} */
362 /*---------------------------------------------------------------------------*/
363 /**
364  * \name Device string used on startup
365  * @{
366  */
367 #define BOARD_STRING "Zolertia Firefly platform"
368 /** @} */
369 
370 #endif /* BOARD_H_ */
371 
372 /**
373  * @}
374  * @}
375  */
Header file for the ARM Nested Vectored Interrupt Controller.
Header file with register and macro declarations for the cc2538 GPIO module.