mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 05:16:47 +08:00
Kinetis: GPIO interrupt handling needs handler argument.
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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 */
|
||||||
|
|
||||||
|
|||||||
@@ -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 */
|
||||||
|
|
||||||
|
|||||||
@@ -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 */
|
||||||
|
|
||||||
|
|||||||
@@ -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 */
|
||||||
|
|||||||
@@ -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 */
|
||||||
|
|
||||||
|
|||||||
@@ -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 */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user