Kinetis: GPIO interrupt handling needs handler argument.

This commit is contained in:
Gregory Nutt
2017-02-27 07:20:21 -06:00
parent b3222bbc8a
commit 6e2ee2b07f
8 changed files with 25 additions and 15 deletions
+2 -1
View File
@@ -490,6 +490,7 @@ void kinetis_pinirqinitialize(void);
* Parameters: * Parameters:
* - pinset: Pin configuration * - pinset: Pin configuration
* - pinisr: Pin interrupt service routine * - pinisr: Pin interrupt service routine
* - arg: And argument that will be provided to the interrupt service routine.
* *
* Returns: * Returns:
* The previous value of the interrupt handler function pointer. This value may, * The previous value of the interrupt handler function pointer. This value may,
@@ -498,7 +499,7 @@ void kinetis_pinirqinitialize(void);
* *
************************************************************************************/ ************************************************************************************/
xcpt_t kinetis_pinirqattach(uint32_t pinset, xcpt_t pinisr); xcpt_t kinetis_pinirqattach(uint32_t pinset, xcpt_t pinisr, void *arg);
/************************************************************************************ /************************************************************************************
* Name: kinetis_pinirqenable * Name: kinetis_pinirqenable
+17 -8
View File
@@ -73,6 +73,12 @@
* Private Types * Private Types
****************************************************************************/ ****************************************************************************/
struct kinetis_pinirq_s
{
xcpt_t handler;
void *arg;
};
/**************************************************************************** /****************************************************************************
* Private Data * Private Data
****************************************************************************/ ****************************************************************************/
@@ -84,19 +90,19 @@
*/ */
#ifdef CONFIG_KINETIS_PORTAINTS #ifdef CONFIG_KINETIS_PORTAINTS
static xcpt_t g_portaisrs[32]; static struct kinetis_pinirq_s g_portaisrs[32];
#endif #endif
#ifdef CONFIG_KINETIS_PORTBINTS #ifdef CONFIG_KINETIS_PORTBINTS
static xcpt_t g_portbisrs[32]; static struct kinetis_pinirq_s g_portbisrs[32];
#endif #endif
#ifdef CONFIG_KINETIS_PORTCINTS #ifdef CONFIG_KINETIS_PORTCINTS
static xcpt_t g_portcisrs[32]; static struct kinetis_pinirq_s g_portcisrs[32];
#endif #endif
#ifdef CONFIG_KINETIS_PORTDINTS #ifdef CONFIG_KINETIS_PORTDINTS
static xcpt_t g_portdisrs[32]; static struct kinetis_pinirq_s g_portdisrs[32];
#endif #endif
#ifdef CONFIG_KINETIS_PORTEINTS #ifdef CONFIG_KINETIS_PORTEINTS
static xcpt_t g_porteisrs[32]; static struct kinetis_pinirq_s g_porteisrs[32];
#endif #endif
/**************************************************************************** /****************************************************************************
@@ -113,7 +119,7 @@ static xcpt_t g_porteisrs[32];
#ifdef HAVE_PORTINTS #ifdef HAVE_PORTINTS
static int kinetis_portinterrupt(int irq, FAR void *context, static int kinetis_portinterrupt(int irq, FAR void *context,
uintptr_t addr, xcpt_t *isrtab) uintptr_t addr, struct kinetis_pinirq_s *isrtab)
{ {
uint32_t isfr = getreg32(addr); uint32_t isfr = getreg32(addr);
int i; int i;
@@ -138,9 +144,12 @@ static int kinetis_portinterrupt(int irq, FAR void *context,
if (isrtab[i]) if (isrtab[i])
{ {
xcpt_t handler = isrtab[i].handler;
void *arg = isrtab[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
@@ -263,7 +272,7 @@ void kinetis_pinirqinitialize(void)
* *
****************************************************************************/ ****************************************************************************/
xcpt_t kinetis_pinirqattach(uint32_t pinset, xcpt_t pinisr) xcpt_t kinetis_pinirqattach(uint32_t pinset, xcpt_t pinisr, void *arg)
{ {
#ifdef HAVE_PORTINTS #ifdef HAVE_PORTINTS
xcpt_t *isrtab; xcpt_t *isrtab;
+1 -1
View File
@@ -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); kinetis_pinirqattach(GPIO_SD_CARDDETECT, k64_cdinterrupt, NULL);
/* Configure the write protect GPIO -- None */ /* Configure the write protect GPIO -- None */
+1 -1
View File
@@ -163,7 +163,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler)
* Attach the new button handler. * Attach the new button handler.
*/ */
oldhandler = kinetis_pinirqattach(pinset, irqhandler); oldhandler = 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 */
+1 -1
View File
@@ -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); kinetis_pinirqattach(GPIO_SD_CARDDETECT, k66_cdinterrupt, NULL);
/* Configure the write protect GPIO -- None */ /* Configure the write protect GPIO -- None */
+1 -1
View File
@@ -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); 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 */
+1 -1
View File
@@ -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); kinetis_pinirqattach(GPIO_SD_CARDDETECT, kinetis_cdinterrupt, NULL);
/* Configure the write protect GPIO */ /* Configure the write protect GPIO */
+1 -1
View File
@@ -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); kinetis_pinirqattach(GPIO_SD_CARDDETECT, k64_cdinterrupt, NULL);
/* Configure the write protect GPIO -- None */ /* Configure the write protect GPIO -- None */