9
0
Fork 0

Fix some LPC17xx GPIO/button interrupt logic

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4246 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo 2011-12-31 23:09:33 +00:00
parent cf142a2633
commit 66ae63c9ec
9 changed files with 59 additions and 26 deletions

View File

@ -152,3 +152,6 @@
driver in loopback mode.
6.14 2012-xx-xx Gregory Nutt <gnutt@nuttx.org>
* apps/examples/buttons/main.c: The test needs to up_buttoninit() to
properly configure the button interrupt GPIOs.

View File

@ -2,7 +2,7 @@
* examples/buttons/main.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -422,6 +422,10 @@ int MAIN_NAME(int argc, char *argv[])
lib_lowprintf("maxbuttons: %d\n", maxbuttons);
#endif
/* Initialize the button GPIOs */
up_buttoninit();
/* Register to recieve button interrupts */
#ifdef CONFIG_ARCH_IRQBUTTONS

View File

@ -2320,3 +2320,5 @@
for NuttX. At present, this is just a stub and it refers to the NuttX
top-level README.txt file which is the only, real "Getting Started" Guide
that exists for the time being.
* arch/arm/src/lpc17xx/lpc17_gpioint.c: Correct an value used as the lower
end of an IRQ number range test.

View File

@ -2,7 +2,7 @@
* arch/arm/src/lpc17xx/lpc17_gpio.c
*
* Copyright (C) 2010-2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -278,7 +278,8 @@ static int lpc17_pullup(uint16_t cfgset, unsigned int port, unsigned int pin)
****************************************************************************/
#ifdef CONFIG_GPIO_IRQ
static void lpc17_setintedge(unsigned int port, unsigned int pin, unsigned int value)
static void lpc17_setintedge(unsigned int port, unsigned int pin,
unsigned int value)
{
uint64_t *intedge;
unsigned int shift;
@ -415,7 +416,9 @@ static inline int lpc17_configinput(uint16_t cfgset, unsigned int port, unsigned
* Configure a GPIO interrupt pin based on bit-encoded description of the pin.
*
****************************************************************************/
static inline int lpc17_configinterrupt(uint16_t cfgset, unsigned int port, unsigned int pin)
static inline int lpc17_configinterrupt(uint16_t cfgset, unsigned int port,
unsigned int pin)
{
/* First, configure the port as a generic input so that we have a known
* starting point and consistent behavior during the re-configuration.
@ -439,7 +442,9 @@ static inline int lpc17_configinterrupt(uint16_t cfgset, unsigned int port, unsi
* Configure a GPIO output pin based on bit-encoded description of the pin.
*
****************************************************************************/
static inline int lpc17_configoutput(uint16_t cfgset, unsigned int port, unsigned int pin)
static inline int lpc17_configoutput(uint16_t cfgset, unsigned int port,
unsigned int pin)
{
uint32_t fiobase;
uint32_t regval;
@ -486,7 +491,9 @@ static inline int lpc17_configoutput(uint16_t cfgset, unsigned int port, unsigne
* of the pin.
*
****************************************************************************/
static int lpc17_configalternate(uint16_t cfgset, unsigned int port, unsigned int pin, uint32_t alt)
static int lpc17_configalternate(uint16_t cfgset, unsigned int port,
unsigned int pin, uint32_t alt)
{
/* First, configure the port as an input so that we have a known
* starting point and consistent behavior during the re-configuration.

View File

@ -1,8 +1,8 @@
/****************************************************************************
* arch/arm/src/lpc17xx/lpc17_gpiodbg.c
*
* Copyright (C) 2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* Copyright (C) 2010-2011 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
@ -49,12 +49,16 @@
#include "lpc17_gpio.h"
#include "lpc17_internal.h"
#ifdef CONFIG_DEBUG_GPIO
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#ifndef CONFIG_DEBUG
# undef CONFIG_DEBUG_GPIO
#endif
#ifdef CONFIG_DEBUG_GPIO
/****************************************************************************
* Private Types
****************************************************************************/

View File

@ -2,7 +2,7 @@
* arch/arm/src/lpc17xx/lpc17_gpioint.c
*
* Copyright (C) 2010-2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -172,7 +172,7 @@ static int lpc17_irq2port(int irq)
/* Set 3: 14 interrupts p2.0-p2.13 */
else if (irq >= LPC17_VALID_NIRQS2 && irq < (LPC17_VALID_FIRST2+LPC17_VALID_NIRQS2))
else if (irq >= LPC17_VALID_FIRST2 && irq < (LPC17_VALID_FIRST2+LPC17_VALID_NIRQS2))
{
return 2;
}

View File

@ -3,7 +3,7 @@
* arch/arm/src/chip/lpc17_irq.c
*
* Copyright (C) 2010-2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* 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
@ -374,7 +374,7 @@ void up_disable_irq(int irq)
putreg32(regval, regaddr);
}
#ifdef CONFIG_GPIO_IRQ
else
else if (irq >= LPC17_VALID_FIRST0L)
{
/* Maybe it is a (derived) GPIO IRQ */
@ -407,7 +407,7 @@ void up_enable_irq(int irq)
putreg32(regval, regaddr);
}
#ifdef CONFIG_GPIO_IRQ
else
else if (irq >= LPC17_VALID_FIRST0L)
{
/* Maybe it is a (derived) GPIO IRQ */

View File

@ -534,20 +534,26 @@ Using OpenOCD and GDB with an FT2232 JTAG emulator
Once the OpenOCD daemon has been started, you can connect to it via
GDB using the following GDB command:
arm-elf-gdb
(gdb) target remote localhost:3333
arm-elf-gdb
(gdb) target remote localhost:3333
NOTE: The name of your GDB program may differ. For example, with the
CodeSourcery toolchain, the ARM GDB would be called arm-none-eabi-gdb.
After starting GDB, you can load the NuttX ELF file:
(gdb) symbol-file nuttx
(gdb) load nuttx
(gdb) symbol-file nuttx
(gdb) load nuttx
Loading the symbol-file is only useful if you have built NuttX to
inclulde debug symbols (by setting CONFIG_DEBUG_SYMBOLS=y in the
.config file).
NOTES:
1. Loading the symbol-file is only useful if you have built NuttX to
inclulde debug symbols (by setting CONFIG_DEBUG_SYMBOLS=y in the
.config file).
2. I usually have to reset, halt, and 'load nuttx' a second time. For
some reason, the first time apparently does not fully program the
FLASH.
3. The MCU must be halted prior to loading code using 'mon reset'
as described below.
OpenOCD will support several special 'monitor' commands. These
GDB commands will send comments to the OpenOCD monitor. Here
@ -556,9 +562,10 @@ Using OpenOCD and GDB with an FT2232 JTAG emulator
(gdb) monitor reset
(gdb) monitor halt
The MCU must be halted prior to loading code. Reset will restart
the processor after loading code. The 'monitor' command can be
abbreviated as just 'mon'.
NOTES:
1. The MCU must be halted using 'mon halt' prior to loading code.
2. Reset will restart the processor after loading code.
3. The 'monitor' command can be abbreviated as just 'mon'.
Olimex LPC1766-STK Configuration Options
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -827,6 +834,12 @@ Where <subdir> is one of the following:
Support for the board's SPI-based MicroSD card is included
(but not passing tests as of this writing).
NOTE: If you start the program with no SD card inserted, there will be
a substantial delay. This is because there is no hardware support to sense
whether or not an SD card is inserted. As a result, the driver has to
go through many retries and timeouts before it finally decides that there
is not SD card in the slot.
nx:
And example using the NuttX graphics system (NX). This example
uses the Nokia 6100 LCD driver.

View File

@ -111,7 +111,7 @@ void up_buttoninit(void)
{
int i;
/* Configure the GPIO pins as inputs. */
/* Configure the GPIO pins as interrupting inputs. */
for (i = 0; i < BOARD_NUM_BUTTONS; i++)
{