Several fixes to get a clean compile of the Arduino touch screen

This commit is contained in:
Gregory Nutt 2013-07-02 13:52:09 -06:00
parent 0ff5a0c791
commit f0ebaf8312
6 changed files with 107 additions and 35 deletions
arch/arm/src/sam34
configs
include/nuttx/spi

@ -84,7 +84,7 @@
*
****************************************************************************/
static inline uint32_t sam_gpiobase(uint16_t pinset)
static inline uint32_t sam_gpiobase(gpio_pinset_t pinset)
{
int port = (pinset & GPIO_PORT_MASK) >> GPIO_PORT_SHIFT;
return SAM_PION_BASE(port >> GPIO_PORT_SHIFT);
@ -98,7 +98,7 @@ static inline uint32_t sam_gpiobase(uint16_t pinset)
*
****************************************************************************/
static inline int sam_gpiopin(uint16_t pinset)
static inline int sam_gpiopin(gpio_pinset_t pinset)
{
return 1 << ((pinset & GPIO_PIN_MASK) >> GPIO_PIN_SHIFT);
}
@ -195,6 +195,27 @@ static int up_gpiocinterrupt(int irq, void *context)
}
#endif
#ifdef CONFIG_GPIOD_IRQ
static int up_gpiodinterrupt(int irq, void *context)
{
return up_gpiointerrupt(SAM_PIOD_BASE, SAM_IRQ_PD0, context);
}
#endif
#ifdef CONFIG_GPIOE_IRQ
static int up_gpioeinterrupt(int irq, void *context)
{
return up_gpiointerrupt(SAM_PIOE_BASE, SAM_IRQ_PE0, context);
}
#endif
#ifdef CONFIG_GPIOF_IRQ
static int up_gpiofinterrupt(int irq, void *context)
{
return up_gpiointerrupt(SAM_PIOF_BASE, SAM_IRQ_PF0, context);
}
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
@ -260,9 +281,63 @@ void sam_gpioirqinitialize(void)
/* Attach and enable the GPIOC IRQ */
(void)irq_attach(SAM_IRQ_PIOC, up_gpioainterrupt);
(void)irq_attach(SAM_IRQ_PIOC, up_gpiocinterrupt);
up_enable_irq(SAM_IRQ_PIOC);
#endif
/* Configure GPIOD interrupts */
#ifdef CONFIG_GPIOD_IRQ
/* Enable GPIOD clocking */
sam_piod_enableclk();
/* Clear and disable all GPIOD interrupts */
(void)getreg32(SAM_PIOD_ISR);
putreg32(0xffffffff, SAM_PIOD_IDR);
/* Attach and enable the GPIOC IRQ */
(void)irq_attach(SAM_IRQ_PIOD, up_gpiodinterrupt);
up_enable_irq(SAM_IRQ_PIOD);
#endif
/* Configure GPIOE interrupts */
#ifdef CONFIG_GPIOE_IRQ
/* Enable GPIOE clocking */
sam_pioe_enableclk();
/* Clear and disable all GPIOE interrupts */
(void)getreg32(SAM_PIOE_ISR);
putreg32(0xffffffff, SAM_PIOE_IDR);
/* Attach and enable the GPIOE IRQ */
(void)irq_attach(SAM_IRQ_PIOE, up_gpioeinterrupt);
up_enable_irq(SAM_IRQ_PIOE);
#endif
/* Configure GPIOF interrupts */
#ifdef CONFIG_GPIOF_IRQ
/* Enable GPIOF clocking */
sam_piof_enableclk();
/* Clear and disable all GPIOF interrupts */
(void)getreg32(SAM_PIOF_ISR);
putreg32(0xffffffff, SAM_PIOF_IDR);
/* Attach and enable the GPIOF IRQ */
(void)irq_attach(SAM_IRQ_PIOF, up_gpiofinterrupt);
up_enable_irq(SAM_IRQ_PIOF);
#endif
}
/************************************************************************************
@ -273,7 +348,7 @@ void sam_gpioirqinitialize(void)
*
************************************************************************************/
void sam_gpioirq(uint16_t pinset)
void sam_gpioirq(gpio_pinset_t pinset)
{
uint32_t base = sam_gpiobase(pinset);
int pin = sam_gpiopin(pinset);

@ -1024,6 +1024,9 @@ Configuration sub-directories
Application Configuration -> NSH Library
CONFIG_NSH_ARCHINIT=y : Board has architecture-specific initialization
STATUS:
2013-7-2: SD card is not responding. All 0's received on SPI.
3. This configuration has been used for verifying the touchscreen on
on the ITEAD TFT Shield. With the modifications below, you can
include the touchscreen test program at apps/examples/touchscreen as
@ -1043,6 +1046,13 @@ Configuration sub-directories
CONFIG_SPI_BITBANG=y : Enable SPI bit-bang support
CONFIG_INPUT=y : Enable support for input devices
CONFIG_INPUT_ADS7843E=y : Enable support for the XPT2046
CONFIG_ADS7843E_SPIDEV=0 : (Doesn't matter)
CONFIG_ADS7843E_SPIMODE=0 : Use SPI mode 0
CONFIG_ADS7843E_FREQUENCY=1000000 : SPI BAUD 1MHz
CONFIG_ADS7843E_SWAPXY=y : If landscpe orientation
CONFIG_ADS7843E_THRESHX=51 : These will probably need to be tuned
CONFIG_ADS7843E_THRESHY=39
System Type:
CONFIG_GPIO_IRQ=y : GPIO interrupt support
@ -1064,3 +1074,7 @@ Configuration sub-directories
CONFIG_DEBUG=y : Enable debug features
CONFIG_DEBUG_VERBOSE=y : Enable verbose debug output
CONFIG_DEBUG_INPUT=y : Enable debug output from input devices
STATUS:
2013-7-2: TSC is not responding. All 0's received on SPI.

@ -248,7 +248,7 @@
# define GPIO_TSC_IRQ (GPIO_INPUT | GPIO_CFG_PULLUP | GPIO_INT_BOTHEDGES | \
GPIO_PORT_PIOC | GPIO_PIN21)
# define SAM_TCS_IRQ SAM_IRQ_PC21
# define SAM_TSC_IRQ SAM_IRQ_PC21
# endif
/* Only CONFIG_LCD is expected to enable the TFT LCD */

@ -264,22 +264,22 @@ static int tsc_attach(FAR struct ads7843e_config_s *state, xcpt_t isr)
{
/* Attach the XPT2046 interrupt */
ivdbg("Attaching %p to IRQ %d\n", isr, SAM_TCS_IRQ);
return irq_attach(SAM_TCS_IRQ, isr);
ivdbg("Attaching %p to IRQ %d\n", isr, SAM_TSC_IRQ);
return irq_attach(SAM_TSC_IRQ, isr);
}
static void tsc_enable(FAR struct ads7843e_config_s *state, bool enable)
{
/* Attach and enable, or detach and disable */
ivdbg("IRQ:%d enable:%d\n", SAM_TCS_IRQ, enable);
ivdbg("IRQ:%d enable:%d\n", SAM_TSC_IRQ, enable);
if (enable)
{
sam_gpioirqenable(SAM_TCS_IRQ);
sam_gpioirqenable(SAM_TSC_IRQ);
}
else
{
sam_gpioirqdisable(SAM_TCS_IRQ);
sam_gpioirqdisable(SAM_TSC_IRQ);
}
}
@ -290,31 +290,14 @@ static void tsc_clear(FAR struct ads7843e_config_s *state)
static bool tsc_busy(FAR struct ads7843e_config_s *state)
{
#if defined(CONFIG_DEBUG_INPUT) && defined(CONFIG_DEBUG_VERBOSE)
static bool last = (bool)-1;
#endif
/* BUSY is high impedance when CS is high (not selected). When CS is
* is low, BUSY is active high.
*/
bool busy = sam_gpioread(GPIO_TCS_BUSY);
#if defined(CONFIG_DEBUG_INPUT) && defined(CONFIG_DEBUG_VERBOSE)
if (busy != last)
{
ivdbg("busy:%d\n", busy);
last = busy;
}
#endif
return busy;
return false; /* The BUSY signal is not connected */
}
static bool tsc_pendown(FAR struct ads7843e_config_s *state)
{
/* The /PENIRQ value is active low */
bool pendown = !sam_gpioread(GPIO_TCS_IRQ);
bool pendown = !sam_gpioread(GPIO_TSC_IRQ);
ivdbg("pendown:%d\n", pendown);
return pendown;
}
@ -382,7 +365,7 @@ int arch_tcinitialize(int minor)
/* Configure the PIO interrupt */
sam_gpioirq(SAM_TCS_IRQ);
sam_gpioirq(SAM_TSC_IRQ);
/* Get an instance of the SPI interface for the touchscreen chip select */

@ -589,7 +589,7 @@ Configurations
CONFIG_SPI_OWNBUS=y : Smaller code if this is the only SPI device
CONFIG_INPUT=y : Enable support for input devices
CONFIG_INPUT_ADS7843E=y : Enable support for the XPT2048
CONFIG_INPUT_ADS7843E=y : Enable support for the XPT2046
CONFIG_ADS7843E_SPIDEV=2 : Use SPI CS 2 for communication
CONFIG_ADS7843E_SPIMODE=0 : Use SPI mode 0
CONFIG_ADS7843E_FREQUENCY=1000000 : SPI BAUD 1MHz

@ -363,7 +363,7 @@ static uint16_t spi_bitexchange0(uint16_t dataout, uint32_t holdtime)
}
SPI_SETSCK; /* Clock transition before getting MISO */
datain = (uint16_t)SPI_GETMISO; /* Get bit 0 = MOSI value */
datain = (uint16_t)SPI_GETMISO; /* Get bit 0 = MISO value */
if (holdtime > 0)
{
spi_delay(holdtime);
@ -428,7 +428,7 @@ static uint16_t spi_bitexchange1(uint16_t dataout, uint32_t holdtime)
}
SPI_CLRSCK; /* Clock transition before getting MISO */
datain = (uint16_t)SPI_GETMISO; /* Get bit 0 = MOSI value */
datain = (uint16_t)SPI_GETMISO; /* Get bit 0 = MISO value */
/* Clock is in resting state after getting MISO */
if (holdtime > 0)
{
@ -482,7 +482,7 @@ static uint16_t spi_bitexchange2(uint16_t dataout, uint32_t holdtime)
}
SPI_CLRSCK; /* Clock transition before getting MISO */
datain = (uint16_t)SPI_GETMISO; /* Get bit 0 = MOSI value */
datain = (uint16_t)SPI_GETMISO; /* Get bit 0 = MISO value */
if (holdtime > 0)
{
spi_delay(holdtime);
@ -547,7 +547,7 @@ static uint16_t spi_bitexchange3(uint16_t dataout, uint32_t holdtime)
}
SPI_SETSCK; /* Clock transition before getting MISO */
datain = (uint16_t)SPI_GETMISO; /* Get bit 0 = MOSI value */
datain = (uint16_t)SPI_GETMISO; /* Get bit 0 = MISO value */
/* Clock is in resting state after getting MISO */
if (holdtime > 0)
{