mirror of
https://github.com/apache/nuttx.git
synced 2026-08-07 13:37:18 +00:00
Merged nuttx/nuttx/master into master
This commit is contained in:
commit
90672504df
160 changed files with 1250 additions and 2078 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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_ */
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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_ */
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
/************************************************************************************
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
/************************************************************************************
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ int k66_sdhc_initialize(void)
|
|||
|
||||
/* Attached the card detect interrupt (but don't enable it yet) */
|
||||
|
||||
kinetis_pinirqattach(GPIO_SD_CARDDETECT, k66_cdinterrupt, NULL);
|
||||
(void)kinetis_pinirqattach(GPIO_SD_CARDDETECT, k66_cdinterrupt, NULL);
|
||||
|
||||
/* Configure the write protect GPIO -- None */
|
||||
|
||||
|
|
|
|||
|
|
@ -211,14 +211,14 @@ static void adxl345_enable(FAR struct adxl345_config_s *state, bool enable)
|
|||
/* Configure the interrupt using the SAVED handler */
|
||||
|
||||
kl_configgpio(GPIO_ADXL345_INT1);
|
||||
(void)kl_gpioirqattach(GPIO_ADXL345_INT1, adxl345_interrupt);
|
||||
(void)kl_gpioirqattach(GPIO_ADXL345_INT1, adxl345_interrupt, NULL);
|
||||
kl_gpioirqenable(GPIO_ADXL345_INT1);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Configure the interrupt with a NULL handler to disable it */
|
||||
|
||||
(void)kl_gpioirqattach(GPIO_ADXL345_INT1, NULL);
|
||||
(void)kl_gpioirqattach(GPIO_ADXL345_INT1, NULL, NULL);
|
||||
kl_gpioirqdisable(GPIO_ADXL345_INT1);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -211,12 +211,12 @@ static void wl_enable_irq(FAR struct cc3000_config_s *state, bool enable)
|
|||
iinfo("enable:%d\n", enable);
|
||||
if (enable)
|
||||
{
|
||||
(void)kl_gpioirqattach(GPIO_WIFI_INT, priv->handler);
|
||||
(void)kl_gpioirqattach(GPIO_WIFI_INT, priv->handler, priv->arg);
|
||||
kl_gpioirqenable(GPIO_WIFI_INT);
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)kl_gpioirqattach(GPIO_WIFI_INT, NULL);
|
||||
(void)kl_gpioirqattach(GPIO_WIFI_INT, NULL, NULL);
|
||||
kl_gpioirqdisable(GPIO_WIFI_INT);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* config/hymini-stm32v/src/stm32_appinit.c
|
||||
*
|
||||
* Copyright (C) 2009, 2011, 2016 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2009, 2011, 2016-2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -182,7 +182,7 @@ int board_app_initialize(uintptr_t arg)
|
|||
|
||||
/* Register an interrupt handler for the card detect pin */
|
||||
|
||||
stm32_gpiosetevent(GPIO_SD_CD, true, true, true, nsh_cdinterrupt, NULL);
|
||||
(void)stm32_gpiosetevent(GPIO_SD_CD, true, true, true, nsh_cdinterrupt, NULL);
|
||||
|
||||
/* Mount the SDIO-based MMC/SD block driver */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* configs/hymini-stm32v/src/stm32_buttons.c
|
||||
*
|
||||
* Copyright (C) 2009, 2011, 2014-2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2009, 2011, 2014-2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -40,6 +40,7 @@
|
|||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/board.h>
|
||||
|
|
@ -69,39 +70,44 @@
|
|||
****************************************************************************/
|
||||
|
||||
void board_button_initialize(void)
|
||||
{
|
||||
stm32_configgpio(GPIO_BTN_KEYA);
|
||||
stm32_configgpio(GPIO_BTN_KEYB);
|
||||
}
|
||||
{
|
||||
stm32_configgpio(GPIO_BTN_KEYA);
|
||||
stm32_configgpio(GPIO_BTN_KEYB);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_buttons
|
||||
****************************************************************************/
|
||||
|
||||
uint8_t board_buttons(void)
|
||||
{
|
||||
uint8_t ret = 0;
|
||||
bool pinValue;
|
||||
{
|
||||
uint8_t ret = 0;
|
||||
bool pinValue;
|
||||
|
||||
/* Check that state of each key */
|
||||
/* Check that state of each key */
|
||||
|
||||
/* Pin is pulled up */
|
||||
pinValue = stm32_gpioread(GPIO_BTN_KEYA);
|
||||
if (!pinValue)
|
||||
{
|
||||
// Button pressed
|
||||
ret = 1 << BUTTON_KEYA;
|
||||
}
|
||||
/* Pin is pulled up */
|
||||
|
||||
/* Pin is pulled down */
|
||||
pinValue = stm32_gpioread(GPIO_BTN_KEYB);
|
||||
if (pinValue)
|
||||
{
|
||||
// Button pressed
|
||||
ret |= 1 << BUTTON_KEYB;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
pinValue = stm32_gpioread(GPIO_BTN_KEYA);
|
||||
if (!pinValue)
|
||||
{
|
||||
/* Button pressed */
|
||||
|
||||
ret = 1 << BUTTON_KEYA;
|
||||
}
|
||||
|
||||
/* Pin is pulled down */
|
||||
|
||||
pinValue = stm32_gpioread(GPIO_BTN_KEYB);
|
||||
if (pinValue)
|
||||
{
|
||||
/* Button pressed */
|
||||
|
||||
ret |= 1 << BUTTON_KEYB;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Button support.
|
||||
|
|
@ -122,28 +128,27 @@ uint8_t board_buttons(void)
|
|||
* be called when a button is depressed or released. The ID value is a
|
||||
* button enumeration value that uniquely identifies a button resource. See
|
||||
* the BUTTON_* definitions in board.h for the meaning of enumeration
|
||||
* value. The previous interrupt handler address is returned (so that it
|
||||
* may be restored, if so desired).
|
||||
* value.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
{
|
||||
xcpt_t oldhandler = NULL;
|
||||
uint32_t pinset = GPIO_BTN_KEYA;
|
||||
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
{
|
||||
uint32_t pinset = GPIO_BTN_KEYA;
|
||||
int ret = -EINVAL;
|
||||
|
||||
if (id == 1)
|
||||
{
|
||||
pinset = GPIO_BTN_KEYB;
|
||||
}
|
||||
if (id < 2)
|
||||
{
|
||||
oldhandler = stm32_gpiosetevent(pinset, true, true, true,
|
||||
irqhandler, arg);
|
||||
}
|
||||
if (id == 1)
|
||||
{
|
||||
pinset = GPIO_BTN_KEYB;
|
||||
}
|
||||
|
||||
return oldhandler;
|
||||
}
|
||||
if (id < 2)
|
||||
{
|
||||
ret = stm32_gpiosetevent(pinset, true, true, true, irqhandler, arg);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
#endif /* CONFIG_ARCH_BUTTONS */
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/************************************************************************************
|
||||
* configs/hymini-stm32v/src/stm32_ts.c
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2011, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Laurent Latil <laurent@latil.nom.fr>
|
||||
*
|
||||
|
|
@ -93,25 +93,29 @@ static xcpt_t tc_isr;
|
|||
************************************************************************************/
|
||||
|
||||
/* Attach the ADS7843E interrupt handler to the GPIO interrupt */
|
||||
|
||||
static int hymini_ts_irq_attach(FAR struct ads7843e_config_s *state, xcpt_t isr)
|
||||
{
|
||||
iinfo("hymini_ts_irq_attach\n");
|
||||
|
||||
tc_isr = isr;
|
||||
stm32_gpiosetevent(GPIO_TS_IRQ, true, true, true, isr, NULL);
|
||||
(void)stm32_gpiosetevent(GPIO_TS_IRQ, true, true, true, isr, NULL);
|
||||
return OK;
|
||||
}
|
||||
|
||||
/* Enable or disable the GPIO interrupt */
|
||||
|
||||
static void hymini_ts_irq_enable(FAR struct ads7843e_config_s *state,
|
||||
bool enable)
|
||||
bool enable)
|
||||
{
|
||||
iinfo("%d\n", enable);
|
||||
|
||||
stm32_gpiosetevent(GPIO_TS_IRQ, true, true, true, enable ? tc_isr : NULL, NULL);
|
||||
(void)stm32_gpiosetevent(GPIO_TS_IRQ, true, true, true,
|
||||
enable ? tc_isr : NULL, NULL);
|
||||
}
|
||||
|
||||
/* Acknowledge/clear any pending GPIO interrupt */
|
||||
|
||||
static void hymini_ts_irq_clear(FAR struct ads7843e_config_s *state)
|
||||
{
|
||||
// FIXME Nothing to do ?
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@ int board_app_initialize(uintptr_t arg)
|
|||
/* Attached the card detect interrupt (but don't enable it yet) */
|
||||
|
||||
kinetis_pinconfig(GPIO_SD_CARDDETECT);
|
||||
kinetis_pinirqattach(GPIO_SD_CARDDETECT, kinetis_cdinterrupt, NULL);
|
||||
(void)kinetis_pinirqattach(GPIO_SD_CARDDETECT, kinetis_cdinterrupt, NULL);
|
||||
|
||||
/* Mount the SDHC-based MMC/SD block driver */
|
||||
/* First, get an instance of the SDHC interface */
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* configs/kwikstik-k40/src/k40_buttons.c
|
||||
*
|
||||
* Copyright (C) 2011, 2014-2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2011, 2014-2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -40,6 +40,7 @@
|
|||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/board.h>
|
||||
|
|
@ -49,18 +50,6 @@
|
|||
|
||||
#ifdef CONFIG_ARCH_BUTTONS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
|
@ -111,17 +100,16 @@ uint8_t board_buttons(void)
|
|||
* be called when a button is depressed or released. The ID value is a
|
||||
* button enumeration value that uniquely identifies a button resource.
|
||||
* See the BUTTON_* and JOYSTICK_* definitions in board.h for the meaning
|
||||
* of enumeration value. The previous interrupt handler address is
|
||||
* returned (so that it may be restored, if so desired).
|
||||
* of enumeration value.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
{
|
||||
/* The KwikStik-K40 board has no standard GPIO contact buttons */
|
||||
|
||||
return NULL;
|
||||
return -EINVAL;
|
||||
}
|
||||
#endif
|
||||
#endif /* CONFIG_ARCH_BUTTONS */
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* configs/sam4e-ek/src/tms570_buttons.c
|
||||
*
|
||||
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -40,6 +40,7 @@
|
|||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/board.h>
|
||||
|
|
@ -84,10 +85,9 @@ static xcpt_t g_irq_button;
|
|||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_IRQBUTTONS
|
||||
static xcpt_t board_button_irqx(gio_pinset_t pinset, int irq,
|
||||
xcpt_t irqhandler, xcpt_t *store, void *arg)
|
||||
static int board_button_irqx(gio_pinset_t pinset, int irq,
|
||||
xcpt_t irqhandler, xcpt_t *store, void *arg)
|
||||
{
|
||||
xcpt_t oldhandler;
|
||||
irqstate_t flags;
|
||||
|
||||
/* Disable interrupts until we are done. This guarantees that the following
|
||||
|
|
@ -98,7 +98,6 @@ static xcpt_t board_button_irqx(gio_pinset_t pinset, int irq,
|
|||
|
||||
/* Get the old button interrupt handler and save the new one */
|
||||
|
||||
oldhandler = *store;
|
||||
*store = irqhandler;
|
||||
|
||||
/* Are we attaching or detaching? */
|
||||
|
|
@ -123,7 +122,7 @@ static xcpt_t board_button_irqx(gio_pinset_t pinset, int irq,
|
|||
|
||||
/* Return the old button handler (so that it can be restored) */
|
||||
|
||||
return oldhandler;
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -171,8 +170,7 @@ uint8_t board_buttons(void)
|
|||
* Description:
|
||||
* This function may be called to register an interrupt handler that will
|
||||
* be called when a button is depressed or released. The ID value is one
|
||||
* of the BUTTON* definitions provided above. The previous interrupt
|
||||
* handler address is returned (so that it may restored, if so desired).
|
||||
* of the BUTTON* definitions provided above.
|
||||
*
|
||||
* Configuration Notes:
|
||||
* Configuration CONFIG_AVR32_GIOIRQ must be selected to enable the
|
||||
|
|
@ -183,7 +181,7 @@ uint8_t board_buttons(void)
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
{
|
||||
#ifdef HAVE_IRQBUTTONS
|
||||
if (id == BUTTON_GIOA7)
|
||||
|
|
@ -193,8 +191,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||
}
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_ARCH_BUTTONS */
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* configs/lincoln60/src/lpc17_buttons.c
|
||||
*
|
||||
* Copyright (C) 2012-2013, 2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2012-2013, 2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -69,13 +69,7 @@ static const uint16_t g_buttoncfg[BOARD_NUM_BUTTONS] =
|
|||
LINCOLN60_BUT1
|
||||
};
|
||||
|
||||
/* This array defines all of the interrupt handlers current attached to
|
||||
* button events.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_LPC17_GPIOIRQ)
|
||||
static xcpt_t g_buttonisr[BOARD_NUM_BUTTONS];
|
||||
|
||||
/* This array provides the mapping from button ID numbers to button IRQ
|
||||
* numbers.
|
||||
*/
|
||||
|
|
@ -168,8 +162,7 @@ uint8_t board_buttons(void)
|
|||
* be called when a button is depressed or released. The ID value is a
|
||||
* button enumeration value that uniquely identifies a button resource. See the
|
||||
* BOARD_BUTTON_* and BOARD_JOYSTICK_* definitions in board.h for the meaning
|
||||
* of enumeration values. The previous interrupt handler address is returned
|
||||
* (so that it may restored, if so desired).
|
||||
* of enumeration values.
|
||||
*
|
||||
* Note that board_button_irq() also enables button interrupts. Button
|
||||
* interrupts will remain enabled after the interrupt handler is attached.
|
||||
|
|
@ -179,9 +172,8 @@ uint8_t board_buttons(void)
|
|||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_LPC17_GPIOIRQ)
|
||||
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
{
|
||||
xcpt_t oldhandler = NULL;
|
||||
irqstate_t flags;
|
||||
int irq;
|
||||
|
||||
|
|
@ -189,11 +181,6 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||
|
||||
if ((unsigned)id < BOARD_NUM_BUTTONS)
|
||||
{
|
||||
/* Return the current button handler and set the new interrupt handler */
|
||||
|
||||
oldhandler = g_buttonisr[id];
|
||||
g_buttonisr[id] = irqhandler;
|
||||
|
||||
/* Disable interrupts until we are done */
|
||||
|
||||
flags = enter_critical_section();
|
||||
|
|
@ -207,7 +194,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||
{
|
||||
/* Attach then enable the new interrupt handler */
|
||||
|
||||
(void)irq_attach(irq, irqhandler, NULL);
|
||||
(void)irq_attach(irq, irqhandler, arg);
|
||||
up_enable_irq(irq);
|
||||
}
|
||||
else
|
||||
|
|
@ -217,9 +204,11 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||
up_disable_irq(irq);
|
||||
(void)irq_detach(irq);
|
||||
}
|
||||
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
return oldhandler;
|
||||
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* configs/lpc4330-xplorer/src/lpc43_buttons.c
|
||||
*
|
||||
* Copyright (C) 2012, 2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2012, 2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -68,13 +68,7 @@ static const uint16_t g_buttoncfg[BOARD_NUM_BUTTONS] =
|
|||
LPC4330_XPLORER_BUT1
|
||||
};
|
||||
|
||||
/* This array defines all of the interrupt handlers current attached to
|
||||
* button events.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_LPC43_GPIO_IRQ)
|
||||
static xcpt_t g_buttonisr[BOARD_NUM_BUTTONS];
|
||||
|
||||
/* This array provides the mapping from button ID numbers to button IRQ
|
||||
* numbers.
|
||||
*/
|
||||
|
|
@ -167,8 +161,7 @@ uint8_t board_buttons(void)
|
|||
* be called when a button is depressed or released. The ID value is a
|
||||
* button enumeration value that uniquely identifies a button resource. See the
|
||||
* BOARD_BUTTON_* and BOARD_JOYSTICK_* definitions in board.h for the meaning
|
||||
* of enumeration values. The previous interrupt handler address is returned
|
||||
* (so that it may restored, if so desired).
|
||||
* of enumeration values.
|
||||
*
|
||||
* Note that board_button_irq() also enables button interrupts. Button
|
||||
* interrupts will remain enabled after the interrupt handler is attached.
|
||||
|
|
@ -178,9 +171,8 @@ uint8_t board_buttons(void)
|
|||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_LPC43_GPIO_IRQ)
|
||||
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
{
|
||||
xcpt_t oldhandler = NULL;
|
||||
irqstate_t flags;
|
||||
int irq;
|
||||
|
||||
|
|
@ -188,11 +180,6 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||
|
||||
if ((unsigned)id < BOARD_NUM_BUTTONS)
|
||||
{
|
||||
/* Return the current button handler and set the new interrupt handler */
|
||||
|
||||
oldhandler = g_buttonisr[id];
|
||||
g_buttonisr[id] = irqhandler;
|
||||
|
||||
/* Disable interrupts until we are done */
|
||||
|
||||
flags = enter_critical_section();
|
||||
|
|
@ -206,7 +193,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||
{
|
||||
/* Attach then enable the new interrupt handler */
|
||||
|
||||
(void)irq_attach(irq, irqhandler, NULL);
|
||||
(void)irq_attach(irq, irqhandler, arg);
|
||||
up_enable_irq(irq);
|
||||
}
|
||||
else
|
||||
|
|
@ -216,9 +203,11 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||
up_disable_irq(irq);
|
||||
(void)irq_detach(irq);
|
||||
}
|
||||
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
return oldhandler;
|
||||
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* configs/lpc4357-evb/src/board_buttons.c
|
||||
*
|
||||
* Copyright (C) 2014-2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2014-2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -41,6 +41,7 @@
|
|||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/board.h>
|
||||
|
|
@ -68,13 +69,7 @@ static const uint16_t g_buttoncfg[BOARD_NUM_BUTTONS] =
|
|||
{
|
||||
};
|
||||
|
||||
/* This array defines all of the interrupt handlers current attached to
|
||||
* button events.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_LPC43_GPIO_IRQ)
|
||||
static xcpt_t g_buttonisr[BOARD_NUM_BUTTONS];
|
||||
|
||||
/* This array provides the mapping from button ID numbers to button IRQ
|
||||
* numbers.
|
||||
*/
|
||||
|
|
@ -173,8 +168,7 @@ uint8_t board_buttons(void)
|
|||
* be called when a button is depressed or released. The ID value is a
|
||||
* button enumeration value that uniquely identifies a button resource. See the
|
||||
* BOARD_BUTTON_* and BOARD_JOYSTICK_* definitions in board.h for the meaning
|
||||
* of enumeration values. The previous interrupt handler address is returned
|
||||
* (so that it may restored, if so desired).
|
||||
* of enumeration values.
|
||||
*
|
||||
* Note that board_button_irq() also enables button interrupts. Button
|
||||
* interrupts will remain enabled after the interrupt handler is attached.
|
||||
|
|
@ -184,22 +178,17 @@ 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)
|
||||
{
|
||||
#if 0 /* Not yet implemented */
|
||||
xcpt_t oldhandler = NULL;
|
||||
irqstate_t flags;
|
||||
int ret = -EINVAL;
|
||||
int irq;
|
||||
|
||||
/* Verify that the button ID is within range */
|
||||
|
||||
if ((unsigned)id < BOARD_NUM_BUTTONS)
|
||||
{
|
||||
/* Return the current button handler and set the new interrupt handler */
|
||||
|
||||
oldhandler = g_buttonisr[id];
|
||||
g_buttonisr[id] = irqhandler;
|
||||
|
||||
/* Disable interrupts until we are done */
|
||||
|
||||
flags = enter_critical_section();
|
||||
|
|
@ -213,7 +202,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||
{
|
||||
/* Attach then enable the new interrupt handler */
|
||||
|
||||
(void)irq_attach(irq, irqhandler, NULL);
|
||||
(void)irq_attach(irq, irqhandler, arg);
|
||||
up_enable_irq(irq);
|
||||
}
|
||||
else
|
||||
|
|
@ -223,12 +212,14 @@ 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);
|
||||
ret = OK;
|
||||
}
|
||||
|
||||
return oldhandler;
|
||||
return ret;
|
||||
#else
|
||||
return NULL;
|
||||
return -ENOSYS;
|
||||
#endif /* Not yet implemented */
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/************************************************************************************
|
||||
* configs/mikroe_stm32f4/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>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -273,16 +273,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 stm32_gpiosetevent(GPIO_OTGFS_OVER, true, true, true, handler, NULL);
|
||||
return stm32_gpiosetevent(GPIO_OTGFS_OVER, true, true, true, handler, arg);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* configs/nucleo-144/src/stm32_buttons.c
|
||||
*
|
||||
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2016-2017 Gregory Nutt. All rights reserved.
|
||||
* Authors: Gregory Nutt <gnutt@nuttx.org>
|
||||
* David Sidrane <david_s5@nscdg.com>
|
||||
*
|
||||
|
|
@ -41,6 +41,7 @@
|
|||
#include <nuttx/config.h>
|
||||
|
||||
#include <stddef.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/board.h>
|
||||
|
|
@ -99,23 +100,21 @@ uint8_t board_buttons(void)
|
|||
* be called when a button is depressed or released. The ID value is a
|
||||
* button enumeration value that uniquely identifies a button resource. See the
|
||||
* BUTTON_* definitions in board.h for the meaning of enumeration
|
||||
* value. The previous interrupt handler address is returned (so that it may
|
||||
* restored, if so desired).
|
||||
* value.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
{
|
||||
xcpt_t oldhandler = NULL;
|
||||
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);
|
||||
}
|
||||
|
||||
return oldhandler;
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
#endif /* CONFIG_ARCH_BUTTONS */
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* config/nucleo-144/src/stm32_sdio.c
|
||||
*
|
||||
* Copyright (C) 2014, 2016 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2014, 2016-2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -132,8 +132,8 @@ int stm32_sdio_initialize(void)
|
|||
|
||||
/* Register an interrupt handler for the card detect pin */
|
||||
|
||||
stm32_gpiosetevent(GPIO_SDMMC1_NCD, true, true, true,
|
||||
stm32_ncd_interrupt, NULL);
|
||||
(void)stm32_gpiosetevent(GPIO_SDMMC1_NCD, true, true, true,
|
||||
stm32_ncd_interrupt, NULL);
|
||||
#endif
|
||||
|
||||
/* Mount the SDIO-based MMC/SD block driver */
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/************************************************************************************
|
||||
* configs//nucleo-144/src/stm32_usb.c
|
||||
*
|
||||
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2016-2017 Gregory Nutt. All rights reserved.
|
||||
* Authors: Gregory Nutt <gnutt@nuttx.org>
|
||||
* David Sidrane <david_s5@nscdg.com>
|
||||
*
|
||||
|
|
@ -295,16 +295,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 stm32_gpiosetevent(GPIO_OTGFS_OVER, true, true, true, handler, NULL);
|
||||
return stm32_gpiosetevent(GPIO_OTGFS_OVER, true, true, true, handler, arg);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* configs/nucleo-f303re/src/stm32_buttons.c
|
||||
*
|
||||
* Copyright (C) 2014-2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2014-2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2015 Omni Hoverboards Inc. All rights reserved.
|
||||
* Authors: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Paul Alexander Patience <paul-a.patience@polymtl.ca>
|
||||
|
|
@ -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
|
||||
****************************************************************************/
|
||||
|
|
@ -120,23 +105,22 @@ uint8_t board_buttons(void)
|
|||
* will be called when a button is depressed or released. The ID value is
|
||||
* a button enumeration value that uniquely identifies a button resource.
|
||||
* See the BUTTON_* definitions in board.h for the meaning of the
|
||||
* enumeration value. The previous interrupt handler address is returned
|
||||
* (so that it may be restored, if so desired).
|
||||
* enumeration value.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
{
|
||||
xcpt_t oldhandler = NULL;
|
||||
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);
|
||||
}
|
||||
|
||||
return oldhandler;
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* configs/nucleo-f4x1re/src/stm32_buttons.c
|
||||
*
|
||||
* Copyright (C) 2014-2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2014-2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -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
|
||||
****************************************************************************/
|
||||
|
|
@ -117,23 +106,21 @@ uint8_t board_buttons(void)
|
|||
* be called when a button is depressed or released. The ID value is a
|
||||
* button enumeration value that uniquely identifies a button resource. See the
|
||||
* BUTTON_* definitions in board.h for the meaning of enumeration
|
||||
* value. The previous interrupt handler address is returned (so that it may
|
||||
* restored, if so desired).
|
||||
* value.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
{
|
||||
xcpt_t oldhandler = NULL;
|
||||
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);
|
||||
}
|
||||
|
||||
return oldhandler;
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
#endif /* CONFIG_ARCH_BUTTONS */
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* configs/nucleo-f4x1re/src/stm32_io.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
|
||||
|
|
@ -40,6 +40,7 @@
|
|||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
#include "chip/stm32_tim.h"
|
||||
|
|
@ -48,18 +49,6 @@
|
|||
|
||||
#ifndef CONFIG_CC3000_PROBES
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
|
@ -176,23 +165,21 @@ void up_write_outputs(int id, bool bits)
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
xcpt_t up_irqio(int id, xcpt_t irqhandler)
|
||||
int up_irqio(int id, xcpt_t irqhandler, void *arg)
|
||||
{
|
||||
xcpt_t oldhandler = NULL;
|
||||
int ret = -EINVAL;
|
||||
|
||||
/* The following should be atomic */
|
||||
|
||||
if (id == 0)
|
||||
{
|
||||
oldhandler = stm32_gpiosetevent(GPIO_D14, true, true, true,
|
||||
irqhandler, arg);
|
||||
ret = stm32_gpiosetevent(GPIO_D14, true, true, true, irqhandler, arg);
|
||||
}
|
||||
else if (id == 1)
|
||||
{
|
||||
oldhandler = stm32_gpiosetevent(GPIO_D15, true, true, true,
|
||||
irqhandler, arg);
|
||||
ret = stm32_gpiosetevent(GPIO_D15, true, true, true, irqhandler, arg);
|
||||
}
|
||||
|
||||
return oldhandler;
|
||||
return ret;
|
||||
}
|
||||
#endif /* CONFIG_CC3000_PROBES */
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* configs/nucleo-l476rg/src/stm32_buttons.c
|
||||
*
|
||||
* Copyright (C) 2014-2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2014-2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -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
|
||||
****************************************************************************/
|
||||
|
|
@ -117,23 +106,21 @@ uint8_t board_buttons(void)
|
|||
* be called when a button is depressed or released. The ID value is a
|
||||
* button enumeration value that uniquely identifies a button resource. See the
|
||||
* BUTTON_* definitions in board.h for the meaning of enumeration
|
||||
* value. The previous interrupt handler address is returned (so that it may
|
||||
* restored, if so desired).
|
||||
* value.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
{
|
||||
xcpt_t oldhandler = NULL;
|
||||
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);
|
||||
}
|
||||
|
||||
return oldhandler;
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
#endif /* CONFIG_ARCH_BUTTONS */
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* configs/nucleo-l476rg/src/stm32_io.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
|
||||
|
|
@ -40,6 +40,7 @@
|
|||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
#include "chip/stm32l4_tim.h"
|
||||
|
|
@ -48,18 +49,6 @@
|
|||
|
||||
#ifndef CONFIG_CC3000_PROBES
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
|
@ -176,23 +165,21 @@ void up_write_outputs(int id, bool bits)
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
xcpt_t up_irqio(int id, xcpt_t irqhandler)
|
||||
int up_irqio(int id, xcpt_t irqhandler, void *arg)
|
||||
{
|
||||
xcpt_t oldhandler = NULL;
|
||||
int ret = -EINVAL;
|
||||
|
||||
/* The following should be atomic */
|
||||
|
||||
if (id == 0)
|
||||
{
|
||||
oldhandler = stm32_gpiosetevent(GPIO_D14, true, true, true,
|
||||
irqhandler, NULL);
|
||||
ret = stm32_gpiosetevent(GPIO_D14, true, true, true, irqhandler, arg);
|
||||
}
|
||||
else if (id == 1)
|
||||
{
|
||||
oldhandler = stm32_gpiosetevent(GPIO_D15, true, true, true,
|
||||
irqhandler, NULL);
|
||||
ret = stm32_gpiosetevent(GPIO_D15, true, true, true, irqhandler, arg);
|
||||
}
|
||||
|
||||
return oldhandler;
|
||||
return ret;
|
||||
}
|
||||
#endif /* CONFIG_CC3000_PROBES */
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* configs/olimex-efm32g880f128-stk/src/efm32_buttons.c
|
||||
*
|
||||
* Copyright (C) 2014-2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2014-2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -75,9 +75,6 @@
|
|||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_EFM32_GPIO_IRQ) && defined(CONFIG_ARCH_IRQBUTTONS)
|
||||
#if 0 /* REVISIT -- See comments in board_button_irq() */
|
||||
static xcpt_t g_button_handlers[NUM_BUTTONS];
|
||||
#endif
|
||||
static const uint8_t g_button_irqs[NUM_BUTTONS];
|
||||
#endif
|
||||
|
||||
|
|
@ -154,8 +151,7 @@ uint8_t board_buttons(void)
|
|||
* Description:
|
||||
* This function may be called to register an interrupt handler that will
|
||||
* be called when a button is depressed or released. The ID value is one
|
||||
* of the BUTTON* definitions provided above. The previous interrupt
|
||||
* handler address is returned (so that it may restored, if so desired).
|
||||
* of the BUTTON* definitions provided above.
|
||||
*
|
||||
* Configuration Notes:
|
||||
* Configuration CONFIG_EFM32_GPIO_IRQ must be selected to enable the
|
||||
|
|
@ -168,10 +164,8 @@ uint8_t board_buttons(void)
|
|||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_EFM32_GPIO_IRQ) && defined(CONFIG_ARCH_IRQBUTTONS)
|
||||
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
{
|
||||
xcpt_t oldhandler = NULL;
|
||||
|
||||
if (id >=0 && id < NUM_BUTTONS)
|
||||
{
|
||||
irqstate_t flags;
|
||||
|
|
@ -182,19 +176,6 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Get/set the old button handler
|
||||
*
|
||||
* REVISIT: Keeping copies of the hander in RAM seems wasteful
|
||||
* since the OS already has this information internally.
|
||||
*/
|
||||
|
||||
#if 0 /* REVISIT */
|
||||
oldhandler = g_button_handlers[id];
|
||||
g_button_handlers[id] = irqhandler;
|
||||
#else
|
||||
oldhandler = NULL;
|
||||
#endif
|
||||
|
||||
/* Are we attaching or detaching? */
|
||||
|
||||
if (irqhandler != NULL)
|
||||
|
|
@ -205,7 +186,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||
|
||||
/* Attach and enable the interrupt */
|
||||
|
||||
(void)irq_attach(g_button_irqs[id], irqhandler, NULL);
|
||||
(void)irq_attach(g_button_irqs[id], irqhandler, arg);
|
||||
efm32_gpioirqenable(g_button_irqs[id]);
|
||||
}
|
||||
else
|
||||
|
|
@ -221,7 +202,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||
|
||||
/* Return the old button handler (so that it can be restored) */
|
||||
|
||||
return oldhandler;
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/************************************************************************************
|
||||
* configs/olimex-lpc-h3131/include/board.h
|
||||
*
|
||||
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2013, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -187,14 +187,15 @@ void lpc31_boardinitialize(void);
|
|||
*
|
||||
* 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);
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/************************************************************************************
|
||||
* configs/olimex-lpc-h3131/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
|
||||
|
|
@ -293,16 +293,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
|
||||
|
|
@ -311,16 +311,9 @@ 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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* configs/olimex-lpc1766stk/src/lpc17_buttons.c
|
||||
*
|
||||
* Copyright (C) 2011, 2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2011, 2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -70,13 +70,7 @@ static const uint16_t g_buttoncfg[BOARD_NUM_BUTTONS] =
|
|||
LPC1766STK_UP, LPC1766STK_DOWN, LPC1766STK_LEFT, LPC1766STK_RIGHT
|
||||
};
|
||||
|
||||
/* This array defines all of the interrupt handlers current attached to
|
||||
* button events.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_LPC17_GPIOIRQ)
|
||||
static xcpt_t g_buttonisr[BOARD_NUM_BUTTONS];
|
||||
|
||||
/* This array provides the mapping from button ID numbers to button IRQ
|
||||
* numbers.
|
||||
*/
|
||||
|
|
@ -171,8 +165,7 @@ uint8_t board_buttons(void)
|
|||
* be called when a button is depressed or released. The ID value is a
|
||||
* button enumeration value that uniquely identifies a button resource. See the
|
||||
* BOARD_BUTTON_* and BOARD_JOYSTICK_* definitions in board.h for the meaning
|
||||
* of enumeration values. The previous interrupt handler address is returned
|
||||
* (so that it may restored, if so desired).
|
||||
* of enumeration values.
|
||||
*
|
||||
* Note that board_button_irq() also enables button interrupts. Button
|
||||
* interrupts will remain enabled after the interrupt handler is attached.
|
||||
|
|
@ -182,9 +175,8 @@ uint8_t board_buttons(void)
|
|||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_LPC17_GPIOIRQ)
|
||||
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
{
|
||||
xcpt_t oldhandler = NULL;
|
||||
irqstate_t flags;
|
||||
int irq;
|
||||
|
||||
|
|
@ -192,11 +184,6 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||
|
||||
if ((unsigned)id < BOARD_NUM_BUTTONS)
|
||||
{
|
||||
/* Return the current button handler and set the new interrupt handler */
|
||||
|
||||
oldhandler = g_buttonisr[id];
|
||||
g_buttonisr[id] = irqhandler;
|
||||
|
||||
/* Disable interrupts until we are done */
|
||||
|
||||
flags = enter_critical_section();
|
||||
|
|
@ -210,7 +197,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||
{
|
||||
/* Attach then enable the new interrupt handler */
|
||||
|
||||
(void)irq_attach(irq, irqhandler, NULL);
|
||||
(void)irq_attach(irq, irqhandler, arg);
|
||||
up_enable_irq(irq);
|
||||
}
|
||||
else
|
||||
|
|
@ -220,9 +207,11 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||
up_disable_irq(irq);
|
||||
(void)irq_detach(irq);
|
||||
}
|
||||
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
return oldhandler;
|
||||
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* configs/olimex-stm32-e407/src/stm32_buttons.c
|
||||
*
|
||||
* Copyright (C) 2014-2016 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2014-2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -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
|
||||
|
|
@ -127,25 +128,24 @@ uint8_t board_buttons(void)
|
|||
* will be called when a button is depressed or released. The ID value is
|
||||
* a button enumeration value that uniquely identifies a button resource.
|
||||
* See the BUTTON_* definitions in board.h for the meaning of enumeration
|
||||
* value. The previous interrupt handler address is returned (so that it
|
||||
* may restored, if so desired).
|
||||
* value.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
{
|
||||
xcpt_t oldhandler = NULL;
|
||||
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 */
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/************************************************************************************
|
||||
* configs/stm32f4discovery/src/stm32_usb.c
|
||||
*
|
||||
* Copyright (C) 2012-2013, 2015-2916 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2012-2013, 2015-2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -302,16 +302,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 stm32_gpiosetevent(GPIO_OTGFS_OVER, true, true, true, handler, NULL);
|
||||
return stm32_gpiosetevent(GPIO_OTGFS_OVER, true, true, true, handler, arg);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* configs/olimex-stm32-h405/src/stm32_buttons.c
|
||||
*
|
||||
* Copyright (C) 2014-2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2014-2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -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
|
||||
*/
|
||||
|
|
@ -135,25 +128,23 @@ uint8_t board_buttons(void)
|
|||
* be called when a button is depressed or released. The ID value is a
|
||||
* button enumeration value that uniquely identifies a button resource. See the
|
||||
* BUTTON_* definitions in board.h for the meaning of enumeration
|
||||
* value. The previous interrupt handler address is returned (so that it may
|
||||
* restored, if so desired).
|
||||
* value.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
{
|
||||
xcpt_t oldhandler = NULL;
|
||||
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 */
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* configs/olimex-stm32-h407/src/stm32_buttons.c
|
||||
*
|
||||
* Copyright (C) 2014-2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2014-2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -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
|
||||
|
|
@ -127,25 +128,24 @@ uint8_t board_buttons(void)
|
|||
* will be called when a button is depressed or released. The ID value is
|
||||
* a button enumeration value that uniquely identifies a button resource.
|
||||
* See the BUTTON_* definitions in board.h for the meaning of enumeration
|
||||
* value. The previous interrupt handler address is returned (so that it
|
||||
* may restored, if so desired).
|
||||
* value.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
{
|
||||
xcpt_t oldhandler = NULL;
|
||||
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 */
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* config/olimex-stm32_h407/src/stm32_sdio.c
|
||||
*
|
||||
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2016-2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -128,8 +128,8 @@ int stm32_sdio_initialize(void)
|
|||
|
||||
/* Register an interrupt handler for the card detect pin */
|
||||
|
||||
stm32_gpiosetevent(GPIO_SDIO_NCD, true, true, true,
|
||||
stm32_ncd_interrupt, NULL);
|
||||
(void)stm32_gpiosetevent(GPIO_SDIO_NCD, true, true, true,
|
||||
stm32_ncd_interrupt, NULL);
|
||||
#endif
|
||||
|
||||
/* Mount the SDIO-based MMC/SD block driver */
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/************************************************************************************
|
||||
* configs/olimex-stm32-h407/src/stm32_usbdev.c
|
||||
*
|
||||
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2016-2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -280,16 +280,18 @@ void stm32_usbhost_vbusdrive(int iface, bool enable)
|
|||
*
|
||||
* Input Parameters:
|
||||
* handler - New overcurrent interrupt handler
|
||||
* arg - The argument provided for the interrupt handler
|
||||
*
|
||||
* Returned Value:
|
||||
* Old overcurrent interrupt handler
|
||||
* Returned value:
|
||||
* 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 stm32_gpiosetevent(GPIO_OTGHS_OVER, true, true, true, handler, NULL);
|
||||
return stm32_gpiosetevent(GPIO_OTGHS_OVER, true, true, true, handler, arg);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* configs/olimex-stm32-p207/src/stm32_buttons.c
|
||||
*
|
||||
* Copyright (C) 2011-2012, 2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2011-2012, 2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -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
|
||||
*/
|
||||
|
|
@ -171,25 +164,23 @@ uint8_t board_buttons(void)
|
|||
* be called when a button is depressed or released. The ID value is a
|
||||
* button enumeration value that uniquely identifies a button resource. See the
|
||||
* BUTTON_* definitions in board.h for the meaning of enumeration
|
||||
* value. The previous interrupt handler address is returned (so that it may
|
||||
* restored, if so desired).
|
||||
* value.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
{
|
||||
xcpt_t oldhandler = NULL;
|
||||
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 */
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/************************************************************************************
|
||||
* configs/olimex-stm32-p207/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>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -238,16 +238,18 @@ int stm32_usbhost_initialize(void)
|
|||
*
|
||||
* 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 stm32_gpiosetevent(GPIO_OTGFS_OVER, true, true, true, handler, NULL);
|
||||
return stm32_gpiosetevent(GPIO_OTGFS_OVER, true, true, true, handler, arg);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* configs/olimex-stm32-p407/src/stm32_buttons.c
|
||||
*
|
||||
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2016-2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -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
|
||||
|
|
@ -165,25 +166,23 @@ uint8_t board_buttons(void)
|
|||
* be called when a button is depressed or released. The ID value is a
|
||||
* button enumeration value that uniquely identifies a button resource. See the
|
||||
* BUTTON_* definitions in board.h for the meaning of enumeration
|
||||
* value. The previous interrupt handler address is returned (so that it may
|
||||
* restored, if so desired).
|
||||
* value.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
{
|
||||
xcpt_t oldhandler = NULL;
|
||||
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 */
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/************************************************************************************
|
||||
* configs/olimex-stm32-p407/src/stm32_usb.c
|
||||
*
|
||||
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2016-2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -238,16 +238,18 @@ int stm32_usbhost_setup(void)
|
|||
*
|
||||
* 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 stm32_gpiosetevent(GPIO_OTGFS_OVER, true, true, true, handler, NULL);
|
||||
return stm32_gpiosetevent(GPIO_OTGFS_OVER, true, true, true, handler, arg);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* configs/olimexino-stm32/src/stm32_buttons.c
|
||||
*
|
||||
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
* David_s5 <david_s5@nscdg.com>
|
||||
*
|
||||
|
|
@ -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.
|
||||
*
|
||||
|
|
@ -80,8 +70,7 @@
|
|||
* will be called when a button is depressed or released. The ID value is
|
||||
* a button enumeration value that uniquely identifies a button resource.
|
||||
* See the BUTTON_* definitions in board.h for the meaning of enumeration
|
||||
* value. The previous interrupt handler address is returned
|
||||
* (so that it may restored, if so desired).
|
||||
* value.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
|
@ -127,25 +116,24 @@ uint8_t board_buttons(void)
|
|||
* will be called when a button is depressed or released. The ID value is
|
||||
* a button enumeration value that uniquely identifies a button resource.
|
||||
* See the BUTTON_* definitions in board.h for the meaning of enumeration
|
||||
* value. The previous interrupt handler address is returned
|
||||
* (so that it may restored, if so desired).
|
||||
* value.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
{
|
||||
xcpt_t oldhandler = NULL;
|
||||
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);
|
||||
}
|
||||
|
||||
return oldhandler;
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
#endif /* CONFIG_ARCH_BUTTONS */
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* configs/open1788/src/lpc17_buttons.c
|
||||
*
|
||||
* Copyright (C) 2013, 2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2013, 2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -41,6 +41,7 @@
|
|||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/board.h>
|
||||
|
|
@ -89,13 +90,7 @@ static const lpc17_pinset_t g_buttoncfg[BOARD_NUM_BUTTONS] =
|
|||
GPIO_JOY_B, GPIO_JOY_C, GPIO_JOY_D, GPIO_JOY_CTR
|
||||
};
|
||||
|
||||
/* This array defines all of the interrupt handlers current attached to
|
||||
* button events.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_LPC17_GPIOIRQ)
|
||||
static xcpt_t g_buttonisr[BOARD_NUM_BUTTONS];
|
||||
|
||||
/* This array provides the mapping from button ID numbers to button IRQ
|
||||
* numbers.
|
||||
*/
|
||||
|
|
@ -189,8 +184,7 @@ uint8_t board_buttons(void)
|
|||
* be called when a button is depressed or released. The ID value is a
|
||||
* button enumeration value that uniquely identifies a button resource. See the
|
||||
* BOARD_BUTTON_* and BOARD_JOYSTICK_* definitions in board.h for the meaning
|
||||
* of enumeration values. The previous interrupt handler address is returned
|
||||
* (so that it may restored, if so desired).
|
||||
* of enumeration values.
|
||||
*
|
||||
* Note that board_button_irq() also enables button interrupts. Button
|
||||
* interrupts will remain enabled after the interrupt handler is attached.
|
||||
|
|
@ -200,10 +194,10 @@ uint8_t board_buttons(void)
|
|||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_LPC17_GPIOIRQ)
|
||||
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
{
|
||||
xcpt_t oldhandler = NULL;
|
||||
irqstate_t flags;
|
||||
int ret = -EINVAL;
|
||||
int irq;
|
||||
|
||||
/* Verify that the button ID is within range */
|
||||
|
|
@ -221,11 +215,6 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Return the current button handler and set the new interrupt handler */
|
||||
|
||||
oldhandler = g_buttonisr[id];
|
||||
g_buttonisr[id] = irqhandler;
|
||||
|
||||
/* Configure the interrupt. Either attach and enable the new
|
||||
* interrupt or disable and detach the old interrupt handler.
|
||||
*/
|
||||
|
|
@ -234,7 +223,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||
{
|
||||
/* Attach then enable the new interrupt handler */
|
||||
|
||||
(void)irq_attach(irq, irqhandler, NULL);
|
||||
(void)irq_attach(irq, irqhandler, arg);
|
||||
up_enable_irq(irq);
|
||||
}
|
||||
else
|
||||
|
|
@ -247,9 +236,11 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
ret = OK;
|
||||
}
|
||||
|
||||
return oldhandler;
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* configs/pcduino-a10/src/a1x_buttons.c
|
||||
*
|
||||
* Copyright (C) 2013-2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2013-2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -40,6 +40,7 @@
|
|||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/board.h>
|
||||
|
|
@ -52,22 +53,6 @@
|
|||
|
||||
#ifdef CONFIG_ARCH_BUTTONS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
static xcpt_t g_irqbutton[BOARD_NBUTTONS];
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
|
@ -110,8 +95,7 @@ uint8_t board_buttons(void)
|
|||
* Description:
|
||||
* This function may be called to register an interrupt handler that will
|
||||
* be called when a button is depressed or released. The ID value is one
|
||||
* of the BUTTON* definitions provided above. The previous interrupt
|
||||
* handler address isreturned (so that it may restored, if so desired).
|
||||
* of the BUTTON* definitions provided above.
|
||||
*
|
||||
* Configuration Notes:
|
||||
* Configuration CONFIG_ARCH_IRQBUTTONS must be selected to enable the
|
||||
|
|
@ -120,9 +104,9 @@ uint8_t board_buttons(void)
|
|||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
{
|
||||
xcpt_t oldhandler = NULL;
|
||||
int ret = -EINVAL;
|
||||
|
||||
if (id < BOARD_NBUTTONS)
|
||||
{
|
||||
|
|
@ -134,22 +118,17 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Get the old button interrupt handler and save the new one */
|
||||
|
||||
oldhandler = g_irqbutton[id];
|
||||
g_irqbutton[id] = irqhandler;
|
||||
|
||||
/* Configure the interrupt */
|
||||
|
||||
a1x_pioirq(xxx);
|
||||
(void)irq_attach(xxx, irqhandler, NULL);
|
||||
(void)irq_attach(xxx, irqhandler, arg);
|
||||
a1x_pioirqenable(xxx);
|
||||
leave_critical_section(flags);
|
||||
|
||||
ret = OK;
|
||||
}
|
||||
|
||||
/* Return the old button handler (so that it can be restored) */
|
||||
|
||||
return oldhandler;
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* configs/pic32mz-starterkit/src/pic32mz_buttons.c
|
||||
*
|
||||
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -40,6 +40,7 @@
|
|||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/board.h>
|
||||
|
|
@ -146,28 +147,27 @@ uint8_t board_buttons(void)
|
|||
* will be called when a button is depressed or released. The ID value is
|
||||
* a button enumeration value that uniquely identifies a button resource.
|
||||
* See the BUTTON_* definitions in board.h for the meaning of enumeration
|
||||
* value. The previous interrupt handler address is returned (so that it
|
||||
* may restored, if so desired).
|
||||
* value.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
{
|
||||
#ifdef CONFIG_PIC32MZ_GPIOIRQ_PORTB
|
||||
xcpt_t oldhandler = NULL;
|
||||
int ret = OK;
|
||||
|
||||
if ((unsigned)id < NUM_BUTTONS)
|
||||
{
|
||||
/* Perform the attach/detach operation */
|
||||
|
||||
oldhandler = pic32mz_gpioattach(g_buttons[id], irqhandler);
|
||||
ret = pic32mz_gpioattach(g_buttons[id], irqhandler, arg);
|
||||
|
||||
/* The interrupt is now disabled. Are we attaching or detaching from
|
||||
* button interrupt?
|
||||
*/
|
||||
|
||||
if (irqhandler)
|
||||
if (ret >= 0)
|
||||
{
|
||||
/* Attaching... enable button interrupts now */
|
||||
|
||||
|
|
@ -175,9 +175,9 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||
}
|
||||
}
|
||||
|
||||
return oldhandler;
|
||||
return ret;
|
||||
#else
|
||||
return NULL;
|
||||
return -ENOSYS;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* configs/sam3u-ek/src/up_leds.c
|
||||
*
|
||||
* Copyright (C) 2010, 2014-2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2010, 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>
|
||||
|
|
@ -53,19 +54,6 @@
|
|||
|
||||
#ifdef CONFIG_ARCH_BUTTONS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_SAM34_GPIOA_IRQ) && defined(CONFIG_ARCH_IRQBUTTONS)
|
||||
static xcpt_t g_irqbutton1;
|
||||
static xcpt_t g_irqbutton2;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
|
@ -79,10 +67,9 @@ static xcpt_t g_irqbutton2;
|
|||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_SAM34_GPIOA_IRQ) && defined(CONFIG_ARCH_IRQBUTTONS)
|
||||
static xcpt_t board_button_irqx(gpio_pinset_t pinset, int irq,
|
||||
xcpt_t irqhandler, xcpt_t *store, void *arg)
|
||||
static int board_button_irqx(gpio_pinset_t pinset, int irq, xcpt_t irqhandler,
|
||||
void *arg)
|
||||
{
|
||||
xcpt_t oldhandler;
|
||||
irqstate_t flags;
|
||||
|
||||
/* Disable interrupts until we are done. This guarantees that the following
|
||||
|
|
@ -91,11 +78,6 @@ static xcpt_t board_button_irqx(gpio_pinset_t pinset, int irq,
|
|||
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Get the old button interrupt handler and save the new one */
|
||||
|
||||
oldhandler = *store;
|
||||
*store = irqhandler;
|
||||
|
||||
/* Are we attaching or detaching? */
|
||||
|
||||
if (irqhandler != NULL)
|
||||
|
|
@ -115,10 +97,7 @@ static xcpt_t board_button_irqx(gpio_pinset_t pinset, int irq,
|
|||
}
|
||||
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* Return the old button handler (so that it can be restored) */
|
||||
|
||||
return oldhandler;
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -170,8 +149,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
|
||||
|
|
@ -183,21 +161,19 @@ uint8_t board_buttons(void)
|
|||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_SAM34_GPIOA_IRQ) && defined(CONFIG_ARCH_IRQBUTTONS)
|
||||
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
{
|
||||
if (id == BUTTON1)
|
||||
{
|
||||
return board_button_irqx(GPIO_BUTTON1, IRQ_BUTTON1,
|
||||
irqhandler, &g_irqbutton1, arg);
|
||||
return board_button_irqx(GPIO_BUTTON1, IRQ_BUTTON1, irqhandler, arg);
|
||||
}
|
||||
else if (id == BUTTON2)
|
||||
{
|
||||
return board_button_irqx(GPIO_BUTTON2, IRQ_BUTTON2,
|
||||
irqhandler, &g_irqbutton2, arg);
|
||||
return board_button_irqx(GPIO_BUTTON2, IRQ_BUTTON2, irqhandler, arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* configs/sam4e-ek/src/sam_buttons.c
|
||||
*
|
||||
* Copyright (C) 2014-2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2014-2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -40,6 +40,7 @@
|
|||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/board.h>
|
||||
|
|
@ -53,21 +54,6 @@
|
|||
|
||||
#ifdef CONFIG_ARCH_BUTTONS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_SAM34_GPIOA_IRQ) && defined(CONFIG_ARCH_IRQBUTTONS)
|
||||
static xcpt_t g_irq_scrollup;
|
||||
static xcpt_t g_irq_scrolldown;
|
||||
static xcpt_t g_irq_waku;
|
||||
static xcpt_t g_irq_tamp;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
|
@ -81,10 +67,9 @@ static xcpt_t g_irq_tamp;
|
|||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_SAM34_GPIOA_IRQ) && defined(CONFIG_ARCH_IRQBUTTONS)
|
||||
static xcpt_t board_button_irqx(gpio_pinset_t pinset, int irq,
|
||||
xcpt_t irqhandler, xcpt_t *store, void *arg)
|
||||
static int board_button_irqx(gpio_pinset_t pinset, int irq, xcpt_t irqhandler,
|
||||
void *arg)
|
||||
{
|
||||
xcpt_t oldhandler;
|
||||
irqstate_t flags;
|
||||
|
||||
/* Disable interrupts until we are done. This guarantees that the following
|
||||
|
|
@ -93,11 +78,6 @@ static xcpt_t board_button_irqx(gpio_pinset_t pinset, int irq,
|
|||
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Get the old button interrupt handler and save the new one */
|
||||
|
||||
oldhandler = *store;
|
||||
*store = irqhandler;
|
||||
|
||||
/* Are we attaching or detaching? */
|
||||
|
||||
if (irqhandler != NULL)
|
||||
|
|
@ -117,10 +97,7 @@ static xcpt_t board_button_irqx(gpio_pinset_t pinset, int irq,
|
|||
}
|
||||
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* Return the old button handler (so that it can be restored) */
|
||||
|
||||
return oldhandler;
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -176,8 +153,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
|
||||
|
|
@ -189,28 +165,24 @@ uint8_t board_buttons(void)
|
|||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_SAM34_GPIOA_IRQ) && defined(CONFIG_ARCH_IRQBUTTONS)
|
||||
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case BUTTON_SCROLLUP:
|
||||
return board_button_irqx(GPIO_SCROLLUP, IRQ_SCROLLUP,
|
||||
irqhandler, &g_irq_scrollup, arg);
|
||||
return board_button_irqx(GPIO_SCROLLUP, IRQ_SCROLLUP, irqhandler, arg);
|
||||
|
||||
case BUTTON_SCROLLDOWN:
|
||||
return board_button_irqx(GPIO_SCROLLDWN, IRQ_SCROLLDWN,
|
||||
irqhandler, &g_irq_scrolldown, arg);
|
||||
return board_button_irqx(GPIO_SCROLLDWN, IRQ_SCROLLDWN, irqhandler, arg);
|
||||
|
||||
case BUTTON_WAKU:
|
||||
return board_button_irqx(GPIO_WAKU, IRQ_WAKU,
|
||||
irqhandler, &g_irq_waku, arg);
|
||||
return board_button_irqx(GPIO_WAKU, IRQ_WAKU, irqhandler, arg);
|
||||
|
||||
case BUTTON_TAMP:
|
||||
return board_button_irqx(GPIO_TAMP, IRQ_TAMP,
|
||||
irqhandler, &g_irq_tamp, arg);
|
||||
return board_button_irqx(GPIO_TAMP, IRQ_TAMP, irqhandler, arg);
|
||||
|
||||
default:
|
||||
return NULL;
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/************************************************************************************
|
||||
* configs/sam4e-ek/src/sam_ethernet.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
|
||||
|
|
@ -83,14 +83,6 @@
|
|||
# define phyinfo(x...)
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Private Data
|
||||
************************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SAM34_GPIOD_IRQ
|
||||
static xcpt_t g_emac_handler;
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Private Functions
|
||||
************************************************************************************/
|
||||
|
|
@ -184,23 +176,21 @@ void weak_function sam_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_SAM34_GPIOD_IRQ
|
||||
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)
|
||||
{
|
||||
irqstate_t flags;
|
||||
xcpt_t *phandler;
|
||||
xcpt_t oldhandler;
|
||||
gpio_pinset_t pinset;
|
||||
phy_enable_t enabler;
|
||||
int irq;
|
||||
|
|
@ -213,7 +203,6 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||
if (strcmp(intf, SAM34_EMAC_DEVNAME) == 0)
|
||||
{
|
||||
phyinfo("Select EMAC\n");
|
||||
phandler = &g_emac_handler;
|
||||
pinset = GPIO_PHY_IRQ;
|
||||
irq = SAM_PHY_IRQ;
|
||||
enabler = sam_emac_phy_enable;
|
||||
|
|
@ -230,11 +219,6 @@ 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 */
|
||||
|
||||
oldhandler = *phandler;
|
||||
*phandler = handler;
|
||||
|
||||
/* Configure the interrupt */
|
||||
|
||||
if (handler)
|
||||
|
|
@ -243,7 +227,7 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||
sam_gpioirq(pinset);
|
||||
|
||||
phyinfo("Attach IRQ%d\n", irq);
|
||||
(void)irq_attach(irq, handler, NULL);
|
||||
(void)irq_attach(irq, handler, arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -266,7 +250,7 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||
/* Return the old handler (so that it can be restored) */
|
||||
|
||||
leave_critical_section(flags);
|
||||
return oldhandler;
|
||||
return OK;
|
||||
}
|
||||
#endif /* CONFIG_SAM34_GPIOD_IRQ */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* configs/sam4l-xplained/src/sam_buttons.c
|
||||
*
|
||||
* Copyright (C) 2013-2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2013-2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -53,18 +53,6 @@
|
|||
|
||||
#ifdef CONFIG_ARCH_BUTTONS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_SAM34_GPIOA_IRQ) && defined(CONFIG_ARCH_IRQBUTTONS)
|
||||
static xcpt_t g_irqsw0;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
|
@ -111,8 +99,7 @@ uint8_t board_buttons(void)
|
|||
* Description:
|
||||
* This function may be called to register an interrupt handler that will
|
||||
* be called when a button is depressed or released. The ID value is one
|
||||
* of the BUTTON* definitions provided above. The previous interrupt
|
||||
* handler address is returned (so that it may restored, if so desired).
|
||||
* of the BUTTON* definitions provided above.
|
||||
*
|
||||
* Configuration Notes:
|
||||
* Configuration CONFIG_AVR32_GPIOIRQ must be selected to enable the
|
||||
|
|
@ -124,9 +111,9 @@ uint8_t board_buttons(void)
|
|||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_SAM34_GPIOA_IRQ) && defined(CONFIG_ARCH_IRQBUTTONS)
|
||||
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
{
|
||||
xcpt_t oldhandler = NULL;
|
||||
int ret = -EINVAL;
|
||||
|
||||
if (id == BUTTON_SW0)
|
||||
{
|
||||
|
|
@ -138,11 +125,6 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Get the old button interrupt handler and save the new one */
|
||||
|
||||
oldhandler = *g_irqsw0;
|
||||
*g_irqsw0 = irqhandler;
|
||||
|
||||
/* Are we attaching or detaching? */
|
||||
|
||||
if (irqhandler != NULL)
|
||||
|
|
@ -150,7 +132,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||
/* Configure the interrupt */
|
||||
|
||||
sam_gpioirq(GPIO_SW0);
|
||||
(void)irq_attach(IRQ_SW0, irqhandler, NULL);
|
||||
(void)irq_attach(IRQ_SW0, irqhandler, arg);
|
||||
sam_gpioirqenable(IRQ_SW0);
|
||||
}
|
||||
else
|
||||
|
|
@ -162,11 +144,10 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||
}
|
||||
|
||||
leave_critical_section(flags);
|
||||
ret = OK;
|
||||
}
|
||||
|
||||
/* Return the old button handler (so that it can be restored) */
|
||||
|
||||
return oldhandler;
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* configs/sam4s-xplained-pro/src/sam_buttons.c
|
||||
*
|
||||
* Copyright (C) 2014-2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2014-2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Authors: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Bob Doiron
|
||||
*
|
||||
|
|
@ -41,6 +41,7 @@
|
|||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/board.h>
|
||||
|
|
@ -54,20 +55,6 @@
|
|||
|
||||
#ifdef CONFIG_ARCH_BUTTONS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static xcpt_t g_irqsw0;
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
|
@ -110,8 +97,7 @@ uint8_t board_buttons(void)
|
|||
* Description:
|
||||
* This function may be called to register an interrupt handler that will
|
||||
* be called when a button is depressed or released. The ID value is one
|
||||
* of the BUTTON* definitions provided above. The previous interrupt
|
||||
* handler address is returned (so that it may restored, if so desired).
|
||||
* of the BUTTON* definitions provided above.
|
||||
*
|
||||
* Configuration Notes:
|
||||
* Configuration CONFIG_AVR32_GPIOIRQ must be selected to enable the
|
||||
|
|
@ -123,9 +109,9 @@ uint8_t board_buttons(void)
|
|||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_SAM34_GPIOA_IRQ) && defined(CONFIG_ARCH_IRQBUTTONS)
|
||||
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
{
|
||||
xcpt_t oldhandler = NULL;
|
||||
int ret = -EINVAL;
|
||||
|
||||
if (id == BUTTON_SW0)
|
||||
{
|
||||
|
|
@ -137,11 +123,6 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Get the old button interrupt handler and save the new one */
|
||||
|
||||
oldhandler = g_irqsw0;
|
||||
g_irqsw0 = irqhandler;
|
||||
|
||||
/* Are we attaching or detaching? */
|
||||
|
||||
if (irqhandler != NULL)
|
||||
|
|
@ -149,7 +130,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||
/* Configure the interrupt */
|
||||
|
||||
sam_gpioirq(GPIO_SW0);
|
||||
(void)irq_attach(IRQ_SW0, irqhandler, NULL);
|
||||
(void)irq_attach(IRQ_SW0, irqhandler, arg);
|
||||
sam_gpioirqenable(IRQ_SW0);
|
||||
}
|
||||
else
|
||||
|
|
@ -161,11 +142,12 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||
}
|
||||
|
||||
leave_critical_section(flags);
|
||||
ret = OK;
|
||||
}
|
||||
|
||||
/* Return the old button handler (so that it can be restored) */
|
||||
|
||||
return oldhandler;
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@
|
|||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/board.h>
|
||||
|
|
@ -53,22 +54,6 @@
|
|||
|
||||
#ifdef CONFIG_ARCH_BUTTONS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_SAM34_GPIOA_IRQ) && defined(CONFIG_ARCH_IRQBUTTONS)
|
||||
static xcpt_t g_irqbp2;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
|
@ -111,8 +96,7 @@ uint8_t board_buttons(void)
|
|||
* Description:
|
||||
* This function may be called to register an interrupt handler that will
|
||||
* be called when a button is depressed or released. The ID value is one
|
||||
* of the BUTTON* definitions provided above. The previous interrupt
|
||||
* handler address is returned (so that it may restored, if so desired).
|
||||
* of the BUTTON* definitions provided above.
|
||||
*
|
||||
* Configuration Notes:
|
||||
* Configuration CONFIG_AVR32_GPIOIRQ must be selected to enable the
|
||||
|
|
@ -124,9 +108,9 @@ uint8_t board_buttons(void)
|
|||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_SAM34_GPIOA_IRQ) && defined(CONFIG_ARCH_IRQBUTTONS)
|
||||
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
{
|
||||
xcpt_t oldhandler = NULL;
|
||||
int ret = -EINVAL;
|
||||
|
||||
if (id == BUTTON_BP2)
|
||||
{
|
||||
|
|
@ -138,11 +122,6 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Get the old button interrupt handler and save the new one */
|
||||
|
||||
oldhandler = *g_irqbp2;
|
||||
*g_irqbp2 = irqhandler;
|
||||
|
||||
/* Are we attaching or detaching? */
|
||||
|
||||
if (irqhandler != NULL)
|
||||
|
|
@ -150,7 +129,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||
/* Configure the interrupt */
|
||||
|
||||
sam_gpioirq(GPIO_BP2);
|
||||
(void)irq_attach(IRQ_BP2, irqhandler, NULL);
|
||||
(void)irq_attach(IRQ_BP2, irqhandler, arg);
|
||||
sam_gpioirqenable(IRQ_BP2);
|
||||
}
|
||||
else
|
||||
|
|
@ -162,11 +141,10 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||
}
|
||||
|
||||
leave_critical_section(flags);
|
||||
ret = OK;
|
||||
}
|
||||
|
||||
/* Return the old button handler (so that it can be restored) */
|
||||
|
||||
return oldhandler;
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@
|
|||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/board.h>
|
||||
|
|
@ -64,22 +65,6 @@
|
|||
|
||||
#ifdef CONFIG_ARCH_BUTTONS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_SAMA5_PIOB_IRQ) && defined(CONFIG_ARCH_IRQBUTTONS)
|
||||
static xcpt_t g_irquser1;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
|
@ -122,8 +107,7 @@ uint8_t board_buttons(void)
|
|||
* Description:
|
||||
* This function may be called to register an interrupt handler that will
|
||||
* be called when a button is depressed or released. The ID value is one
|
||||
* of the BUTTON* definitions provided above. The previous interrupt
|
||||
* handler address is returned (so that it may restored, if so desired).
|
||||
* of the BUTTON* definitions provided above.
|
||||
*
|
||||
* Configuration Notes:
|
||||
* Configuration CONFIG_SAMA5_PIO_IRQ must be selected to enable the
|
||||
|
|
@ -133,9 +117,9 @@ uint8_t board_buttons(void)
|
|||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_SAMA5_PIOB_IRQ) && defined(CONFIG_ARCH_IRQBUTTONS)
|
||||
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
{
|
||||
xcpt_t oldhandler = NULL;
|
||||
int ret = -EINVAL;
|
||||
|
||||
if (id == BUTTON_USER)
|
||||
{
|
||||
|
|
@ -147,11 +131,6 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Get the old button interrupt handler and save the new one */
|
||||
|
||||
oldhandler = g_irquser1;
|
||||
g_irquser1 = irqhandler;
|
||||
|
||||
/* Are we attaching or detaching? */
|
||||
|
||||
if (irqhandler != NULL)
|
||||
|
|
@ -159,7 +138,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||
/* Configure the interrupt */
|
||||
|
||||
sam_pioirq(PIO_BTN_USER);
|
||||
(void)irq_attach(IRQ_BTN_USER, irqhandler, NULL);
|
||||
(void)irq_attach(IRQ_BTN_USER, irqhandler, arg);
|
||||
sam_pioirqenable(IRQ_BTN_USER);
|
||||
}
|
||||
else
|
||||
|
|
@ -171,11 +150,10 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||
}
|
||||
|
||||
leave_critical_section(flags);
|
||||
ret = OK;
|
||||
}
|
||||
|
||||
/* Return the old button handler (so that it can be restored) */
|
||||
|
||||
return oldhandler;
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* configs/sama5d3-xplained/src/sam_buttons.c
|
||||
*
|
||||
* Copyright (C) 2014-2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2014-2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -55,6 +55,7 @@
|
|||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/board.h>
|
||||
|
|
@ -68,22 +69,6 @@
|
|||
|
||||
#ifdef CONFIG_ARCH_BUTTONS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_SAMA5_PIOE_IRQ) && defined(CONFIG_ARCH_IRQBUTTONS)
|
||||
static xcpt_t g_irquser1;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
|
@ -126,8 +111,7 @@ uint8_t board_buttons(void)
|
|||
* Description:
|
||||
* This function may be called to register an interrupt handler that will
|
||||
* be called when a button is depressed or released. The ID value is one
|
||||
* of the BUTTON* definitions provided above. The previous interrupt
|
||||
* handler address is returned (so that it may restored, if so desired).
|
||||
* of the BUTTON* definitions provided above.
|
||||
*
|
||||
* Configuration Notes:
|
||||
* Configuration CONFIG_SAMA5_PIO_IRQ must be selected to enable the
|
||||
|
|
@ -137,9 +121,9 @@ uint8_t board_buttons(void)
|
|||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_SAMA5_PIOE_IRQ) && defined(CONFIG_ARCH_IRQBUTTONS)
|
||||
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
{
|
||||
xcpt_t oldhandler = NULL;
|
||||
int ret = -EINVAL;
|
||||
|
||||
if (id == BUTTON_USER)
|
||||
{
|
||||
|
|
@ -151,11 +135,6 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Get the old button interrupt handler and save the new one */
|
||||
|
||||
oldhandler = g_irquser1;
|
||||
g_irquser1 = irqhandler;
|
||||
|
||||
/* Are we attaching or detaching? */
|
||||
|
||||
if (irqhandler != NULL)
|
||||
|
|
@ -163,7 +142,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||
/* Configure the interrupt */
|
||||
|
||||
sam_pioirq(PIO_USER);
|
||||
(void)irq_attach(IRQ_USER1, irqhandler, NULL);
|
||||
(void)irq_attach(IRQ_USER1, irqhandler, arg);
|
||||
sam_pioirqenable(IRQ_USER1);
|
||||
}
|
||||
else
|
||||
|
|
@ -173,14 +152,12 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||
sam_pioirqdisable(IRQ_USER1);
|
||||
(void)irq_detach(IRQ_USER1);
|
||||
}
|
||||
/* Configure the interrupt */
|
||||
|
||||
leave_critical_section(flags);
|
||||
ret = OK;
|
||||
}
|
||||
|
||||
/* Return the old button handler (so that it can be restored) */
|
||||
|
||||
return oldhandler;
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/************************************************************************************
|
||||
* configs/sama5d3-xplained/src/sam_ethernet.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
|
||||
|
|
@ -93,19 +93,6 @@
|
|||
# define phyinfo(x...)
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Private Data
|
||||
************************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SAMA5_PIOE_IRQ
|
||||
#ifdef CONFIG_SAMA5_EMACA
|
||||
static xcpt_t g_emac_handler;
|
||||
#endif
|
||||
#ifdef CONFIG_SAMA5_GMAC
|
||||
static xcpt_t g_gmac_handler;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Private Functions
|
||||
************************************************************************************/
|
||||
|
|
@ -255,23 +242,21 @@ void weak_function sam_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_SAMA5_PIOE_IRQ
|
||||
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)
|
||||
{
|
||||
irqstate_t flags;
|
||||
xcpt_t *phandler;
|
||||
xcpt_t oldhandler;
|
||||
pio_pinset_t pinset;
|
||||
phy_enable_t enabler;
|
||||
int irq;
|
||||
|
|
@ -290,7 +275,6 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||
if (strcmp(intf, SAMA5_EMAC_DEVNAME) == 0)
|
||||
{
|
||||
phyinfo("Select EMAC\n");
|
||||
phandler = &g_emac_handler;
|
||||
pinset = PIO_INT_ETH1;
|
||||
irq = IRQ_INT_ETH1;
|
||||
enabler = sam_emac_phy_enable;
|
||||
|
|
@ -301,7 +285,6 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||
if (strcmp(intf, SAMA5_GMAC_DEVNAME) == 0)
|
||||
{
|
||||
phyinfo("Select GMAC\n");
|
||||
phandler = &g_gmac_handler;
|
||||
pinset = PIO_INT_ETH0;
|
||||
irq = IRQ_INT_ETH0;
|
||||
enabler = sam_gmac_phy_enable;
|
||||
|
|
@ -319,11 +302,6 @@ 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 */
|
||||
|
||||
oldhandler = *phandler;
|
||||
*phandler = handler;
|
||||
|
||||
/* Configure the interrupt */
|
||||
|
||||
if (handler)
|
||||
|
|
@ -332,7 +310,7 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||
sam_pioirq(pinset);
|
||||
|
||||
phyinfo("Attach IRQ%d\n", irq);
|
||||
(void)irq_attach(irq, handler, NULL);
|
||||
(void)irq_attach(irq, handler, arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -355,7 +333,7 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||
/* Return the old handler (so that it can be restored) */
|
||||
|
||||
leave_critical_section(flags);
|
||||
return oldhandler;
|
||||
return OK;
|
||||
}
|
||||
#endif /* CONFIG_SAMA5_PIOE_IRQ */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* configs/sama5d3x-ek/src/sam_buttons.c
|
||||
*
|
||||
* Copyright (C) 2013, 2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2013, 2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -55,6 +55,7 @@
|
|||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/board.h>
|
||||
|
|
@ -68,22 +69,6 @@
|
|||
|
||||
#ifdef CONFIG_ARCH_BUTTONS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_SAMA5_PIOE_IRQ) && defined(CONFIG_ARCH_IRQBUTTONS)
|
||||
static xcpt_t g_irquser1;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
|
@ -126,8 +111,7 @@ uint8_t board_buttons(void)
|
|||
* Description:
|
||||
* This function may be called to register an interrupt handler that will
|
||||
* be called when a button is depressed or released. The ID value is one
|
||||
* of the BUTTON* definitions provided above. The previous interrupt
|
||||
* handler address isreturned (so that it may restored, if so desired).
|
||||
* of the BUTTON* definitions provided above.
|
||||
*
|
||||
* Configuration Notes:
|
||||
* Configuration CONFIG_SAMA5_PIO_IRQ must be selected to enable the
|
||||
|
|
@ -137,9 +121,9 @@ uint8_t board_buttons(void)
|
|||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_SAMA5_PIOE_IRQ) && defined(CONFIG_ARCH_IRQBUTTONS)
|
||||
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
{
|
||||
xcpt_t oldhandler = NULL;
|
||||
int ret = -EINVAL;
|
||||
|
||||
if (id == BUTTON_USER1)
|
||||
{
|
||||
|
|
@ -151,11 +135,6 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Get the old button interrupt handler and save the new one */
|
||||
|
||||
oldhandler = g_irquser1;
|
||||
g_irquser1 = irqhandler;
|
||||
|
||||
/* Are we attaching or detaching? */
|
||||
|
||||
if (irqhandler != NULL)
|
||||
|
|
@ -163,7 +142,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||
/* Configure the interrupt */
|
||||
|
||||
sam_pioirq(PIO_USER1);
|
||||
(void)irq_attach(IRQ_USER1, irqhandler, NULL);
|
||||
(void)irq_attach(IRQ_USER1, irqhandler, arg);
|
||||
sam_pioirqenable(IRQ_USER1);
|
||||
}
|
||||
else
|
||||
|
|
@ -175,11 +154,10 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||
}
|
||||
|
||||
leave_critical_section(flags);
|
||||
ret = OK;
|
||||
}
|
||||
|
||||
/* Return the old button handler (so that it can be restored) */
|
||||
|
||||
return oldhandler;
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/************************************************************************************
|
||||
* configs/sama5d3x-ek/src/sam_ethernet.c
|
||||
*
|
||||
* Copyright (C) 2013-2014 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2013-2014, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -93,19 +93,6 @@
|
|||
# define phyinfo(x...)
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Private Data
|
||||
************************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SAMA5_PIOE_IRQ
|
||||
#ifdef CONFIG_SAMA5_EMACA
|
||||
static xcpt_t g_emac_handler;
|
||||
#endif
|
||||
#ifdef CONFIG_SAMA5_GMAC
|
||||
static xcpt_t g_gmac_handler;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Private Functions
|
||||
************************************************************************************/
|
||||
|
|
@ -255,23 +242,21 @@ void weak_function sam_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_SAMA5_PIOE_IRQ
|
||||
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)
|
||||
{
|
||||
irqstate_t flags;
|
||||
xcpt_t *phandler;
|
||||
xcpt_t oldhandler;
|
||||
pio_pinset_t pinset;
|
||||
phy_enable_t enabler;
|
||||
int irq;
|
||||
|
|
@ -290,7 +275,6 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||
if (strcmp(intf, SAMA5_EMAC_DEVNAME) == 0)
|
||||
{
|
||||
phyinfo("Select EMAC\n");
|
||||
phandler = &g_emac_handler;
|
||||
pinset = PIO_INT_ETH1;
|
||||
irq = IRQ_INT_ETH1;
|
||||
enabler = sam_emac_phy_enable;
|
||||
|
|
@ -301,7 +285,6 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||
if (strcmp(intf, SAMA5_GMAC_DEVNAME) == 0)
|
||||
{
|
||||
phyinfo("Select GMAC\n");
|
||||
phandler = &g_gmac_handler;
|
||||
pinset = PIO_INT_ETH0;
|
||||
irq = IRQ_INT_ETH0;
|
||||
enabler = sam_gmac_phy_enable;
|
||||
|
|
@ -319,11 +302,6 @@ 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 */
|
||||
|
||||
oldhandler = *phandler;
|
||||
*phandler = handler;
|
||||
|
||||
/* Configure the interrupt */
|
||||
|
||||
if (handler)
|
||||
|
|
@ -332,7 +310,7 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||
sam_pioirq(pinset);
|
||||
|
||||
phyinfo("Attach IRQ%d\n", irq);
|
||||
(void)irq_attach(irq, handler, NULL);
|
||||
(void)irq_attach(irq, handler, arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -355,7 +333,7 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||
/* Return the old handler (so that it can be restored) */
|
||||
|
||||
leave_critical_section(flags);
|
||||
return oldhandler;
|
||||
return OK;
|
||||
}
|
||||
#endif /* CONFIG_SAMA5_PIOE_IRQ */
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue