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 remote-reva RE-Mote platform revision A
37  *
38  * The RE-Mote was designed jointly with universities and industry partners in
39  * RERUM European project, to ease the development of private and secure
40  * applications for IoT and Smart City applications. The RE-Mote packs several
41  * on-board resources, like a RTC, external WDT, Micro-SD, RF switch and a
42  * Shutdown mode to reduce its power consumption down to 300nA.
43  *
44  * This file provides connectivity information on LEDs, Buttons, UART and
45  * other RE-Mote revision A 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  * RE-Mote platform (revision A), cc2538-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 RE-Mote features two 2.54 mm header rows over which exposes the following
67  * pins (facing up, Zolertia/RERUM logo above, buttons and micro USB at bottom):
68  * ----------------------+---+---+---------------------------------------------
69  * PIN_NAME |JP6|JP5| PIN_NAME
70  * ----------------------+---+---+---------------------------------------------
71  * LED1/EXT_WDT/PD5 |-01|18-| PC6/SPI1.MISO/USD.MISO
72  * LED2/UART1.CTS/PD4 |-02|17-| PC5/SPI1.MOSI/USD.MOSI
73  * LED3/UART1.RTS/PD3 |-03|16-| PC4/SPI1.SCLK/USD.SCLK
74  * UART0.RX/PA0 |-04|15-| PA3/BUTTON.USER
75  * UART0.TX/PA1 |-05|14-| RESET/JTAG.RESET/BUTTON.RESET
76  * SHUTDOWN_ENABLE/PD1 |-06|13-| DGND
77  * RTC.SDA/I2C.SDA/PC2 |-07|12-| D+3.3
78  * RTC.SCL/I2C.SCL/PC3 |-08|11-| PA5/AIN5/ADC1
79  * DGND |-09|10-| PA4/RTC_INT1/AIN4/ADC2
80  * D+3.3 |-10|09-| DGND
81  * USD.CS/AIN7/PA7 |-11|08-| D+5.1
82  * SHUTDOWN_DONE/PD0 |-12|07-| PA2/AIN2/ADC3
83  * UART1.RX/PC1 |-13|06-| JTAG.TMS
84  * UART1.TX/PC0 |-14|05-| JTAG.TCK
85  * DGND |-15|04-| PB7/JTAG.TDO
86  * D+3.3 |-16|03-| PB6/JTAG.TDI
87  * DGND |-17|02-| PS+EXT
88  * +VBAT |-18|01-| DGND
89  * ----------------------+---+---+---------------------------------------------
90  */
91 /*---------------------------------------------------------------------------*/
92 /** \name RE-Mote LED configuration
93  *
94  * LEDs on the RE-Mote are connected as follows:
95  * - LED1 (Red) -> PD5
96  * - LED2 (Green) -> PD4
97  * - LED3 (Blue) -> PD3
98  *
99  * LED1 pin shared with EXT_WDT and exposed in JP6 connector
100  * LED2 pin shared with UART1 CTS, pin exposed in JP6 connector
101  * LED3 pin shared with UART1 RTS, exposed in JP6 connector
102  * @{
103  */
104 /*---------------------------------------------------------------------------*/
105 #define LEDS_ARCH_L1_PORT GPIO_D_NUM
106 #define LEDS_ARCH_L1_PIN 5
107 #define LEDS_ARCH_L2_PORT GPIO_D_NUM
108 #define LEDS_ARCH_L2_PIN 4
109 #define LEDS_ARCH_L3_PORT GPIO_D_NUM
110 #define LEDS_ARCH_L3_PIN 3
111 
112 #define LEDS_CONF_RED 1
113 #define LEDS_CONF_GREEN 2
114 #define LEDS_CONF_BLUE 4
115 
116 #define LEDS_CONF_COUNT 3
117 /** @} */
118 /*---------------------------------------------------------------------------*/
119 /** \name USB configuration
120  *
121  * The USB pullup is enabled by an external resistor, not mapped to a GPIO
122  */
123 #ifdef USB_PULLUP_PORT
124 #undef USB_PULLUP_PORT
125 #endif
126 #ifdef USB_PULLUP_PIN
127 #undef USB_PULLUP_PIN
128 #endif
129 /** @} */
130 /*---------------------------------------------------------------------------*/
131 /** \name UART configuration
132  *
133  * On the RE-Mote, the UARTs are connected to the following ports/pins:
134  *
135  * - UART0:
136  * - RX: PA0, connected to CP2104 serial-to-usb converter TX pin
137  * - TX: PA1, connected to CP2104 serial-to-usb converter RX pin
138  * - UART1:
139  * - RX: PC1
140  * - TX: PC0
141  * - CTS: PD4, shared with LED2 (Green), disabled as default
142  * - RTS: PD3, shared with LED3 (Blue), disabled as default
143  *
144  * We configure the port to use UART0 and UART1, CTS/RTS only for UART1,
145  * both without a HW pull-up resistor
146  * UART0 and UART1 pins are exposed over the JP6 connector
147  * @{
148  */
149 #define UART0_RX_PORT GPIO_A_NUM
150 #define UART0_RX_PIN 0
151 #define UART0_TX_PORT GPIO_A_NUM
152 #define UART0_TX_PIN 1
153 
154 #define UART1_RX_PORT GPIO_C_NUM
155 #define UART1_RX_PIN 1
156 #define UART1_TX_PORT GPIO_C_NUM
157 #define UART1_TX_PIN 0
158 #define UART1_CTS_PORT (-1)
159 #define UART1_CTS_PIN (-1)
160 #define UART1_RTS_PORT (-1)
161 #define UART1_RTS_PIN (-1)
162 /** @} */
163 /*---------------------------------------------------------------------------*/
164 /**
165  * \name ADC configuration
166  *
167  * These values configure which CC2538 pins and ADC channels to use for the ADC
168  * inputs. By default the RE-Mote allows two out-of-the-box ADC ports with a
169  * phidget-like 3-pin connector (GND/VDD/ADC)
170  *
171  * The RE-Mote allows both 3.3V and 5V analogue sensors as follow:
172  *
173  * - ADC1: up to 3.3V.
174  * - ADC2: up to 3.3V, shared with RTC_INT
175  * - ADC3: up to 5V, by means of a 2/3 voltage divider.
176  *
177  * Also there are other ADC channels shared by default with Micro SD card and
178  * user button implementations:
179  * - ADC4: up to 3.3V.
180  * - ADC5: up to 3.3V.
181  * - ADC6: up to 3.3V.
182  *
183  * ADC inputs can only be on port A.
184  * All ADCx are exposed in JP5 connector, but only ADC1 and ADC3 have GND and
185  * VDD (3/5V) pins next to it, so these can be exposed into a 3-pin phidget-like
186  * connector, for ADC2 either solder a wire to connect, or use a 4-pin connector
187  * to expose both ADC1 and ADC2 in a single connector, but this will leave no
188  * space for a ADC3 connector.
189  * The internal ADC reference is 1190mV, use either a voltage divider as input,
190  * or a different voltage reference, like AVDD5 or other externally (AIN7), but
191  * note the PA7 is shared with the Micro-SD CSn pin, likewise for PA6 (AIN6)
192  * shared witht the Micro-SD select pin
193  * To use the ADC2 pin, remove the resistor on the Zoul's PA4 pin (JP1, pin 10)
194  * and enable below (replace -1 with 4).
195  * @{
196  */
197 #define ADC_SENSORS_PORT GPIO_A_NUM /**< ADC GPIO control port */
198 
199 #ifndef ADC_SENSORS_CONF_ADC1_PIN
200 #define ADC_SENSORS_ADC1_PIN 5 /**< ADC1 to PA5, 3V3 */
201 #else
202 #if ((ADC_SENSORS_CONF_ADC1_PIN != -1) && (ADC_SENSORS_CONF_ADC1_PIN != 5))
203 #error "ADC1 channel should be mapped to PA5 or disabled with -1"
204 #else
205 #define ADC_SENSORS_ADC1_PIN ADC_SENSORS_CONF_ADC1_PIN
206 #endif
207 #endif
208 
209 #ifndef ADC_SENSORS_CONF_ADC3_PIN
210 #define ADC_SENSORS_ADC3_PIN 2 /**< ADC3 to PA2, 5V */
211 #else
212 #if ((ADC_SENSORS_CONF_ADC3_PIN != -1) && (ADC_SENSORS_CONF_ADC3_PIN != 2))
213 #error "ADC3 channel should be mapped to PA2 or disabled with -1"
214 #else
215 #define ADC_SENSORS_ADC3_PIN ADC_SENSORS_CONF_ADC3_PIN
216 #endif
217 #endif
218 
219 #ifndef ADC_SENSORS_CONF_ADC2_PIN
220 #define ADC_SENSORS_ADC2_PIN (-1) /**< ADC2 no declared */
221 #else
222 #define ADC_SENSORS_ADC2_PIN 4 /**< Hard-coded to PA4 */
223 #endif
224 
225 #ifndef ADC_SENSORS_CONF_ADC4_PIN
226 #define ADC_SENSORS_ADC4_PIN (-1) /**< ADC4 not declared */
227 #else
228 #define ADC_SENSORS_ADC4_PIN 6 /**< Hard-coded to PA6 */
229 #endif
230 
231 #ifndef ADC_SENSORS_CONF_ADC5_PIN
232 #define ADC_SENSORS_ADC5_PIN (-1) /**< ADC5 not declared */
233 #else
234 #define ADC_SENSORS_ADC5_PIN 7 /**< Hard-coded to PA7 */
235 #endif
236 
237 #ifndef ADC_SENSORS_CONF_ADC6_PIN
238 #define ADC_SENSORS_ADC6_PIN (-1) /**< ADC6 not declared */
239 #else
240 #define ADC_SENSORS_ADC6_PIN 3 /**< Hard-coded to PA3 */
241 #endif
242 
243 #ifndef ADC_SENSORS_CONF_MAX
244 #define ADC_SENSORS_MAX 2 /**< Maximum sensors */
245 #else
246 #define ADC_SENSORS_MAX ADC_SENSORS_CONF_MAX
247 #endif
248 /** @} */
249 /*---------------------------------------------------------------------------*/
250 /** \name RE-Mote Button configuration
251  *
252  * Buttons on the RE-Mote are connected as follows:
253  * - BUTTON_USER -> PA3, S1 user button, shared with bootloader and RTC_INT1
254  * - BUTTON_RESET -> RESET_N line, S2 reset both CC2538 and CoP
255  * - BUTTON_PIC1W -> shared with SHUTDOWN_ENABLE, not mounted.
256  * @{
257  */
258 /** BUTTON_USER -> PA3 */
259 #define BUTTON_USER_PORT GPIO_A_NUM
260 #define BUTTON_USER_PIN 3
261 #define BUTTON_USER_VECTOR GPIO_A_IRQn
262 
263 /* Notify various examples that we have an user button.
264  * If ADC6 channel is used, then disable the user button
265  */
266 #ifdef PLATFORM_CONF_WITH_BUTTON
267 #if (PLATFORM_CONF_WITH_BUTTON && (ADC_SENSORS_ADC6_PIN == 3))
268 #error "The ADC6 (PA3) and user button cannot be enabled at the same time"
269 #else
270 #define PLATFORM_HAS_BUTTON (PLATFORM_CONF_WITH_BUTTON && \
271  !(ADC_SENSORS_ADC6_PIN == 3))
272 #endif /* (PLATFORM_CONF_WITH_BUTTON && (ADC_SENSORS_ADC6_PIN == 3)) */
273 #else
274 #define PLATFORM_HAS_BUTTON !(ADC_SENSORS_ADC6_PIN == 3)
275 #endif /* PLATFORM_CONF_WITH_BUTTON */
276 /** @} */
277 /*---------------------------------------------------------------------------*/
278 /**
279  * \name SPI (SSI0) configuration
280  *
281  * These values configure which CC2538 pins to use for the SPI (SSI0) lines,
282  * reserved exclusively for the CC1200 RF transceiver. These pins are not
283  * exposed to any connector, and should be avoid to use it.
284  * TX -> MOSI, RX -> MISO
285  * @{
286  */
287 #define SPI0_CLK_PORT GPIO_B_NUM
288 #define SPI0_CLK_PIN 2
289 #define SPI0_TX_PORT GPIO_B_NUM
290 #define SPI0_TX_PIN 1
291 #define SPI0_RX_PORT GPIO_B_NUM
292 #define SPI0_RX_PIN 3
293 /** @} */
294 /*---------------------------------------------------------------------------*/
295 /**
296  * \name SPI (SSI1) configuration
297  *
298  * These values configure which CC2538 pins to use for the SPI (SSI1) lines,
299  * shared with the microSD and exposed over JP5 connector.
300  * It is advisable to use a CSn pin other than the Micro-SD's.
301  * TX -> MOSI, RX -> MISO
302  * @{
303  */
304 #define SPI1_CLK_PORT GPIO_C_NUM
305 #define SPI1_CLK_PIN 4
306 #define SPI1_TX_PORT GPIO_C_NUM
307 #define SPI1_TX_PIN 5
308 #define SPI1_RX_PORT GPIO_C_NUM
309 #define SPI1_RX_PIN 6
310 /** @} */
311 /*---------------------------------------------------------------------------*/
312 /**
313  * \name I2C configuration
314  *
315  * These values configure which CC2538 pins to use for the I2C lines, exposed
316  * over JP6 connector, also available as testpoints T2 (PC2) and T3 (PC3).
317  * The I2C bus is shared with the on-board RTC.
318  * The I2C is exposed over the JP6 header, using a 5-pin connector with 2.54 mm
319  * spacing, providing also D+3.3V, GND and a generic pin that can be used as an
320  * interrupt pin
321  * @{
322  */
323 #define I2C_SCL_PORT GPIO_C_NUM
324 #define I2C_SCL_PIN 3
325 #define I2C_SDA_PORT GPIO_C_NUM
326 #define I2C_SDA_PIN 2
327 #define I2C_INT_PORT GPIO_D_NUM
328 #define I2C_INT_PIN 1
329 #define I2C_INT_VECTOR GPIO_D_IRQn
330 /** @} */
331 /*---------------------------------------------------------------------------*/
332 /**
333  * \name Antenna switch configuration
334  *
335  * These values configure the required pin to drive the RF antenna switch, to
336  * either enable the sub-1Ghz RF interface (power-up the CC1200) or the 2.4GHz
337  * RF interface of the CC2538, both alternatively routed to a RP-SMA connector
338  * to allow using an external antenna for both cases.
339  *
340  * Note it is also possible to enable both RF interfaces at the same time, by
341  * switching On the sub-1GHz RF interface, and placing an 0Ohm resistor (R19),
342  * to select between using a ceramic chip antenna (not mounted), or to connect
343  * and external antenna over a pigtail to the U.Fl connector (not mounted).
344  *
345  * RF switch state:
346  * - LOW: 2.4GHz RF interface on RP-SMA connector, CC1200 powered-off.
347  * - HIGH: Sub-1GHz RF interface on RP-SMA connector.
348  * @{
349  */
350 #define ANTENNA_RF_SW_PORT GPIO_D_NUM
351 #define ANTENNA_RF_SW_PIN 2
352 /** @} */
353 /*---------------------------------------------------------------------------*/
354 /**
355  * \name Dual RF interface support
356  *
357  * Enables support for dual band operation (both CC1200 and 2.4GHz enabled).
358  * The driver checks the selected Radio stack, and forces the antenna switch to
359  * either position. Enabling the definition below forces to skip this check.
360  * @{
361  */
362 #define REMOTE_DUAL_RF_ENABLED 0
363 /** @} */
364 /*---------------------------------------------------------------------------*/
365 /**
366  * \name CC1200 configuration
367  *
368  * These values configure the required pins to drive the CC1200
369  * None of the following pins are exposed to any connector, kept for internal
370  * use only
371  * @{
372  */
373 #define CC1200_SPI_INSTANCE 0
374 #define CC1200_SPI_SCLK_PORT SPI0_CLK_PORT
375 #define CC1200_SPI_SCLK_PIN SPI0_CLK_PIN
376 #define CC1200_SPI_MOSI_PORT SPI0_TX_PORT
377 #define CC1200_SPI_MOSI_PIN SPI0_TX_PIN
378 #define CC1200_SPI_MISO_PORT SPI0_RX_PORT
379 #define CC1200_SPI_MISO_PIN SPI0_RX_PIN
380 #define CC1200_SPI_CSN_PORT GPIO_B_NUM
381 #define CC1200_SPI_CSN_PIN 5
382 #define CC1200_GDO0_PORT GPIO_B_NUM
383 #define CC1200_GDO0_PIN 4
384 #define CC1200_GDO2_PORT GPIO_B_NUM
385 #define CC1200_GDO2_PIN 0
386 #define CC1200_RESET_PORT GPIO_C_NUM
387 #define CC1200_RESET_PIN 7
388 #define CC1200_GPIOx_VECTOR GPIO_B_IRQn
389 /** @} */
390 /*---------------------------------------------------------------------------*/
391 /**
392  * \name microSD configuration
393  *
394  * These values configure the required pins to drive the built-in microSD
395  * external module, to be used with SSI1
396  * @{
397  */
398 #define USD_SPI_INSTANCE 1
399 #define USD_CLK_PORT SPI1_CLK_PORT
400 #define USD_CLK_PIN SPI1_CLK_PIN
401 #define USD_MOSI_PORT SPI1_TX_PORT
402 #define USD_MOSI_PIN SPI1_TX_PIN
403 #define USD_MISO_PORT SPI1_RX_PORT
404 #define USD_MISO_PIN SPI1_RX_PIN
405 #define USD_CSN_PORT GPIO_A_NUM
406 #define USD_CSN_PIN 7
407 #define USD_SEL_PORT GPIO_A_NUM
408 #define USD_SEL_PIN 6
409 /** @} */
410 /*---------------------------------------------------------------------------*/
411 /**
412  * \name Power management and shutdown mode
413  *
414  * The shutdown mode is an ultra-low power operation mode that effectively
415  * powers-down the entire RE-Mote (CC2538, CC1200, attached sensors, etc) and
416  * only keeps running a power gating timer (NanoTimer), the on-board RTC and
417  * an ultra-low power consumption MCU (PIC12F635). The Shutdown mode allows:
418  *
419  * - Put the RE-Mote in an ultra-low power sleep (shutdown) drawing <200nA avg.
420  * - Periodically awake and execute tasks, being the shutdown period selectable
421  * via R47 resistor value (22KOhm as default for 1 minute shutdown period).
422  * - Enter shutdown mode before the shutdown period expiration, by invoking the
423  * PM_SHUTDOWN_NOW macrp
424  *
425  * The shutdown mode can be disabled by hardware by short-circuiting or placing
426  * an 0Ohm resistor across W1 pad.
427  * @{
428  */
429 #define PM_DONE_PORT GPIO_D_NUM
430 #define PM_DONE_PIN 0
431 #define PM_CMD_PORT GPIO_D_NUM
432 #define PM_CMD_PIN 1
433 /** @} */
434 /*---------------------------------------------------------------------------*/
435 /**
436  * \name On-board RTC
437  *
438  * The shutdown mode can be disabled by hardware by short-circuiting or placing
439  * an 0Ohm resistor across W1 pad. As the RTC_INT1 pin is also shared with the
440  * BUTTON_USER, so either disable or not use the user button, or upon receiving
441  * an interrupt, poll the RTC.
442  *
443  * The RTC_INT1 can be used to exit the CC2538's LPM3 mode.
444  * A second interruption pin is connected to the PIC12F635, for applications
445  * requiring to put the PIC into deep-sleep and waking up at a certain time.
446  * @{
447  */
448 #define PLATFORM_HAS_RTC 1
449 #define RTC_SDA_PORT I2C_SDA_PORT
450 #define RTC_SDA_PIN I2C_SDA_PIN
451 #define RTC_SCL_PORT I2C_SCL_PORT
452 #define RTC_SCL_PIN I2C_SCL_PIN
453 #define RTC_INT1_PORT GPIO_A_NUM
454 #define RTC_INT1_PIN 4
455 #define RTC_INT1_VECTOR GPIO_A_IRQn
456 /** @} */
457 /*---------------------------------------------------------------------------*/
458 /**
459  * \name On-board external WDT
460  * The RE-Mote features an on-board external WDT and battery monitor, which
461  * adds more robustness and prevents the mote to run wild if any unexpected
462  * problem shows-up.
463  * The external WDT requires a short pulse (<1ms) to be sent before a 2-second
464  * period. The battery monitor keeps the device in Reset if the voltage input
465  * is lower than 2.5V.
466  * The external WDT can be disabled by removing the R40 0Ohm resistor.
467  * The EXT_WDT pin is shared with LED1 (Red). For long-time operation, it is
468  * advised to remove R14 resistor to disable LED1.
469  * As default the Texas Instrument's TPS3823 WDT is not mounted.
470  * @{
471  */
472 #define EXT_WDT_PORT GPIO_D_NUM
473 #define EXT_WDT_PIN 5
474 /** @} */
475 /*---------------------------------------------------------------------------*/
476 /**
477  * \name Device string used on startup
478  * @{
479  */
480 #define BOARD_STRING "Zolertia RE-Mote revision A platform"
481 /** @} */
482 
483 #endif /* BOARD_H_ */
484 
485 /**
486  * @}
487  * @}
488  */
Header file for the ARM Nested Vectored Interrupt Controller.
Header file with register and macro declarations for the cc2538 GPIO module.