Flesh out a few missing pieces for the Arduino ITEAD TFT shield

This commit is contained in:
Gregory Nutt
2013-07-02 11:36:48 -06:00
parent 3c36e6e8b5
commit d09fd9a9ca
5 changed files with 200 additions and 111 deletions
+89 -49
View File
@@ -113,50 +113,51 @@
* 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
* ---------- ---- ---------------------- ----------- ----- ---------- ------------------
* ---------- --------------------------- ----------- --------------------------- ------------------
* 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 ---
* 10 SCL1 PA18 TWCK0/A20/WKUP9 SCL1 --- --- --- SCL not available
* 9 SDA1 PA17 TWD0SPCK0 SDA1 --- --- --- SDA not available
* 8 Aref --- --- AREF J2 pin 8 Vref N/C ---
* 7 GND --- --- GND J2 pin 7 GND --- ---
* 6 PWM13 PB27 SPI0_SPCK/A20/WKUP10 PWM13 J2 pin 6 D13 SD_SCK SCK, also LED "L", Pulled low
* 5 PWM12 PD8 A21/NANDALE/TIOB8 PWM12 J2 pin 5 D12 SD_MISO MISO not available
* 4 PWM11 PD7 A17/BA1/TIOA8 PWM11 J2 pin 4 D11 SD_MOSI MOSI not available, Pulled low
* 3 PWM10 PA28 SPI0_NPCS0/PCK2/WKUP11 SS0/PWM10 J2 pin 3 D10 SD_CS Pulled low on-board
* 2 PWM9 PC21 A0/NBS0/PWML4 PWM9 J2 pin 2 D9 Touch_Dout ---
* 1 PWM8 PC22 A1/PWML5 PWM8 J2 pin 1 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
* ---------- ---- ---------------------- ----------- ----- ---------- ------------------
* 8 PWM7 PC23 A2/PWML6 PWM7 J3 pin 8 D7 DB15 ---
* 7 PWM6 PC24 A3/PWML7 PWM6 J3 pin 7 D6 DB14 ---
* 6 PWM5 PC25 A4/TIOA6 PWM5 J3 pin 6 D5 DB13 ---
* 5 PWM4 PC26 A5/TIOB6 SS1/PWM4 J3 pin 5 D4 DB12 ---
* 4 PWM3 PC28 A7/TIOA7 PWM3 J3 pin 4 D3 DB11 ---
* 3 PWM2 PB25 RTS0/TIOA0 PWM2 J3 pin 3 D2 DB10 ---
* 2 PWM1 PA9 UTXD/PWMH3 TX J3 pin 2 D1 DB9 UART0 TX
* 1 PWM0 PA8 URXD/PWMH0/WKUP4 RX J3 pin 1 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 --- ---
* 1 --- --- --- --- --- --- --- ---
* 2 IOref --- --- IOREF +3V3 --- --- --- ---
* 3 RESET --- --- MASTER_RESET J4 pin 1 RST --- ---
* 5 5V --- --- +5V J4 pin 2 3.3V --- ---
* 4 3.3V --- --- +3V3 J4 pin 3 5V --- ---
* 6 GND --- --- GND J4 pin 4 GND --- ---
* 7 GND --- --- GND J4 pin 5 GND --- ---
* 8 Vin --- --- VIN J4 pin 6 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 --- --- ---
* ---------- ---- ---------------------- ----------- ----- ---------- ------------------
* 1 A0 PA16 SPCK1/TD/AD7 AD0 J1 pin 1 A0/D14 Touch_Din ---
* 2 A1 PA24 MCDA3/PCK1/AD6 AD1 J1 pin 1 A1/D15 Touch_CLK ---
* 3 A2 PA23 MCDA2/TCLK4/AD5 AD2 J1 pin 1 A2/D16 --- ---
* 4 A3 PA22 MCDA1/TCLK3/AD4 AD3 J1 pin 1 A3/D17 TFT_CS ---
* 5 A4 PA6 TIOB2/NCS0/AD3 AD4 J1 pin 1 A4/D18 TFT_WR ---
* 6 A5 PA4 TCLK1/NWAIT/AD2 AD5 J1 pin 1 A5/D19 TFT_RS ---
* 7 A6 PA3 TIOB1/PWMFI1/AD1/WKUP1 AD6 --- --- --- ---
* 8 A7 PA2 TIOA1/NANDRDY/AD0 AD7 --- --- --- ---
* ---------- ---- ---------------------- ----------- ---------------- ---------- ------------------
*
* NOTES:
*
@@ -165,7 +166,8 @@
* 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.
* 4. Touchcontroller /CS pin is connected to ground (always selected).
* 5. Either PA28 or PC29 may drive PWM10
*/
#ifdef CONFIG_ARDUINO_ITHEAD_TFT
@@ -175,9 +177,27 @@
# 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.
*/
/* SD Interface:
*
* ------------ ------------------ ------- ------------- ------------------ -------
* SD CONNECTOR ARDUINO CONNECTORS AT91SAM SD CONNECTOR ARDUINO CONNECTORS AT91SAM
* PIN SIGNAL PIN SIGNAL GPIO PIN SIGNAL PIN SIGNAL GPIO
* --- -------- -------- --------- -------- ---- -------- -------- --------- -------
* 1 /CS J2 pin 3 D10 PA28 2 DI J2 pin 4 D11 PD7
* 3 GND --- --- --- 4 VCC --- --- ---
* 5 CLK J2 pin 6 D13 PB27 6 GND --- --- ---
* 7 DO J2 pin 5 D12 PD8 8 IRQ N/C --- ---
* 9 N/C --- --- --- 10 SW N/C --- ---
* 11 WP N/C --- --- 12 CD N/C --- ---
* 13 CD N/C --- --- 14 GND --- --- ---
* 15 GND --- --- --- 16 GND --- --- ---
* --- -------- -------- --------- -------- ---- -------- -------- --------- -------
*
* NOTES:
* - 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.
* - Either PA28 or PC29 may drive D10
*/
# ifdef CONFIG_ARCH_LEDs
# error LEDs may not be used with the ITEAD SD card
@@ -189,8 +209,9 @@
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?)
GPIO_PORT_PIOA | GPIO_PIN28)
# endif
/* In order to use the touchscreen on the ITEAD shield, you must enable the
@@ -198,16 +219,35 @@
*/
# if defined(CONFIG_SPI_BITBANG) && defined(CONFIG_INPUT_ADS7843E)
/* Touch Controller Interface:
*
* ----------- ------------------ -------- ------------- ------------------ -------
* XPT2046 ARDUINO CONNECTORS AT91SAM XPT2046 ARDUINO CONNECTORS AT91SAM
* PIN SIGNAL PIN SIGNAL GPIO PIN SIGNAL PIN SIGNAL GPIO
* --- ------- -------- --------- -------- ---- -------- -------- --------- -------
* 1 VCC --- --- --- 2 X+ --- --- ---
* 3 Y+ --- --- --- 4 X- --- --- ---
* 5 Y- --- --- --- 6 GND --- --- ---
* 7 IN3 N/C --- --- 8 IN4 N/C --- ---
* 9 VREF --- --- --- 10 VCC --- --- ---
* 11 IRQ J2 pin 2 D9 PC21 12 DOUT J2 pin 1 D8 PC22
* 13 BUSY N/C --- --- 14 DIN J1 pin 1 D14 PA16
* 15 /CS --- --- --- 16 DCLK J1 pin 2 D15 PA24
* --- ------- -------- --------- -------- ---- -------- -------- --------- -------
*
* NOTE: /CS is connected to ground (XPT2046 is always selected)
*/
# 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)
GPIO_PORT_PIOC | GPIO_PIN22)
# 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)
GPIO_PORT_PIOC | GPIO_PIN21)
# define SAM_TCS_IRQ SAM_IRQ_PC21
# endif
+14 -3
View File
@@ -76,6 +76,8 @@
#define SPI_SETMOSI putreg32(1 << 7, SAM_PIOD_SODR)
#define SPI_CLRMOSI putreg32(1 << 7, SAM_PIOD_CODR)
#define SPI_GETMISO ((getreg32(SAM_PIOD_PDSR) >> 8) & 1)
#define SPI_SETCS putreg32(1 << 28, SAM_PIOA_SODR)
#define SPI_CLRCS putreg32(1 << 28, SAM_PIOA_CODR)
/* Only mode 0 */
@@ -143,7 +145,17 @@ static int spi_cmddata(FAR struct spi_bitbang_s *priv, enum spi_dev_e devid,
static void spi_select(FAR struct spi_bitbang_s *priv, enum spi_dev_e devid,
bool selected)
{
# warning Still need CS GPIO pin
if (devid == SPIDEV_MMCSD)
{
if (selected)
{
SPI_CLRCS;
}
else
{
SPI_SETCS;
}
}
}
/****************************************************************************
@@ -216,8 +228,7 @@ static FAR struct spi_dev_s *sam_mmcsd_spiinitialize(void)
sam_configgpio(GPIO_SD_SCK);
sam_configgpio(GPIO_SD_MISO);
sam_configgpio(GPIO_SD_MOSI);
// sam_configgpio(GPIO_SD_CS);
# warning Still need CS GPIO pin
sam_configgpio(GPIO_SD_CS);
/* Create the SPI driver instance */
+10 -14
View File
@@ -92,8 +92,6 @@
#define SPI_SETMOSI putreg32(1 << 16, SAM_PIOA_SODR)
#define SPI_CLRMOSI putreg32(1 << 16, SAM_PIOA_CODR)
#define SPI_GETMISO ((getreg32(SAM_PIOC_PDSR) >> 21) & 1)
#define SPI_SETCS putreg32(1 << ?, SAM_PIO?_SODR)
#define SPI_CLRCS putreg32(1 << ?, SAM_PIO?_CODR)
/* Only mode 0 */
@@ -131,12 +129,12 @@ static int spi_cmddata(FAR struct spi_bitbang_s *priv, enum spi_dev_e devid,
#endif
/* IRQ/GPIO access callbacks. These operations all hidden behind
* callbacks to isolate the ADS7843E driver from differences in GPIO
* callbacks to isolate the XPT2046 driver from differences in GPIO
* interrupt handling by varying boards and MCUs. If possible,
* interrupts should be configured on both rising and falling edges
* so that contact and loss-of-contact events can be detected.
*
* attach - Attach the ADS7843E interrupt handler to the GPIO interrupt
* attach - Attach the XPT2046 interrupt handler to the GPIO interrupt
* enable - Enable or disable the GPIO interrupt
* clear - Acknowledge/clear any pending GPIO interrupt
* pendown - Return the state of the pen down GPIO input
@@ -152,9 +150,9 @@ static bool tsc_pendown(FAR struct ads7843e_config_s *state);
* Private Data
****************************************************************************/
/* A reference to a structure of this type must be passed to the ADS7843E
/* A reference to a structure of this type must be passed to the XPT2046
* driver. This structure provides information about the configuration
* of the ADS7843E and provides some board-specific hooks.
* of the XPT2046 and provides some board-specific hooks.
*
* Memory for this structure is provided by the caller. It is not copied
* by the driver and is presumed to persist while the driver is active. The
@@ -201,7 +199,7 @@ static struct ads7843e_config_s g_tscinfo =
static void spi_select(FAR struct spi_bitbang_s *priv, enum spi_dev_e devid,
bool selected)
{
# warning Still need CS GPIO pin
/* The touchscreen controller is always selected */
}
/****************************************************************************
@@ -250,12 +248,12 @@ static int spi_cmddata(FAR struct spi_bitbang_s *priv, enum spi_dev_e devid,
/****************************************************************************
* IRQ/GPIO access callbacks. These operations all hidden behind
* callbacks to isolate the ADS7843E driver from differences in GPIO
* callbacks to isolate the XPT2046 driver from differences in GPIO
* interrupt handling by varying boards and MCUs. If possible,
* interrupts should be configured on both rising and falling edges
* so that contact and loss-of-contact events can be detected.
*
* attach - Attach the ADS7843E interrupt handler to the GPIO interrupt
* attach - Attach the XPT2046 interrupt handler to the GPIO interrupt
* enable - Enable or disable the GPIO interrupt
* clear - Acknowledge/clear any pending GPIO interrupt
* pendown - Return the state of the pen down GPIO input
@@ -264,7 +262,7 @@ static int spi_cmddata(FAR struct spi_bitbang_s *priv, enum spi_dev_e devid,
static int tsc_attach(FAR struct ads7843e_config_s *state, xcpt_t isr)
{
/* Attach the ADS7843E interrupt */
/* Attach the XPT2046 interrupt */
ivdbg("Attaching %p to IRQ %d\n", isr, SAM_TCS_IRQ);
return irq_attach(SAM_TCS_IRQ, isr);
@@ -342,7 +340,6 @@ static FAR struct spi_dev_s *sam_tsc_spiinitialize(void)
sam_configgpio(GPIO_TSC_SCK);
sam_configgpio(GPIO_TSC_MISO);
sam_configgpio(GPIO_TSC_MOSI);
sam_configgpio(GPIO_TSC_CS);
/* Create the SPI driver instance */
@@ -379,10 +376,9 @@ int arch_tcinitialize(int minor)
idbg("minor %d\n", minor);
DEBUGASSERT(minor == 0);
/* Configure and enable the ADS7843E interrupt pin as an input */
/* Configure and enable the XPT2046 interrupt pin as an input */
(void)sam_configgpio(GPIO_TSC_IRQ);
(void)sam_configgpio(GPIO_TCS_IRQ);
/* Configure the PIO interrupt */
@@ -428,7 +424,7 @@ int arch_tcinitialize(int minor)
void arch_tcuninitialize(void)
{
/* No support for un-initializing the touchscreen ADS7843E device yet */
/* No support for un-initializing the touchscreen XPT2046 device yet */
}
#endif /* CONFIG_ARDUINO_ITHEAD_TFT && CONFIG_SPI_BITBANG && CONFIG_INPUT_ADS7843E */