mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 14:53:47 +08:00
Merged nuttx/nuttx/master into master
This commit is contained in:
@@ -568,19 +568,17 @@ void kinetis_pinirqinitialize(void);
|
|||||||
* 3. Call kinetis_pinirqenable() to enable interrupts on the pin.
|
* 3. Call kinetis_pinirqenable() to enable interrupts on the pin.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* pinset - Pin configuration
|
* pinset - Pin configuration
|
||||||
* pinisr -:wq
|
* pinisr - Pin interrupt service routine
|
||||||
:wq: Pin interrupt service routine
|
* arg - An argument that will be provided to the interrupt service routine.
|
||||||
* arg:r - And argument that will be provided to the interrupt service routine.
|
|
||||||
*
|
*
|
||||||
* Return Value:
|
* Return Value:
|
||||||
* The previous value of the interrupt handler function pointer. This value may,
|
* Zero (OK) is returned on success; a negated errno value is returned on any
|
||||||
* for example, be used to restore the previous handler when multiple handlers are
|
* failure to indicate the nature of the failure.
|
||||||
* used.
|
|
||||||
*
|
*
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
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
|
* Name: kinetis_pinirqenable
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/arm/src/kinetis/kinetis_pinirq.c
|
* 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>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* 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.
|
* 3. Call kinetis_pinirqenable() to enable interrupts on the pin.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* - pinset: Pin configuration
|
* pinset - Pin configuration
|
||||||
* - pinisr: Pin interrupt service routine
|
* pinisr - Pin interrupt service routine
|
||||||
|
* arg - An argument that will be provided to the interrupt service routine.
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* The previous value of the interrupt handler function pointer. This
|
* Zero (OK) is returned on success; a negated errno value is returned on any
|
||||||
* value may, for example, be used to restore the previous handler whe
|
* failure to indicate the nature of the failure.
|
||||||
* multiple handlers are used.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
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
|
#ifdef HAVE_PORTINTS
|
||||||
struct kinetis_pinirq_s *isrtab;
|
struct kinetis_pinirq_s *isrtab;
|
||||||
xcpt_t oldisr;
|
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
unsigned int port;
|
unsigned int port;
|
||||||
unsigned int pin;
|
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 */
|
/* Get the old PIN ISR and set the new PIN ISR */
|
||||||
|
|
||||||
oldisr = isrtab[pin].handler;
|
|
||||||
isrtab[pin].handler = pinisr;
|
isrtab[pin].handler = pinisr;
|
||||||
isrtab[pin].arg = arg;
|
isrtab[pin].arg = arg;
|
||||||
|
|
||||||
/* And return the old PIN isr address */
|
/* And return the old PIN isr address */
|
||||||
|
|
||||||
leave_critical_section(flags);
|
leave_critical_section(flags);
|
||||||
return oldisr;
|
return OK;
|
||||||
#else
|
#else
|
||||||
return NULL;
|
return -ENOSYS;
|
||||||
#endif /* HAVE_PORTINTS */
|
#endif /* HAVE_PORTINTS */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -355,7 +355,7 @@ void kl_gpiowrite(uint32_t pinset, bool value);
|
|||||||
bool kl_gpioread(uint32_t pinset);
|
bool kl_gpioread(uint32_t pinset);
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Name: kl_pinirqattach
|
* Name: kl_gpioirqattach
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Attach a pin interrupt handler. The normal initalization sequence is:
|
* Attach a pin interrupt handler. The normal initalization sequence is:
|
||||||
@@ -368,15 +368,15 @@ bool kl_gpioread(uint32_t pinset);
|
|||||||
* Parameters:
|
* Parameters:
|
||||||
* - pinset: Pin configuration
|
* - pinset: Pin configuration
|
||||||
* - pinisr: Pin interrupt service routine
|
* - pinisr: Pin interrupt service routine
|
||||||
|
* - pinarg: The argument that will accompany the pin interrupt
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* The previous value of the interrupt handler function pointer. This value may,
|
* Zero (OK) is returned on success; On any failure, a negated errno value is
|
||||||
* for example, be used to restore the previous handler when multiple handlers are
|
* returned to indicate the nature of the failure.
|
||||||
* used.
|
|
||||||
*
|
*
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
xcpt_t kl_gpioirqattach(uint32_t pinset, xcpt_t pinisr);
|
int kl_gpioirqattach(uint32_t pinset, xcpt_t pinisr, void *pinarg);
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Name: kl_gpioirqenable
|
* Name: kl_gpioirqenable
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/arm/src/kl/kl_gpioirq.c
|
* 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>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -76,6 +76,12 @@
|
|||||||
* Private Types
|
* Private Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
struct g_portisrs_s
|
||||||
|
{
|
||||||
|
xcpt_t handler; /* Interrupt handler entry point */
|
||||||
|
void *arg; /* The argument that accompanies the interrupt handler */
|
||||||
|
};
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Data
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -87,11 +93,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef CONFIG_KL_PORTAINTS
|
#ifdef CONFIG_KL_PORTAINTS
|
||||||
static xcpt_t g_portaisrs[32];
|
static struct g_portisrs_s g_portaisrs[32];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_KL_PORTDINTS
|
#ifdef CONFIG_KL_PORTDINTS
|
||||||
static xcpt_t g_portdisrs[32];
|
static struct g_portisrs_s g_portdisrs[32];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -131,11 +137,14 @@ static int kl_portinterrupt(int irq, FAR void *context,
|
|||||||
* interrupt handler for the pin.
|
* 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 */
|
/* 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
|
/* Writing a one to the ISFR register will clear the pending
|
||||||
@@ -219,20 +228,20 @@ void kl_gpioirqinitialize(void)
|
|||||||
* Parameters:
|
* Parameters:
|
||||||
* - pinset: Pin configuration
|
* - pinset: Pin configuration
|
||||||
* - pinisr: Pin interrupt service routine
|
* - pinisr: Pin interrupt service routine
|
||||||
|
* - pinarg: The argument that will accompany the pin interrupt
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* The previous value of the interrupt handler function pointer. This
|
* Returns:
|
||||||
* value may, for example, be used to restore the previous handler when
|
* Zero (OK) is returned on success; On any failure, a negated errno value is
|
||||||
* multiple handlers are used.
|
* 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
|
#ifdef HAVE_PORTINTS
|
||||||
xcpt_t *isrtab;
|
struct g_portisrs_s *isrtab;
|
||||||
xcpt_t oldisr;
|
irqstate_t flags;
|
||||||
irqstate_t flags;
|
|
||||||
unsigned int port;
|
unsigned int port;
|
||||||
unsigned int pin;
|
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 */
|
/* Get the old PIN ISR and set the new PIN ISR */
|
||||||
|
|
||||||
oldisr = isrtab[pin];
|
isrtab[pin].handler = pinisr;
|
||||||
isrtab[pin] = pinisr;
|
isrtab[pin].arg = pinarg;
|
||||||
|
|
||||||
/* And return the old PIN isr address */
|
/* And return the old PIN isr address */
|
||||||
|
|
||||||
leave_critical_section(flags);
|
leave_critical_section(flags);
|
||||||
return oldisr;
|
return OK;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
return NULL;
|
return -ENOSYS;
|
||||||
#endif /* HAVE_PORTINTS */
|
#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_exti1510, STM32_IRQ_EXTI1510) /* 40: EXTI Line[15:10] interrupts */
|
||||||
VECTOR(stm32_rtcalrm, STM32_IRQ_RTCALRM) /* 41: RTC alarm through EXTI line interrupt */
|
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_RESERVED43) /* 43: Reserved */
|
||||||
UNUSED(STM32_IRQ_RESERVED44) /* 44: Reserved */
|
UNUSED(STM32_IRQ_RESERVED44) /* 44: Reserved */
|
||||||
UNUSED(STM32_IRQ_RESERVED45) /* 45: 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_RESERVED50) /* 50: Reserved */
|
||||||
UNUSED(STM32_IRQ_RESERVED51) /* 51: 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 */
|
UNUSED(STM32_IRQ_RESERVED52) /* 53: Reserved */
|
||||||
VECTOR(stm32_dac1, STM32_IRQ_DAC1) /* 54: TIM6 global or DAC1 underrun interrupts */
|
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 */
|
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 */
|
uint8_t fduplex : 1; /* Full (vs. half) duplex */
|
||||||
WDOG_ID txpoll; /* TX poll timer */
|
WDOG_ID txpoll; /* TX poll timer */
|
||||||
WDOG_ID txtimeout; /* TX timeout 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 */
|
/* 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);
|
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. */
|
/* And disable further TX interrupts. */
|
||||||
|
|
||||||
stm32_disableint(priv, ETH_DMAINT_TI);
|
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);
|
wd_cancel(priv->txtimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Cancel any pending poll work */
|
|
||||||
|
|
||||||
work_cancel(ETHWORK, &priv->work);
|
|
||||||
|
|
||||||
/* Schedule to perform the interrupt processing on the worker thread. */
|
/* 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;
|
return OK;
|
||||||
@@ -2196,15 +2172,15 @@ static void stm32_txtimeout_expiry(int argc, uint32_t arg, ...)
|
|||||||
|
|
||||||
up_disable_irq(STM32_IRQ_ETH);
|
up_disable_irq(STM32_IRQ_ETH);
|
||||||
|
|
||||||
/* Cancel any pending poll or interrupt work. This will have no effect
|
/* Cancel any pending interrupt work. This will have no effect on work that
|
||||||
* on work that has already been started.
|
* 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. */
|
/* 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.
|
* pending interrupt actions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (work_available(&priv->work))
|
if (work_available(&priv->pollwork))
|
||||||
{
|
{
|
||||||
/* Schedule to perform the interrupt processing on the worker thread. */
|
/* 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
|
else
|
||||||
{
|
{
|
||||||
@@ -2487,11 +2463,11 @@ static int stm32_txavail(struct net_driver_s *dev)
|
|||||||
* availability action.
|
* availability action.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (work_available(&priv->work))
|
if (work_available(&priv->pollwork))
|
||||||
{
|
{
|
||||||
/* Schedule to serialize the poll on the worker thread. */
|
/* 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;
|
return OK;
|
||||||
|
|||||||
@@ -72,22 +72,21 @@ extern "C"
|
|||||||
* Description:
|
* Description:
|
||||||
* Sets/clears GPIO based event and interrupt triggers.
|
* Sets/clears GPIO based event and interrupt triggers.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Input Parameters:
|
||||||
* - pinset: gpio pin configuration
|
* - pinset: gpio pin configuration
|
||||||
* - rising/falling edge: enables
|
* - rising/falling edge: enables
|
||||||
* - event: generate event when set
|
* - event: generate event when set
|
||||||
* - func: when non-NULL, generate interrupt
|
* - func: when non-NULL, generate interrupt
|
||||||
* - arg: Argument passed to the interrupt callback
|
* - arg: Argument passed to the interrupt callback
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returned Value:
|
||||||
* The previous value of the interrupt handler function pointer. This value may,
|
* Zero (OK) on success; a negated errno value on failure indicating the
|
||||||
* for example, be used to restore the previous handler when multiple handlers are
|
* nature of the failure.
|
||||||
* used.
|
|
||||||
*
|
*
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
xcpt_t stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
|
int stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
|
||||||
bool event, xcpt_t func, void *arg);
|
bool event, xcpt_t func, void *arg);
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Name: stm32_exti_alarm
|
* Name: stm32_exti_alarm
|
||||||
@@ -95,22 +94,21 @@ xcpt_t stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
|
|||||||
* Description:
|
* Description:
|
||||||
* Sets/clears EXTI alarm interrupt.
|
* Sets/clears EXTI alarm interrupt.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Input Parameters:
|
||||||
* - rising/falling edge: enables interrupt on rising/falling edges
|
* - rising/falling edge: enables interrupt on rising/falling edges
|
||||||
* - event: generate event when set
|
* - event: generate event when set
|
||||||
* - func: when non-NULL, generate interrupt
|
* - func: when non-NULL, generate interrupt
|
||||||
* - arg: Argument passed to the interrupt callback
|
* - arg: Argument passed to the interrupt callback
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returned Value:
|
||||||
* The previous value of the interrupt handler function pointer. This value may,
|
* Zero (OK) on success; a negated errno value on failure indicating the
|
||||||
* for example, be used to restore the previous handler when multiple handlers are
|
* nature of the failure.
|
||||||
* used.
|
|
||||||
*
|
*
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_RTC_ALARM
|
#ifdef CONFIG_RTC_ALARM
|
||||||
xcpt_t stm32_exti_alarm(bool risingedge, bool fallingedge, bool event, xcpt_t func,
|
int stm32_exti_alarm(bool risingedge, bool fallingedge, bool event, xcpt_t func,
|
||||||
void *arg);
|
void *arg);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/arm/src/stm32/stm32_exti_alarm.c
|
* 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>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
* Diego Sanchez <dsanchez@nx-engineering.com>
|
* 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
|
* - arg: Argument passed to the interrupt callback
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* The previous value of the interrupt handler function pointer. This
|
* Zero (OK) on success; a negated errno value on failure indicating the
|
||||||
* value may, for example, be used to restore the previous handler when
|
* nature of the failure.
|
||||||
* multiple handlers are used.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
xcpt_t stm32_exti_alarm(bool risingedge, bool fallingedge, bool event,
|
int stm32_exti_alarm(bool risingedge, bool fallingedge, bool event,
|
||||||
xcpt_t func, void *arg)
|
xcpt_t func, void *arg)
|
||||||
{
|
{
|
||||||
xcpt_t oldhandler;
|
|
||||||
|
|
||||||
/* Get the previous GPIO IRQ handler; Save the new IRQ handler. */
|
/* Get the previous GPIO IRQ handler; Save the new IRQ handler. */
|
||||||
|
|
||||||
oldhandler = g_alarm_callback;
|
|
||||||
g_alarm_callback = func;
|
g_alarm_callback = func;
|
||||||
g_callback_arg = arg;
|
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 the old IRQ handler */
|
||||||
|
|
||||||
return oldhandler;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/arm/src/stm32/stm32_exti_gpio.c
|
* 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.
|
* Copyright (C) 2011 Uros Platise. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
* Uros Platise <uros.platise@isotel.eu>
|
* Uros Platise <uros.platise@isotel.eu>
|
||||||
@@ -250,7 +250,7 @@ static int stm32_exti1510_isr(int irq, void *context, void *arg)
|
|||||||
* Description:
|
* Description:
|
||||||
* Sets/clears GPIO based event and interrupt triggers.
|
* Sets/clears GPIO based event and interrupt triggers.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Input Parameters:
|
||||||
* - pinset: GPIO pin configuration
|
* - pinset: GPIO pin configuration
|
||||||
* - risingedge: Enables interrupt on rising edges
|
* - risingedge: Enables interrupt on rising edges
|
||||||
* - fallingedge: Enables interrupt on falling 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
|
* - func: When non-NULL, generate interrupt
|
||||||
* - arg: Argument passed to the interrupt callback
|
* - arg: Argument passed to the interrupt callback
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returned Value:
|
||||||
* The previous value of the interrupt handler function pointer. This
|
* Zero (OK) on success; a negated errno value on failure indicating the
|
||||||
* value may, for example, be used to restore the previous handler when
|
* nature of the failure.
|
||||||
* multiple handlers are used.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
xcpt_t stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
|
int stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
|
||||||
bool event, xcpt_t func, void *arg)
|
bool event, xcpt_t func, void *arg)
|
||||||
{
|
{
|
||||||
FAR struct gpio_callback_s *shared_cbs;
|
FAR struct gpio_callback_s *shared_cbs;
|
||||||
uint32_t pin = pinset & GPIO_PIN_MASK;
|
uint32_t pin = pinset & GPIO_PIN_MASK;
|
||||||
uint32_t exti = STM32_EXTI_BIT(pin);
|
uint32_t exti = STM32_EXTI_BIT(pin);
|
||||||
int irq;
|
int irq;
|
||||||
xcpt_t handler;
|
xcpt_t handler;
|
||||||
xcpt_t oldhandler = NULL;
|
|
||||||
int nshared;
|
int nshared;
|
||||||
int i;
|
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. */
|
/* 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].callback = func;
|
||||||
g_gpio_callbacks[pin].arg = arg;
|
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 ? 0 : exti,
|
||||||
func ? exti : 0);
|
func ? exti : 0);
|
||||||
|
|
||||||
/* Return the old IRQ handler */
|
return OK;
|
||||||
|
|
||||||
return oldhandler;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/arm/src/stm32/stm32_exti_pwr.c
|
* 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.
|
* Copyright (C) 2015 Haltian Ltd. All rights reserved.
|
||||||
* Authors: Gregory Nutt <gnutt@nuttx.org>
|
* Authors: Gregory Nutt <gnutt@nuttx.org>
|
||||||
* Dmitry Nikolaev <dmitry.nikolaev@haltian.com>
|
* 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
|
* - arg: Argument passed to the interrupt callback
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* The previous value of the interrupt handler function pointer. This
|
* Zero (OK) returned on success; a negated errno value is returned on
|
||||||
* value may, for example, be used to restore the previous handler when
|
* failure.
|
||||||
* multiple handlers are used.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
xcpt_t stm32_exti_pvd(bool risingedge, bool fallingedge, bool event,
|
int stm32_exti_pvd(bool risingedge, bool fallingedge, bool event,
|
||||||
xcpt_t func, void *arg)
|
xcpt_t func, void *arg)
|
||||||
{
|
{
|
||||||
xcpt_t oldhandler;
|
|
||||||
|
|
||||||
/* Get the previous GPIO IRQ handler; Save the new IRQ handler. */
|
/* Get the previous GPIO IRQ handler; Save the new IRQ handler. */
|
||||||
|
|
||||||
oldhandler = g_pvd_callback;
|
|
||||||
g_pvd_callback = func;
|
g_pvd_callback = func;
|
||||||
g_callback_arg = arg;
|
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 ? 0 : EXTI_PVD_LINE,
|
||||||
func ? EXTI_PVD_LINE : 0);
|
func ? EXTI_PVD_LINE : 0);
|
||||||
|
|
||||||
/* Return the old IRQ handler */
|
return OK;
|
||||||
|
|
||||||
return oldhandler;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,13 +60,12 @@
|
|||||||
* - arg: Argument passed to the interrupt callback
|
* - arg: Argument passed to the interrupt callback
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* The previous value of the interrupt handler function pointer. This
|
* Zero (OK) returned on success; a negated errno value is returned on
|
||||||
* value may, for example, be used to restore the previous handler when
|
* failure.
|
||||||
* multiple handlers are used.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
xcpt_t stm32_exti_pvd(bool risingedge, bool fallingedge, bool event,
|
int stm32_exti_pvd(bool risingedge, bool fallingedge, bool event,
|
||||||
xcpt_t func, void *arg);
|
xcpt_t func, void *arg);
|
||||||
|
|
||||||
#endif /* STM32_EXTI_PWR_H_ */
|
#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
|
* function, it must be unconfigured with stm32_unconfiggpio() with
|
||||||
* the same cfgset first before it can be set to non-alternative function.
|
* the same cfgset first before it can be set to non-alternative function.
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returned Value:
|
||||||
* OK on success
|
* OK on success
|
||||||
* ERROR on invalid port, or when pin is locked as ALT function.
|
* 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
|
* operate in PWM mode could produce excessive on-board currents and trigger
|
||||||
* over-current/alarm function.
|
* over-current/alarm function.
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returned Value:
|
||||||
* OK on success
|
* OK on success
|
||||||
* ERROR on invalid port
|
* ERROR on invalid port
|
||||||
*
|
*
|
||||||
@@ -487,22 +487,21 @@ bool stm32_gpioread(uint32_t pinset);
|
|||||||
* Description:
|
* Description:
|
||||||
* Sets/clears GPIO based event and interrupt triggers.
|
* Sets/clears GPIO based event and interrupt triggers.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Input Parameters:
|
||||||
* - pinset: gpio pin configuration
|
* - pinset: gpio pin configuration
|
||||||
* - rising/falling edge: enables
|
* - rising/falling edge: enables
|
||||||
* - event: generate event when set
|
* - event: generate event when set
|
||||||
* - func: when non-NULL, generate interrupt
|
* - func: when non-NULL, generate interrupt
|
||||||
* - arg: Argument passed to the interrupt callback
|
* - arg: Argument passed to the interrupt callback
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returned Value:
|
||||||
* The previous value of the interrupt handler function pointer. This value may,
|
* Zero (OK) on success; a negated errno value on failure indicating the
|
||||||
* for example, be used to restore the previous handler when multiple handlers are
|
* nature of the failure.
|
||||||
* used.
|
|
||||||
*
|
*
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
xcpt_t stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
|
int stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
|
||||||
bool event, xcpt_t func, void *arg);
|
bool event, xcpt_t func, void *arg);
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Function: stm32_dumpgpio
|
* 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 */
|
/* Arm the SDIO_D Ready and install Isr */
|
||||||
|
|
||||||
stm32_gpiosetevent(pinset, true, false, false,
|
(void)stm32_gpiosetevent(pinset, true, false, false,
|
||||||
stm32_rdyinterrupt, priv);
|
stm32_rdyinterrupt, priv);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Disarm SDIO_D ready */
|
/* Disarm SDIO_D ready */
|
||||||
|
|
||||||
if ((wkupevent & SDIOWAIT_WRCOMPLETE) != 0)
|
if ((wkupevent & SDIOWAIT_WRCOMPLETE) != 0)
|
||||||
{
|
{
|
||||||
stm32_gpiosetevent(GPIO_SDIO_D0, false, false, false,
|
(void)stm32_gpiosetevent(GPIO_SDIO_D0, false, false, false,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
stm32_configgpio(GPIO_SDIO_D0);
|
stm32_configgpio(GPIO_SDIO_D0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/arm/src/stm32/stm32f40xxx_rtcc.c
|
* 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>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
* Modified: Neil Hancock
|
* 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).
|
* 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;
|
g_alarm_enabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/arm/src/stm32f7/stm32_exti.h
|
* 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>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -72,7 +72,7 @@ extern "C"
|
|||||||
* Description:
|
* Description:
|
||||||
* Sets/clears GPIO based event and interrupt triggers.
|
* Sets/clears GPIO based event and interrupt triggers.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Input Parameters:
|
||||||
* - pinset: GPIO pin configuration
|
* - pinset: GPIO pin configuration
|
||||||
* - risingedge: Enables interrupt on rising edges
|
* - risingedge: Enables interrupt on rising edges
|
||||||
* - fallingedge: Enables interrupt on falling edges
|
* - fallingedge: Enables interrupt on falling edges
|
||||||
@@ -80,15 +80,14 @@ extern "C"
|
|||||||
* - func: When non-NULL, generate interrupt
|
* - func: When non-NULL, generate interrupt
|
||||||
* - arg: Argument passed to the interrupt callback
|
* - arg: Argument passed to the interrupt callback
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returned Value:
|
||||||
* The previous value of the interrupt handler function pointer. This
|
* Zero (OK) on success; a negated errno value on failure indicating the
|
||||||
* value may, for example, be used to restore the previous handler when
|
* nature of the failure.
|
||||||
* multiple handlers are used.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
xcpt_t stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
|
int stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
|
||||||
bool event, xcpt_t func, void *arg);
|
bool event, xcpt_t func, void *arg);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: stm32_exti_alarm
|
* Name: stm32_exti_alarm
|
||||||
@@ -96,23 +95,22 @@ xcpt_t stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
|
|||||||
* Description:
|
* Description:
|
||||||
* Sets/clears EXTI alarm interrupt.
|
* Sets/clears EXTI alarm interrupt.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Input Parameters:
|
||||||
* - risingedge: Enables interrupt on rising edges
|
* - risingedge: Enables interrupt on rising edges
|
||||||
* - fallingedge: Enables interrupt on falling edges
|
* - fallingedge: Enables interrupt on falling edges
|
||||||
* - event: Generate event when set
|
* - event: Generate event when set
|
||||||
* - func: When non-NULL, generate interrupt
|
* - func: When non-NULL, generate interrupt
|
||||||
* - arg: Argument passed to the interrupt callback
|
* - arg: Argument passed to the interrupt callback
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returned Value:
|
||||||
* The previous value of the interrupt handler function pointer. This
|
* Zero (OK) on success; a negated errno value on failure indicating the
|
||||||
* value may, for example, be used to restore the previous handler when
|
* nature of the failure.
|
||||||
* multiple handlers are used.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_RTC_ALARM
|
#ifdef CONFIG_RTC_ALARM
|
||||||
xcpt_t stm32_exti_alarm(bool risingedge, bool fallingedge, bool event,
|
int stm32_exti_alarm(bool risingedge, bool fallingedge, bool event,
|
||||||
xcpt_t func, void *arg);
|
xcpt_t func, void *arg);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/arm/src/stm32f7/stm32_exti_alarm.c
|
* 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>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* This file derives from similar logic for the STM32 F1:
|
* This file derives from similar logic for the STM32 F1:
|
||||||
@@ -57,10 +57,6 @@
|
|||||||
#include "stm32_gpio.h"
|
#include "stm32_gpio.h"
|
||||||
#include "stm32_exti.h"
|
#include "stm32_exti.h"
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Data
|
* 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
|
* - arg: Argument passed to the interrupt callback
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* The previous value of the interrupt handler function pointer. This
|
* Zero (OK) on success; a negated errno value on failure indicating the
|
||||||
* value may, for example, be used to restore the previous handler when
|
* nature of the failure.
|
||||||
* multiple handlers are used.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
xcpt_t stm32_exti_alarm(bool risingedge, bool fallingedge, bool event,
|
int stm32_exti_alarm(bool risingedge, bool fallingedge, bool event,
|
||||||
xcpt_t func, void *arg)
|
xcpt_t func, void *arg)
|
||||||
{
|
{
|
||||||
xcpt_t oldhandler;
|
|
||||||
|
|
||||||
/* Get the previous GPIO IRQ handler; Save the new IRQ handler. */
|
/* Get the previous GPIO IRQ handler; Save the new IRQ handler. */
|
||||||
|
|
||||||
oldhandler = g_alarm_callback;
|
|
||||||
g_alarm_callback = func;
|
g_alarm_callback = func;
|
||||||
g_callback_arg = arg;
|
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 the old IRQ handler */
|
||||||
|
|
||||||
return oldhandler;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/arm/src/stm32f7/stm32_exti_gpio.c
|
* 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>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Based on EXTI GPIO logic from the Cortex-M3/4 which includes contributions
|
* 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:
|
* Description:
|
||||||
* Sets/clears GPIO based event and interrupt triggers.
|
* Sets/clears GPIO based event and interrupt triggers.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Input Parameters:
|
||||||
* - pinset: GPIO pin configuration
|
* - pinset: GPIO pin configuration
|
||||||
* - risingedge: Enables interrupt on rising edges
|
* - risingedge: Enables interrupt on rising edges
|
||||||
* - fallingedge: Enables interrupt on falling 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
|
* - func: When non-NULL, generate interrupt
|
||||||
* - arg: Argument passed to the interrupt callback
|
* - arg: Argument passed to the interrupt callback
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returned Value:
|
||||||
* The previous value of the interrupt handler function pointer. This
|
* Zero (OK) on success; a negated errno value on failure indicating the
|
||||||
* value may, for example, be used to restore the previous handler when
|
* nature of the failure.
|
||||||
* multiple handlers are used.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
xcpt_t stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
|
int stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
|
||||||
bool event, xcpt_t func, void *arg)
|
bool event, xcpt_t func, void *arg)
|
||||||
{
|
{
|
||||||
struct gpio_callback_s *shared_cbs;
|
struct gpio_callback_s *shared_cbs;
|
||||||
uint32_t pin = pinset & GPIO_PIN_MASK;
|
uint32_t pin = pinset & GPIO_PIN_MASK;
|
||||||
uint32_t exti = STM32_EXTI_BIT(pin);
|
uint32_t exti = STM32_EXTI_BIT(pin);
|
||||||
int irq;
|
int irq;
|
||||||
xcpt_t handler;
|
xcpt_t handler;
|
||||||
xcpt_t oldhandler = NULL;
|
|
||||||
int nshared;
|
int nshared;
|
||||||
int i;
|
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. */
|
/* 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].callback = func;
|
||||||
g_gpio_callbacks[pin].arg = arg;
|
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 ? 0 : exti,
|
||||||
func ? exti : 0);
|
func ? exti : 0);
|
||||||
|
|
||||||
/* Return the old IRQ handler */
|
return OK;
|
||||||
|
|
||||||
return oldhandler;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_STM32F7_STM32F74XX || CONFIG_STM32F7_STM32F75XX */
|
#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
|
* - func: when non-NULL, generate interrupt
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* The previous value of the interrupt handler function pointer. This
|
* Zero (OK) returned on success; a negated errno value is returned on
|
||||||
* value may, for example, be used to restore the previous handler when
|
* failure.
|
||||||
* multiple handlers are used.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
xcpt_t stm32_exti_pvd(bool risingedge, bool fallingedge, bool event,
|
int stm32_exti_pvd(bool risingedge, bool fallingedge, bool event,
|
||||||
xcpt_t func, void *arg)
|
xcpt_t func, void *arg);
|
||||||
{
|
{
|
||||||
xcpt_t oldhandler;
|
|
||||||
|
|
||||||
/* Get the previous GPIO IRQ handler; Save the new IRQ handler. */
|
/* Get the previous GPIO IRQ handler; Save the new IRQ handler. */
|
||||||
|
|
||||||
oldhandler = g_pvd_callback;
|
|
||||||
g_pvd_callback = func;
|
g_pvd_callback = func;
|
||||||
g_callback_arg = arg;
|
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 ? 0 : EXTI_PVD_LINE,
|
||||||
func ? EXTI_PVD_LINE : 0);
|
func ? EXTI_PVD_LINE : 0);
|
||||||
|
|
||||||
/* Return the old IRQ handler */
|
return OK;
|
||||||
|
|
||||||
return oldhandler;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,13 +61,12 @@
|
|||||||
* - arg: Argument passed to the interrupt callback
|
* - arg: Argument passed to the interrupt callback
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* The previous value of the interrupt handler function pointer. This
|
* Zero (OK) returned on success; a negated errno value is returned on
|
||||||
* value may, for example, be used to restore the previous handler when
|
* failure.
|
||||||
* multiple handlers are used.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
xcpt_t stm32_exti_pvd(bool risingedge, bool fallingedge, bool event,
|
int stm32_exti_pvd(bool risingedge, bool fallingedge, bool event,
|
||||||
xcpt_t func, void *arg);
|
xcpt_t func, void *arg);
|
||||||
|
|
||||||
#endif /* __ARCH_ARM_SRC_STM32F7_STM32_EXTI_PWR_H */
|
#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
|
* function, it must be unconfigured with stm32_unconfiggpio() with
|
||||||
* the same cfgset first before it can be set to non-alternative function.
|
* the same cfgset first before it can be set to non-alternative function.
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returned Value:
|
||||||
* OK on success
|
* OK on success
|
||||||
* ERROR on invalid port, or when pin is locked as ALT function.
|
* 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
|
* operate in PWM mode could produce excessive on-board currents and trigger
|
||||||
* over-current/alarm function.
|
* over-current/alarm function.
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returned Value:
|
||||||
* OK on success
|
* OK on success
|
||||||
* ERROR on invalid port
|
* ERROR on invalid port
|
||||||
*
|
*
|
||||||
@@ -321,7 +321,7 @@ bool stm32_gpioread(uint32_t pinset);
|
|||||||
* Description:
|
* Description:
|
||||||
* Sets/clears GPIO based event and interrupt triggers.
|
* Sets/clears GPIO based event and interrupt triggers.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Input Parameters:
|
||||||
* - pinset: GPIO pin configuration
|
* - pinset: GPIO pin configuration
|
||||||
* - risingedge: Enables interrupt on rising edges
|
* - risingedge: Enables interrupt on rising edges
|
||||||
* - fallingedge: Enables interrupt on falling edges
|
* - fallingedge: Enables interrupt on falling edges
|
||||||
@@ -329,15 +329,14 @@ bool stm32_gpioread(uint32_t pinset);
|
|||||||
* - func: When non-NULL, generate interrupt
|
* - func: When non-NULL, generate interrupt
|
||||||
* - arg: Argument passed to the interrupt callback
|
* - arg: Argument passed to the interrupt callback
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returned Value:
|
||||||
* The previous value of the interrupt handler function pointer. This
|
* Zero (OK) on success; a negated errno value on failure indicating the
|
||||||
* value may, for example, be used to restore the previous handler when
|
* nature of the failure.
|
||||||
* multiple handlers are used.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
xcpt_t stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
|
int stm32_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
|
||||||
bool event, xcpt_t func, void *arg);
|
bool event, xcpt_t func, void *arg);
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Function: stm32_dumpgpio
|
* 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).
|
* 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");
|
rtc_dumpregs("After InitExtiAlarm");
|
||||||
#else
|
#else
|
||||||
rtc_dumpregs("After Initialization");
|
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 */
|
/* Arm the SDMMC_D Ready and install Isr */
|
||||||
|
|
||||||
stm32_gpiosetevent(pinset, true, false, false,
|
(void)stm32_gpiosetevent(pinset, true, false, false,
|
||||||
priv->wrchandler, priv);
|
priv->wrchandler, priv);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Disarm SDMMC_D ready */
|
/* Disarm SDMMC_D ready */
|
||||||
|
|
||||||
if ((wkupevent & SDIOWAIT_WRCOMPLETE) != 0)
|
if ((wkupevent & SDIOWAIT_WRCOMPLETE) != 0)
|
||||||
{
|
{
|
||||||
stm32_gpiosetevent(priv->d0_gpio, false, false, false,
|
(void)stm32_gpiosetevent(priv->d0_gpio, false, false, false,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
stm32_configgpio(priv->d0_gpio);
|
stm32_configgpio(priv->d0_gpio);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -72,22 +72,22 @@ extern "C"
|
|||||||
* Description:
|
* Description:
|
||||||
* Sets/clears GPIO based event and interrupt triggers.
|
* Sets/clears GPIO based event and interrupt triggers.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Input Parameters:
|
||||||
* - pinset: gpio pin configuration
|
* pinset - GPIO pin configuration
|
||||||
* - rising/falling edge: enables
|
* risingedge - Enables interrupt on rising edges
|
||||||
* - event: generate event when set
|
* fallingedge - Enables interrupt on falling edges
|
||||||
* - func: when non-NULL, generate interrupt
|
* event - Generate event when set
|
||||||
* - arg: Argument passed to the interrupt callback
|
* func - When non-NULL, generate interrupt
|
||||||
|
* arg - Argument passed to the interrupt callback
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returned Value:
|
||||||
* The previous value of the interrupt handler function pointer. This value may,
|
* Zero (OK) is returned on success, otherwise a negated errno value is returned
|
||||||
* for example, be used to restore the previous handler when multiple handlers are
|
* to indicate the nature of the failure.
|
||||||
* used.
|
|
||||||
*
|
*
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
xcpt_t stm32l4_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
|
int stm32l4_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
|
||||||
bool event, xcpt_t func, void *arg);
|
bool event, xcpt_t func, void *arg);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: stm32l4_exti_alarm
|
* 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
|
* - arg: Argument passed to the interrupt callback
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* The previous value of the interrupt handler function pointer. This
|
* Zero (OK) on success; a negated errno value on failure indicating the
|
||||||
* value may, for example, be used to restore the previous handler when
|
* nature of the failure.
|
||||||
* multiple handlers are used.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_RTC_ALARM
|
#ifdef CONFIG_RTC_ALARM
|
||||||
xcpt_t stm32l4_exti_alarm(bool risingedge, bool fallingedge, bool event,
|
int stm32l4_exti_alarm(bool risingedge, bool fallingedge, bool event,
|
||||||
xcpt_t func, void *arg);
|
xcpt_t func, void *arg);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -127,15 +126,14 @@ xcpt_t stm32l4_exti_alarm(bool risingedge, bool fallingedge, bool event,
|
|||||||
* - arg: Argument passed to the interrupt callback
|
* - arg: Argument passed to the interrupt callback
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* The previous value of the interrupt handler function pointer. This
|
* Zero (OK) returned on success; a negated errno value is returned on
|
||||||
* value may, for example, be used to restore the previous handler when
|
* failure.
|
||||||
* multiple handlers are used.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_STM32L4_COMP
|
#ifdef CONFIG_STM32L4_COMP
|
||||||
xcpt_t stm32l4_exti_comp(int cmp, bool risingedge, bool fallingedge,
|
int stm32l4_exti_comp(int cmp, bool risingedge, bool fallingedge,
|
||||||
bool event, xcpt_t func, void *arg);
|
bool event, xcpt_t func, void *arg);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/arm/src/stm32l4/stm32l4_exti_alarm.c
|
* 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>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
* Diego Sanchez <dsanchez@nx-engineering.com>
|
* Diego Sanchez <dsanchez@nx-engineering.com>
|
||||||
* dev@ziggurat29.com (adaptation to stm32l4)
|
* 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
|
* - func: when non-NULL, generate interrupt
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* The previous value of the interrupt handler function pointer. This
|
* Zero (OK) on success; a negated errno value on failure indicating the
|
||||||
* value may, for example, be used to restore the previous handler when
|
* nature of the failure.
|
||||||
* multiple handlers are used.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
xcpt_t stm32l4_exti_alarm(bool risingedge, bool fallingedge, bool event,
|
int stm32l4_exti_alarm(bool risingedge, bool fallingedge, bool event,
|
||||||
xcpt_t func, void *arg)
|
xcpt_t func, void *arg)
|
||||||
{
|
{
|
||||||
xcpt_t oldhandler;
|
|
||||||
|
|
||||||
/* Get the previous GPIO IRQ handler; Save the new IRQ handler. */
|
/* Get the previous GPIO IRQ handler; Save the new IRQ handler. */
|
||||||
|
|
||||||
oldhandler = g_alarm_callback;
|
|
||||||
g_alarm_callback = func;
|
g_alarm_callback = func;
|
||||||
g_callback_arg = arg;
|
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 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
|
* - arg: Argument passed to the interrupt callback
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* The previous value of the interrupt handler function pointer. This
|
* Zero (OK) returned on success; a negated errno value is returned on
|
||||||
* value may, for example, be used to restore the previous handler when
|
* failure.
|
||||||
* multiple handlers are used.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
xcpt_t stm32l4_exti_comp(int cmp, bool risingedge, bool fallingedge,
|
int stm32l4_exti_comp(int cmp, bool risingedge, bool fallingedge,
|
||||||
bool event, xcpt_t func, void *arg)
|
bool event, xcpt_t func, void *arg)
|
||||||
{
|
{
|
||||||
xcpt_t oldhandler;
|
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
uint32_t ln = g_comp_lines[cmp];
|
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)
|
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);
|
up_enable_irq(STM32L4_IRQ_COMP);
|
||||||
}
|
}
|
||||||
else
|
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. */
|
/* 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].callback = func;
|
||||||
g_comp_handlers[cmp].arg = arg;
|
g_comp_handlers[cmp].arg = arg;
|
||||||
|
|
||||||
/* Leave the critical section */
|
/* Leave the critical section */
|
||||||
|
|
||||||
leave_critical_section(flags);
|
leave_critical_section(flags);
|
||||||
|
return OK;
|
||||||
/* Return the old IRQ handler */
|
|
||||||
|
|
||||||
return oldhandler;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,8 +61,8 @@
|
|||||||
|
|
||||||
struct gpio_callback_s
|
struct gpio_callback_s
|
||||||
{
|
{
|
||||||
xcpt_t callback;
|
xcpt_t callback; /* Callback entry point */
|
||||||
void *arg;
|
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:
|
* Description:
|
||||||
* Sets/clears GPIO based event and interrupt triggers.
|
* Sets/clears GPIO based event and interrupt triggers.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Description:
|
||||||
* - pinset: GPIO pin configuration
|
* Sets/clears GPIO based event and interrupt triggers.
|
||||||
* - 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:
|
* Input Parameters:
|
||||||
* The previous value of the interrupt handler function pointer. This
|
* pinset - GPIO pin configuration
|
||||||
* value may, for example, be used to restore the previous handler when
|
* risingedge - Enables interrupt on rising edges
|
||||||
* multiple handlers are used.
|
* 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,
|
int stm32l4_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
|
||||||
bool event, xcpt_t func, void *arg)
|
bool event, xcpt_t func, void *arg)
|
||||||
{
|
{
|
||||||
struct gpio_callback_s *shared_cbs;
|
struct gpio_callback_s *shared_cbs;
|
||||||
uint32_t pin = pinset & GPIO_PIN_MASK;
|
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. */
|
/* 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].callback = func;
|
||||||
g_gpio_handlers[pin].arg = arg;
|
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 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
|
* - func: when non-NULL, generate interrupt
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* The previous value of the interrupt handler function pointer. This
|
* Zero (OK) returned on success; a negated errno value is returned on
|
||||||
* value may, for example, be used to restore the previous handler when
|
* failure.
|
||||||
* multiple handlers are used.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
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 func, void *arg)
|
||||||
{
|
{
|
||||||
xcpt_t oldhandler;
|
|
||||||
|
|
||||||
/* Get the previous GPIO IRQ handler; Save the new IRQ handler. */
|
/* Get the previous GPIO IRQ handler; Save the new IRQ handler. */
|
||||||
|
|
||||||
oldhandler = g_pvd_callback;
|
|
||||||
g_pvd_callback = func;
|
g_pvd_callback = func;
|
||||||
g_callback_arg = arg;
|
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 ? 0 : EXTI1_PVD_LINE,
|
||||||
func ? EXTI1_PVD_LINE : 0);
|
func ? EXTI1_PVD_LINE : 0);
|
||||||
|
|
||||||
/* Return the old IRQ handler */
|
return OK;
|
||||||
|
|
||||||
return oldhandler;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,13 +60,12 @@
|
|||||||
* - arg: Argument passed to the interrupt callback
|
* - arg: Argument passed to the interrupt callback
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* The previous value of the interrupt handler function pointer. This
|
* Zero (OK) returned on success; a negated errno value is returned on
|
||||||
* value may, for example, be used to restore the previous handler when
|
* failure.
|
||||||
* multiple handlers are used.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
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 func, void *arg);
|
||||||
|
|
||||||
#endif /* STM32L4_EXTI_PWR_H_ */
|
#endif /* STM32L4_EXTI_PWR_H_ */
|
||||||
|
|||||||
@@ -326,22 +326,22 @@ bool stm32l4_gpioread(uint32_t pinset);
|
|||||||
* Description:
|
* Description:
|
||||||
* Sets/clears GPIO based event and interrupt triggers.
|
* Sets/clears GPIO based event and interrupt triggers.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Input Parameters:
|
||||||
* - pinset: gpio pin configuration
|
* pinset - GPIO pin configuration
|
||||||
* - rising/falling edge: enables
|
* risingedge - Enables interrupt on rising edges
|
||||||
* - event: generate event when set
|
* fallingedge - Enables interrupt on falling edges
|
||||||
* - func: when non-NULL, generate interrupt
|
* event - Generate event when set
|
||||||
* - arg: Argument passed to the interrupt callback
|
* func - When non-NULL, generate interrupt
|
||||||
|
* arg - Argument passed to the interrupt callback
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returned Value:
|
||||||
* The previous value of the interrupt handler function pointer. This value may,
|
* Zero (OK) is returned on success, otherwise a negated errno value is returned
|
||||||
* for example, be used to restore the previous handler when multiple handlers are
|
* to indicate the nature of the failure.
|
||||||
* used.
|
|
||||||
*
|
*
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
xcpt_t stm32l4_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
|
int stm32l4_gpiosetevent(uint32_t pinset, bool risingedge, bool fallingedge,
|
||||||
bool event, xcpt_t func, void *arg);
|
bool event, xcpt_t func, void *arg);
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Function: stm32l4_dumpgpio
|
* 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).
|
* 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;
|
g_alarm_enabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/arm/src/tiva/tiva_gpio.h
|
* 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>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* With modifications from Calvin Maguranis <calvin.maguranis@trd2inc.com>
|
* With modifications from Calvin Maguranis <calvin.maguranis@trd2inc.com>
|
||||||
@@ -412,15 +412,19 @@ int weak_function tiva_gpioirqinitialize(void);
|
|||||||
* Name: tiva_gpioirqattach
|
* Name: tiva_gpioirqattach
|
||||||
*
|
*
|
||||||
* Description:
|
* 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:
|
* Returned Value:
|
||||||
* 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);
|
||||||
# define tiva_gpioirqdetach(pinset) tiva_gpioirqattach(pinset, NULL)
|
# define tiva_gpioirqdetach(p) tiva_gpioirqattach((p),NULL,NULL)
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: tiva_gpioportirqattach
|
* Name: tiva_gpioportirqattach
|
||||||
|
|||||||
@@ -66,17 +66,23 @@
|
|||||||
#define TIVA_NIRQ_PINS (TIVA_NPORTS * TIVA_NPINS)
|
#define TIVA_NIRQ_PINS (TIVA_NPORTS * TIVA_NPINS)
|
||||||
#define TIVA_GPIO_IRQ_IDX(port,pin) ((port*TIVA_NPINS)+(pin))
|
#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
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* A table of handlers for each GPIO port interrupt */
|
/* A table of handlers for each GPIO port interrupt */
|
||||||
|
|
||||||
static FAR xcpt_t g_gpioportirqvector[TIVA_NIRQ_PINS];
|
static struct gpio_handler_s g_gpioportirqvector[TIVA_NIRQ_PINS];
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Public Data
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
@@ -303,12 +309,13 @@ static int tiva_gpioporthandler(uint8_t port, void *context)
|
|||||||
{
|
{
|
||||||
if (((mis >> pin) & 1) != 0)
|
if (((mis >> pin) & 1) != 0)
|
||||||
{
|
{
|
||||||
gpioinfo("port=%d pin=%d irq=%p index=%d\n",
|
int index = TIVA_GPIO_IRQ_IDX(port, pin);
|
||||||
port, pin,
|
FAR struct gpio_handler_s *handler = &g_gpioportirqvector[index];
|
||||||
g_gpioportirqvector[TIVA_GPIO_IRQ_IDX(port, pin)],
|
|
||||||
TIVA_GPIO_IRQ_IDX(port, pin));
|
|
||||||
|
|
||||||
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)
|
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",
|
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.
|
* and the pin's interrupt mask is set.
|
||||||
*
|
*
|
||||||
* Returns:
|
* 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;
|
irqstate_t flags;
|
||||||
xcpt_t oldhandler = NULL;
|
|
||||||
uint8_t port = (pinset & GPIO_PORT_MASK) >> GPIO_PORT_SHIFT;
|
uint8_t port = (pinset & GPIO_PORT_MASK) >> GPIO_PORT_SHIFT;
|
||||||
uint8_t pinno = (pinset & GPIO_PIN_MASK);
|
uint8_t pinno = (pinset & GPIO_PIN_MASK);
|
||||||
uint8_t pin = 1 << pinno;
|
uint8_t pin = 1 << pinno;
|
||||||
|
int index;
|
||||||
|
|
||||||
/* assign per-pin interrupt handlers */
|
/* Assign per-pin interrupt handlers */
|
||||||
|
|
||||||
if (port < TIVA_NPORTS)
|
if (port < TIVA_NPORTS)
|
||||||
{
|
{
|
||||||
flags = enter_critical_section();
|
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.
|
/* If the new ISR is NULL, then the ISR is being detached.
|
||||||
* In this case, disable the ISR and direct any interrupts
|
* In this case, disable the ISR and direct any interrupts
|
||||||
* to the unexpected interrupt handler.
|
* 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",
|
gpioinfo("assign port=%d pin=%d function=%p to idx=%d\n",
|
||||||
port, pinno, isr, TIVA_GPIO_IRQ_IDX(port, pinno));
|
port, pinno, isr, TIVA_GPIO_IRQ_IDX(port, pinno));
|
||||||
|
|
||||||
|
handler = &g_gpioportirqvector[TIVA_GPIO_IRQ_IDX(port, pinno)];
|
||||||
if (isr == NULL)
|
if (isr == NULL)
|
||||||
{
|
{
|
||||||
tiva_gpioirqdisable(port, pin);
|
tiva_gpioirqdisable(port, pin);
|
||||||
g_gpioportirqvector[TIVA_GPIO_IRQ_IDX(port, pinno)] = irq_unexpected_isr;
|
handler->isr = irq_unexpected_isr;
|
||||||
|
handler->arg = NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_gpioportirqvector[TIVA_GPIO_IRQ_IDX(port, pinno)] = isr;
|
handler->isr = isr;
|
||||||
|
handler->arg = arg;
|
||||||
tiva_gpioirqenable(port, pin);
|
tiva_gpioirqenable(port, pin);
|
||||||
}
|
}
|
||||||
|
|
||||||
leave_critical_section(flags);
|
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 */
|
struct work_s work; /* For deferring work to the work queue */
|
||||||
#ifdef CONFIG_TIVA_PHY_INTERRUPTS
|
#ifdef CONFIG_TIVA_PHY_INTERRUPTS
|
||||||
xcpt_t handler; /* Attached PHY interrupt handler */
|
xcpt_t handler; /* Attached PHY interrupt handler */
|
||||||
|
void *arg; /* Argument that accompanies the interrupt */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* This holds the information visible to the NuttX network */
|
/* 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 */
|
/* 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
|
#endif
|
||||||
@@ -4254,23 +4255,22 @@ void up_netinitialize(void)
|
|||||||
* asserts an interrupt. Must reside in OS space, but can
|
* asserts an interrupt. Must reside in OS space, but can
|
||||||
* signal tasks in user space. A value of NULL can be passed
|
* signal tasks in user space. A value of NULL can be passed
|
||||||
* in order to detach and disable the PHY interrupt.
|
* 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
|
* enable - A function pointer that be unsed to enable or disable the
|
||||||
* PHY interrupt.
|
* PHY interrupt.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* The previous PHY interrupt handler address is returned. This allows you
|
* Zero (OK) returned on success; a negated errno value is returned on
|
||||||
* to temporarily replace an interrupt handler, then restore the original
|
* failure.
|
||||||
* interrupt handler. NULL is returned if there is was not handler in
|
|
||||||
* place when the call was made.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_TIVA_PHY_INTERRUPTS
|
#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;
|
struct tiva_ethmac_s *priv;
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
xcpt_t oldhandler;
|
|
||||||
|
|
||||||
DEBUGASSERT(intf);
|
DEBUGASSERT(intf);
|
||||||
ninfo("%s: handler=%p\n", intf, handler);
|
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();
|
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->handler = handler;
|
||||||
|
priv->arg = arg;
|
||||||
|
|
||||||
/* Return with the interrupt disabled in any case */
|
/* 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;
|
*enable = handler ? tiva_phy_intenable : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the old handler (so that it can be restored) */
|
|
||||||
|
|
||||||
leave_critical_section(flags);
|
leave_critical_section(flags);
|
||||||
return oldhandler;
|
return OK;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_TIVA_PHY_INTERRUPTS */
|
#endif /* CONFIG_TIVA_PHY_INTERRUPTS */
|
||||||
|
|
||||||
|
|||||||
@@ -296,7 +296,7 @@ void weak_function gpio_irqinitialize(void);
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_AVR32_GPIOIRQ
|
#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
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
@@ -57,20 +57,22 @@
|
|||||||
#ifdef CONFIG_AVR32_GPIOIRQ
|
#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
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* A table of handlers for each GPIO interrupt */
|
/* A table of handlers for each GPIO interrupt */
|
||||||
|
|
||||||
static FAR xcpt_t g_gpiohandler[NR_GPIO_IRQS];
|
static struct g_gpiohandler_s g_gpiohandler[NR_GPIO_IRQS];
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Public Data
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
@@ -221,10 +223,10 @@ static void gpio_porthandler(uint32_t regbase, int irqbase, uint32_t irqset, voi
|
|||||||
|
|
||||||
/* Dispatch handling for this pin */
|
/* Dispatch handling for this pin */
|
||||||
|
|
||||||
xcpt_t handler = g_gpiohandler[irq];
|
xcpt_t handler = g_gpiohandler[irq].handler;
|
||||||
if (handler)
|
if (handler != NULL)
|
||||||
{
|
{
|
||||||
handler(irq, context);
|
handler(irq, contex, g_gpiohandler[irq].arg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -304,7 +306,8 @@ void gpio_irqinitialize(void)
|
|||||||
|
|
||||||
for (i = 0; i < NR_GPIO_IRQS; i++)
|
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 */
|
/* 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;
|
irqstate_t flags;
|
||||||
int ret = -EINVAL;
|
int ret = -EINVAL;
|
||||||
@@ -338,25 +341,23 @@ int gpio_irqattach(int irq, xcpt_t newisr, xcpt_t *oldisr)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
flags = enter_critical_section();
|
flags = enter_critical_section();
|
||||||
if (newisr == NULL)
|
if (handler == NULL)
|
||||||
{
|
{
|
||||||
gpio_irqdisable(irq);
|
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)
|
g_gpiohandler[irq].handler = handler;
|
||||||
{
|
g_gpiohandler[irq].arg = arg;
|
||||||
*oldisr = g_gpiohandler[irq];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Then save the new ISR in the table. */
|
|
||||||
|
|
||||||
g_gpiohandler[irq] = newisr;
|
|
||||||
leave_critical_section(flags);
|
leave_critical_section(flags);
|
||||||
ret = OK;
|
ret = OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/mips/src/pic32mx/pic32mx-gpio.c
|
* 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>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -52,23 +52,21 @@
|
|||||||
|
|
||||||
#ifdef CONFIG_PIC32MX_GPIOIRQ
|
#ifdef CONFIG_PIC32MX_GPIOIRQ
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Types
|
* Private Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
struct g_cnisrs_s
|
||||||
* Public Data
|
{
|
||||||
****************************************************************************/
|
xcpt_t handler; /* Interrupt handler entry point */
|
||||||
|
void *arg; /* The argument that accompanies the interrupt handler */
|
||||||
|
};
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Data
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static xcpt_t g_cnisrs[IOPORT_NUMCN];
|
static struct g_cnisrs_s g_cnisrs[IOPORT_NUMCN];
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
@@ -113,11 +111,14 @@ static int pic32mx_cninterrupt(int irq, FAR void *context)
|
|||||||
{
|
{
|
||||||
/* Is this one attached */
|
/* 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 */
|
/* 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 */
|
/* 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;
|
ret = status;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clear the pending interrupt */
|
/* Clear the pending interrupt */
|
||||||
@@ -189,21 +191,21 @@ void pic32mx_gpioirqinitialize(void)
|
|||||||
* In that case, all attached handlers will be called. Each handler must
|
* In that case, all attached handlers will be called. Each handler must
|
||||||
* maintain state and determine if the unlying GPIO input value changed.
|
* maintain state and determine if the unlying GPIO input value changed.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Input Parameters:
|
||||||
* - pinset: GPIO pin configuration
|
* pinset - GPIO pin configuration
|
||||||
* - cn: The change notification number associated with the pin.
|
* cn - The change notification number associated with the pin.
|
||||||
* - handler: Interrupt handler (may be NULL to detach)
|
* handler - Interrupt handler (may be NULL to detach)
|
||||||
|
* arg - The argument that accompanies the interrupt
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returned Value:
|
||||||
* The previous value of the interrupt handler function pointer. This
|
* Zero (OK) is returned on success. A negated error value is returned on
|
||||||
* value may, for example, be used to restore the previous handler when
|
* any failure to indicate the nature of the failure.
|
||||||
* multiple handlers are used.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
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;
|
irqstate_t flags;
|
||||||
|
|
||||||
DEBUGASSERT(cn < IOPORT_NUMCN);
|
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 */
|
/* Get the previously attached handler as the return value */
|
||||||
|
|
||||||
flags = enter_critical_section();
|
flags = enter_critical_section();
|
||||||
oldhandler = g_cnisrs[cn];
|
|
||||||
|
|
||||||
/* Are we attaching or detaching? */
|
/* 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) */
|
/* 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);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
return oldhandler;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* arch/mips/src/pic32mx/pic32mx.h
|
* 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>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* 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
|
* case, all attached handlers will be called. Each handler must maintain state
|
||||||
* and determine if the underlying GPIO input value changed.
|
* and determine if the underlying GPIO input value changed.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Input Parameters:
|
||||||
* - pinset: GPIO pin configuration
|
* pinset - GPIO pin configuration
|
||||||
* - cn: The change notification number associated with the pin
|
* cn - The change notification number associated with the pin.
|
||||||
* - handler: Interrupt handler (may be NULL to detach)
|
* handler - Interrupt handler (may be NULL to detach)
|
||||||
|
* arg - The argument that accompanies the interrupt
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returned Value:
|
||||||
* The previous value of the interrupt handler function pointer. This value may,
|
* Zero (OK) is returned on success. A negated error value is returned on
|
||||||
* for example, be used to restore the previous handler when multiple handlers are
|
* any failure to indicate the nature of the failure.
|
||||||
* used.
|
|
||||||
*
|
*
|
||||||
************************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_PIC32MX_GPIOIRQ
|
#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
|
#else
|
||||||
# define pic32mx_gpioattach(p,f) (NULL)
|
# define pic32mx_gpioattach(p,c,h,a) (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
|
|||||||
@@ -199,22 +199,20 @@ void pic32mz_gpioirqinitialize(void);
|
|||||||
* case, all attached handlers will be called. Each handler must maintain state
|
* case, all attached handlers will be called. Each handler must maintain state
|
||||||
* and determine if the underlying GPIO input value changed.
|
* and determine if the underlying GPIO input value changed.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* pinset - GPIO pin configuration
|
||||||
* - pinset: GPIO pin configuration
|
* handler - Interrupt handler (may be NULL to detach)
|
||||||
* - cn: The change notification number associated with the pin
|
* arg - The argument that accompanies the interrupt
|
||||||
* - handler: Interrupt handler (may be NULL to detach)
|
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returned Value:
|
||||||
* The previous value of the interrupt handler function pointer. This value may,
|
* Zero (OK) is returned on success. A negated error value is returned on
|
||||||
* for example, be used to restore the previous handler when multiple handlers are
|
* any failure to indicate the nature of the failure.
|
||||||
* used.
|
|
||||||
*
|
*
|
||||||
************************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_PIC32MZ_GPIOIRQ
|
#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
|
#else
|
||||||
# define pic32mz_gpioattach(p,f) (NULL)
|
# define pic32mz_gpioattach(p,h,a) (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
|
|||||||
@@ -78,9 +78,15 @@ static int pic32mz_cninterrupt(int irq, FAR void *context, FAR void *arg);
|
|||||||
* Public Data
|
* 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
|
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? */
|
/* Yes.. Has the user attached a handler? */
|
||||||
|
|
||||||
handler = handlers->handler[i];
|
handler = handlers->handler[i].entry;
|
||||||
if (handler)
|
if (handler)
|
||||||
{
|
{
|
||||||
/* Yes.. call the attached 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
|
/* Keep track of the status of the last handler that
|
||||||
* failed.
|
* failed.
|
||||||
@@ -365,22 +371,21 @@ void pic32mz_gpioirqinitialize(void)
|
|||||||
* In that case, all attached handlers will be called. Each handler must
|
* In that case, all attached handlers will be called. Each handler must
|
||||||
* maintain state and determine if the underlying GPIO input value changed.
|
* maintain state and determine if the underlying GPIO input value changed.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Input Parameters:
|
||||||
* - pinset: GPIO pin configuration
|
* pinset - GPIO pin configuration
|
||||||
* - pin: The change notification number associated with the pin.
|
* handler - Interrupt handler (may be NULL to detach)
|
||||||
* - handler: Interrupt handler (may be NULL to detach)
|
* arg - The argument that accompanies the interrupt
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returned Value:
|
||||||
* The previous value of the interrupt handler function pointer. This
|
* Zero (OK) is returned on success. A negated error value is returned on
|
||||||
* value may, for example, be used to restore the previous handler when
|
* any failure to indicate the nature of the failure.
|
||||||
* multiple handlers are used.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
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;
|
struct ioport_level2_s *handlers;
|
||||||
xcpt_t oldhandler = NULL;
|
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
uintptr_t base;
|
uintptr_t base;
|
||||||
int ioport;
|
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 */
|
/* Get the previously attached handler as the return value */
|
||||||
|
|
||||||
flags = enter_critical_section();
|
flags = enter_critical_section();
|
||||||
oldhandler = handlers->handler[pin];
|
|
||||||
|
|
||||||
/* Are we attaching or detaching? */
|
/* 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) */
|
/* 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);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return oldhandler;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
@@ -42,6 +42,7 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/board.h>
|
#include <nuttx/board.h>
|
||||||
@@ -69,28 +70,26 @@
|
|||||||
|
|
||||||
#if defined(CONFIG_AVR32_GPIOIRQ) && defined(CONFIG_ARCH_IRQBUTTONS) && \
|
#if defined(CONFIG_AVR32_GPIOIRQ) && defined(CONFIG_ARCH_IRQBUTTONS) && \
|
||||||
(defined(CONFIG_AVR32DEV_BUTTON1_IRQ) || defined(CONFIG_AVR32DEV_BUTTON2_IRQ))
|
(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 */
|
/* Attach the handler */
|
||||||
|
|
||||||
gpio_irqattach(irq, irqhandler, &oldhandler);
|
int ret = gpio_irqattach(irq, irqhandler, &oldhandler, arg);
|
||||||
|
if (ret >= 0)
|
||||||
/* Enable/disable the interrupt */
|
|
||||||
|
|
||||||
if (irqhandler)
|
|
||||||
{
|
{
|
||||||
gpio_irqenable(irq);
|
/* Enable/disable the interrupt */
|
||||||
}
|
|
||||||
else
|
if (irqhandler != NULL)
|
||||||
{
|
{
|
||||||
gpio_irqdisable(irq);
|
gpio_irqenable(irq);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gpio_irqdisable(irq);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the old button handler (so that it can be restored) */
|
return OK;
|
||||||
|
|
||||||
return oldhandler;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -143,8 +142,7 @@ uint8_t board_buttons(void)
|
|||||||
* Description:
|
* Description:
|
||||||
* This function may be called to register an interrupt handler that will
|
* 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
|
* be called when a button is depressed or released. The ID value is one
|
||||||
* of the BUTTON* definitions provided above. The previous interrupt
|
* of the BUTTON* definitions provided above.
|
||||||
* handler address isreturned (so that it may restored, if so desired).
|
|
||||||
*
|
*
|
||||||
* Configuration Notes:
|
* Configuration Notes:
|
||||||
* Configuration CONFIG_AVR32_GPIOIRQ must be selected to enable the
|
* 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)
|
#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
|
#ifdef CONFIG_AVR32DEV_BUTTON1_IRQ
|
||||||
if (id == BUTTON1)
|
if (id == BUTTON1)
|
||||||
{
|
{
|
||||||
return board_button_irqx(GPIO_BUTTON1_IRQ, irqhandler, arg);
|
ret = board_button_irqx(GPIO_BUTTON1_IRQ, irqhandler, arg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_AVR32DEV_BUTTON2_IRQ
|
#ifdef CONFIG_AVR32DEV_BUTTON2_IRQ
|
||||||
if (id == BUTTON2)
|
if (id == BUTTON2)
|
||||||
{
|
{
|
||||||
return board_button_irqx(GPIO_BUTTON2_IRQ, irqhandler, arg);
|
ret = board_button_irqx(GPIO_BUTTON2_IRQ, irqhandler, arg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
return NULL;
|
ret = -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif /* CONFIG_ARCH_BUTTONS */
|
#endif /* CONFIG_ARCH_BUTTONS */
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* configs/bambino-200e/src/lpc43_buttons.c
|
* 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>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
* Alan Carvalho de Assis acassis@gmail.com [nuttx] <nuttx@yahoogroups.com>
|
* 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
|
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)
|
#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
|
/* This array provides the mapping from button ID numbers to button IRQ
|
||||||
* numbers.
|
* numbers.
|
||||||
*/
|
*/
|
||||||
@@ -161,8 +155,7 @@ uint8_t board_buttons(void)
|
|||||||
* be called when a button is depressed or released. The ID value is a
|
* 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 enumeration value that uniquely identifies a button resource. See the
|
||||||
* BOARD_BUTTON_* and BOARD_JOYSTICK_* definitions in board.h for the meaning
|
* BOARD_BUTTON_* and BOARD_JOYSTICK_* definitions in board.h for the meaning
|
||||||
* of enumeration values. The previous interrupt handler address is returned
|
* of enumeration values.
|
||||||
* (so that it may restored, if so desired).
|
|
||||||
*
|
*
|
||||||
* Note that board_button_irq() also enables button interrupts. Button
|
* Note that board_button_irq() also enables button interrupts. Button
|
||||||
* interrupts will remain enabled after the interrupt handler is attached.
|
* 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)
|
#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;
|
irqstate_t flags;
|
||||||
int irq;
|
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)
|
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 */
|
/* Disable interrupts until we are done */
|
||||||
|
|
||||||
flags = enter_critical_section();
|
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 */
|
/* Attach then enable the new interrupt handler */
|
||||||
|
|
||||||
(void)irq_attach(irq, irqhandler, NULL);
|
(void)irq_attach(irq, irqhandler, arg);
|
||||||
up_enable_irq(irq);
|
up_enable_irq(irq);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -210,10 +197,11 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||||||
up_disable_irq(irq);
|
up_disable_irq(irq);
|
||||||
(void)irq_detach(irq);
|
(void)irq_detach(irq);
|
||||||
}
|
}
|
||||||
|
|
||||||
leave_critical_section(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
return oldhandler;
|
return OK;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -192,60 +192,5 @@
|
|||||||
|
|
||||||
void tiva_boardinitialize(void);
|
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 /* __ASSEMBLY__ */
|
||||||
#endif /* __CONFIGS_CC3200_LAUNCHPAD_INCLUDE_BOARD_H */
|
#endif /* __CONFIGS_CC3200_LAUNCHPAD_INCLUDE_BOARD_H */
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* configs/cloudctrl/src/stm32_buttons.c
|
* 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>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
* Darcy Gong <darcy.gong@gmail.com>
|
* Darcy Gong <darcy.gong@gmail.com>
|
||||||
*
|
*
|
||||||
@@ -41,6 +41,7 @@
|
|||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/board.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
|
* 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
|
* be called when a button is depressed or released. The ID value is a
|
||||||
* button enumeration value that uniquely identifies a button resource. See
|
* button enumeration value that uniquely identifies a button resource. See
|
||||||
* the
|
* the BUTTON_* and JOYSTICK_* definitions in board.h for the meaning of
|
||||||
* BUTTON_* and JOYSTICK_* definitions in board.h for the meaning of
|
* enumeration value.
|
||||||
* enumeration value. The previous interrupt handler address is returned
|
|
||||||
* (so that it may restored, if so desired).
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
#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 */
|
/* The following should be atomic */
|
||||||
|
|
||||||
if (id >= MIN_IRQBUTTON && id <= MAX_IRQBUTTON)
|
if (id >= MIN_IRQBUTTON && id <= MAX_IRQBUTTON)
|
||||||
{
|
{
|
||||||
oldhandler = stm32_gpiosetevent(g_buttons[id], true, true, true,
|
ret = stm32_gpiosetevent(g_buttons[id], true, true, true, irqhandler,
|
||||||
irqhandler, arg);
|
arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return oldhandler;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif /* CONFIG_ARCH_BUTTONS */
|
#endif /* CONFIG_ARCH_BUTTONS */
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* configs/cloudctrl/src/stm32_usb.c
|
* 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>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
* Darcy Gong <darcy.gong@gmail.com>
|
* Darcy Gong <darcy.gong@gmail.com>
|
||||||
*
|
*
|
||||||
@@ -274,16 +274,18 @@ void stm32_usbhost_vbusdrive(int iface, bool enable)
|
|||||||
*
|
*
|
||||||
* Input Parameter:
|
* Input Parameter:
|
||||||
* handler - New overcurrent interrupt handler
|
* handler - New overcurrent interrupt handler
|
||||||
|
* arg - The argument provided for the interrupt handler
|
||||||
*
|
*
|
||||||
* Returned value:
|
* 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
|
#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
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/board.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
|
* 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 enumeration value that uniquely identifies a button resource. See the
|
||||||
* BUTTON_* and JOYSTICK_* definitions in board.h for the meaning of enumeration
|
* BUTTON_* and JOYSTICK_* definitions in board.h for the meaning of enumeration
|
||||||
* value. The previous interrupt handler address is returned (so that it may
|
* value.
|
||||||
* restored, if so desired).
|
|
||||||
*
|
*
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_TIVA_GPIOP_IRQS)
|
#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;
|
static xcpt_t handler = NULL;
|
||||||
xcpt_t oldhandler = handler;
|
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
int ret;
|
int ret = -EINVAL;
|
||||||
|
|
||||||
/* Interrupts are supported only on ports P and Q and, hence, only on button SW4 */
|
/* 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)
|
if (irqhandler)
|
||||||
{
|
{
|
||||||
ret = irq_attach(IRQ_SW4, irqhandler, NULL);
|
ret = irq_attach(IRQ_SW4, irqhandler, arg);
|
||||||
if (ret == OK)
|
if (ret == OK)
|
||||||
{
|
{
|
||||||
handler = irqhandler;
|
handler = irqhandler;
|
||||||
@@ -186,7 +185,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||||||
leave_critical_section(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
return oldhandler;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif /* CONFIG_ARCH_BUTTONS */
|
#endif /* CONFIG_ARCH_BUTTONS */
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* configs/ea3131/src/lpc31_usbhost.c
|
* 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>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -82,12 +82,6 @@
|
|||||||
|
|
||||||
static struct usbhost_connection_s *g_ehciconn;
|
static struct usbhost_connection_s *g_ehciconn;
|
||||||
|
|
||||||
/* Overcurrent interrupt handler */
|
|
||||||
|
|
||||||
#if 0 /* Not yet implemented */
|
|
||||||
static xcpt_t g_ochandler;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
@@ -292,16 +286,16 @@ void lpc31_usbhost_vbusdrive(int rhport, bool enable)
|
|||||||
*
|
*
|
||||||
* Input parameter:
|
* Input parameter:
|
||||||
* handler - New overcurrent interrupt handler
|
* handler - New overcurrent interrupt handler
|
||||||
|
* arg - The argument that will accompany the interrupt
|
||||||
*
|
*
|
||||||
* Returned value:
|
* Returned value:
|
||||||
* Old overcurrent interrupt handler
|
* Zero (OK) returned on success; a negated errno value is returned on failure.
|
||||||
*
|
*
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
#if 0 /* Not ready yet */
|
#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;
|
irqstate_t flags;
|
||||||
|
|
||||||
/* Disable interrupts until we are done. This guarantees that the
|
/* 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();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Get the old button interrupt handler and save the new one */
|
|
||||||
|
|
||||||
oldhandler = g_ochandler;
|
|
||||||
g_ochandler = handler;
|
|
||||||
|
|
||||||
/* Configure the interrupt */
|
/* Configure the interrupt */
|
||||||
#warning Missing logic
|
#warning Missing logic
|
||||||
|
|
||||||
/* Return the old button handler (so that it can be restored) */
|
|
||||||
|
|
||||||
leave_critical_section(flags);
|
leave_critical_section(flags);
|
||||||
return oldhandler;
|
return OK;
|
||||||
}
|
}
|
||||||
#endif /* 0 */
|
#endif /* 0 */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* configs/fire-stm32v2/src/stm32_buttons.c
|
* 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>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -40,6 +40,7 @@
|
|||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/board.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
|
* be called when a button is depressed or released. The ID value is a
|
||||||
* button enumeration value that uniquely identifies a button resource. See
|
* button enumeration value that uniquely identifies a button resource. See
|
||||||
* the BUTTON_* and JOYSTICK_* definitions in board.h for the meaning of
|
* the BUTTON_* and JOYSTICK_* definitions in board.h for the meaning of
|
||||||
* enumeration values. The previous interrupt handler address is returned
|
* enumeration values.
|
||||||
* (so that it may restored, if so desired).
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
#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;
|
uint16_t gpio;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (id == BUTTON_KEY1)
|
if (id == BUTTON_KEY1)
|
||||||
{
|
{
|
||||||
@@ -148,7 +149,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return NULL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return stm32_gpiosetevent(gpio, true, true, true, irqhandler, arg);
|
return stm32_gpiosetevent(gpio, true, true, true, irqhandler, arg);
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/board.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
|
* will be called when a button is depressed or released. The ID value is
|
||||||
* a button enumeration value that uniquely identifies a button resource.
|
* a button enumeration value that uniquely identifies a button resource.
|
||||||
* See the BUTTON_* and JOYSTICK_* definitions in board.h for the meaning
|
* See the BUTTON_* and JOYSTICK_* definitions in board.h for the meaning
|
||||||
* of enumeration value. The previous interrupt handler address is
|
* of enumeration value.
|
||||||
* returned (so that it may restored, if so desired).
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
#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;
|
uint32_t pinset;
|
||||||
|
int ret;
|
||||||
|
|
||||||
/* Map the button id to the GPIO bit set. */
|
/* 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
|
else
|
||||||
{
|
{
|
||||||
return NULL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The button has already been configured as an interrupting input (by
|
/* 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.
|
* 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 ret;
|
||||||
return oldhandler;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif /* CONFIG_ARCH_BUTTONS */
|
#endif /* CONFIG_ARCH_BUTTONS */
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ int k64_sdhc_initialize(void)
|
|||||||
|
|
||||||
/* Attached the card detect interrupt (but don't enable it yet) */
|
/* 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 */
|
/* Configure the write protect GPIO -- None */
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/board.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
|
* will be called when a button is depressed or released. The ID value is
|
||||||
* a button enumeration value that uniquely identifies a button resource.
|
* a button enumeration value that uniquely identifies a button resource.
|
||||||
* See the BUTTON_* and JOYSTICK_* definitions in board.h for the meaning
|
* See the BUTTON_* and JOYSTICK_* definitions in board.h for the meaning
|
||||||
* of enumeration value. The previous interrupt handler address is
|
* of enumeration value.
|
||||||
* returned (so that it may restored, if so desired).
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
#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;
|
uint32_t pinset;
|
||||||
|
|
||||||
/* Map the button id to the GPIO bit set. */
|
/* 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
|
else
|
||||||
{
|
{
|
||||||
return NULL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The button has already been configured as an interrupting input (by
|
/* 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.
|
* 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 NULL;
|
||||||
return oldhandler;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif /* CONFIG_ARCH_BUTTONS */
|
#endif /* CONFIG_ARCH_BUTTONS */
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user