summaryrefslogtreecommitdiff
path: root/nuttx/configs/avr32dev1/src
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2010-10-17 01:05:14 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2010-10-17 01:05:14 +0000
commit0956ec5b471ce98d3ee0bdad3d95e8f55881ccd9 (patch)
tree81cc0ae390a923757826dd0034d5bdc336ba4622 /nuttx/configs/avr32dev1/src
parentbd71dd5b4ccbb8c51c537e43a5d0bed98f1790b8 (diff)
downloadpx4-nuttx-0956ec5b471ce98d3ee0bdad3d95e8f55881ccd9.tar.gz
px4-nuttx-0956ec5b471ce98d3ee0bdad3d95e8f55881ccd9.tar.bz2
px4-nuttx-0956ec5b471ce98d3ee0bdad3d95e8f55881ccd9.zip
Add button support
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3029 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/configs/avr32dev1/src')
-rwxr-xr-xnuttx/configs/avr32dev1/src/Makefile8
-rwxr-xr-xnuttx/configs/avr32dev1/src/avr32dev1_internal.h8
-rwxr-xr-xnuttx/configs/avr32dev1/src/up_buttons.c159
3 files changed, 170 insertions, 5 deletions
diff --git a/nuttx/configs/avr32dev1/src/Makefile b/nuttx/configs/avr32dev1/src/Makefile
index 4edb47c81..282aaa8aa 100755
--- a/nuttx/configs/avr32dev1/src/Makefile
+++ b/nuttx/configs/avr32dev1/src/Makefile
@@ -38,7 +38,13 @@
CFLAGS += -I$(TOPDIR)/sched
ASRCS =
-CSRCS = up_boot.c up_leds.c
+CSRCS = up_boot.c
+ifeq ($(CONFIG_ARCH_LEDS),y)
+CSRCS += up_leds.c
+endif
+ifeq ($(CONFIG_ARCH_BUTTONS),y)
+CSRCS += up_buttons.c
+endif
AOBJS = $(ASRCS:.S=$(OBJEXT))
COBJS = $(CSRCS:.c=$(OBJEXT))
diff --git a/nuttx/configs/avr32dev1/src/avr32dev1_internal.h b/nuttx/configs/avr32dev1/src/avr32dev1_internal.h
index 9a673ae0c..f46ed5516 100755
--- a/nuttx/configs/avr32dev1/src/avr32dev1_internal.h
+++ b/nuttx/configs/avr32dev1/src/avr32dev1_internal.h
@@ -60,16 +60,16 @@
#define PINMUX_GPIO_LED1 (GPIO_ENABLE | GPIO_OUTPUT | GPIO_LOW | GPIO_PORTA | 7)
#define PINMUX_GPIO_LED2 (GPIO_ENABLE | GPIO_OUTPUT | GPIO_LOW | GPIO_PORTA | 8)
-/* KEYs
+/* BUTTONs
*
- * The AVR32DEV1 board has 3 KEYs, two of which can be sensed through GPIO pins.
+ * The AVR32DEV1 board has 3 BUTTONs, two of which can be sensed through GPIO pins.
*
* PIN 24 PB2 KEY1
* PIN 25 PB3 KEY2
*/
-#define PINMUX_GPIO_KEY1 (GPIO_ENABLE | GPIO_INPUT | GPIO_PORTB | 2)
-#define PINMUX_GPIO_KEY2 (GPIO_ENABLE | GPIO_INPUT | GPIO_PORTB | 3)
+#define PINMUX_GPIO_BUTTON1 (GPIO_ENABLE | GPIO_INPUT | GPIO_PORTB | 2)
+#define PINMUX_GPIO_BUTTON2 (GPIO_ENABLE | GPIO_INPUT | GPIO_PORTB | 3)
/************************************************************************************
* Public Types
diff --git a/nuttx/configs/avr32dev1/src/up_buttons.c b/nuttx/configs/avr32dev1/src/up_buttons.c
new file mode 100755
index 000000000..37434d656
--- /dev/null
+++ b/nuttx/configs/avr32dev1/src/up_buttons.c
@@ -0,0 +1,159 @@
+/****************************************************************************
+ * configs/sam3u-ek/src/up_leds.c
+ *
+ * Copyright (C) 2010 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+
+#include <nuttx/irq.h>
+
+#include <arch/irq.h>
+#include <arch/board/board.h>
+
+#include "at91uc3_internal.h"
+#include "avr32dev1_internal.h"
+
+#ifdef CONFIG_ARCH_BUTTONS
+
+/****************************************************************************
+ * Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static xcpt_t g_irqbutton1;
+static xcpt_t g_irqbutton2;
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: up_buttoninit
+ ****************************************************************************/
+
+void up_buttoninit(void)
+{
+ (void)at91uc3_configgpio(PINMUX_GPIO_BUTTON1);
+ (void)at91uc3_configgpio(PINMUX_GPIO_BUTTON2);
+}
+
+/****************************************************************************
+ * Name: up_buttons
+ ****************************************************************************/
+
+uint8_t up_buttons(void)
+{
+ uint8_t retval;
+
+ retval = at91uc3_gpioread(PINMUX_GPIO_BUTTON1) ? 0 : BUTTON1;
+ retval |= sat91uc3_gpioread(PINMUX_GPIO_BUTTON2) ? 0 : BUTTON2;
+
+ return retval;
+}
+
+/****************************************************************************
+ * Name: up_irqbutton1
+ ****************************************************************************/
+
+#ifdef CONFIG_GPIOB_IRQ
+xcpt_t up_irqbutton1(xcpt_t irqhandler)
+{
+ xcpt_t oldhandler;
+ irqstate_t flags;
+
+ /* Disable interrupts until we are done */
+
+ flags = irqsave();
+
+ /* Get the old button interrupt handler and save the new one */
+
+ oldhandler = g_irqbutton1;
+ g_irqbutton1 = irqhandler;
+
+ /* Configure and enable the interrupt */
+
+#warning "Missing Logic"
+
+ irqrestore(flags);
+
+ /* Return the old button handler (so that it can be restored) */
+
+ return oldhandler;
+}
+#endif
+
+/****************************************************************************
+ * Name: up_irqbutton2
+ ****************************************************************************/
+
+#ifdef CONFIG_GPIOB_IRQ
+xcpt_t up_irqbutton2(xcpt_t irqhandler)
+{
+ xcpt_t oldhandler;
+ irqstate_t flags;
+
+ /* Disable interrupts until we are done */
+
+ flags = irqsave();
+
+ /* Get the old button interrupt handler and save the new one */
+
+ oldhandler = g_irqbutton2;
+ g_irqbutton2 = irqhandler;
+
+ /* Configure and enable the interrupt */
+
+#warning "Missing Logic"
+
+ irqrestore(flags);
+
+ /* Return the old button handler (so that it can be restored) */
+
+ return oldhandler;
+}
+#endif
+
+#endif /* CONFIG_ARCH_BUTTONS */