mirror of
https://github.com/apache/nuttx.git
synced 2026-06-01 16:59:28 +08:00
Kinetis-L GPIO: Pin IRQ logic no longer returns the xcpt_t oldhandler. There value is useless and dangerous after the recent changes to interrupt argument passing.
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -76,6 +76,12 @@
|
|||||||
* Private Types
|
* Private Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
struct g_portisrs_s
|
||||||
|
{
|
||||||
|
xcpt_t handler; /* Entery hander 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,19 +228,19 @@ 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 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user