Merged nuttx/nuttx/master into master

This commit is contained in:
Masayuki Ishikawa
2017-03-03 10:22:54 +09:00
160 changed files with 1250 additions and 2078 deletions
+6 -8
View File
@@ -568,19 +568,17 @@ void kinetis_pinirqinitialize(void);
* 3. Call kinetis_pinirqenable() to enable interrupts on the pin.
*
* Parameters:
* pinset - Pin configuration
* pinisr -:wq
:wq: Pin interrupt service routine
* arg:r - And argument that will be provided to the interrupt service routine.
* pinset - Pin configuration
* pinisr - Pin interrupt service routine
* arg - An argument that will be provided to the interrupt service routine.
*
* Return Value:
* 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.
* Zero (OK) is returned on success; a negated errno value is returned on any
* failure to indicate the nature of the failure.
*
************************************************************************************/
xcpt_t kinetis_pinirqattach(uint32_t pinset, xcpt_t pinisr, void *arg);
int kinetis_pinirqattach(uint32_t pinset, xcpt_t pinisr, void *arg);
/************************************************************************************
* Name: kinetis_pinirqenable
+10 -12
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/kinetis/kinetis_pinirq.c
*
* Copyright (C) 2011, 2013, 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2011, 2013, 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -262,21 +262,20 @@ void kinetis_pinirqinitialize(void)
* 3. Call kinetis_pinirqenable() to enable interrupts on the pin.
*
* Parameters:
* - pinset: Pin configuration
* - pinisr: Pin interrupt service routine
* pinset - Pin configuration
* pinisr - Pin interrupt service routine
* arg - An argument that will be provided to the interrupt service routine.
*
* Returns:
* The previous value of the interrupt handler function pointer. This
* value may, for example, be used to restore the previous handler whe
* multiple handlers are used.
* Zero (OK) is returned on success; a negated errno value is returned on any
* failure to indicate the nature of the failure.
*
****************************************************************************/
************************************************************************************/
xcpt_t kinetis_pinirqattach(uint32_t pinset, xcpt_t pinisr, void *arg)
int kinetis_pinirqattach(uint32_t pinset, xcpt_t pinisr, void *arg)
{
#ifdef HAVE_PORTINTS
struct kinetis_pinirq_s *isrtab;
xcpt_t oldisr;
irqstate_t flags;
unsigned int port;
unsigned int pin;
@@ -331,16 +330,15 @@ xcpt_t kinetis_pinirqattach(uint32_t pinset, xcpt_t pinisr, void *arg)
/* Get the old PIN ISR and set the new PIN ISR */
oldisr = isrtab[pin].handler;
isrtab[pin].handler = pinisr;
isrtab[pin].arg = arg;
/* And return the old PIN isr address */
leave_critical_section(flags);
return oldisr;
return OK;
#else
return NULL;
return -ENOSYS;
#endif /* HAVE_PORTINTS */
}
+5 -5
View File
@@ -355,7 +355,7 @@ void kl_gpiowrite(uint32_t pinset, bool value);
bool kl_gpioread(uint32_t pinset);
/************************************************************************************
* Name: kl_pinirqattach
* Name: kl_gpioirqattach
*
* Description:
* Attach a pin interrupt handler. The normal initalization sequence is:
@@ -368,15 +368,15 @@ bool kl_gpioread(uint32_t pinset);
* Parameters:
* - pinset: Pin configuration
* - pinisr: Pin interrupt service routine
* - pinarg: The argument that will accompany the pin interrupt
*
* 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.
* Zero (OK) is returned on success; On any failure, a negated errno value is
* returned to indicate the nature of the failure.
*
************************************************************************************/
xcpt_t kl_gpioirqattach(uint32_t pinset, xcpt_t pinisr);
int kl_gpioirqattach(uint32_t pinset, xcpt_t pinisr, void *pinarg);
/************************************************************************************
* Name: kl_gpioirqenable
+27 -18
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/kl/kl_gpioirq.c
*
* Copyright (C) 2014 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
@@ -68,7 +68,7 @@
#endif
#if defined(CONFIG_KL_PORTBINTS) || defined(CONFIG_KL_PORTCINTS) || \
defined(CONFIG_KL_PORTEINTS)
defined(CONFIG_KL_PORTEINTS)
# error Kinetis KL25 only supports interrupt on PORTA or PORTD
#endif
@@ -76,6 +76,12 @@
* Private Types
****************************************************************************/
struct g_portisrs_s
{
xcpt_t handler; /* Interrupt handler entry point */
void *arg; /* The argument that accompanies the interrupt handler */
};
/****************************************************************************
* Private Data
****************************************************************************/
@@ -87,11 +93,11 @@
*/
#ifdef CONFIG_KL_PORTAINTS
static xcpt_t g_portaisrs[32];
static struct g_portisrs_s g_portaisrs[32];
#endif
#ifdef CONFIG_KL_PORTDINTS
static xcpt_t g_portdisrs[32];
static struct g_portisrs_s g_portdisrs[32];
#endif
/****************************************************************************
@@ -131,11 +137,14 @@ static int kl_portinterrupt(int irq, FAR void *context,
* interrupt handler for the pin.
*/
if (isrtab[i])
if (isrtab[i].handler != NULL)
{
xcpt_t handler = irstab[i].handler;
void *arg = irstab[i].arg;
/* There is a registered interrupt handler... invoke it */
(void)isrtab[i](irq, context);
(void)handler(irq, context, arg);
}
/* Writing a one to the ISFR register will clear the pending
@@ -219,20 +228,20 @@ void kl_gpioirqinitialize(void)
* Parameters:
* - pinset: Pin configuration
* - pinisr: Pin interrupt service routine
* - pinarg: The argument that will accompany the pin interrupt
*
* 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.
* Returns:
* Zero (OK) is returned on success; On any failure, a negated errno value is
* returned to indicate the nature of the failure.
*
****************************************************************************/
************************************************************************************/
xcpt_t kl_gpioirqattach(uint32_t pinset, xcpt_t pinisr)
int kl_gpioirqattach(uint32_t pinset, xcpt_t pinisr, void *pinarg)
{
#ifdef HAVE_PORTINTS
xcpt_t *isrtab;
xcpt_t oldisr;
irqstate_t flags;
struct g_portisrs_s *isrtab;
irqstate_t flags;
unsigned int port;
unsigned int pin;
@@ -271,16 +280,16 @@ xcpt_t kl_gpioirqattach(uint32_t pinset, xcpt_t pinisr)
/* Get the old PIN ISR and set the new PIN ISR */
oldisr = isrtab[pin];
isrtab[pin] = pinisr;
isrtab[pin].handler = pinisr;
isrtab[pin].arg = pinarg;
/* And return the old PIN isr address */
leave_critical_section(flags);
return oldisr;
return OK;
#else
return NULL;
return -ENOSYS;
#endif /* HAVE_PORTINTS */
}
@@ -102,7 +102,7 @@ VECTOR(stm32_usart3, STM32_IRQ_USART3) /* 39: USART3 global or EXTI Line
VECTOR(stm32_exti1510, STM32_IRQ_EXTI1510) /* 40: EXTI Line[15:10] interrupts */
VECTOR(stm32_rtcalrm, STM32_IRQ_RTCALRM) /* 41: RTC alarm through EXTI line interrupt */
UNUSED(STM32_IRQ_RESERVED42) /* 42: Reserved*/
UNUSED(STM32_IRQ_RESERVED42) /* 42: Reserved */
UNUSED(STM32_IRQ_RESERVED43) /* 43: Reserved */
UNUSED(STM32_IRQ_RESERVED44) /* 44: Reserved */
UNUSED(STM32_IRQ_RESERVED45) /* 45: Reserved */
@@ -113,7 +113,7 @@ UNUSED(STM32_IRQ_RESERVED49) /* 49: Reserved */
UNUSED(STM32_IRQ_RESERVED50) /* 50: Reserved */
UNUSED(STM32_IRQ_RESERVED51) /* 51: Reserved */
UNUSED(STM32_IRQ_RESERVED51) /* 52: Reserved*/
UNUSED(STM32_IRQ_RESERVED51) /* 52: Reserved */
UNUSED(STM32_IRQ_RESERVED52) /* 53: Reserved */
VECTOR(stm32_dac1, STM32_IRQ_DAC1) /* 54: TIM6 global or DAC1 underrun interrupts */
VECTOR(stm32_dac2, STM32_IRQ_DAC2) /* 55: TIM7 global or DAC2 underrun interrupt */
+11 -35
View File
@@ -583,7 +583,8 @@ struct stm32_ethmac_s
uint8_t fduplex : 1; /* Full (vs. half) duplex */
WDOG_ID txpoll; /* TX poll timer */
WDOG_ID txtimeout; /* TX timeout timer */
struct work_s work; /* For deferring work to the work queue */
struct work_s irqwork; /* For deferring interrupt work to the work queue */
struct work_s pollwork; /* For deferring poll work to the work queue */
/* This holds the information visible to the NuttX network */
@@ -1933,27 +1934,6 @@ static void stm32_txdone(FAR struct stm32_ethmac_s *priv)
wd_cancel(priv->txtimeout);
/* Check if the poll timer is running. If it is not, then start it
* now. There is a race condition here: We may test the time
* remaining on the poll timer and determine that it is still running,
* but then the timer expires immiately. That should not be problem,
* however, the poll timer is queued processing should be in the work
* queue and should execute immediately after we complete the TX poll.
* Inefficient, but not fatal.
*/
delay = wd_gettime(priv->txpoll);
if (delay <= 0)
{
/* The poll timer is not running .. restart it. This is necessary
* to avoid certain race conditions where the polling sequence can
* be interrupted.
*/
(void)wd_start(priv->txpoll, STM32_WDDELAY, stm32_poll_expiry,
1, priv);
}
/* And disable further TX interrupts. */
stm32_disableint(priv, ETH_DMAINT_TI);
@@ -2117,13 +2097,9 @@ static int stm32_interrupt(int irq, FAR void *context, FAR void *arg)
wd_cancel(priv->txtimeout);
}
/* Cancel any pending poll work */
work_cancel(ETHWORK, &priv->work);
/* Schedule to perform the interrupt processing on the worker thread. */
work_queue(ETHWORK, &priv->work, stm32_interrupt_work, priv, 0);
work_queue(ETHWORK, &priv->irqwork, stm32_interrupt_work, priv, 0);
}
return OK;
@@ -2196,15 +2172,15 @@ static void stm32_txtimeout_expiry(int argc, uint32_t arg, ...)
up_disable_irq(STM32_IRQ_ETH);
/* Cancel any pending poll or interrupt work. This will have no effect
* on work that has already been started.
/* Cancel any pending interrupt work. This will have no effect on work that
* has already been started.
*/
work_cancel(ETHWORK, &priv->work);
work_cancel(ETHWORK, &priv->irqwork);
/* Schedule to perform the TX timeout processing on the worker thread. */
work_queue(ETHWORK, &priv->work, stm32_txtimeout_work, priv, 0);
work_queue(ETHWORK, &priv->irqwork, stm32_txtimeout_work, priv, 0);
}
/****************************************************************************
@@ -2305,11 +2281,11 @@ static void stm32_poll_expiry(int argc, uint32_t arg, ...)
* pending interrupt actions.
*/
if (work_available(&priv->work))
if (work_available(&priv->pollwork))
{
/* Schedule to perform the interrupt processing on the worker thread. */
work_queue(ETHWORK, &priv->work, stm32_poll_work, priv, 0);
work_queue(ETHWORK, &priv->pollwork, stm32_poll_work, priv, 0);
}
else
{
@@ -2487,11 +2463,11 @@ static int stm32_txavail(struct net_driver_s *dev)
* availability action.
*/
if (work_available(&priv->work))
if (work_available(&priv->pollwork))
{
/* Schedule to serialize the poll on the worker thread. */
work_queue(ETHWORK, &priv->work, stm32_txavail_work, priv, 0);
work_queue(ETHWORK, &priv->pollwork, stm32_txavail_work, priv, 0);
}
return OK;
+12 -14
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,22 +94,21 @@ 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:
* 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.
*
************************************************************************************/
#ifdef CONFIG_RTC_ALARM
xcpt_t stm32_exti_alarm(bool risingedge, bool fallingedge, bool event, xcpt_t func,
void *arg);
int stm32_exti_alarm(bool risingedge, bool fallingedge, bool event, xcpt_t func,
void *arg);
#endif
#undef EXTERN
+6 -10
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/stm32/stm32_exti_alarm.c
*
* Copyright (C) 2009, 2012 Gregory Nutt. All rights reserved.
* Copyright (C) 2009, 2012, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
* Diego Sanchez <dsanchez@nx-engineering.com>
*
@@ -109,20 +109,16 @@ static int stm32_exti_alarm_isr(int irq, void *context, FAR void *arg)
* - 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.
* Zero (OK) on success; a negated errno value on failure indicating the
* nature of the failure.
*
****************************************************************************/
xcpt_t stm32_exti_alarm(bool risingedge, bool fallingedge, bool event,
xcpt_t func, void *arg)
int stm32_exti_alarm(bool risingedge, bool fallingedge, bool event,
xcpt_t func, void *arg)
{
xcpt_t oldhandler;
/* Get the previous GPIO IRQ handler; Save the new IRQ handler. */
oldhandler = g_alarm_callback;
g_alarm_callback = func;
g_callback_arg = arg;
@@ -158,5 +154,5 @@ xcpt_t stm32_exti_alarm(bool risingedge, bool fallingedge, bool event,
/* Return the old IRQ handler */
return oldhandler;
return OK;
}
+8 -13
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;
}
+6 -12
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/stm32/stm32_exti_pwr.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) 2015 Haltian Ltd. All rights reserved.
* Authors: Gregory Nutt <gnutt@nuttx.org>
* Dmitry Nikolaev <dmitry.nikolaev@haltian.com>
@@ -115,20 +115,16 @@ static int stm32_exti_pvd_isr(int irq, void *context, FAR void *arg)
* - 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.
* Zero (OK) returned on success; a negated errno value is returned on
* failure.
*
****************************************************************************/
xcpt_t stm32_exti_pvd(bool risingedge, bool fallingedge, bool event,
xcpt_t func, void *arg)
int stm32_exti_pvd(bool risingedge, bool fallingedge, bool event,
xcpt_t func, void *arg)
{
xcpt_t oldhandler;
/* Get the previous GPIO IRQ handler; Save the new IRQ handler. */
oldhandler = g_pvd_callback;
g_pvd_callback = func;
g_callback_arg = arg;
@@ -162,7 +158,5 @@ xcpt_t stm32_exti_pvd(bool risingedge, bool fallingedge, bool event,
func ? 0 : EXTI_PVD_LINE,
func ? EXTI_PVD_LINE : 0);
/* Return the old IRQ handler */
return oldhandler;
return OK;
}
+4 -5
View File
@@ -60,13 +60,12 @@
* - 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.
* Zero (OK) returned on success; a negated errno value is returned on
* failure.
*
****************************************************************************/
xcpt_t stm32_exti_pvd(bool risingedge, bool fallingedge, bool event,
xcpt_t func, void *arg);
int stm32_exti_pvd(bool risingedge, bool fallingedge, bool event,
xcpt_t func, void *arg);
#endif /* STM32_EXTI_PWR_H_ */
+8 -9
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
+4 -4
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
+2 -2
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/stm32/stm32f40xxx_rtcc.c
*
* Copyright (C) 2012-2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2012-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
* Modified: Neil Hancock
*
@@ -847,7 +847,7 @@ static inline void rtc_enable_alarm(void)
* 3. Configure the RTC to generate RTC alarms (Alarm A or Alarm B).
*/
stm32_exti_alarm(true, false, true, stm32_rtc_alarm_handler, NULL);
(void)stm32_exti_alarm(true, false, true, stm32_rtc_alarm_handler, NULL);
g_alarm_enabled = true;
}
}
+14 -16
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/stm32f7/stm32_exti.h
*
* 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
@@ -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,23 +95,22 @@ 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:
* 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.
*
****************************************************************************/
#ifdef CONFIG_RTC_ALARM
xcpt_t stm32_exti_alarm(bool risingedge, bool fallingedge, bool event,
xcpt_t func, void *arg);
int stm32_exti_alarm(bool risingedge, bool fallingedge, bool event,
xcpt_t func, void *arg);
#endif
#undef EXTERN
+6 -14
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/stm32f7/stm32_exti_alarm.c
*
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* This file derives from similar logic for the STM32 F1:
@@ -57,10 +57,6 @@
#include "stm32_gpio.h"
#include "stm32_exti.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
@@ -121,20 +117,16 @@ static int stm32_exti_alarm_isr(int irq, void *context, FAR void *arg)
* - 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.
* Zero (OK) on success; a negated errno value on failure indicating the
* nature of the failure.
*
****************************************************************************/
xcpt_t stm32_exti_alarm(bool risingedge, bool fallingedge, bool event,
xcpt_t func, void *arg)
int stm32_exti_alarm(bool risingedge, bool fallingedge, bool event,
xcpt_t func, void *arg)
{
xcpt_t oldhandler;
/* Get the previous GPIO IRQ handler; Save the new IRQ handler. */
oldhandler = g_alarm_callback;
g_alarm_callback = func;
g_callback_arg = arg;
@@ -170,5 +162,5 @@ xcpt_t stm32_exti_alarm(bool risingedge, bool fallingedge, bool event,
/* Return the old IRQ handler */
return oldhandler;
return OK;
}
+8 -13
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 */
+5 -11
View File
@@ -123,20 +123,16 @@ static int stm32_exti_pvd_isr(int irq, void *context, void *arg)
* - func: when non-NULL, generate interrupt
*
* 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.
* Zero (OK) returned on success; a negated errno value is returned on
* failure.
*
****************************************************************************/
xcpt_t stm32_exti_pvd(bool risingedge, bool fallingedge, bool event,
xcpt_t func, void *arg)
int stm32_exti_pvd(bool risingedge, bool fallingedge, bool event,
xcpt_t func, void *arg);
{
xcpt_t oldhandler;
/* Get the previous GPIO IRQ handler; Save the new IRQ handler. */
oldhandler = g_pvd_callback;
g_pvd_callback = func;
g_callback_arg = arg;
@@ -170,7 +166,5 @@ xcpt_t stm32_exti_pvd(bool risingedge, bool fallingedge, bool event,
func ? 0 : EXTI_PVD_LINE,
func ? EXTI_PVD_LINE : 0);
/* Return the old IRQ handler */
return oldhandler;
return OK;
}
+4 -5
View File
@@ -61,13 +61,12 @@
* - 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.
* Zero (OK) returned on success; a negated errno value is returned on
* failure.
*
****************************************************************************/
xcpt_t stm32_exti_pvd(bool risingedge, bool fallingedge, bool event,
xcpt_t func, void *arg);
int stm32_exti_pvd(bool risingedge, bool fallingedge, bool event,
xcpt_t func, void *arg);
#endif /* __ARCH_ARM_SRC_STM32F7_STM32_EXTI_PWR_H */
+9 -10
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
+1 -1
View File
@@ -1037,7 +1037,7 @@ int up_rtc_initialize(void)
* 3. Configure the RTC to generate RTC alarms (Alarm A or Alarm B).
*/
stm32_exti_alarm(true, false, true, stm32_rtc_alarm_handler);
(void)stm32_exti_alarm(true, false, true, stm32_rtc_alarm_handler, NULL);
rtc_dumpregs("After InitExtiAlarm");
#else
rtc_dumpregs("After Initialization");
+4 -4
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
+20 -22
View File
@@ -72,22 +72,22 @@ extern "C"
* Description:
* Sets/clears GPIO based event and interrupt triggers.
*
* 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
* Input Parameters:
* pinset - GPIO pin configuration
* 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:
* 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) is returned on success, otherwise a negated errno value is returned
* to indicate the nature of the failure.
*
************************************************************************************/
xcpt_t stm32l4_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
bool event, xcpt_t func, void *arg);
int stm32l4_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
bool event, xcpt_t func, void *arg);
/****************************************************************************
* Name: stm32l4_exti_alarm
@@ -102,15 +102,14 @@ xcpt_t stm32l4_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
* - 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.
* Zero (OK) on success; a negated errno value on failure indicating the
* nature of the failure.
*
****************************************************************************/
#ifdef CONFIG_RTC_ALARM
xcpt_t stm32l4_exti_alarm(bool risingedge, bool fallingedge, bool event,
xcpt_t func, void *arg);
int stm32l4_exti_alarm(bool risingedge, bool fallingedge, bool event,
xcpt_t func, void *arg);
#endif
/****************************************************************************
@@ -127,15 +126,14 @@ xcpt_t stm32l4_exti_alarm(bool risingedge, bool fallingedge, bool event,
* - 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.
* Zero (OK) returned on success; a negated errno value is returned on
* failure.
*
****************************************************************************/
#ifdef CONFIG_STM32L4_COMP
xcpt_t stm32l4_exti_comp(int cmp, bool risingedge, bool fallingedge,
bool event, xcpt_t func, void *arg);
int stm32l4_exti_comp(int cmp, bool risingedge, bool fallingedge,
bool event, xcpt_t func, void *arg);
#endif
#undef EXTERN
+6 -10
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/stm32l4/stm32l4_exti_alarm.c
*
* Copyright (C) 2009, 2012 Gregory Nutt. All rights reserved.
* Copyright (C) 2009, 2012, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
* Diego Sanchez <dsanchez@nx-engineering.com>
* dev@ziggurat29.com (adaptation to stm32l4)
@@ -109,20 +109,16 @@ static int stm32l4_exti_alarm_isr(int irq, void *context, FAR void *arg)
* - func: when non-NULL, generate interrupt
*
* 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.
* Zero (OK) on success; a negated errno value on failure indicating the
* nature of the failure.
*
****************************************************************************/
xcpt_t stm32l4_exti_alarm(bool risingedge, bool fallingedge, bool event,
xcpt_t func, void *arg)
int stm32l4_exti_alarm(bool risingedge, bool fallingedge, bool event,
xcpt_t func, void *arg)
{
xcpt_t oldhandler;
/* Get the previous GPIO IRQ handler; Save the new IRQ handler. */
oldhandler = g_alarm_callback;
g_alarm_callback = func;
g_callback_arg = arg;
@@ -158,5 +154,5 @@ xcpt_t stm32l4_exti_alarm(bool risingedge, bool fallingedge, bool event,
/* Return the old IRQ handler */
return oldhandler;
return OK;
}
+6 -12
View File
@@ -129,16 +129,14 @@ static int stm32l4_exti_comp_isr(int irq, void *context)
* - 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.
* Zero (OK) returned on success; a negated errno value is returned on
* failure.
*
****************************************************************************/
xcpt_t stm32l4_exti_comp(int cmp, bool risingedge, bool fallingedge,
bool event, xcpt_t func, void *arg)
int stm32l4_exti_comp(int cmp, bool risingedge, bool fallingedge,
bool event, xcpt_t func, void *arg)
{
xcpt_t oldhandler;
irqstate_t flags;
uint32_t ln = g_comp_lines[cmp];
@@ -152,7 +150,7 @@ xcpt_t stm32l4_exti_comp(int cmp, bool risingedge, bool fallingedge,
if (func != NULL)
{
irq_attach(STM32L4_IRQ_COMP, stm32l4_exti_comp_isr);
irq_attach(STM32L4_IRQ_COMP, stm32l4_exti_comp_isr, NULL);
up_enable_irq(STM32L4_IRQ_COMP);
}
else
@@ -172,15 +170,11 @@ xcpt_t stm32l4_exti_comp(int cmp, bool risingedge, bool fallingedge,
/* Get the previous IRQ handler and save the new IRQ handler. */
oldhandler = g_comp_handlers[cmp].callback;
g_comp_handlers[cmp].callback = func;
g_comp_handlers[cmp].arg = arg;
/* Leave the critical section */
leave_critical_section(flags);
/* Return the old IRQ handler */
return oldhandler;
return OK;
}
+19 -18
View File
@@ -61,8 +61,8 @@
struct gpio_callback_s
{
xcpt_t callback;
void *arg;
xcpt_t callback; /* Callback entry point */
void *arg; /* The argument that accompanies the callback */
};
/****************************************************************************
@@ -249,23 +249,25 @@ static int stm32l4_exti1510_isr(int irq, void *context, FAR void *arg)
* Description:
* Sets/clears GPIO based event and interrupt triggers.
*
* Parameters:
* - pinset: GPIO pin configuration
* - 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
* Description:
* Sets/clears GPIO based event and interrupt triggers.
*
* 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.
* Input Parameters:
* pinset - GPIO pin configuration
* 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
*
****************************************************************************/
* Returned Value:
* Zero (OK) is returned on success, otherwise a negated errno value is returned
* to indicate the nature of the failure.
*
************************************************************************************/
xcpt_t stm32l4_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
bool event, xcpt_t func, void *arg)
int stm32l4_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;
@@ -323,7 +325,6 @@ xcpt_t stm32l4_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
/* Get the previous GPIO IRQ handler; Save the new IRQ handler. */
oldhandler = g_gpio_handlers[pin].callback;
g_gpio_handlers[pin].callback = func;
g_gpio_handlers[pin].arg = arg;
@@ -385,5 +386,5 @@ xcpt_t stm32l4_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
/* Return the old IRQ handler */
return oldhandler;
return OK;
}
+4 -10
View File
@@ -114,20 +114,16 @@ static int stm32l4_exti_pvd_isr(int irq, void *context, FAR void *arg)
* - func: when non-NULL, generate interrupt
*
* 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.
* Zero (OK) returned on success; a negated errno value is returned on
* failure.
*
****************************************************************************/
xcpt_t stm32l4_exti_pvd(bool risingedge, bool fallingedge, bool event,
int stm32l4_exti_pvd(bool risingedge, bool fallingedge, bool event,
xcpt_t func, void *arg)
{
xcpt_t oldhandler;
/* Get the previous GPIO IRQ handler; Save the new IRQ handler. */
oldhandler = g_pvd_callback;
g_pvd_callback = func;
g_callback_arg = arg;
@@ -161,7 +157,5 @@ xcpt_t stm32l4_exti_pvd(bool risingedge, bool fallingedge, bool event,
func ? 0 : EXTI1_PVD_LINE,
func ? EXTI1_PVD_LINE : 0);
/* Return the old IRQ handler */
return oldhandler;
return OK;
}
+4 -5
View File
@@ -60,13 +60,12 @@
* - 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.
* Zero (OK) returned on success; a negated errno value is returned on
* failure.
*
****************************************************************************/
xcpt_t stm32l4_exti_pvd(bool risingedge, bool fallingedge, bool event,
xcpt_t func, void *arg);
int stm32l4_exti_pvd(bool risingedge, bool fallingedge, bool event,
xcpt_t func, void *arg);
#endif /* STM32L4_EXTI_PWR_H_ */
+12 -12
View File
@@ -326,22 +326,22 @@ bool stm32l4_gpioread(uint32_t pinset);
* Description:
* Sets/clears GPIO based event and interrupt triggers.
*
* 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
* Input Parameters:
* pinset - GPIO pin configuration
* 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:
* 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) is returned on success, otherwise a negated errno value is returned
* to indicate the nature of the failure.
*
************************************************************************************/
xcpt_t stm32l4_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
bool event, xcpt_t func, void *arg);
int stm32l4_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
bool event, xcpt_t func, void *arg);
/************************************************************************************
* Function: stm32l4_dumpgpio
+1 -1
View File
@@ -801,7 +801,7 @@ static inline void rtc_enable_alarm(void)
* 3. Configure the RTC to generate RTC alarms (Alarm A or Alarm B).
*/
stm32l4_exti_alarm(true, false, true, stm32l4_rtc_alarm_handler, NULL);
(void)stm32l4_exti_alarm(true, false, true, stm32l4_rtc_alarm_handler, NULL);
g_alarm_enabled = true;
}
}
+10 -6
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/tiva/tiva_gpio.h
*
* Copyright (C) 2009-2010, 2013-2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2009-2010, 2013-2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* With modifications from Calvin Maguranis <calvin.maguranis@trd2inc.com>
@@ -412,15 +412,19 @@ int weak_function tiva_gpioirqinitialize(void);
* Name: tiva_gpioirqattach
*
* Description:
* Attach a GPIO interrupt to the provided 'isr'
* Attach in GPIO interrupt to the provided 'isr'. If isr==NULL, then the
* irq_unexpected_isr handler is assigned and the pin's interrupt mask is
* disabled to stop further interrupts. Otherwise, the new isr is linked
* and the pin's interrupt mask is set.
*
* Returns:
* oldhandler - the old interrupt handler assigned to this pin.
* Returned Value:
* Zero (OK) is returned on success. Otherwise a negated errno value is
* return to indicate the nature of the failure.
*
****************************************************************************/
xcpt_t tiva_gpioirqattach(uint32_t pinset, xcpt_t isr);
# define tiva_gpioirqdetach(pinset) tiva_gpioirqattach(pinset, NULL)
int tiva_gpioirqattach(uint32_t pinset, xcpt_t isr, void *arg);
# define tiva_gpioirqdetach(p) tiva_gpioirqattach((p),NULL,NULL)
/****************************************************************************
* Name: tiva_gpioportirqattach
+31 -22
View File
@@ -66,17 +66,23 @@
#define TIVA_NIRQ_PINS (TIVA_NPORTS * TIVA_NPINS)
#define TIVA_GPIO_IRQ_IDX(port,pin) ((port*TIVA_NPINS)+(pin))
/****************************************************************************
* Private types
****************************************************************************/
struct gpio_handler_s
{
xcpt_t isr; /* Interrupt service routine entry point */
void *arg; /* The argument that accompanies the interrupt */
};
/****************************************************************************
* Private Data
****************************************************************************/
/* A table of handlers for each GPIO port interrupt */
static FAR xcpt_t g_gpioportirqvector[TIVA_NIRQ_PINS];
/****************************************************************************
* Public Data
****************************************************************************/
static struct gpio_handler_s g_gpioportirqvector[TIVA_NIRQ_PINS];
/****************************************************************************
* Private Functions
@@ -303,12 +309,13 @@ static int tiva_gpioporthandler(uint8_t port, void *context)
{
if (((mis >> pin) & 1) != 0)
{
gpioinfo("port=%d pin=%d irq=%p index=%d\n",
port, pin,
g_gpioportirqvector[TIVA_GPIO_IRQ_IDX(port, pin)],
TIVA_GPIO_IRQ_IDX(port, pin));
int index = TIVA_GPIO_IRQ_IDX(port, pin);
FAR struct gpio_handler_s *handler = &g_gpioportirqvector[index];
g_gpioportirqvector[TIVA_GPIO_IRQ_IDX(port, pin)](irq, context, NULL);
gpioinfo("port=%d pin=%d isr=%p arg=%p index=%d\n",
port, pin, handler->isr, handler->arg, index);
handler->isr(irq, context, handler->arg);
}
}
}
@@ -557,7 +564,8 @@ int tiva_gpioirqinitialize(void)
for (i = 0; i < TIVA_NIRQ_PINS; ++i)
{
g_gpioportirqvector[i] = irq_unexpected_isr;
g_gpioportirqvector[i].isr = irq_unexpected_isr;
g_gpioportirqvector[i].arg = NULL;
}
gpioinfo("tiva_gpioirqinitialize isr=%d/%d irq_unexpected_isr=%p\n",
@@ -665,28 +673,26 @@ int tiva_gpioirqinitialize(void)
* and the pin's interrupt mask is set.
*
* Returns:
* oldhandler - the old interrupt handler assigned to this pin.
* Zero (OK) is returned on success. Otherwise a negated errno value is
* return to indicate the nature of the failure.
*
****************************************************************************/
xcpt_t tiva_gpioirqattach(uint32_t pinset, xcpt_t isr)
int tiva_gpioirqattach(uint32_t pinset, xcpt_t isr, void *arg)
{
FAR stuct gpio_handler_s *handler;
irqstate_t flags;
xcpt_t oldhandler = NULL;
uint8_t port = (pinset & GPIO_PORT_MASK) >> GPIO_PORT_SHIFT;
uint8_t pinno = (pinset & GPIO_PIN_MASK);
uint8_t pin = 1 << pinno;
int index;
/* assign per-pin interrupt handlers */
/* Assign per-pin interrupt handlers */
if (port < TIVA_NPORTS)
{
flags = enter_critical_section();
/* store the older handler to return */
oldhandler = g_gpioportirqvector[TIVA_GPIO_IRQ_IDX(port, pinno)];
/* If the new ISR is NULL, then the ISR is being detached.
* In this case, disable the ISR and direct any interrupts
* to the unexpected interrupt handler.
@@ -695,21 +701,24 @@ xcpt_t tiva_gpioirqattach(uint32_t pinset, xcpt_t isr)
gpioinfo("assign port=%d pin=%d function=%p to idx=%d\n",
port, pinno, isr, TIVA_GPIO_IRQ_IDX(port, pinno));
handler = &g_gpioportirqvector[TIVA_GPIO_IRQ_IDX(port, pinno)];
if (isr == NULL)
{
tiva_gpioirqdisable(port, pin);
g_gpioportirqvector[TIVA_GPIO_IRQ_IDX(port, pinno)] = irq_unexpected_isr;
handler->isr = irq_unexpected_isr;
handler->arg = NULL;
}
else
{
g_gpioportirqvector[TIVA_GPIO_IRQ_IDX(port, pinno)] = isr;
handler->isr = isr;
handler->arg = arg;
tiva_gpioirqenable(port, pin);
}
leave_critical_section(flags);
}
return oldhandler;
return OK;
}
/****************************************************************************
+11 -13
View File
@@ -629,6 +629,7 @@ struct tiva_ethmac_s
struct work_s work; /* For deferring work to the work queue */
#ifdef CONFIG_TIVA_PHY_INTERRUPTS
xcpt_t handler; /* Attached PHY interrupt handler */
void *arg; /* Argument that accompanies the interrupt */
#endif
/* This holds the information visible to the NuttX network */
@@ -2165,9 +2166,9 @@ static int tiva_interrupt(int irq, FAR void *context, FAR void *arg)
/* Dispatch to the registered handler */
if (priv->handler)
if (priv->handler != NULL)
{
(void)priv->handler(irq, context, arg);
(void)priv->handler(irq, context, priv->arg);
}
}
#endif
@@ -4254,23 +4255,22 @@ void up_netinitialize(void)
* asserts an interrupt. Must reside in OS space, but can
* signal tasks in user space. A value of NULL can be passed
* in order to detach and disable the PHY interrupt.
* arg - The argument that will accompany the interrupt
* enable - A function pointer that be unsed to enable or disable the
* PHY interrupt.
*
* Returned Value:
* The previous PHY interrupt handler address is returned. This allows you
* to temporarily replace an interrupt handler, then restore the original
* interrupt handler. NULL is returned if there is was not handler in
* place when the call was made.
* Zero (OK) returned on success; a negated errno value is returned on
* failure.
*
****************************************************************************/
#ifdef CONFIG_TIVA_PHY_INTERRUPTS
xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
int arch_phy_irq(FAR const char *intf, xcpt_t handler, void *arg,
phy_enable_t *enable)
{
struct tiva_ethmac_s *priv;
irqstate_t flags;
xcpt_t oldhandler;
DEBUGASSERT(intf);
ninfo("%s: handler=%p\n", intf, handler);
@@ -4290,10 +4290,10 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
flags = enter_critical_section();
/* Get the old interrupt handler and save the new one */
/* Save the new interrupt handler information */
oldhandler = priv->handler;
priv->handler = handler;
priv->arg = arg;
/* Return with the interrupt disabled in any case */
@@ -4306,10 +4306,8 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
*enable = handler ? tiva_phy_intenable : NULL;
}
/* Return the old handler (so that it can be restored) */
leave_critical_section(flags);
return oldhandler;
return OK;
}
#endif /* CONFIG_TIVA_PHY_INTERRUPTS */
+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;
}
+26 -24
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/mips/src/pic32mx/pic32mx-gpio.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Copyright (C) 2011, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -52,23 +52,21 @@
#ifdef CONFIG_PIC32MX_GPIOIRQ
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
struct g_cnisrs_s
{
xcpt_t handler; /* Interrupt handler entry point */
void *arg; /* The argument that accompanies the interrupt handler */
};
/****************************************************************************
* Private Data
****************************************************************************/
static xcpt_t g_cnisrs[IOPORT_NUMCN];
static struct g_cnisrs_s g_cnisrs[IOPORT_NUMCN];
/****************************************************************************
* Private Functions
@@ -113,11 +111,14 @@ static int pic32mx_cninterrupt(int irq, FAR void *context)
{
/* Is this one attached */
if (g_cnisrs[i])
if (g_cnisrs[i].handler != NULL)
{
xcpt_t handler = irstab[i].handler;
void *arg = irstab[i].arg;
/* Call the attached handler */
status = g_cnisrs[i](irq, context);
status = handler(irq, context, arg);
/* Keep track of the status of the last handler that failed */
@@ -125,6 +126,7 @@ static int pic32mx_cninterrupt(int irq, FAR void *context)
{
ret = status;
}
}
}
/* Clear the pending interrupt */
@@ -189,21 +191,21 @@ void pic32mx_gpioirqinitialize(void)
* In that case, all attached handlers will be called. Each handler must
* maintain state and determine if the unlying GPIO input value changed.
*
* Parameters:
* - pinset: GPIO pin configuration
* - cn: The change notification number associated with the pin.
* - handler: Interrupt handler (may be NULL to detach)
* Input Parameters:
* pinset - GPIO pin configuration
* cn - The change notification number associated with the pin.
* handler - Interrupt handler (may be NULL to detach)
* arg - The argument that accompanies the interrupt
*
* 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) is returned on success. A negated error value is returned on
* any failure to indicate the nature of the failure.
*
****************************************************************************/
xcpt_t pic32mx_gpioattach(uint32_t pinset, unsigned int cn, xcpt_t handler)
int pic32mx_gpioattach(uint32_t pinset, unsigned int cn, xcpt_t handler,
void *arg)
{
xcpt_t oldhandler = NULL;
irqstate_t flags;
DEBUGASSERT(cn < IOPORT_NUMCN);
@@ -215,7 +217,6 @@ xcpt_t pic32mx_gpioattach(uint32_t pinset, unsigned int cn, xcpt_t handler)
/* Get the previously attached handler as the return value */
flags = enter_critical_section();
oldhandler = g_cnisrs[cn];
/* Are we attaching or detaching? */
@@ -250,11 +251,12 @@ xcpt_t pic32mx_gpioattach(uint32_t pinset, unsigned int cn, xcpt_t handler)
/* Set the new handler (perhaps NULLifying the current handler) */
g_cnisrs[cn] = handler;
g_cnisrs[cn].handler = handler;
g_cnisrs[cn].arg = arg;
leave_critical_section(flags);
}
return oldhandler;
return OK;
}
/****************************************************************************
+13 -12
View File
@@ -1,7 +1,7 @@
/************************************************************************************
* arch/mips/src/pic32mx/pic32mx.h
*
* 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
@@ -324,22 +324,23 @@ void pic32mx_gpioirqinitialize(void);
* case, all attached handlers will be called. Each handler must maintain state
* and determine if the underlying GPIO input value changed.
*
* Parameters:
* - pinset: GPIO pin configuration
* - cn: The change notification number associated with the pin
* - handler: Interrupt handler (may be NULL to detach)
* Input Parameters:
* pinset - GPIO pin configuration
* cn - The change notification number associated with the pin.
* handler - Interrupt handler (may be NULL to detach)
* arg - The argument that accompanies the interrupt
*
* 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) is returned on success. A negated error value is returned on
* any failure to indicate the nature of the failure.
*
************************************************************************************/
****************************************************************************/
#ifdef CONFIG_PIC32MX_GPIOIRQ
xcpt_t pic32mx_gpioattach(uint32_t pinset, unsigned int cn, xcpt_t handler);
int pic32mx_gpioattach(uint32_t pinset, unsigned int cn, xcpt_t handler,
void *arg);
#else
# define pic32mx_gpioattach(p,f) (NULL)
# define pic32mx_gpioattach(p,c,h,a) (0)
#endif
/************************************************************************************
+9 -11
View File
@@ -199,22 +199,20 @@ void pic32mz_gpioirqinitialize(void);
* case, all attached handlers will be called. Each handler must maintain state
* and determine if the underlying GPIO input value changed.
*
* Parameters:
* - pinset: GPIO pin configuration
* - cn: The change notification number associated with the pin
* - handler: Interrupt handler (may be NULL to detach)
* pinset - GPIO pin configuration
* handler - Interrupt handler (may be NULL to detach)
* arg - The argument that accompanies the interrupt
*
* 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) is returned on success. A negated error value is returned on
* any failure to indicate the nature of the failure.
*
************************************************************************************/
****************************************************************************/
#ifdef CONFIG_PIC32MZ_GPIOIRQ
xcpt_t pic32mz_gpioattach(pinset_t pinset, xcpt_t handler);
int pic32mz_gpioattach(uint32_t pinset, xcpt_t handler, void *arg);
#else
# define pic32mz_gpioattach(p,f) (NULL)
# define pic32mz_gpioattach(p,h,a) (0)
#endif
/************************************************************************************
+21 -16
View File
@@ -78,9 +78,15 @@ static int pic32mz_cninterrupt(int irq, FAR void *context, FAR void *arg);
* Public Data
****************************************************************************/
struct ioport_handler_s
{
xcpt_t entry; /* Interrupt handler entry point */
void *arg; /* The argument that accompanies the interrupt handler */
};
struct ioport_level2_s
{
xcpt_t handler[16];
struct ioport_handler_s handler[16];
};
/****************************************************************************
@@ -260,12 +266,12 @@ static int pic32mz_cninterrupt(int irq, FAR void *context, FAR void *arg)
{
/* Yes.. Has the user attached a handler? */
handler = handlers->handler[i];
handler = handlers->handler[i].entry;
if (handler)
{
/* Yes.. call the attached handler */
status = handler(irq, context);
status = handler(irq, context, handlers->handler[i].arg);
/* Keep track of the status of the last handler that
* failed.
@@ -365,22 +371,21 @@ void pic32mz_gpioirqinitialize(void)
* In that case, all attached handlers will be called. Each handler must
* maintain state and determine if the underlying GPIO input value changed.
*
* Parameters:
* - pinset: GPIO pin configuration
* - pin: The change notification number associated with the pin.
* - handler: Interrupt handler (may be NULL to detach)
* Input Parameters:
* pinset - GPIO pin configuration
* handler - Interrupt handler (may be NULL to detach)
* arg - The argument that accompanies the interrupt
*
* 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) is returned on success. A negated error value is returned on
* any failure to indicate the nature of the failure.
*
****************************************************************************/
xcpt_t pic32mz_gpioattach(pinset_t pinset, xcpt_t handler)
#ifdef CONFIG_PIC32MZ_GPIOIRQ
int pic32mz_gpioattach(uint32_t pinset, xcpt_t handler, void *arg)
{
struct ioport_level2_s *handlers;
xcpt_t oldhandler = NULL;
irqstate_t flags;
uintptr_t base;
int ioport;
@@ -415,7 +420,6 @@ xcpt_t pic32mz_gpioattach(pinset_t pinset, xcpt_t handler)
/* Get the previously attached handler as the return value */
flags = enter_critical_section();
oldhandler = handlers->handler[pin];
/* Are we attaching or detaching? */
@@ -467,12 +471,13 @@ xcpt_t pic32mz_gpioattach(pinset_t pinset, xcpt_t handler)
/* Set the new handler (perhaps NULLifying the current handler) */
handlers->handler[pin] = handler;
handlers->handler[pin].entry = handler;
handlers->handler[pin].arg = arg;
leave_critical_section(flags);
}
}
return oldhandler;
return OK;
}
/****************************************************************************
+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
-55
View File
@@ -192,60 +192,5 @@
void tiva_boardinitialize(void);
/************************************************************************************
* Name: up_buttoninit
*
* Description:
* up_buttoninit() must be called to initialize button resources. After that,
* up_buttons() may be called to collect the current state of all buttons or
* up_irqbutton() may be called to register button interrupt handlers.
*
************************************************************************************/
#ifdef CONFIG_ARCH_BUTTONS
void up_buttoninit(void);
/************************************************************************************
* Name: up_buttons
*
* Description:
* up_buttoninit() must be called to initialize button resources. After that,
* up_buttons() may be called to collect the current state of all buttons.
*
* After up_buttoninit() has been called, up_buttons() may be called to collect
* the state of all buttons. up_buttons() returns an 8-bit bit set with each bit
* associated with a button. See the BOARD_BUTTON_*_BIT and BOARD_JOYSTICK_*_BIT
* definitions above for the meaning of each bit.
*
************************************************************************************/
uint8_t up_buttons(void);
/************************************************************************************
* Button support.
*
* Description:
* up_buttoninit() must be called to initialize button resources. After that,
* up_irqbutton() may be called to register button interrupt handlers.
*
* up_irqbutton() 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 BOARD_BUTTON_* and
* BOARD_JOYSTICK_* definitions in above for the meaning of enumeration values
* The previous interrupt handler address is returned (so that it may restored, if
* so desired).
*
* Note that up_irqbutton() also enables button interrupts. Button interrupts
* will remain enabled after the interrupt handler is attached. Interrupts may
* be disabled (and detached) by calling up_irqbutton with irqhandler equal to
* NULL.
*
************************************************************************************/
#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_TIVA_GPIO_IRQS)
xcpt_t up_irqbutton(int id, xcpt_t irqhandler);
#endif
#endif /* CONFIG_ARCH_BUTTONS */
#endif /* __ASSEMBLY__ */
#endif /* __CONFIGS_CC3200_LAUNCHPAD_INCLUDE_BOARD_H */
+9 -10
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>
*
@@ -41,6 +41,7 @@
#include <nuttx/config.h>
#include <stdint.h>
#include <errno.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
@@ -151,27 +152,25 @@ 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;
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);
}
return oldhandler;
return ret;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */
+6 -4
View File
@@ -1,7 +1,7 @@
/************************************************************************************
* configs/cloudctrl/src/stm32_usb.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>
* Darcy Gong <darcy.gong@gmail.com>
*
@@ -274,16 +274,18 @@ void stm32_usbhost_vbusdrive(int iface, bool enable)
*
* Input Parameter:
* handler - New overcurrent interrupt handler
* arg - The argument provided for the interrupt handler
*
* Returned value:
* Old overcurrent interrupt handler
* Zero (OK) is returned on success. Otherwise, a negated errno value is returned
* to indicate the nature of the failure.
*
************************************************************************************/
#ifdef CONFIG_USBHOST
xcpt_t stm32_setup_overcurrent(xcpt_t handler)
int stm32_setup_overcurrent(xcpt_t handler, void *arg)
{
return NULL;
return -ENOSYS;
}
#endif
+6 -7
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 */
@@ -175,7 +174,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
if (irqhandler)
{
ret = irq_attach(IRQ_SW4, irqhandler, NULL);
ret = irq_attach(IRQ_SW4, irqhandler, arg);
if (ret == OK)
{
handler = irqhandler;
@@ -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 */
+5 -18
View File
@@ -1,7 +1,7 @@
/************************************************************************************
* configs/ea3131/src/lpc31_usbhost.c
*
* Copyright (C) 2013, 2015-2016 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
@@ -82,12 +82,6 @@
static struct usbhost_connection_s *g_ehciconn;
/* Overcurrent interrupt handler */
#if 0 /* Not yet implemented */
static xcpt_t g_ochandler;
#endif
/************************************************************************************
* Private Functions
************************************************************************************/
@@ -292,16 +286,16 @@ void lpc31_usbhost_vbusdrive(int rhport, bool enable)
*
* Input parameter:
* handler - New overcurrent interrupt handler
* arg - The argument that will accompany the interrupt
*
* Returned value:
* Old overcurrent interrupt handler
* Zero (OK) returned on success; a negated errno value is returned on failure.
*
************************************************************************************/
#if 0 /* Not ready yet */
xcpt_t lpc31_setup_overcurrent(xcpt_t handler)
int lpc31_setup_overcurrent(xcpt_t handler, void *arg)
{
xcpt_t oldhandler;
irqstate_t flags;
/* Disable interrupts until we are done. This guarantees that the
@@ -310,18 +304,11 @@ xcpt_t lpc31_setup_overcurrent(xcpt_t handler)
flags = enter_critical_section();
/* Get the old button interrupt handler and save the new one */
oldhandler = g_ochandler;
g_ochandler = handler;
/* Configure the interrupt */
#warning Missing logic
/* Return the old button handler (so that it can be restored) */
leave_critical_section(flags);
return oldhandler;
return OK;
}
#endif /* 0 */
+6 -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
@@ -40,6 +40,7 @@
#include <nuttx/config.h>
#include <stdint.h>
#include <errno.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
@@ -128,15 +129,15 @@ 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)
{
uint16_t gpio;
int ret;
if (id == BUTTON_KEY1)
{
@@ -148,7 +149,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
}
else
{
return NULL;
return -EINVAL;
}
return stm32_gpiosetevent(gpio, true, true, true, irqhandler, arg);
+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 */
+1 -1
View File
@@ -169,7 +169,7 @@ int k64_sdhc_initialize(void)
/* Attached the card detect interrupt (but don't enable it yet) */
kinetis_pinirqattach(GPIO_SD_CARDDETECT, k64_cdinterrupt, NULL);
(void)kinetis_pinirqattach(GPIO_SD_CARDDETECT, k64_cdinterrupt, NULL);
/* Configure the write protect GPIO -- None */
+11 -9
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,15 +132,13 @@ 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;
/* Map the button id to the GPIO bit set. */
@@ -154,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
@@ -163,12 +162,15 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
* Attach the new button handler.
*/
oldhandler = 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 oldhandler;
return NULL;
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

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