stm32_gpiosetevent: GPIO IRQ logic no longer returns the xcpt_t oldhandler. This value is useless and dangerous after the recent changes to interrupt argument passing.

This commit is contained in:
Gregory Nutt 2017-03-02 16:34:37 -06:00
parent 4f5e0e3519
commit f4bad1a280
34 changed files with 179 additions and 330 deletions

View File

@ -72,22 +72,21 @@ extern "C"
* Description:
* Sets/clears GPIO based event and interrupt triggers.
*
* Parameters:
* Input Parameters:
* - pinset: gpio pin configuration
* - rising/falling edge: enables
* - event: generate event when set
* - func: when non-NULL, generate interrupt
* - arg: Argument passed to the interrupt callback
*
* Returns:
* The previous value of the interrupt handler function pointer. This value may,
* for example, be used to restore the previous handler when multiple handlers are
* used.
* Returned Value:
* Zero (OK) on success; a negated errno value on failure indicating the
* nature of the failure.
*
************************************************************************************/
xcpt_t stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
bool event, xcpt_t func, void *arg);
int stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
bool event, xcpt_t func, void *arg);
/************************************************************************************
* Name: stm32_exti_alarm
@ -95,13 +94,13 @@ xcpt_t stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
* Description:
* Sets/clears EXTI alarm interrupt.
*
* Parameters:
* Input Parameters:
* - rising/falling edge: enables interrupt on rising/falling edges
* - event: generate event when set
* - func: when non-NULL, generate interrupt
* - arg: Argument passed to the interrupt callback
*
* Returns:
* Returned Value:
* Zero (OK) on success; a negated errno value on failure indicating the
* nature of the failure.
*

View File

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/stm32/stm32_exti_gpio.c
*
* Copyright (C) 2009, 2011-2012, 2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2009, 2011-2012, 2015, 2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2011 Uros Platise. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
* Uros Platise <uros.platise@isotel.eu>
@ -250,7 +250,7 @@ static int stm32_exti1510_isr(int irq, void *context, void *arg)
* Description:
* Sets/clears GPIO based event and interrupt triggers.
*
* Parameters:
* Input Parameters:
* - pinset: GPIO pin configuration
* - risingedge: Enables interrupt on rising edges
* - fallingedge: Enables interrupt on falling edges
@ -258,22 +258,20 @@ static int stm32_exti1510_isr(int irq, void *context, void *arg)
* - func: When non-NULL, generate interrupt
* - arg: Argument passed to the interrupt callback
*
* Returns:
* The previous value of the interrupt handler function pointer. This
* value may, for example, be used to restore the previous handler when
* multiple handlers are used.
* Returned Value:
* Zero (OK) on success; a negated errno value on failure indicating the
* nature of the failure.
*
****************************************************************************/
xcpt_t stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
bool event, xcpt_t func, void *arg)
int stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
bool event, xcpt_t func, void *arg)
{
FAR struct gpio_callback_s *shared_cbs;
uint32_t pin = pinset & GPIO_PIN_MASK;
uint32_t exti = STM32_EXTI_BIT(pin);
int irq;
xcpt_t handler;
xcpt_t oldhandler = NULL;
int nshared;
int i;
@ -324,7 +322,6 @@ xcpt_t stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
/* Get the previous GPIO IRQ handler; Save the new IRQ handler. */
oldhandler = g_gpio_callbacks[pin].callback;
g_gpio_callbacks[pin].callback = func;
g_gpio_callbacks[pin].arg = arg;
@ -384,7 +381,5 @@ xcpt_t stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
func ? 0 : exti,
func ? exti : 0);
/* Return the old IRQ handler */
return oldhandler;
return OK;
}

View File

@ -432,7 +432,7 @@ EXTERN const uint32_t g_gpiobase[STM32_NGPIO_PORTS];
* function, it must be unconfigured with stm32_unconfiggpio() with
* the same cfgset first before it can be set to non-alternative function.
*
* Returns:
* Returned Value:
* OK on success
* ERROR on invalid port, or when pin is locked as ALT function.
*
@ -453,7 +453,7 @@ int stm32_configgpio(uint32_t cfgset);
* operate in PWM mode could produce excessive on-board currents and trigger
* over-current/alarm function.
*
* Returns:
* Returned Value:
* OK on success
* ERROR on invalid port
*
@ -487,22 +487,21 @@ bool stm32_gpioread(uint32_t pinset);
* Description:
* Sets/clears GPIO based event and interrupt triggers.
*
* Parameters:
* Input Parameters:
* - pinset: gpio pin configuration
* - rising/falling edge: enables
* - event: generate event when set
* - func: when non-NULL, generate interrupt
* - arg: Argument passed to the interrupt callback
*
* Returns:
* The previous value of the interrupt handler function pointer. This value may,
* for example, be used to restore the previous handler when multiple handlers are
* used.
* Returned Value:
* Zero (OK) on success; a negated errno value on failure indicating the
* nature of the failure.
*
************************************************************************************/
xcpt_t stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
bool event, xcpt_t func, void *arg);
int stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
bool event, xcpt_t func, void *arg);
/************************************************************************************
* Function: stm32_dumpgpio

View File

@ -668,16 +668,16 @@ static void stm32_configwaitints(struct stm32_dev_s *priv, uint32_t waitmask,
/* Arm the SDIO_D Ready and install Isr */
stm32_gpiosetevent(pinset, true, false, false,
stm32_rdyinterrupt, priv);
(void)stm32_gpiosetevent(pinset, true, false, false,
stm32_rdyinterrupt, priv);
}
/* Disarm SDIO_D ready */
if ((wkupevent & SDIOWAIT_WRCOMPLETE) != 0)
{
stm32_gpiosetevent(GPIO_SDIO_D0, false, false, false,
NULL, NULL);
(void)stm32_gpiosetevent(GPIO_SDIO_D0, false, false, false,
NULL, NULL);
stm32_configgpio(GPIO_SDIO_D0);
}
#endif

View File

@ -72,7 +72,7 @@ extern "C"
* Description:
* Sets/clears GPIO based event and interrupt triggers.
*
* Parameters:
* Input Parameters:
* - pinset: GPIO pin configuration
* - risingedge: Enables interrupt on rising edges
* - fallingedge: Enables interrupt on falling edges
@ -80,15 +80,14 @@ extern "C"
* - func: When non-NULL, generate interrupt
* - arg: Argument passed to the interrupt callback
*
* Returns:
* The previous value of the interrupt handler function pointer. This
* value may, for example, be used to restore the previous handler when
* multiple handlers are used.
* Returned Value:
* Zero (OK) on success; a negated errno value on failure indicating the
* nature of the failure.
*
****************************************************************************/
************************************************************************************/
xcpt_t stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
bool event, xcpt_t func, void *arg);
int stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
bool event, xcpt_t func, void *arg);
/****************************************************************************
* Name: stm32_exti_alarm
@ -96,14 +95,14 @@ xcpt_t stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
* Description:
* Sets/clears EXTI alarm interrupt.
*
* Parameters:
* Input Parameters:
* - risingedge: Enables interrupt on rising edges
* - fallingedge: Enables interrupt on falling edges
* - event: Generate event when set
* - func: When non-NULL, generate interrupt
* - arg: Argument passed to the interrupt callback
*
* Returns:
* Returned Value:
* Zero (OK) on success; a negated errno value on failure indicating the
* nature of the failure.
*

View File

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/stm32f7/stm32_exti_gpio.c
*
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Based on EXTI GPIO logic from the Cortex-M3/4 which includes contributions
@ -262,7 +262,7 @@ static int stm32_exti1510_isr(int irq, void *context, void *arg)
* Description:
* Sets/clears GPIO based event and interrupt triggers.
*
* Parameters:
* Input Parameters:
* - pinset: GPIO pin configuration
* - risingedge: Enables interrupt on rising edges
* - fallingedge: Enables interrupt on falling edges
@ -270,22 +270,20 @@ static int stm32_exti1510_isr(int irq, void *context, void *arg)
* - func: When non-NULL, generate interrupt
* - arg: Argument passed to the interrupt callback
*
* Returns:
* The previous value of the interrupt handler function pointer. This
* value may, for example, be used to restore the previous handler when
* multiple handlers are used.
* Returned Value:
* Zero (OK) on success; a negated errno value on failure indicating the
* nature of the failure.
*
****************************************************************************/
xcpt_t stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
bool event, xcpt_t func, void *arg)
int stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
bool event, xcpt_t func, void *arg)
{
struct gpio_callback_s *shared_cbs;
uint32_t pin = pinset & GPIO_PIN_MASK;
uint32_t exti = STM32_EXTI_BIT(pin);
int irq;
xcpt_t handler;
xcpt_t oldhandler = NULL;
int nshared;
int i;
@ -336,7 +334,6 @@ xcpt_t stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
/* Get the previous GPIO IRQ handler; Save the new IRQ handler. */
oldhandler = g_gpio_callbacks[pin].callback;
g_gpio_callbacks[pin].callback = func;
g_gpio_callbacks[pin].arg = arg;
@ -396,9 +393,7 @@ xcpt_t stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
func ? 0 : exti,
func ? exti : 0);
/* Return the old IRQ handler */
return oldhandler;
return OK;
}
#endif /* CONFIG_STM32F7_STM32F74XX || CONFIG_STM32F7_STM32F75XX */

View File

@ -266,7 +266,7 @@ EXTERN const uint32_t g_gpiobase[STM32F7_NGPIO];
* function, it must be unconfigured with stm32_unconfiggpio() with
* the same cfgset first before it can be set to non-alternative function.
*
* Returns:
* Returned Value:
* OK on success
* ERROR on invalid port, or when pin is locked as ALT function.
*
@ -287,7 +287,7 @@ int stm32_configgpio(uint32_t cfgset);
* operate in PWM mode could produce excessive on-board currents and trigger
* over-current/alarm function.
*
* Returns:
* Returned Value:
* OK on success
* ERROR on invalid port
*
@ -321,7 +321,7 @@ bool stm32_gpioread(uint32_t pinset);
* Description:
* Sets/clears GPIO based event and interrupt triggers.
*
* Parameters:
* Input Parameters:
* - pinset: GPIO pin configuration
* - risingedge: Enables interrupt on rising edges
* - fallingedge: Enables interrupt on falling edges
@ -329,15 +329,14 @@ bool stm32_gpioread(uint32_t pinset);
* - func: When non-NULL, generate interrupt
* - arg: Argument passed to the interrupt callback
*
* Returns:
* The previous value of the interrupt handler function pointer. This
* value may, for example, be used to restore the previous handler when
* multiple handlers are used.
* Returned Value:
* Zero (OK) on success; a negated errno value on failure indicating the
* nature of the failure.
*
****************************************************************************/
************************************************************************************/
xcpt_t stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
bool event, xcpt_t func, void *arg);
int stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
bool event, xcpt_t func, void *arg);
/************************************************************************************
* Function: stm32_dumpgpio

View File

@ -846,16 +846,16 @@ static void stm32_configwaitints(struct stm32_dev_s *priv, uint32_t waitmask,
/* Arm the SDMMC_D Ready and install Isr */
stm32_gpiosetevent(pinset, true, false, false,
priv->wrchandler, priv);
(void)stm32_gpiosetevent(pinset, true, false, false,
priv->wrchandler, priv);
}
/* Disarm SDMMC_D ready */
if ((wkupevent & SDIOWAIT_WRCOMPLETE) != 0)
{
stm32_gpiosetevent(priv->d0_gpio, false, false, false,
NULL, NULL);
(void)stm32_gpiosetevent(priv->d0_gpio, false, false, false,
NULL, NULL);
stm32_configgpio(priv->d0_gpio);
}
#endif

View File

@ -41,6 +41,7 @@
#include <nuttx/config.h>
#include <stdint.h>
#include <errno.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
@ -159,18 +160,17 @@ uint8_t board_buttons(void)
#ifdef CONFIG_ARCH_IRQBUTTONS
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
int ret = -EINVAL;
/* The following should be atomic */
if (id >= MIN_IRQBUTTON && id <= MAX_IRQBUTTON)
{
oldhandler = stm32_gpiosetevent(g_buttons[id], true, true, true,
irqhandler, arg);
ret = stm32_gpiosetevent(g_buttons[id], true, true, true, irqhandler,
arg);
}
UNUSED(oldhandler);
return OK;
return ret;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -40,6 +40,7 @@
#include <nuttx/config.h>
#include <stdint.h>
#include <errno.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
@ -135,8 +136,8 @@ uint8_t board_buttons(void)
#ifdef CONFIG_ARCH_IRQBUTTONS
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler;
uint16_t gpio;
int ret;
if (id == BUTTON_KEY1)
{
@ -148,13 +149,10 @@ int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
}
else
{
return NULL;
return -EINVAL;
}
oldhandler = stm32_gpiosetevent(gpio, true, true, true, irqhandler, arg);
UNUSED(oldhandler);
return OK;
return stm32_gpiosetevent(gpio, true, true, true, irqhandler, arg);
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -40,6 +40,7 @@
#include <nuttx/config.h>
#include <stdint.h>
#include <errno.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
@ -134,8 +135,8 @@ uint8_t board_buttons(void)
#ifdef CONFIG_ARCH_IRQBUTTONS
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
uint32_t pinset = GPIO_BTN_KEYA;
int ret = -EINVAL;
if (id == 1)
{
@ -144,12 +145,10 @@ int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
if (id < 2)
{
oldhandler = stm32_gpiosetevent(pinset, true, true, true,
irqhandler, arg);
ret = stm32_gpiosetevent(pinset, true, true, true, irqhandler, arg);
}
UNUSED(oldhandler);
return OK;
return ret;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -41,6 +41,7 @@
#include <nuttx/config.h>
#include <stddef.h>
#include <errno.h>
#include <nuttx/irq.h>
#include <nuttx/board.h>
@ -106,16 +107,14 @@ uint8_t board_buttons(void)
#ifdef CONFIG_ARCH_IRQBUTTONS
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
int ret = -EINVAL;
if (id == BUTTON_USER)
{
oldhandler = stm32_gpiosetevent(GPIO_BTN_USER, true, true, true,
irqhandler, arg);
ret = stm32_gpiosetevent(GPIO_BTN_USER, true, true, true, irqhandler, arg);
}
UNUSED(oldhandler);
return OK;
return ret;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -43,6 +43,7 @@
#include <stdint.h>
#include <stdbool.h>
#include <errno.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
@ -52,22 +53,6 @@
#ifdef CONFIG_ARCH_BUTTONS
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
@ -127,16 +112,15 @@ uint8_t board_buttons(void)
#ifdef CONFIG_ARCH_IRQBUTTONS
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
int ret = -EINVAL;
if (id == BUTTON_USER)
{
oldhandler = stm32_gpiosetevent(GPIO_BTN_USER, true, true, true,
irqhandler, arg);
ret = stm32_gpiosetevent(GPIO_BTN_USER, true, true, true, irqhandler,
arg);
}
UNUSED(oldhandler);
return OK;
return ret;
}
#endif

View File

@ -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
****************************************************************************/
@ -124,16 +113,14 @@ uint8_t board_buttons(void)
#ifdef CONFIG_ARCH_IRQBUTTONS
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
int ret = -EINVAL;
if (id == BUTTON_USER)
{
oldhandler = stm32_gpiosetevent(GPIO_BTN_USER, true, true, true,
irqhandler, arg);
ret = stm32_gpiosetevent(GPIO_BTN_USER, true, true, true, irqhandler, arg);
}
UNUSED(oldhandler);
return OK;
return ret;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -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
****************************************************************************/
@ -124,16 +113,14 @@ uint8_t board_buttons(void)
#ifdef CONFIG_ARCH_IRQBUTTONS
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
int ret = -EINVAL;
if (id == BUTTON_USER)
{
oldhandler = stm32_gpiosetevent(GPIO_BTN_USER, true, true, true,
irqhandler, arg);
ret = stm32_gpiosetevent(GPIO_BTN_USER, true, true, true, irqhandler, arg);
}
UNUSED(oldhandler);
return OK;
return ret;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -40,6 +40,7 @@
#include <nuttx/config.h>
#include <stdint.h>
#include <errno.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
@ -50,7 +51,7 @@
#ifdef CONFIG_ARCH_BUTTONS
/****************************************************************************
* Private Functions
* Private Data
****************************************************************************/
/* Pin configuration for each Olimex-STM32-H405 button. This array is
@ -134,18 +135,17 @@ uint8_t board_buttons(void)
#ifdef CONFIG_ARCH_IRQBUTTONS
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
int ret = -EINVAL;
/* The following should be atomic */
if (id >= MIN_IRQBUTTON && id <= MAX_IRQBUTTON)
{
oldhandler =
stm32_gpiosetevent(g_buttons[id], true, true, true, irqhandler, arg);
ret = stm32_gpiosetevent(g_buttons[id], true, true, true, irqhandler,
arg);
}
UNUSED(oldhandler);
return OK;
return ret;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -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,10 @@
#ifdef CONFIG_ARCH_BUTTONS
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/* Pin configuration for each Olimex-STM32-H405 button. This array is indexed by
* the BUTTON_* definitions in board.h
*/
@ -142,18 +135,16 @@ uint8_t board_buttons(void)
#ifdef CONFIG_ARCH_IRQBUTTONS
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
int ret = -EINVAL;
/* The following should be atomic */
if (id >= MIN_IRQBUTTON && id <= MAX_IRQBUTTON)
{
oldhandler = stm32_gpiosetevent(g_buttons[id], true, true, true,
irqhandler, arg);
ret = stm32_gpiosetevent(g_buttons[id], true, true, true, irqhandler, arg);
}
UNUSED(oldhandler);
return OK;
return ret;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -40,6 +40,7 @@
#include <nuttx/config.h>
#include <stdint.h>
#include <errno.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
@ -50,7 +51,7 @@
#ifdef CONFIG_ARCH_BUTTONS
/****************************************************************************
* Private Functions
* Private Data
****************************************************************************/
/* Pin configuration for each Olimex-STM32-H405 button. This array is indexed by
@ -134,18 +135,17 @@ uint8_t board_buttons(void)
#ifdef CONFIG_ARCH_IRQBUTTONS
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
int ret = -EINVAL;
/* The following should be atomic */
if (id >= MIN_IRQBUTTON && id <= MAX_IRQBUTTON)
{
oldhandler = stm32_gpiosetevent(g_buttons[id], true, true, true,
irqhandler, arg);
ret = stm32_gpiosetevent(g_buttons[id], true, true, true, irqhandler,
arg);
}
UNUSED(oldhandler);
return OK;
return ret;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -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,10 @@
#ifdef CONFIG_ARCH_BUTTONS
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/* Pin configuration for each STM32F4 Discovery button. This array is indexed by
* the BUTTON_* definitions in board.h
*/
@ -178,18 +171,16 @@ uint8_t board_buttons(void)
#ifdef CONFIG_ARCH_IRQBUTTONS
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
int ret = -EINVAL;
/* The following should be atomic */
if (id >= MIN_IRQBUTTON && id <= MAX_IRQBUTTON)
{
oldhandler = stm32_gpiosetevent(g_buttons[id], true, true, true,
irqhandler, arg);
ret = stm32_gpiosetevent(g_buttons[id], true, true, true, irqhandler, arg);
}
UNUSED(oldhandler);
return OK;
return ret;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -40,6 +40,7 @@
#include <nuttx/config.h>
#include <stdint.h>
#include <errno.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
@ -52,7 +53,7 @@
#ifdef CONFIG_ARCH_BUTTONS
/****************************************************************************
* Private Functions
* Private Data
****************************************************************************/
/* Pin configuration for each STM32F4 Discovery button. This array is indexed by
@ -172,18 +173,16 @@ uint8_t board_buttons(void)
#ifdef CONFIG_ARCH_IRQBUTTONS
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
int ret = -EINVAL;
/* The following should be atomic */
if (id >= MIN_IRQBUTTON && id <= MAX_IRQBUTTON)
{
oldhandler = stm32_gpiosetevent(g_buttons[id], true, true, true,
irqhandler, arg);
ret = stm32_gpiosetevent(g_buttons[id], true, true, true, irqhandler, arg);
}
UNUSED(oldhandler);
return OK;
return ret;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -41,6 +41,7 @@
#include <nuttx/config.h>
#include <stdint.h>
#include <errno.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
@ -50,21 +51,10 @@
#ifdef CONFIG_ARCH_BUTTONS
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Button support.
*
@ -133,18 +123,17 @@ uint8_t board_buttons(void)
#ifdef CONFIG_ARCH_IRQBUTTONS
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
int ret = -EINVAL;
/* The following should be atomic */
if (id == IRQBUTTON)
{
oldhandler = stm32_gpiosetevent(BUTTON_BOOT0n, true, true, true,
irqhandler, arg);
ret = stm32_gpiosetevent(BUTTON_BOOT0n, true, true, true, irqhandler,
arg);
}
UNUSED(oldhandler);
return OK;
return ret;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -40,6 +40,7 @@
#include <nuttx/config.h>
#include <stdint.h>
#include <errno.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
@ -49,13 +50,10 @@
#ifdef CONFIG_ARCH_BUTTONS
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/* Pin configuration for each Shenzhou button. This array is indexed by
* the BUTTON_* definitions in board.h
*/
@ -65,10 +63,6 @@ static const uint32_t g_buttons[NUM_BUTTONS] =
GPIO_BTN_USERKEY2, GPIO_BTN_USERKEY, GPIO_BTN_TAMPER, GPIO_BTN_WAKEUP
};
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
@ -157,18 +151,16 @@ uint8_t board_buttons(void)
#ifdef CONFIG_ARCH_IRQBUTTONS
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
int ret = -EINVAL;
/* The following should be atomic */
if (id >= MIN_IRQBUTTON && id <= MAX_IRQBUTTON)
{
oldhandler = stm32_gpiosetevent(g_buttons[id], true, true, true,
irqhandler, arg);
ret = stm32_gpiosetevent(g_buttons[id], true, true, true, irqhandler, arg);
}
UNUSED(oldhandler);
return OK;
return ret;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -40,6 +40,7 @@
#include <nuttx/config.h>
#include <stdint.h>
#include <errno.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
@ -109,17 +110,16 @@ uint8_t board_buttons(void)
#ifdef CONFIG_ARCH_IRQBUTTONS
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
int ret = -EINVAL;
/* The following should be atomic */
if (id == BUTTON_USER)
{
oldhandler = stm32_gpiosetevent(GPIO_BTN, true, true, true, irqhandler, arg);
ret = stm32_gpiosetevent(GPIO_BTN, true, true, true, irqhandler, arg);
}
UNUSED(oldhandler);
return OK;
return ret;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -40,6 +40,7 @@
#include <nuttx/config.h>
#include <stdint.h>
#include <errno.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
@ -162,18 +163,16 @@ uint8_t board_buttons(void)
#ifdef CONFIG_ARCH_IRQBUTTONS
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
int ret = -EINVAL;
/* The following should be atomic */
if (id >= MIN_IRQBUTTON && id <= MAX_IRQBUTTON)
{
oldhandler = stm32_gpiosetevent(g_buttons[id], true, true, true,
irqhandler, arg);
ret = stm32_gpiosetevent(g_buttons[id], true, true, true, irqhandler, arg);
}
UNUSED(oldhandler);
return OK;
return ret;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -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,10 @@
#ifdef CONFIG_ARCH_BUTTONS
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/* Pin configuration for each STM3210E-EVAL button. This array is indexed by
* the BUTTON_* and JOYSTICK_* definitions in board.h
*/
@ -158,18 +151,16 @@ uint8_t board_buttons(void)
#ifdef CONFIG_ARCH_IRQBUTTONS
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
int ret = -EINVAL;
/* The following should be atomic */
if (id >= MIN_IRQBUTTON && id <= MAX_IRQBUTTON)
{
oldhandler = stm32_gpiosetevent(g_buttons[id], true, true, true,
irqhandler, arg);
ret = stm32_gpiosetevent(g_buttons[id], true, true, true, irqhandler, arg);
}
UNUSED(oldhandler);
return OK;
return ret;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -40,6 +40,7 @@
#include <nuttx/config.h>
#include <stdint.h>
#include <errno.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
@ -158,18 +159,16 @@ uint8_t board_buttons(void)
#ifdef CONFIG_ARCH_IRQBUTTONS
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
int ret = -EINVAL;
/* The following should be atomic */
if (id >= MIN_IRQBUTTON && id <= MAX_IRQBUTTON)
{
oldhandler = stm32_gpiosetevent(g_buttons[id], true, true, true,
irqhandler, arg);
ret = stm32_gpiosetevent(g_buttons[id], true, true, true, irqhandler, arg);
}
UNUSED(oldhandler);
return OK;
return ret;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -40,6 +40,7 @@
#include <nuttx/config.h>
#include <stdint.h>
#include <errno.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
@ -153,18 +154,17 @@ uint8_t board_buttons(void)
#ifdef CONFIG_ARCH_IRQBUTTONS
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
int ret = -EINVAL;
/* The following should be atomic */
if (id >= MIN_IRQBUTTON && id <= MAX_IRQBUTTON)
{
oldhandler = stm32_gpiosetevent(g_buttons[id], true, true, true,
irqhandler, arg);
ret = stm32_gpiosetevent(g_buttons[id], true, true, true, irqhandler,
arg);
}
UNUSED(oldhandler);
return OK;
return ret;
}
#endif

View File

@ -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,10 @@
#ifdef CONFIG_ARCH_BUTTONS
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/* Pin configuration for each STM32F3Discovery button. This array is indexed by
* the BUTTON_* definitions in board.h
*/
@ -153,18 +146,16 @@ uint8_t board_buttons(void)
#ifdef CONFIG_ARCH_IRQBUTTONS
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
int ret = -EINVAL;
/* The following should be atomic */
if (id >= MIN_IRQBUTTON && id <= MAX_IRQBUTTON)
{
oldhandler = stm32_gpiosetevent(g_buttons[id], true, true, true,
irqhandler, arg);
ret = stm32_gpiosetevent(g_buttons[id], true, true, true, irqhandler, arg);
}
UNUSED(oldhandler);
return OK;
return ret;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -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,10 @@
#ifdef CONFIG_ARCH_BUTTONS
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/* Pin configuration for each STM32F4 Discovery button. This array is indexed by
* the BUTTON_* definitions in board.h
*/
@ -153,18 +146,16 @@ uint8_t board_buttons(void)
#ifdef CONFIG_ARCH_IRQBUTTONS
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
int ret = -EINVAL;
/* The following should be atomic */
if (id >= MIN_IRQBUTTON && id <= MAX_IRQBUTTON)
{
oldhandler = stm32_gpiosetevent(g_buttons[id], true, true, true,
irqhandler, arg);
ret = stm32_gpiosetevent(g_buttons[id], true, true, true, irqhandler, arg);
}
UNUSED(oldhandler);
return OK;
return ret;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -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,10 @@
#ifdef CONFIG_ARCH_BUTTONS
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/* Pin configuration for each STM32F4 Discovery button. This array is indexed by
* the BUTTON_* definitions in board.h
*/
@ -153,18 +146,16 @@ uint8_t board_buttons(void)
#ifdef CONFIG_ARCH_IRQBUTTONS
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
int ret = -EINVAL;
/* The following should be atomic */
if (id >= MIN_IRQBUTTON && id <= MAX_IRQBUTTON)
{
oldhandler = stm32_gpiosetevent(g_buttons[id], true, true, true,
irqhandler, arg);
ret = stm32_gpiosetevent(g_buttons[id], true, true, true, irqhandler, arg);
}
UNUSED(oldhandler);
return OK;
return ret;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -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,10 @@
#ifdef CONFIG_ARCH_BUTTONS
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/* Pin configuration for each STM32F3Discovery button. This array is indexed by
* the BUTTON_* definitions in board.h
*/
@ -153,18 +146,16 @@ uint8_t board_buttons(void)
#ifdef CONFIG_ARCH_IRQBUTTONS
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
int ret = -EINVAL;
/* The following should be atomic */
if (id >= MIN_IRQBUTTON && id <= MAX_IRQBUTTON)
{
oldhandler = stm32_gpiosetevent(g_buttons[id], true, true, true,
irqhandler, arg);
ret = stm32_gpiosetevent(g_buttons[id], true, true, true, irqhandler, arg);
}
UNUSED(oldhandler);
return OK;
return ret;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -41,6 +41,7 @@
#include <nuttx/config.h>
#include <stdint.h>
#include <errno.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
@ -108,15 +109,14 @@ uint8_t board_buttons(void)
#ifdef CONFIG_ARCH_IRQBUTTONS
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
int ret = -EINVAL;
if (id == 0)
{
oldhandler = stm32_gpiosetevent(GPIO_BTN_0, true, true, true, irqhandler, arg);
ret = stm32_gpiosetevent(GPIO_BTN_0, true, true, true, irqhandler, arg);
}
UNUSED(oldhandler);
return OK;
return ret;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -40,6 +40,7 @@
#include <nuttx/config.h>
#include <stdint.h>
#include <errno.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
@ -49,13 +50,10 @@
#ifdef CONFIG_ARCH_BUTTONS
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/* Pin configuration for each STM3210E-EVAL button. This array is indexed by
* the BUTTON_* and JOYSTICK_* definitions in board.h
*/
@ -65,10 +63,6 @@ static const uint32_t g_buttons[NUM_BUTTONS] =
GPIO_SW2, GPIO_SW3, GPIO_SW4
};
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
@ -153,18 +147,16 @@ uint8_t board_buttons(void)
#ifdef CONFIG_ARCH_IRQBUTTONS
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
{
xcpt_t oldhandler = NULL;
int ret = -EINVAL;
/* The following should be atomic */
if (id >= MIN_IRQBUTTON && id <= MAX_IRQBUTTON)
{
oldhandler = stm32_gpiosetevent(g_buttons[id], true, true, true,
irqhandler, arg);
ret = stm32_gpiosetevent(g_buttons[id], true, true, true, irqhandler, arg);
}
UNUSED(oldhandler);
return OK;
return ret;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -585,11 +585,10 @@ struct cc1101_dev_s *cc1101_init(struct spi_dev_s *spi, uint8_t isrpin,
cc1101_setgdo(dev, dev->isrpin, CC1101_GDO_SYNC);
/* Bind to external interrupt line */
/* depends on STM32: TODO: Make that config within pinset and
* provide general gpio interface
* stm32_gpiosetevent(pinset, false, true, true, cc1101_eventcb);
/* Configure to receive interrupts on the external GPIO interrupt line.
*
* REVISIT: There is no MCU-independent way to do this in this
* context.
*/
return dev;
@ -599,8 +598,11 @@ int cc1101_deinit(struct cc1101_dev_s *dev)
{
ASSERT(dev);
/* Release interrupt */
/* stm32_gpiosetevent(pinset, false, false, false, NULL); */
/* Release the external GPIO interrupt
*
* REVISIT: There is no MCU-independent way to do this in this
* context.
*/
/* Power down chip */