1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
|
/************************************************************************************
* configs/arduino-due/src/arduino-due.h
*
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
************************************************************************************/
#ifndef __CONFIGS_ARDUINO_DUE_SRC_ARDUNO_DUE_H
#define __CONFIGS_ARDUINO_DUE_SRC_ARDUNO_DUE_H
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
#include <nuttx/compiler.h>
#include <stdint.h>
#include <arch/irq.h>
#include <nuttx/irq.h>
#include "chip/sam_pinmap.h"
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
/* There are three user-controllable LEDs on board the Arduino Due board:
*
* LED GPIO
* ---------------- -----
* L Amber LED PB27
* TX Yellow LED PA21
* RX Yellow LED PC30
*
* LED L is connected to ground and can be illuminated by driving the PB27
* output high. The TX and RX LEDs are pulled high and can be illuminated by
* driving the corresponding
* GPIO output to low.
*
* These LEDs are not used by the board port unless CONFIG_ARCH_LEDS is
* defined. In that case, the usage by the board port is defined in
* include/board.h and src/sam_leds.c. The LEDs are used to encode OS-related
* events as follows:
*
* SYMBOL MEANING LED STATE
* L TX RX
* ------------------- ----------------------- -------- -------- --------
* LED_STARTED NuttX has been started OFF OFF OFF
* LED_HEAPALLOCATE Heap has been allocated OFF OFF OFF
* LED_IRQSENABLED Interrupts enabled OFF OFF OFF
* LED_STACKCREATED Idle stack created ON OFF OFF
* LED_INIRQ In an interrupt N/C GLOW OFF
* LED_SIGNAL In a signal handler N/C GLOW OFF
* LED_ASSERTION An assertion failed N/C GLOW OFF
* LED_PANIC The system has crashed N/C N/C Blinking
* LED_IDLE MCU is is sleep mode ------ Not used --------
*
* Thus if LED L is statically on, NuttX has successfully booted and is,
* apparently, running normmally. If LED RX is glowing, then NuttX is
* handling interupts (and also signals and assertions). If TX is flashing
* at approximately 2Hz, then a fatal error has been detected and the system
*/
#define GPIO_LED_L (GPIO_OUTPUT | GPIO_CFG_PULLUP | GPIO_OUTPUT_CLEAR | \
GPIO_PORT_PIOB | GPIO_PIN27)
#define GPIO_LED_RX (GPIO_OUTPUT | GPIO_CFG_PULLUP | GPIO_OUTPUT_SET | \
GPIO_PORT_PIOC | GPIO_PIN30)
#define GPIO_LED_TX (GPIO_OUTPUT | GPIO_CFG_PULLUP | GPIO_OUTPUT_SET | \
GPIO_PORT_PIOA | GPIO_PIN21)
/* ITEAD 2.4" TFT with Touch
*
* The Arduino 2.4" TFT Touch Shield is designed for all the Arduino
* compatible boards. It works in 3.3V voltage level. It can be directly
* plugged on the Arduino and other compatible boards. It will offer
* display, touch and storage functions for the Arduino board
*
* Features:
*
* 1. Compatible with 3.3/5V operation voltage level
* 2. Compatible with UTFT library
* 3. With SD Card Socket
*
* The Arduino 2.4" TFT Touch shield uses the S6D1121 controller , it
* supports 8-bit data interface. The touch IC is TSC2046.
*
* ---------- --------------------------- ----------- ----- ---------- ------------------
* Arduino ATSAM3X Due ITHEAD
* Due PIN GPIO FUNCTION SIGNAL PIN SIGNAL NOTES
* ---------- ---- ---------------------- ----------- ----- ---------- ------------------
* PWMH
* 10 SCL1 PA18 TWCK0/A20/WKUP9 SCL1 --- --- SCL not available
* 9 SDA1 PA17 TWD0SPCK0 SDA1 --- --- SDA not available
* 8 Aref --- --- AREF Vref --- ---
* 7 GND --- --- GND GND --- ---
* 6 PWM13 PB27 SPI0_SPCK/A20/WKUP10 PWM13 D13 SD_SCK SCK, also LED "L", Pulled low on-board
* 5 PWM12 PD8 A21/NANDALE/TIOB8 PWM12 D12 SD_MISO MISO not available
* 4 PWM11 PD7 A17/BA1/TIOA8 PWM11 D11 SD_MOSI MOSI not available, Pulled low on-board
* 3 PWM10 ??? ??? SS0/PWM10 D10 SD_CS Pulled low on-board
* 2 PWM9 PC21 A0/NBS0/PWML4 PWM9 D9 Touch_Dout ---
* 1 PWM8 PC22 A1/PWML5 PWM8 D8 Touch_IRQ ---
* PWML
* 8 PWM7 PC23 A2/PWML6 PWM7 D7 DB15 ---
* 7 PWM6 PC24 A3/PWML7 PWM6 D6 DB14 ---
* 6 PWM5 PC25 A4/TIOA6 PWM5 D5 DB13 ---
* 5 PWM4 PC26 A5/TIOB6 SS1/PWM4 D4 DB12 ---
* 4 PWM3 PC28 A7/TIOA7 PWM3 D3 DB11 ---
* 3 PWM2 PB25 RTS0/TIOA0 PWM2 D2 DB10 ---
* 2 PWM1 PA9 UTXD/PWMH3 TX D1 DB9 UART0 TX
* 1 PWM0 PA8 URXD/PWMH0/WKUP4 RX D0 DB8 UART0 RX
* ---------- ---- ---------------------- ----------- ----- ---------- ------------------
* POWER
* 1 --- --- --- --- --- --- ---
* 2 IOref --- --- IOREF +3V3 --- --- ---
* 3 RESET --- --- MASTER_RESET RST --- ---
* 4 3.3V --- --- +3V3 5V --- ---
* 5 5V --- --- +5V 3.3V --- ---
* 6 GND --- --- GND GND --- ---
* 7 GND --- --- GND GND --- ---
* 8 Vin --- --- VIN Vin --- ---
* ADCL
* 1 A0 PA16 SPCK1/TD/AD7 AD0 A0 Touch_Din ---
* 2 A1 PA24 MCDA3/PCK1/AD6 AD1 A1 Touch_CLK ---
* 3 A2 PA23 MCDA2/TCLK4/AD5 AD2 A2 --- ---
* 4 A3 PA22 MCDA1/TCLK3/AD4 AD3 A3 TFT_CS ---
* 5 A4 PA6 TIOB2/NCS0/AD3 AD4 A4 TFT_WR ---
* 6 A5 PA4 TCLK1/NWAIT/AD2 AD5 A5 TFT_RS ---
* 7 A6 PA3 TIOB1/PWMFI1/AD1/WKUP1 AD6 --- --- ---
* 8 A7 PA2 TIOA1/NANDRDY/AD0 AD7 --- --- ---
* ---------- ---- ---------------------- ----------- ----- ---------- ------------------
*
* NOTES:
*
* 1. It is not possible to use any of the SPI devices on the Shield unless
* a bit-bang SPI interface is used. This includes the touch controller
* and the SD card.
* 2. UART0 cannot be used. USARTs on the COMM connector should be available.
* 3. Parallel data is not contiguous in the PIO register
* 4. 3.3V and 5V are reversed.
*/
#ifdef CONFIG_ARDUINO_ITHEAD_TFT
/* In order to use the SD card on the ITEAD shield, you must enable the
* SPI bit-bang driver as well as support for SPI-based MMC/SD cards.
*/
# if defined(CONFIG_SPI_BITBANG) && defined(CONFIG_MMCSD_SPI)
/* The SD slot shares the pin with LED "L" so LED support must be disabled
* to use the MMC/SD card on the ITEAD shield.
*/
# ifdef CONFIG_ARCH_LEDs
# error LEDs may not be used with the ITEAD SD card
# endif
# define GPIO_SD_SCK (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \
GPIO_PORT_PIOB | GPIO_PIN27)
# define GPIO_SD_MISO (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \
GPIO_PORT_PIOD | GPIO_PIN8)
# define GPIO_SD_MOSI (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \
GPIO_PORT_PIOD | GPIO_PIN7)
# define GPIO_SD_CS (GPIO_OUTPUT | GPIO_CFG_PULLUP | GPIO_OUTPUT_CLEAR | \
GPIO_PORT_PIO? | GPIO_PIN?)
# endif
/* In order to use the touchscreen on the ITEAD shield, you must enable the
* SPI bit-bang driver and ADS7843E/XPT2046 device support.
*/
# if defined(CONFIG_SPI_BITBANG) && defined(CONFIG_INPUT_ADS7843E)
# define GPIO_TSC_SCK (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \
GPIO_PORT_PIOA | GPIO_PIN24)
# define GPIO_TSC_MISO (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \
GPIO_PORT_PIOC | GPIO_PIN21)
# define GPIO_TSC_MOSI (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \
GPIO_PORT_PIOA | GPIO_PIN16)
# define GPIO_TSC_CS (GPIO_OUTPUT | GPIO_CFG_PULLUP | GPIO_OUTPUT_CLEAR | \
GPIO_PORT_PIO? | GPIO_PIN?)
# define GPIO_TSC_IRQ (GPIO_INPUT | GPIO_CFG_PULLUP | GPIO_INT_BOTHEDGES | \
GPIO_PORT_PIOC | GPIO_PIN22)
# define SAM_TCS_IRQ SAM_IRQ_PC21
# endif
/* Only CONFIG_LCD is expected to enable the TFT LCD */
# ifdef CONFIG_LCD
/* UART0 cannot be used with the LCD because the UART0 pins are used
* by the LCD.
*/
# ifdef CONFIG_SAM34_UART0
# error "UART0 cannot be used with the ITEAD LCD"
# endif
/* Data pins are initially configured but may be switched dynamically to
* either inputs or outputs as needed.
*/
# define GPIO_LCD_D0IN (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \
GPIO_PORT_PIOA | GPIO_PIN8)
# define GPIO_LCD_D1IN (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \
GPIO_PORT_PIOA | GPIO_PIN9)
# define GPIO_LCD_D2IN (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \
GPIO_PORT_PIOB | GPIO_PIN25)
# define GPIO_LCD_D3IN (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \
GPIO_PORT_PIOC | GPIO_PIN28)
# define GPIO_LCD_D4IN (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \
GPIO_PORT_PIOC | GPIO_PIN26)
# define GPIO_LCD_D5IN (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \
GPIO_PORT_PIOC | GPIO_PIN25)
# define GPIO_LCD_D6IN (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \
GPIO_PORT_PIOC | GPIO_PIN24)
# define GPIO_LCD_D7IN (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \
GPIO_PORT_PIOC | GPIO_PIN23)
# define GPIO_LCD_D7IN (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \
GPIO_PORT_PIOC | GPIO_PIN23)
# define GPIO_LCD_CS (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \
GPIO_PORT_PIOA | GPIO_PIN22)
# define GPIO_LCD_WR (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \
GPIO_PORT_PIOA | GPIO_PIN6)
# define GPIO_LCD_RS (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \
GPIO_PORT_PIOA | GPIO_PIN4)
# endif
#endif
/************************************************************************************
* Public Types
************************************************************************************/
/************************************************************************************
* Public data
************************************************************************************/
#ifndef __ASSEMBLY__
/************************************************************************************
* Public Functions
************************************************************************************/
/************************************************************************************
* Name: sam_sram_initialize
*
* Description:
* Configure and enable SRAM on board the SAM4S Xplained
*
************************************************************************************/
#ifdef CONFIG_ARCH_EXTSRAM0
void sam_sram_initialize(void);
#endif
/************************************************************************************
* Name: up_ledinit
************************************************************************************/
#ifdef CONFIG_ARCH_LEDS
void up_ledinit(void);
#endif
/****************************************************************************
* Name: sam_sdinitialize
*
* Description:
* Initialize the SPI-based SD card.
*
*****************************************************************************/
#if defined(CONFIG_ARDUINO_ITHEAD_TFT) && defined(CONFIG_SPI_BITBANG) && \
defined(CONFIG_MMCSD_SPI)
int sam_sdinitialize(int minor);
#endif
#endif /* __ASSEMBLY__ */
#endif /* __CONFIGS_ARDUINO_DUE_SRC_ARDUNO_DUE_H */
|