mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
Kinetis 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:
@@ -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 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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 */
|
||||||
|
|
||||||
|
|||||||
@@ -139,7 +139,6 @@ uint8_t board_buttons(void)
|
|||||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||||
xcpt_t board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
xcpt_t 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. */
|
||||||
@@ -163,12 +162,12 @@ 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);
|
(void)kinetis_pinirqattach(pinset, irqhandler, NULL);
|
||||||
|
|
||||||
/* Then make sure that interrupts are enabled on the pin */
|
/* Then make sure that interrupts are enabled on the pin */
|
||||||
|
|
||||||
kinetis_pinirqenable(pinset);
|
kinetis_pinirqenable(pinset);
|
||||||
return oldhandler;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif /* CONFIG_ARCH_BUTTONS */
|
#endif /* CONFIG_ARCH_BUTTONS */
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ int k66_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, k66_cdinterrupt, NULL);
|
(void)kinetis_pinirqattach(GPIO_SD_CARDDETECT, k66_cdinterrupt, NULL);
|
||||||
|
|
||||||
/* Configure the write protect GPIO -- None */
|
/* Configure the write protect GPIO -- None */
|
||||||
|
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ int board_app_initialize(uintptr_t arg)
|
|||||||
/* Attached the card detect interrupt (but don't enable it yet) */
|
/* Attached the card detect interrupt (but don't enable it yet) */
|
||||||
|
|
||||||
kinetis_pinconfig(GPIO_SD_CARDDETECT);
|
kinetis_pinconfig(GPIO_SD_CARDDETECT);
|
||||||
kinetis_pinirqattach(GPIO_SD_CARDDETECT, kinetis_cdinterrupt, NULL);
|
(void)kinetis_pinirqattach(GPIO_SD_CARDDETECT, kinetis_cdinterrupt, NULL);
|
||||||
|
|
||||||
/* Mount the SDHC-based MMC/SD block driver */
|
/* Mount the SDHC-based MMC/SD block driver */
|
||||||
/* First, get an instance of the SDHC interface */
|
/* First, get an instance of the SDHC interface */
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ int board_app_initialize(uintptr_t arg)
|
|||||||
/* Attached the card detect interrupt (but don't enable it yet) */
|
/* Attached the card detect interrupt (but don't enable it yet) */
|
||||||
|
|
||||||
kinetis_pinconfig(GPIO_SD_CARDDETECT);
|
kinetis_pinconfig(GPIO_SD_CARDDETECT);
|
||||||
kinetis_pinirqattach(GPIO_SD_CARDDETECT, kinetis_cdinterrupt, NULL);
|
(void)kinetis_pinirqattach(GPIO_SD_CARDDETECT, kinetis_cdinterrupt, NULL);
|
||||||
|
|
||||||
/* Configure the write protect GPIO */
|
/* Configure the write protect GPIO */
|
||||||
|
|
||||||
|
|||||||
@@ -166,7 +166,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 */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user