diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2013-07-02 13:52:09 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2013-07-02 13:52:09 -0600 |
commit | 839fa173a58af540fe9b8232ded8559661d3826c (patch) | |
tree | be54613e8a52887b1ca52b81032edf5e35f4e61f | |
parent | cae1325e2b7a87ca6fb94b96ef01d524aebb3e0f (diff) | |
download | nuttx-839fa173a58af540fe9b8232ded8559661d3826c.tar.gz nuttx-839fa173a58af540fe9b8232ded8559661d3826c.tar.bz2 nuttx-839fa173a58af540fe9b8232ded8559661d3826c.zip |
Several fixes to get a clean compile of the Arduino touch screen
-rw-r--r-- | nuttx/arch/arm/src/sam34/sam_gpioirq.c | 83 | ||||
-rw-r--r-- | nuttx/configs/arduino-due/README.txt | 14 | ||||
-rw-r--r-- | nuttx/configs/arduino-due/src/arduino-due.h | 2 | ||||
-rw-r--r-- | nuttx/configs/arduino-due/src/sam_touchscreen.c | 33 | ||||
-rw-r--r-- | nuttx/configs/sam3u-ek/README.txt | 2 | ||||
-rwxr-xr-x | nuttx/include/nuttx/spi/spi_bitbang.c | 8 |
6 files changed, 107 insertions, 35 deletions
diff --git a/nuttx/arch/arm/src/sam34/sam_gpioirq.c b/nuttx/arch/arm/src/sam34/sam_gpioirq.c index 11ea34aa6..854644bfb 100644 --- a/nuttx/arch/arm/src/sam34/sam_gpioirq.c +++ b/nuttx/arch/arm/src/sam34/sam_gpioirq.c @@ -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); diff --git a/nuttx/configs/arduino-due/README.txt b/nuttx/configs/arduino-due/README.txt index 976322e43..92b3437a7 100644 --- a/nuttx/configs/arduino-due/README.txt +++ b/nuttx/configs/arduino-due/README.txt @@ -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. + diff --git a/nuttx/configs/arduino-due/src/arduino-due.h b/nuttx/configs/arduino-due/src/arduino-due.h index 0679f6ea4..34a33b3a6 100644 --- a/nuttx/configs/arduino-due/src/arduino-due.h +++ b/nuttx/configs/arduino-due/src/arduino-due.h @@ -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 */ diff --git a/nuttx/configs/arduino-due/src/sam_touchscreen.c b/nuttx/configs/arduino-due/src/sam_touchscreen.c index 0ed62cb63..7aefb1279 100644 --- a/nuttx/configs/arduino-due/src/sam_touchscreen.c +++ b/nuttx/configs/arduino-due/src/sam_touchscreen.c @@ -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 */ diff --git a/nuttx/configs/sam3u-ek/README.txt b/nuttx/configs/sam3u-ek/README.txt index e6c77331f..c1193b831 100644 --- a/nuttx/configs/sam3u-ek/README.txt +++ b/nuttx/configs/sam3u-ek/README.txt @@ -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 diff --git a/nuttx/include/nuttx/spi/spi_bitbang.c b/nuttx/include/nuttx/spi/spi_bitbang.c index 02038de47..d2cc22a5e 100755 --- a/nuttx/include/nuttx/spi/spi_bitbang.c +++ b/nuttx/include/nuttx/spi/spi_bitbang.c @@ -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) { |