board_button_irq: Button IRQ logic no longer returns the xcpt_t oldhandler. There value is useless and dangerous after the recent changes to interrupt argument passing.

This commit is contained in:
Gregory Nutt
2017-03-02 14:37:22 -06:00
parent 4a4636c8a1
commit 4c82827ab1
65 changed files with 335 additions and 488 deletions
+1 -1
View File
@@ -296,7 +296,7 @@ void weak_function gpio_irqinitialize(void);
****************************************************************************/
#ifdef CONFIG_AVR32_GPIOIRQ
int gpio_irqattach(int irq, xcpt_t newisr, xcpt_t *oldisr);
int gpio_irqattach(int irq, xcpt_t handler, void *arg);
#endif
/****************************************************************************
+22 -21
View File
@@ -57,20 +57,22 @@
#ifdef CONFIG_AVR32_GPIOIRQ
/****************************************************************************
* Pre-processor Definitions
* Private Types
****************************************************************************/
struct g_gpiohandler_s
{
xcpt_t handler; /* Interrupt handler entry point */
void *arg; /* The argument that accompanies the interrupt handler */
};
/****************************************************************************
* Private Data
****************************************************************************/
/* A table of handlers for each GPIO interrupt */
static FAR xcpt_t g_gpiohandler[NR_GPIO_IRQS];
/****************************************************************************
* Public Data
****************************************************************************/
static struct g_gpiohandler_s g_gpiohandler[NR_GPIO_IRQS];
/****************************************************************************
* Private Functions
@@ -221,10 +223,10 @@ static void gpio_porthandler(uint32_t regbase, int irqbase, uint32_t irqset, voi
/* Dispatch handling for this pin */
xcpt_t handler = g_gpiohandler[irq];
if (handler)
xcpt_t handler = g_gpiohandler[irq].handler;
if (handler != NULL)
{
handler(irq, context);
handler(irq, contex, g_gpiohandler[irq].arg);
}
else
{
@@ -304,7 +306,8 @@ void gpio_irqinitialize(void)
for (i = 0; i < NR_GPIO_IRQS; i++)
{
g_gpiohandler[i] = irq_unexpected_isr;
g_gpiohandler[i].handler = irq_unexpected_isr;
g_gpiohandler[i].arg = NULL;
}
/* Then attach the GPIO interrupt handlers */
@@ -325,7 +328,7 @@ void gpio_irqinitialize(void)
*
****************************************************************************/
int gpio_irqattach(int irq, xcpt_t newisr, xcpt_t *oldisr)
int gpio_irqattach(int irq, xcpt_t handler, void *arg)
{
irqstate_t flags;
int ret = -EINVAL;
@@ -338,25 +341,23 @@ int gpio_irqattach(int irq, xcpt_t newisr, xcpt_t *oldisr)
*/
flags = enter_critical_section();
if (newisr == NULL)
if (handler == NULL)
{
gpio_irqdisable(irq);
newisr = irq_unexpected_isr;
handler = irq_unexpected_isr;
arg = NULL;
}
/* Return the old ISR (in case the caller ever wants to restore it) */
/* Save the new ISR in the table. */
if (oldisr)
{
*oldisr = g_gpiohandler[irq];
}
g_gpiohandler[irq].handler = handler;
g_gpiohandler[irq].arg = arg;
/* Then save the new ISR in the table. */
g_gpiohandler[irq] = newisr;
leave_critical_section(flags);
ret = OK;
}
return ret;
}
+24 -22
View File
@@ -42,6 +42,7 @@
#include <sys/types.h>
#include <stdint.h>
#include <errno.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
@@ -69,28 +70,26 @@
#if defined(CONFIG_AVR32_GPIOIRQ) && defined(CONFIG_ARCH_IRQBUTTONS) && \
(defined(CONFIG_AVR32DEV_BUTTON1_IRQ) || defined(CONFIG_AVR32DEV_BUTTON2_IRQ))
static xcpt_t board_button_irqx(int irq, xcpt_t irqhandler, void *arg)
static int board_button_irqx(int irq, xcpt_t irqhandler, void *arg)
{
xcpt_t oldhandler;
/* Attach the handler */
gpio_irqattach(irq, irqhandler, &oldhandler);
/* Enable/disable the interrupt */
if (irqhandler)
int ret = gpio_irqattach(irq, irqhandler, &oldhandler, arg);
if (ret >= 0)
{
gpio_irqenable(irq);
}
else
{
gpio_irqdisable(irq);
/* Enable/disable the interrupt */
if (irqhandler != NULL)
{
gpio_irqenable(irq);
}
else
{
gpio_irqdisable(irq);
}
}
/* Return the old button handler (so that it can be restored) */
return oldhandler;
return OK;
}
#endif
@@ -143,8 +142,7 @@ uint8_t board_buttons(void)
* Description:
* This function may be called to register an interrupt handler that will
* be called when a button is depressed or released. The ID value is one
* of the BUTTON* definitions provided above. The previous interrupt
* handler address isreturned (so that it may restored, if so desired).
* of the BUTTON* definitions provided above.
*
* Configuration Notes:
* Configuration CONFIG_AVR32_GPIOIRQ must be selected to enable the
@@ -156,25 +154,29 @@ uint8_t board_buttons(void)
****************************************************************************/
#if defined(CONFIG_AVR32_GPIOIRQ) && defined(CONFIG_ARCH_IRQBUTTONS)
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
int ret;
#ifdef CONFIG_AVR32DEV_BUTTON1_IRQ
if (id == BUTTON1)
{
return board_button_irqx(GPIO_BUTTON1_IRQ, irqhandler, arg);
ret = board_button_irqx(GPIO_BUTTON1_IRQ, irqhandler, arg);
}
else
#endif
#ifdef CONFIG_AVR32DEV_BUTTON2_IRQ
if (id == BUTTON2)
{
return board_button_irqx(GPIO_BUTTON2_IRQ, irqhandler, arg);
ret = board_button_irqx(GPIO_BUTTON2_IRQ, irqhandler, arg);
}
else
#endif
{
return NULL;
ret = -EINVAL;
}
return ret;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */
+6 -18
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* configs/bambino-200e/src/lpc43_buttons.c
*
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
* Alan Carvalho de Assis acassis@gmail.com [nuttx] <nuttx@yahoogroups.com>
*
@@ -66,13 +66,7 @@ static const uint16_t g_buttoncfg[BOARD_NUM_BUTTONS] =
BAMBINO_BUT1
};
/* This array defines all of the interrupt handlers current attached to
* button events.
*/
#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_LPC43_GPIO_IRQ)
static xcpt_t g_buttonisr[BOARD_NUM_BUTTONS];
/* This array provides the mapping from button ID numbers to button IRQ
* numbers.
*/
@@ -161,8 +155,7 @@ uint8_t board_buttons(void)
* be called when a button is depressed or released. The ID value is a
* button enumeration value that uniquely identifies a button resource. See the
* BOARD_BUTTON_* and BOARD_JOYSTICK_* definitions in board.h for the meaning
* of enumeration values. The previous interrupt handler address is returned
* (so that it may restored, if so desired).
* of enumeration values.
*
* Note that board_button_irq() also enables button interrupts. Button
* interrupts will remain enabled after the interrupt handler is attached.
@@ -172,9 +165,8 @@ uint8_t board_buttons(void)
****************************************************************************/
#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_LPC43_GPIO_IRQ)
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
irqstate_t flags;
int irq;
@@ -182,11 +174,6 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
if ((unsigned)id < BOARD_NUM_BUTTONS)
{
/* Return the current button handler and set the new interrupt handler */
oldhandler = g_buttonisr[id];
g_buttonisr[id] = irqhandler;
/* Disable interrupts until we are done */
flags = enter_critical_section();
@@ -200,7 +187,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
/* Attach then enable the new interrupt handler */
(void)irq_attach(irq, irqhandler, NULL);
(void)irq_attach(irq, irqhandler, arg);
up_enable_irq(irq);
}
else
@@ -210,10 +197,11 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
up_disable_irq(irq);
(void)irq_detach(irq);
}
leave_critical_section(flags);
}
return oldhandler;
return OK;
}
#endif
+6 -7
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* configs/cloudctrl/src/stm32_buttons.c
*
* Copyright (C) 2012, 2014-2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2012, 2014-2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
* Darcy Gong <darcy.gong@gmail.com>
*
@@ -151,15 +151,13 @@ uint8_t board_buttons(void)
* board_button_irq() may be called to register an interrupt handler that will
* be called when a button is depressed or released. The ID value is a
* button enumeration value that uniquely identifies a button resource. See
* the
* BUTTON_* and JOYSTICK_* definitions in board.h for the meaning of
* enumeration value. The previous interrupt handler address is returned
* (so that it may restored, if so desired).
* the BUTTON_* and JOYSTICK_* definitions in board.h for the meaning of
* enumeration value.
*
****************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
@@ -171,7 +169,8 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
irqhandler, arg);
}
return oldhandler;
UNUSED(oldhandler);
return OK;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */
+5 -6
View File
@@ -40,6 +40,7 @@
#include <nuttx/config.h>
#include <stdint.h>
#include <errno.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
@@ -144,18 +145,16 @@ uint8_t board_buttons(void)
* be called when a button is depressed or released. The ID value is a
* button enumeration value that uniquely identifies a button resource. See the
* BUTTON_* and JOYSTICK_* definitions in board.h for the meaning of enumeration
* value. The previous interrupt handler address is returned (so that it may
* restored, if so desired).
* value.
*
************************************************************************************/
#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_TIVA_GPIOP_IRQS)
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
static xcpt_t handler = NULL;
xcpt_t oldhandler = handler;
irqstate_t flags;
int ret;
int ret = -EINVAL;
/* Interrupts are supported only on ports P and Q and, hence, only on button SW4 */
@@ -186,7 +185,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
leave_critical_section(flags);
}
return oldhandler;
return ret;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */
+8 -5
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* configs/fire-stm32v2/src/stm32_buttons.c
*
* Copyright (C) 2012, 2014-2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2012, 2014-2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -128,14 +128,14 @@ uint8_t board_buttons(void)
* be called when a button is depressed or released. The ID value is a
* button enumeration value that uniquely identifies a button resource. See
* the BUTTON_* and JOYSTICK_* definitions in board.h for the meaning of
* enumeration values. The previous interrupt handler address is returned
* (so that it may restored, if so desired).
* enumeration values.
*
****************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler;
uint16_t gpio;
if (id == BUTTON_KEY1)
@@ -151,7 +151,10 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
return NULL;
}
return stm32_gpiosetevent(gpio, true, true, true, irqhandler, arg);
oldhandler = stm32_gpiosetevent(gpio, true, true, true, irqhandler, arg);
UNUSED(oldhandler);
return OK;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */
+12 -9
View File
@@ -40,6 +40,7 @@
#include <nuttx/config.h>
#include <stdint.h>
#include <errno.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
@@ -127,16 +128,15 @@ uint8_t board_buttons(void)
* will be called when a button is depressed or released. The ID value is
* a button enumeration value that uniquely identifies a button resource.
* See the BUTTON_* and JOYSTICK_* definitions in board.h for the meaning
* of enumeration value. The previous interrupt handler address is
* returned (so that it may restored, if so desired).
* of enumeration value.
*
****************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler;
uint32_t pinset;
int ret;
/* Map the button id to the GPIO bit set. */
@@ -150,7 +150,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
}
else
{
return NULL;
return -EINVAL;
}
/* The button has already been configured as an interrupting input (by
@@ -159,12 +159,15 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
* Attach the new button handler.
*/
oldhandler = knetis_pinirqattach(pinset, irqhandler);
ret = kinetis_pinirqattach(pinset, irqhandler);
if (ret >= 0)
{
/* Then make sure that interrupts are enabled on the pin */
/* Then make sure that interrupts are enabled on the pin */
kinetis_pindmaenable(pinset);
}
kinetis_pindmaenable(pinset);
return oldhandler;
return ret;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */
+10 -7
View File
@@ -41,6 +41,7 @@
#include <nuttx/config.h>
#include <stdint.h>
#include <errno.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
@@ -131,13 +132,12 @@ uint8_t board_buttons(void)
* will be called when a button is depressed or released. The ID value is
* a button enumeration value that uniquely identifies a button resource.
* See the BUTTON_* and JOYSTICK_* definitions in board.h for the meaning
* of enumeration value. The previous interrupt handler address is
* returned (so that it may restored, if so desired).
* of enumeration value.
*
****************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
uint32_t pinset;
@@ -153,7 +153,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
}
else
{
return NULL;
return -EINVAL;
}
/* The button has already been configured as an interrupting input (by
@@ -162,11 +162,14 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
* Attach the new button handler.
*/
(void)kinetis_pinirqattach(pinset, irqhandler, NULL);
ret = kinetis_pinirqattach(pinset, irqhandler, NULL);
if (ret >= 0)
{
/* Then make sure that interrupts are enabled on the pin */
/* Then make sure that interrupts are enabled on the pin */
kinetis_pinirqenable(pinset);
}
kinetis_pinirqenable(pinset);
return NULL;
}
#endif
+48 -42
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* configs/hymini-stm32v/src/stm32_buttons.c
*
* Copyright (C) 2009, 2011, 2014-2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2009, 2011, 2014-2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -69,39 +69,44 @@
****************************************************************************/
void board_button_initialize(void)
{
stm32_configgpio(GPIO_BTN_KEYA);
stm32_configgpio(GPIO_BTN_KEYB);
}
{
stm32_configgpio(GPIO_BTN_KEYA);
stm32_configgpio(GPIO_BTN_KEYB);
}
/****************************************************************************
* Name: board_buttons
****************************************************************************/
uint8_t board_buttons(void)
{
uint8_t ret = 0;
bool pinValue;
{
uint8_t ret = 0;
bool pinValue;
/* Check that state of each key */
/* Check that state of each key */
/* Pin is pulled up */
pinValue = stm32_gpioread(GPIO_BTN_KEYA);
if (!pinValue)
{
// Button pressed
ret = 1 << BUTTON_KEYA;
}
/* Pin is pulled up */
/* Pin is pulled down */
pinValue = stm32_gpioread(GPIO_BTN_KEYB);
if (pinValue)
{
// Button pressed
ret |= 1 << BUTTON_KEYB;
}
return ret;
}
pinValue = stm32_gpioread(GPIO_BTN_KEYA);
if (!pinValue)
{
/* Button pressed */
ret = 1 << BUTTON_KEYA;
}
/* Pin is pulled down */
pinValue = stm32_gpioread(GPIO_BTN_KEYB);
if (pinValue)
{
/* Button pressed */
ret |= 1 << BUTTON_KEYB;
}
return ret;
}
/****************************************************************************
* Button support.
@@ -122,28 +127,29 @@ uint8_t board_buttons(void)
* be called when a button is depressed or released. The ID value is a
* button enumeration value that uniquely identifies a button resource. See
* the BUTTON_* definitions in board.h for the meaning of enumeration
* value. The previous interrupt handler address is returned (so that it
* may be restored, if so desired).
* value.
*
****************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
uint32_t pinset = GPIO_BTN_KEYA;
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
uint32_t pinset = GPIO_BTN_KEYA;
if (id == 1)
{
pinset = GPIO_BTN_KEYB;
}
if (id < 2)
{
oldhandler = stm32_gpiosetevent(pinset, true, true, true,
irqhandler, arg);
}
if (id == 1)
{
pinset = GPIO_BTN_KEYB;
}
return oldhandler;
}
if (id < 2)
{
oldhandler = stm32_gpiosetevent(pinset, true, true, true,
irqhandler, arg);
}
UNUSED(oldhandler);
return OK;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */
+5 -17
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* configs/kwikstik-k40/src/k40_buttons.c
*
* Copyright (C) 2011, 2014-2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2011, 2014-2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -40,6 +40,7 @@
#include <nuttx/config.h>
#include <stdint.h>
#include <errno.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
@@ -49,18 +50,6 @@
#ifdef CONFIG_ARCH_BUTTONS
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -111,17 +100,16 @@ uint8_t board_buttons(void)
* be called when a button is depressed or released. The ID value is a
* button enumeration value that uniquely identifies a button resource.
* See the BUTTON_* and JOYSTICK_* definitions in board.h for the meaning
* of enumeration value. The previous interrupt handler address is
* returned (so that it may be restored, if so desired).
* of enumeration value.
*
****************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
/* The KwikStik-K40 board has no standard GPIO contact buttons */
return NULL;
return -EINVAL;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */
+8 -11
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* configs/sam4e-ek/src/tms570_buttons.c
*
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -40,6 +40,7 @@
#include <nuttx/config.h>
#include <stdint.h>
#include <errno.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
@@ -84,10 +85,9 @@ static xcpt_t g_irq_button;
****************************************************************************/
#ifdef HAVE_IRQBUTTONS
static xcpt_t board_button_irqx(gio_pinset_t pinset, int irq,
xcpt_t irqhandler, xcpt_t *store, void *arg)
static int board_button_irqx(gio_pinset_t pinset, int irq,
xcpt_t irqhandler, xcpt_t *store, void *arg)
{
xcpt_t oldhandler;
irqstate_t flags;
/* Disable interrupts until we are done. This guarantees that the following
@@ -98,7 +98,6 @@ static xcpt_t board_button_irqx(gio_pinset_t pinset, int irq,
/* Get the old button interrupt handler and save the new one */
oldhandler = *store;
*store = irqhandler;
/* Are we attaching or detaching? */
@@ -123,7 +122,7 @@ static xcpt_t board_button_irqx(gio_pinset_t pinset, int irq,
/* Return the old button handler (so that it can be restored) */
return oldhandler;
return OK;
}
#endif
@@ -171,8 +170,7 @@ uint8_t board_buttons(void)
* Description:
* This function may be called to register an interrupt handler that will
* be called when a button is depressed or released. The ID value is one
* of the BUTTON* definitions provided above. The previous interrupt
* handler address is returned (so that it may restored, if so desired).
* of the BUTTON* definitions provided above.
*
* Configuration Notes:
* Configuration CONFIG_AVR32_GIOIRQ must be selected to enable the
@@ -183,7 +181,7 @@ uint8_t board_buttons(void)
*
****************************************************************************/
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
#ifdef HAVE_IRQBUTTONS
if (id == BUTTON_GIOA7)
@@ -193,8 +191,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
}
#endif
return NULL;
return -EINVAL;
}
#endif /* CONFIG_ARCH_BUTTONS */
+7 -18
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* configs/lincoln60/src/lpc17_buttons.c
*
* Copyright (C) 2012-2013, 2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2012-2013, 2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -69,13 +69,7 @@ static const uint16_t g_buttoncfg[BOARD_NUM_BUTTONS] =
LINCOLN60_BUT1
};
/* This array defines all of the interrupt handlers current attached to
* button events.
*/
#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_LPC17_GPIOIRQ)
static xcpt_t g_buttonisr[BOARD_NUM_BUTTONS];
/* This array provides the mapping from button ID numbers to button IRQ
* numbers.
*/
@@ -168,8 +162,7 @@ uint8_t board_buttons(void)
* be called when a button is depressed or released. The ID value is a
* button enumeration value that uniquely identifies a button resource. See the
* BOARD_BUTTON_* and BOARD_JOYSTICK_* definitions in board.h for the meaning
* of enumeration values. The previous interrupt handler address is returned
* (so that it may restored, if so desired).
* of enumeration values.
*
* Note that board_button_irq() also enables button interrupts. Button
* interrupts will remain enabled after the interrupt handler is attached.
@@ -179,9 +172,8 @@ uint8_t board_buttons(void)
****************************************************************************/
#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_LPC17_GPIOIRQ)
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
irqstate_t flags;
int irq;
@@ -189,11 +181,6 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
if ((unsigned)id < BOARD_NUM_BUTTONS)
{
/* Return the current button handler and set the new interrupt handler */
oldhandler = g_buttonisr[id];
g_buttonisr[id] = irqhandler;
/* Disable interrupts until we are done */
flags = enter_critical_section();
@@ -207,7 +194,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
/* Attach then enable the new interrupt handler */
(void)irq_attach(irq, irqhandler, NULL);
(void)irq_attach(irq, irqhandler, arg);
up_enable_irq(irq);
}
else
@@ -217,9 +204,11 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
up_disable_irq(irq);
(void)irq_detach(irq);
}
leave_critical_section(flags);
}
return oldhandler;
return OK;
}
#endif
+7 -18
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* configs/lpc4330-xplorer/src/lpc43_buttons.c
*
* Copyright (C) 2012, 2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2012, 2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -68,13 +68,7 @@ static const uint16_t g_buttoncfg[BOARD_NUM_BUTTONS] =
LPC4330_XPLORER_BUT1
};
/* This array defines all of the interrupt handlers current attached to
* button events.
*/
#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_LPC43_GPIO_IRQ)
static xcpt_t g_buttonisr[BOARD_NUM_BUTTONS];
/* This array provides the mapping from button ID numbers to button IRQ
* numbers.
*/
@@ -167,8 +161,7 @@ uint8_t board_buttons(void)
* be called when a button is depressed or released. The ID value is a
* button enumeration value that uniquely identifies a button resource. See the
* BOARD_BUTTON_* and BOARD_JOYSTICK_* definitions in board.h for the meaning
* of enumeration values. The previous interrupt handler address is returned
* (so that it may restored, if so desired).
* of enumeration values.
*
* Note that board_button_irq() also enables button interrupts. Button
* interrupts will remain enabled after the interrupt handler is attached.
@@ -178,9 +171,8 @@ uint8_t board_buttons(void)
****************************************************************************/
#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_LPC43_GPIO_IRQ)
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
irqstate_t flags;
int irq;
@@ -188,11 +180,6 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
if ((unsigned)id < BOARD_NUM_BUTTONS)
{
/* Return the current button handler and set the new interrupt handler */
oldhandler = g_buttonisr[id];
g_buttonisr[id] = irqhandler;
/* Disable interrupts until we are done */
flags = enter_critical_section();
@@ -206,7 +193,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
/* Attach then enable the new interrupt handler */
(void)irq_attach(irq, irqhandler, NULL);
(void)irq_attach(irq, irqhandler, arg);
up_enable_irq(irq);
}
else
@@ -216,9 +203,11 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
up_disable_irq(irq);
(void)irq_detach(irq);
}
leave_critical_section(flags);
}
return oldhandler;
return OK;
}
#endif
+7 -18
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* configs/lpc4357-evb/src/board_buttons.c
*
* Copyright (C) 2014-2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2014-2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -41,6 +41,7 @@
#include <stdint.h>
#include <stdbool.h>
#include <errno.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
@@ -68,13 +69,7 @@ static const uint16_t g_buttoncfg[BOARD_NUM_BUTTONS] =
{
};
/* This array defines all of the interrupt handlers current attached to
* button events.
*/
#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_LPC43_GPIO_IRQ)
static xcpt_t g_buttonisr[BOARD_NUM_BUTTONS];
/* This array provides the mapping from button ID numbers to button IRQ
* numbers.
*/
@@ -173,8 +168,7 @@ uint8_t board_buttons(void)
* be called when a button is depressed or released. The ID value is a
* button enumeration value that uniquely identifies a button resource. See the
* BOARD_BUTTON_* and BOARD_JOYSTICK_* definitions in board.h for the meaning
* of enumeration values. The previous interrupt handler address is returned
* (so that it may restored, if so desired).
* of enumeration values.
*
* Note that board_button_irq() also enables button interrupts. Button
* interrupts will remain enabled after the interrupt handler is attached.
@@ -187,7 +181,6 @@ uint8_t board_buttons(void)
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
#if 0 /* Not yet implemented */
xcpt_t oldhandler = NULL;
irqstate_t flags;
int irq;
@@ -195,11 +188,6 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
if ((unsigned)id < BOARD_NUM_BUTTONS)
{
/* Return the current button handler and set the new interrupt handler */
oldhandler = g_buttonisr[id];
g_buttonisr[id] = irqhandler;
/* Disable interrupts until we are done */
flags = enter_critical_section();
@@ -213,7 +201,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
/* Attach then enable the new interrupt handler */
(void)irq_attach(irq, irqhandler, NULL);
(void)irq_attach(irq, irqhandler, arg);
up_enable_irq(irq);
}
else
@@ -223,12 +211,13 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
up_disable_irq(irq);
(void)irq_detach(irq);
}
leave_critical_section(flags);
}
return oldhandler;
return OK;
#else
return NULL;
return -ENOSYS;
#endif /* Not yet implemented */
}
#endif
+5 -5
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* configs/nucleo-144/src/stm32_buttons.c
*
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2016-2017 Gregory Nutt. All rights reserved.
* Authors: Gregory Nutt <gnutt@nuttx.org>
* David Sidrane <david_s5@nscdg.com>
*
@@ -99,13 +99,12 @@ uint8_t board_buttons(void)
* be called when a button is depressed or released. The ID value is a
* button enumeration value that uniquely identifies a button resource. See the
* BUTTON_* definitions in board.h for the meaning of enumeration
* value. The previous interrupt handler address is returned (so that it may
* restored, if so desired).
* value.
*
************************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
@@ -115,7 +114,8 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
irqhandler, arg);
}
return oldhandler;
UNUSED(oldhandler);
return OK;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */
+5 -5
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* configs/nucleo-f303re/src/stm32_buttons.c
*
* Copyright (C) 2014-2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2014-2015, 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2015 Omni Hoverboards Inc. All rights reserved.
* Authors: Gregory Nutt <gnutt@nuttx.org>
* Paul Alexander Patience <paul-a.patience@polymtl.ca>
@@ -120,13 +120,12 @@ uint8_t board_buttons(void)
* will be called when a button is depressed or released. The ID value is
* a button enumeration value that uniquely identifies a button resource.
* See the BUTTON_* definitions in board.h for the meaning of the
* enumeration value. The previous interrupt handler address is returned
* (so that it may be restored, if so desired).
* enumeration value.
*
****************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
@@ -136,7 +135,8 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
irqhandler, arg);
}
return oldhandler;
UNUSED(oldhandler);
return OK;
}
#endif
+5 -5
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* configs/nucleo-f4x1re/src/stm32_buttons.c
*
* Copyright (C) 2014-2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2014-2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -117,13 +117,12 @@ uint8_t board_buttons(void)
* be called when a button is depressed or released. The ID value is a
* button enumeration value that uniquely identifies a button resource. See the
* BUTTON_* definitions in board.h for the meaning of enumeration
* value. The previous interrupt handler address is returned (so that it may
* restored, if so desired).
* value.
*
************************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
@@ -133,7 +132,8 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
irqhandler, arg);
}
return oldhandler;
UNUSED(oldhandler);
return OK;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */
+5 -5
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* configs/nucleo-l476rg/src/stm32_buttons.c
*
* Copyright (C) 2014-2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2014-2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -117,13 +117,12 @@ uint8_t board_buttons(void)
* be called when a button is depressed or released. The ID value is a
* button enumeration value that uniquely identifies a button resource. See the
* BUTTON_* definitions in board.h for the meaning of enumeration
* value. The previous interrupt handler address is returned (so that it may
* restored, if so desired).
* value.
*
************************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
@@ -133,7 +132,8 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
irqhandler, arg);
}
return oldhandler;
UNUSED(oldhandler);
return OK;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */
@@ -1,7 +1,7 @@
/****************************************************************************
* configs/olimex-efm32g880f128-stk/src/efm32_buttons.c
*
* Copyright (C) 2014-2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2014-2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -75,9 +75,6 @@
****************************************************************************/
#if defined(CONFIG_EFM32_GPIO_IRQ) && defined(CONFIG_ARCH_IRQBUTTONS)
#if 0 /* REVISIT -- See comments in board_button_irq() */
static xcpt_t g_button_handlers[NUM_BUTTONS];
#endif
static const uint8_t g_button_irqs[NUM_BUTTONS];
#endif
@@ -154,8 +151,7 @@ uint8_t board_buttons(void)
* Description:
* This function may be called to register an interrupt handler that will
* be called when a button is depressed or released. The ID value is one
* of the BUTTON* definitions provided above. The previous interrupt
* handler address is returned (so that it may restored, if so desired).
* of the BUTTON* definitions provided above.
*
* Configuration Notes:
* Configuration CONFIG_EFM32_GPIO_IRQ must be selected to enable the
@@ -168,10 +164,8 @@ uint8_t board_buttons(void)
****************************************************************************/
#if defined(CONFIG_EFM32_GPIO_IRQ) && defined(CONFIG_ARCH_IRQBUTTONS)
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
if (id >=0 && id < NUM_BUTTONS)
{
irqstate_t flags;
@@ -182,19 +176,6 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
flags = enter_critical_section();
/* Get/set the old button handler
*
* REVISIT: Keeping copies of the hander in RAM seems wasteful
* since the OS already has this information internally.
*/
#if 0 /* REVISIT */
oldhandler = g_button_handlers[id];
g_button_handlers[id] = irqhandler;
#else
oldhandler = NULL;
#endif
/* Are we attaching or detaching? */
if (irqhandler != NULL)
@@ -205,7 +186,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
/* Attach and enable the interrupt */
(void)irq_attach(g_button_irqs[id], irqhandler, NULL);
(void)irq_attach(g_button_irqs[id], irqhandler, arg);
efm32_gpioirqenable(g_button_irqs[id]);
}
else
@@ -221,7 +202,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
/* Return the old button handler (so that it can be restored) */
return oldhandler;
return OK;
}
#endif
+7 -18
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* configs/olimex-lpc1766stk/src/lpc17_buttons.c
*
* Copyright (C) 2011, 2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2011, 2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -70,13 +70,7 @@ static const uint16_t g_buttoncfg[BOARD_NUM_BUTTONS] =
LPC1766STK_UP, LPC1766STK_DOWN, LPC1766STK_LEFT, LPC1766STK_RIGHT
};
/* This array defines all of the interrupt handlers current attached to
* button events.
*/
#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_LPC17_GPIOIRQ)
static xcpt_t g_buttonisr[BOARD_NUM_BUTTONS];
/* This array provides the mapping from button ID numbers to button IRQ
* numbers.
*/
@@ -171,8 +165,7 @@ uint8_t board_buttons(void)
* be called when a button is depressed or released. The ID value is a
* button enumeration value that uniquely identifies a button resource. See the
* BOARD_BUTTON_* and BOARD_JOYSTICK_* definitions in board.h for the meaning
* of enumeration values. The previous interrupt handler address is returned
* (so that it may restored, if so desired).
* of enumeration values.
*
* Note that board_button_irq() also enables button interrupts. Button
* interrupts will remain enabled after the interrupt handler is attached.
@@ -182,9 +175,8 @@ uint8_t board_buttons(void)
****************************************************************************/
#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_LPC17_GPIOIRQ)
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
irqstate_t flags;
int irq;
@@ -192,11 +184,6 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
if ((unsigned)id < BOARD_NUM_BUTTONS)
{
/* Return the current button handler and set the new interrupt handler */
oldhandler = g_buttonisr[id];
g_buttonisr[id] = irqhandler;
/* Disable interrupts until we are done */
flags = enter_critical_section();
@@ -210,7 +197,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
/* Attach then enable the new interrupt handler */
(void)irq_attach(irq, irqhandler, NULL);
(void)irq_attach(irq, irqhandler, arg);
up_enable_irq(irq);
}
else
@@ -220,9 +207,11 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
up_disable_irq(irq);
(void)irq_detach(irq);
}
leave_critical_section(flags);
}
return oldhandler;
return OK;
}
#endif
@@ -1,7 +1,7 @@
/****************************************************************************
* configs/olimex-stm32-e407/src/stm32_buttons.c
*
* Copyright (C) 2014-2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2014-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -127,13 +127,12 @@ uint8_t board_buttons(void)
* will be called when a button is depressed or released. The ID value is
* a button enumeration value that uniquely identifies a button resource.
* See the BUTTON_* definitions in board.h for the meaning of enumeration
* value. The previous interrupt handler address is returned (so that it
* may restored, if so desired).
* value.
*
****************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
@@ -145,7 +144,8 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
stm32_gpiosetevent(g_buttons[id], true, true, true, irqhandler, arg);
}
return oldhandler;
UNUSED(oldhandler);
return OK;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */
@@ -1,7 +1,7 @@
/****************************************************************************
* configs/olimex-stm32-h405/src/stm32_buttons.c
*
* Copyright (C) 2014-2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2014-2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -135,13 +135,12 @@ uint8_t board_buttons(void)
* be called when a button is depressed or released. The ID value is a
* button enumeration value that uniquely identifies a button resource. See the
* BUTTON_* definitions in board.h for the meaning of enumeration
* value. The previous interrupt handler address is returned (so that it may
* restored, if so desired).
* value.
*
************************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
@@ -153,7 +152,8 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
irqhandler, arg);
}
return oldhandler;
UNUSED(oldhandler);
return OK;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */
@@ -1,7 +1,7 @@
/****************************************************************************
* configs/olimex-stm32-h407/src/stm32_buttons.c
*
* Copyright (C) 2014-2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2014-2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -127,13 +127,12 @@ uint8_t board_buttons(void)
* will be called when a button is depressed or released. The ID value is
* a button enumeration value that uniquely identifies a button resource.
* See the BUTTON_* definitions in board.h for the meaning of enumeration
* value. The previous interrupt handler address is returned (so that it
* may restored, if so desired).
* value.
*
****************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
@@ -145,7 +144,8 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
irqhandler, arg);
}
return oldhandler;
UNUSED(oldhandler);
return OK;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */
@@ -1,7 +1,7 @@
/****************************************************************************
* configs/olimex-stm32-p207/src/stm32_buttons.c
*
* Copyright (C) 2011-2012, 2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2011-2012, 2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -171,13 +171,12 @@ uint8_t board_buttons(void)
* be called when a button is depressed or released. The ID value is a
* button enumeration value that uniquely identifies a button resource. See the
* BUTTON_* definitions in board.h for the meaning of enumeration
* value. The previous interrupt handler address is returned (so that it may
* restored, if so desired).
* value.
*
************************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
@@ -189,7 +188,8 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
irqhandler, arg);
}
return oldhandler;
UNUSED(oldhandler);
return OK;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */
@@ -1,7 +1,7 @@
/****************************************************************************
* configs/olimex-stm32-p407/src/stm32_buttons.c
*
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -165,13 +165,12 @@ uint8_t board_buttons(void)
* be called when a button is depressed or released. The ID value is a
* button enumeration value that uniquely identifies a button resource. See the
* BUTTON_* definitions in board.h for the meaning of enumeration
* value. The previous interrupt handler address is returned (so that it may
* restored, if so desired).
* value.
*
************************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
@@ -183,7 +182,8 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
irqhandler, arg);
}
return oldhandler;
UNUSED(oldhandler);
return OK;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */
+6 -7
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* configs/olimexino-stm32/src/stm32_buttons.c
*
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
* David_s5 <david_s5@nscdg.com>
*
@@ -80,8 +80,7 @@
* will be called when a button is depressed or released. The ID value is
* a button enumeration value that uniquely identifies a button resource.
* See the BUTTON_* definitions in board.h for the meaning of enumeration
* value. The previous interrupt handler address is returned
* (so that it may restored, if so desired).
* value.
*
****************************************************************************/
@@ -127,13 +126,12 @@ uint8_t board_buttons(void)
* will be called when a button is depressed or released. The ID value is
* a button enumeration value that uniquely identifies a button resource.
* See the BUTTON_* definitions in board.h for the meaning of enumeration
* value. The previous interrupt handler address is returned
* (so that it may restored, if so desired).
* value.
*
****************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
@@ -145,7 +143,8 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
irqhandler, arg);
}
return oldhandler;
UNUSED(oldhandler);
return OK;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */
+9 -18
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* configs/open1788/src/lpc17_buttons.c
*
* Copyright (C) 2013, 2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2013, 2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -41,6 +41,7 @@
#include <stdint.h>
#include <stdbool.h>
#include <errno.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
@@ -89,13 +90,7 @@ static const lpc17_pinset_t g_buttoncfg[BOARD_NUM_BUTTONS] =
GPIO_JOY_B, GPIO_JOY_C, GPIO_JOY_D, GPIO_JOY_CTR
};
/* This array defines all of the interrupt handlers current attached to
* button events.
*/
#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_LPC17_GPIOIRQ)
static xcpt_t g_buttonisr[BOARD_NUM_BUTTONS];
/* This array provides the mapping from button ID numbers to button IRQ
* numbers.
*/
@@ -189,8 +184,7 @@ uint8_t board_buttons(void)
* be called when a button is depressed or released. The ID value is a
* button enumeration value that uniquely identifies a button resource. See the
* BOARD_BUTTON_* and BOARD_JOYSTICK_* definitions in board.h for the meaning
* of enumeration values. The previous interrupt handler address is returned
* (so that it may restored, if so desired).
* of enumeration values.
*
* Note that board_button_irq() also enables button interrupts. Button
* interrupts will remain enabled after the interrupt handler is attached.
@@ -200,10 +194,10 @@ uint8_t board_buttons(void)
****************************************************************************/
#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_LPC17_GPIOIRQ)
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
irqstate_t flags;
int ret = -EINVAL;
int irq;
/* Verify that the button ID is within range */
@@ -221,11 +215,6 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
flags = enter_critical_section();
/* Return the current button handler and set the new interrupt handler */
oldhandler = g_buttonisr[id];
g_buttonisr[id] = irqhandler;
/* Configure the interrupt. Either attach and enable the new
* interrupt or disable and detach the old interrupt handler.
*/
@@ -234,7 +223,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
/* Attach then enable the new interrupt handler */
(void)irq_attach(irq, irqhandler, NULL);
(void)irq_attach(irq, irqhandler, arg);
up_enable_irq(irq);
}
else
@@ -247,9 +236,11 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
leave_critical_section(flags);
}
ret = OK;
}
return oldhandler;
return ret;
}
#endif
+8 -29
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* configs/pcduino-a10/src/a1x_buttons.c
*
* Copyright (C) 2013-2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2013-2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -40,6 +40,7 @@
#include <nuttx/config.h>
#include <stdint.h>
#include <errno.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
@@ -52,22 +53,6 @@
#ifdef CONFIG_ARCH_BUTTONS
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
static xcpt_t g_irqbutton[BOARD_NBUTTONS];
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -110,8 +95,7 @@ uint8_t board_buttons(void)
* Description:
* This function may be called to register an interrupt handler that will
* be called when a button is depressed or released. The ID value is one
* of the BUTTON* definitions provided above. The previous interrupt
* handler address isreturned (so that it may restored, if so desired).
* of the BUTTON* definitions provided above.
*
* Configuration Notes:
* Configuration CONFIG_ARCH_IRQBUTTONS must be selected to enable the
@@ -120,9 +104,9 @@ uint8_t board_buttons(void)
****************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
int ret = -EINVAL;
if (id < BOARD_NBUTTONS)
{
@@ -134,22 +118,17 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
flags = enter_critical_section();
/* Get the old button interrupt handler and save the new one */
oldhandler = g_irqbutton[id];
g_irqbutton[id] = irqhandler;
/* Configure the interrupt */
a1x_pioirq(xxx);
(void)irq_attach(xxx, irqhandler, NULL);
a1x_pioirqenable(xxx);
leave_critical_section(flags);
ret = OK;
}
/* Return the old button handler (so that it can be restored) */
return oldhandler;
return ret;
}
#endif
@@ -1,7 +1,7 @@
/****************************************************************************
* configs/pic32mz-starterkit/src/pic32mz_buttons.c
*
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -40,6 +40,7 @@
#include <nuttx/config.h>
#include <stdint.h>
#include <errno.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
@@ -146,13 +147,12 @@ uint8_t board_buttons(void)
* will be called when a button is depressed or released. The ID value is
* a button enumeration value that uniquely identifies a button resource.
* See the BUTTON_* definitions in board.h for the meaning of enumeration
* value. The previous interrupt handler address is returned (so that it
* may restored, if so desired).
* value.
*
****************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
#ifdef CONFIG_PIC32MZ_GPIOIRQ_PORTB
int ret = OK;
+1 -2
View File
@@ -170,8 +170,7 @@ uint8_t board_buttons(void)
* Description:
* This function may be called to register an interrupt handler that will
* be called when a button is depressed or released. The ID value is one
* of the BUTTON* definitions provided above. The previous interrupt
* handler address isreturned (so that it may restored, if so desired).
* of the BUTTON* definitions provided above.
*
* Configuration Notes:
* Configuration CONFIG_AVR32_GPIOIRQ must be selected to enable the
+1 -2
View File
@@ -176,8 +176,7 @@ uint8_t board_buttons(void)
* Description:
* This function may be called to register an interrupt handler that will
* be called when a button is depressed or released. The ID value is one
* of the BUTTON* definitions provided above. The previous interrupt
* handler address isreturned (so that it may restored, if so desired).
* of the BUTTON* definitions provided above.
*
* Configuration Notes:
* Configuration CONFIG_AVR32_GPIOIRQ must be selected to enable the
+1 -2
View File
@@ -111,8 +111,7 @@ uint8_t board_buttons(void)
* Description:
* This function may be called to register an interrupt handler that will
* be called when a button is depressed or released. The ID value is one
* of the BUTTON* definitions provided above. The previous interrupt
* handler address is returned (so that it may restored, if so desired).
* of the BUTTON* definitions provided above.
*
* Configuration Notes:
* Configuration CONFIG_AVR32_GPIOIRQ must be selected to enable the
+1 -2
View File
@@ -110,8 +110,7 @@ uint8_t board_buttons(void)
* Description:
* This function may be called to register an interrupt handler that will
* be called when a button is depressed or released. The ID value is one
* of the BUTTON* definitions provided above. The previous interrupt
* handler address is returned (so that it may restored, if so desired).
* of the BUTTON* definitions provided above.
*
* Configuration Notes:
* Configuration CONFIG_AVR32_GPIOIRQ must be selected to enable the
+1 -2
View File
@@ -111,8 +111,7 @@ uint8_t board_buttons(void)
* Description:
* This function may be called to register an interrupt handler that will
* be called when a button is depressed or released. The ID value is one
* of the BUTTON* definitions provided above. The previous interrupt
* handler address is returned (so that it may restored, if so desired).
* of the BUTTON* definitions provided above.
*
* Configuration Notes:
* Configuration CONFIG_AVR32_GPIOIRQ must be selected to enable the
+1 -2
View File
@@ -122,8 +122,7 @@ uint8_t board_buttons(void)
* Description:
* This function may be called to register an interrupt handler that will
* be called when a button is depressed or released. The ID value is one
* of the BUTTON* definitions provided above. The previous interrupt
* handler address is returned (so that it may restored, if so desired).
* of the BUTTON* definitions provided above.
*
* Configuration Notes:
* Configuration CONFIG_SAMA5_PIO_IRQ must be selected to enable the
+1 -2
View File
@@ -126,8 +126,7 @@ uint8_t board_buttons(void)
* Description:
* This function may be called to register an interrupt handler that will
* be called when a button is depressed or released. The ID value is one
* of the BUTTON* definitions provided above. The previous interrupt
* handler address is returned (so that it may restored, if so desired).
* of the BUTTON* definitions provided above.
*
* Configuration Notes:
* Configuration CONFIG_SAMA5_PIO_IRQ must be selected to enable the
+1 -2
View File
@@ -126,8 +126,7 @@ uint8_t board_buttons(void)
* Description:
* This function may be called to register an interrupt handler that will
* be called when a button is depressed or released. The ID value is one
* of the BUTTON* definitions provided above. The previous interrupt
* handler address isreturned (so that it may restored, if so desired).
* of the BUTTON* definitions provided above.
*
* Configuration Notes:
* Configuration CONFIG_SAMA5_PIO_IRQ must be selected to enable the
+1 -2
View File
@@ -122,8 +122,7 @@ uint8_t board_buttons(void)
* Description:
* This function may be called to register an interrupt handler that will
* be called when a button is depressed or released. The ID value is one
* of the BUTTON* definitions provided above. The previous interrupt
* handler address is returned (so that it may restored, if so desired).
* of the BUTTON* definitions provided above.
*
* Configuration Notes:
* Configuration CONFIG_SAMA5_PIO_IRQ must be selected to enable the
+1 -2
View File
@@ -111,8 +111,7 @@ uint8_t board_buttons(void)
* Description:
* This function may be called to register an interrupt handler that will
* be called when a button is depressed or released. The ID value is one
* of the BUTTON* definitions provided above. The previous interrupt
* handler address isreturned (so that it may restored, if so desired).
* of the BUTTON* definitions provided above.
*
* Configuration Notes:
* Configuration CONFIG_AVR32_PORTIRQ must be selected to enable the
+1 -2
View File
@@ -111,8 +111,7 @@ uint8_t board_buttons(void)
* Description:
* This function may be called to register an interrupt handler that will
* be called when a button is depressed or released. The ID value is one
* of the BUTTON* definitions provided above. The previous interrupt
* handler address isreturned (so that it may restored, if so desired).
* of the BUTTON* definitions provided above.
*
* Configuration Notes:
* Configuration CONFIG_AVR32_PORTIRQ must be selected to enable the
+1 -2
View File
@@ -175,8 +175,7 @@ uint8_t board_buttons(void)
* Description:
* This function may be called to register an interrupt handler that will
* be called when a button is depressed or released. The ID value is one
* of the BUTTON* definitions provided above. The previous interrupt
* handler address is returned (so that it may restored, if so desired).
* of the BUTTON* definitions provided above.
*
* Configuration Notes:
* Configuration CONFIG_AVR32_GPIOIRQ must be selected to enable the
+1 -2
View File
@@ -111,8 +111,7 @@ uint8_t board_buttons(void)
* Description:
* This function may be called to register an interrupt handler that will
* be called when a button is depressed or released. The ID value is one
* of the BUTTON* definitions provided above. The previous interrupt
* handler address isreturned (so that it may restored, if so desired).
* of the BUTTON* definitions provided above.
*
* Configuration Notes:
* Configuration CONFIG_AVR32_PORTIRQ must be selected to enable the
+1 -2
View File
@@ -195,8 +195,7 @@ uint8_t board_buttons(void)
* Description:
* This function may be called to register an interrupt handler that will
* be called when a button is depressed or released. The ID value is one
* of the BUTTON* definitions provided above. The previous interrupt
* handler address is returned (so that it may restored, if so desired).
* of the BUTTON* definitions provided above.
*
* Configuration Notes:
* Configuration CONFIG_AVR32_GPIOIRQ must be selected to enable the
+6 -5
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* configs/shenzhou/src/stm32_buttons.c
*
* Copyright (C) 2012, 2014-2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2012, 2014-2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -150,13 +150,12 @@ uint8_t board_buttons(void)
* be called when a button is depressed or released. The ID value is a
* button enumeration value that uniquely identifies a button resource. See the
* BUTTON_* and JOYSTICK_* definitions in board.h for the meaning of enumeration
* value. The previous interrupt handler address is returned (so that it may
* restored, if so desired).
* value.
*
************************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
@@ -167,7 +166,9 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
oldhandler = stm32_gpiosetevent(g_buttons[id], true, true, true,
irqhandler, arg);
}
return oldhandler;
UNUSED(oldhandler);
return OK;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */
+5 -17
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* configs/spark/src/stm32_buttons.c
*
* Copyright (C) 2011-2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2011-2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -49,18 +49,6 @@
#ifdef CONFIG_ARCH_BUTTONS
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -114,13 +102,12 @@ uint8_t board_buttons(void)
* be called when a button is depressed or released. The ID value is a
* button enumeration value that uniquely identifies a button resource. See the
* BUTTON_* definitions in board.h for the meaning of enumeration
* value. The previous interrupt handler address is returned (so that it may
* restored, if so desired).
* value.
*
************************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
@@ -131,7 +118,8 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
oldhandler = stm32_gpiosetevent(GPIO_BTN, true, true, true, irqhandler, arg);
}
return oldhandler;
UNUSED(oldhandler);
return OK;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */
+1 -2
View File
@@ -155,8 +155,7 @@ uint8_t board_buttons(void)
* be called when a button is depressed or released. The ID value is a
* button enumeration value that uniquely identifies a button resource. See the
* BUTTON_* and JOYSTICK_* definitions in board.h for the meaning of enumeration
* value. The previous interrupt handler address is returned (so that it may
* restored, if so desired).
* value.
*
************************************************************************************/
+1 -2
View File
@@ -151,8 +151,7 @@ uint8_t board_buttons(void)
* be called when a button is depressed or released. The ID value is a
* button enumeration value that uniquely identifies a button resource. See the
* BUTTON_* definitions in board.h for the meaning of enumeration
* value. The previous interrupt handler address is returned (so that it may
* restored, if so desired).
* value.
*
************************************************************************************/
+1 -2
View File
@@ -151,8 +151,7 @@ uint8_t board_buttons(void)
* be called when a button is depressed or released. The ID value is a
* button enumeration value that uniquely identifies a button resource. See the
* BUTTON_* definitions in board.h for the meaning of enumeration
* value. The previous interrupt handler address is returned (so that it may
* restored, if so desired).
* value.
*
************************************************************************************/
@@ -146,8 +146,7 @@ uint8_t board_buttons(void)
* will be called when a button is depressed or released. The ID value is
* a button enumeration value that uniquely identifies a button resource.
* See the BUTTON_* definitions in board.h for the meaning of enumeration
* value. The previous interrupt handler address is returned (so that it
* may be restored, if so desired).
* value.
*
****************************************************************************/

Some files were not shown because too many files have changed in this diff Show More