From 3e37ff2fc49dec6505d29150152ea129fe608027 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 7 Apr 2013 13:46:05 -0600 Subject: [PATCH] LPC17xx GPIO interrupt fixes: lpc17_setintedge() must be atomic. Can't disable interrupts from interrupt handlers because they are automatically re-enabled. Try re-configuring pin instead. --- configs/open1788/README.txt | 80 +++++++++++++++++------- configs/open1788/src/lpc17_touchscreen.c | 20 ++++-- configs/open1788/src/open1788.h | 1 + 3 files changed, 76 insertions(+), 25 deletions(-) diff --git a/configs/open1788/README.txt b/configs/open1788/README.txt index 1c3a5191eb..2f7a3860ca 100644 --- a/configs/open1788/README.txt +++ b/configs/open1788/README.txt @@ -12,6 +12,7 @@ CONTENTS o Buttons o FPU o Using OpenOCD with the Olimex ARM-USB-OCD + o Loading Code with the ISP Board o Configuration LEDs @@ -245,27 +246,53 @@ Using OpenOCD with the Olimex ARM-USB-OCD (gdb) monitor halt NOTES: + 1. The MCU must be halted using 'monitor halt' prior to loading code. + 2. 'monitor reset' will restart the processor after loading code. + 3. The 'monitor' command can be abbreviated as just 'mon'. - After starting GDB, you can load the NuttX ELF file: + After starting GDB, you can load the NuttX ELF file like this: (gdb) mon halt (gdb) load nuttx NOTES: + 1. NuttX should have been built so that it has debugging symbols (by setting CONFIG_DEBUG_SYMBOLS=y in the .config file). + 2. The MCU must be halted prior to loading code. - 3. I find that there are often undetected write failures. I usually - load nuttx twice to assure good FLASH contents: + + 3. I find that there are often undetected write failures when using + the Olimex ARM-USB-OCD debugber and that if you start the program + with a bad FLASH failure, it will lock up OpenOCD. I usually + oad nuttx twice, restarting OpenOCD in between in order to assure + good FLASH contents: (gdb) mon halt (gdb) load nuttx (gdb) mon reset + + Exit GDB, kill the OpenOCD server, recycle power on the board, + restart the OpenOCD server and GDB, then: + (gdb) mon halt (gdb) load nuttx + (gdb) mon reset + + Other debuggers may not have these issues and such drastic steps may + not be necessary. + +Loading Code with the ISP Board +=============================== + + Use can also load code onto the board using the WaveShare and the UART0 + ISP/VCOM board. I use the FlashMagic program for Windows available here: + http://www.flashmagictool.com/ . It is so easy to use that no further + explanation should be necessary: Just select the LPC1788, the ISP COM + port, and the NuttX .hex file and program it. CONFIGURATION ============= @@ -452,15 +479,20 @@ CONFIGURATION on the 4.3" LCD module by modifying the configuration in the following ways: - CONFIG_INPUT=y : Enable support for input devices - CONFIG_INPUT_ADS7843E=y : Enable support for the XPT2048 - CONFIG_ADS7843E_SPIDEV=1 : Use SSP1 for communication - CONFIG_SPI=y : Enable SPI support - CONFIG_SPI_EXCHANGE=n : exchange() method is not supported - CONFIG_GPIO_IRQ=y : GPIO interrupt support - CONFIG_LPC17_SSP1=y : Enable support for SSP1 - CONFIG_EXAMPLES_TOUCHSCREEN=y : Enable the touchscreen built-int test - CONFIG_EXAMPLES_TOUCHSCREEN_BUILTIN=y + Drivers: + CONFIG_INPUT=y : Enable support for input devices + CONFIG_INPUT_ADS7843E=y : Enable support for the XPT2048 + CONFIG_ADS7843E_SPIDEV=1 : Use SSP1 for communication + CONFIG_SPI=y : Enable SPI support + CONFIG_SPI_EXCHANGE=n : exchange() method is not supported + + System Type: + CONFIG_GPIO_IRQ=y : GPIO interrupt support + CONFIG_LPC17_SSP1=y : Enable support for SSP1 + + Applicaton Configuration: + CONFIG_EXAMPLES_TOUCHSCREEN=y : Enable the touchscreen built-int test + CONFIG_EXAMPLES_TOUCHSCREEN_BUILTIN=y Defaults should be okay for related touchscreen settings. @@ -470,18 +502,24 @@ CONFIGURATION There is a jumper on board that enables the CD pin. OR, you can simply remove the SD module so that it does not drive the CD pin. - CONFIG_LPC17_GPDMA=n : No DMA - CONFIG_ARCH_DMA=n - CONFIG_LPC17_SDCARD=n : No SD card driver - CONFIG_SDIO_DMA=n : No SD card DMA - CONFIG_MMCSD=n : No MMC/SD driver support - CONFIG_FS_FAT=n : No FAT file system support + Drivers: + CONFIG_MMCSD=n : No MMC/SD driver support + + System Type: + CONFIG_LPC17_GPDMA=n : No DMA + CONFIG_LPC17_SDCARD=n : No SD card driver + CONFIG_SDIO_DMA=n : No SD card DMA + CONFIG_ARCH_DMA=n + + File Systems: + CONFIG_FS_FAT=n : No FAT file system support For touchscreen debug output: - CONFIG_DEBUG=y - CONFIG_DEBUG_VERBOSE=y - CONFIG_DEBUG_INPUT=y + Build Setup: + CONFIG_DEBUG=y + CONFIG_DEBUG_VERBOSE=y + CONFIG_DEBUG_INPUT=y nxlines ------- diff --git a/configs/open1788/src/lpc17_touchscreen.c b/configs/open1788/src/lpc17_touchscreen.c index af2a6152fc..7bb872a200 100644 --- a/configs/open1788/src/lpc17_touchscreen.c +++ b/configs/open1788/src/lpc17_touchscreen.c @@ -178,11 +178,21 @@ static void tsc_enable(FAR struct ads7843e_config_s *state, bool enable) ivdbg("enable:%d\n", enable); if (enable) { + /* Configure the PENIRQ GPIO as an interrupting enable and enable the interrupt */ + + (void)lpc17_configgpio(GPIO_TC_PENIRQ); up_enable_irq(LPC17_IRQ_PENIRQ); } else { + /* Disable PENIRQ interrupts and reconfigure the pin as a normal input pin. + * We have to do this because the PENIRQ interrupt will be disabled from + * interrupt handling logic and, in that case, will be automatically re-enabled + * when the interrupt returns. + */ + up_disable_irq(LPC17_IRQ_PENIRQ); + (void)lpc17_configgpio(GPIO_TC_PEN); } } @@ -278,9 +288,12 @@ int arch_tcinitialize(int minor) if (!initialized) { - /* Configure and enable the XPT2046 PENIRQ pin as an interrupting input. */ + /* Configure and enable the XPT2046 PENIRQ pin as a normal input. It + * will be reconfigured as an interrupting input when tsc_enable is + * called to enable the PENIRQ interrupt. + */ - (void)lpc17_configgpio(GPIO_TC_PENIRQ); + (void)lpc17_configgpio(GPIO_TC_PEN); /* Configure the XPT2046 BUSY pin as a normal input. */ @@ -304,7 +317,7 @@ int arch_tcinitialize(int minor) { idbg("Failed to register touchscreen device minor=%d\n", CONFIG_ADS7843E_DEVMINOR); - /* up_spiuninitialize(dev); */ + /* up_spiuninitialize(dev); */ return -ENODEV; } @@ -336,4 +349,3 @@ void arch_tcuninitialize(void) } #endif /* CONFIG_INPUT_ADS7843E */ - diff --git a/configs/open1788/src/open1788.h b/configs/open1788/src/open1788.h index e70eebe5db..4f5796c98f 100644 --- a/configs/open1788/src/open1788.h +++ b/configs/open1788/src/open1788.h @@ -132,6 +132,7 @@ * Pins are configured as floating because there are pullups on the module. */ +#define GPIO_TC_PEN (GPIO_INPUT | GPIO_FLOAT | GPIO_PORT2 | GPIO_PIN15) #define GPIO_TC_PENIRQ (GPIO_INTBOTH | GPIO_FLOAT | GPIO_PORT2 | GPIO_PIN15) #define GPIO_TC_BUSY (GPIO_INPUT | GPIO_FLOAT | GPIO_PORT2 | GPIO_PIN14) #define GPIO_TC_CS (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT1 | GPIO_PIN8)