Several other interrupt button implementations had the same problem as did the sam4s-xplained

This commit is contained in:
Gregory Nutt 2014-06-15 12:55:48 -06:00
parent 4bac220b77
commit b013a0fa48
5 changed files with 59 additions and 16 deletions

View File

@ -94,11 +94,24 @@ static xcpt_t board_button_irqx(int irq, xcpt_t irqhandler, xcpt_t *store)
oldhandler = *store;
*store = irqhandler;
/* Configure the interrupt */
/* Are we attaching or detaching? */
if (irqhandler != NULL)
{
/* Configure the interrupt */
sam_gpioirq(irq);
(void)irq_attach(irq, irqhandler);
sam_gpioirqenable(irq);
}
else
{
/* Detach and disable the interrupt */
(void)irq_detach(irq)
sam_gpioirqdisable(irq);
}
sam_gpioirq(irq);
(void)irq_attach(irq, irqhandler);
sam_gpioirqenable(irq);
irqrestore(flags);
/* Return the old button handler (so that it can be restored) */

View File

@ -96,11 +96,24 @@ static xcpt_t board_button_irqx(int irq, xcpt_t irqhandler, xcpt_t *store)
oldhandler = *store;
*store = irqhandler;
/* Configure the interrupt */
/* Are we attaching or detaching? */
if (irqhandler != NULL)
{
/* Configure the interrupt */
sam_gpioirq(irq);
(void)irq_attach(irq, irqhandler);
sam_gpioirqenable(irq);
}
else
{
/* Detach and disable the interrupt */
(void)irq_detach(irq)
sam_gpioirqdisable(irq);
}
sam_gpioirq(irq);
(void)irq_attach(irq, irqhandler);
sam_gpioirqenable(irq);
irqrestore(flags);
/* Return the old button handler (so that it can be restored) */

View File

@ -142,11 +142,24 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler)
oldhandler = *g_irqsw0;
*g_irqsw0 = irqhandler;
/* Configure the interrupt */
/* Are we attaching or detaching? */
if (irqhandler != NULL)
{
/* Configure the interrupt */
sam_gpioirq(IRQ_SW0);
(void)irq_attach(IRQ_SW0, irqhandler);
sam_gpioirqenable(IRQ_SW0);
}
else
{
/* Detach and disable the interrupt */
(void)irq_detach(IRQ_SW0)
sam_gpioirqdisable(IRQ_SW0);
}
sam_gpioirq(IRQ_SW0);
(void)irq_attach(IRQ_SW0, irqhandler);
sam_gpioirqenable(IRQ_SW0);
irqrestore(flags);
}

View File

@ -1,7 +1,7 @@
/****************************************************************************
* configs/sure-pic32mx/src/pic32mx_buttons.c
*
* Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved.
* Copyright (C) 2011, 2013-2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -211,12 +211,14 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler)
if (id < NUM_BUTTONS)
{
pic32mx_gpioirqdisable(g_buttoncn[id]);
oldhandler = pic32mx_gpioattach(g_buttonset[id], g_buttoncn[id], irqhandler);
if (irqbuttron)
if (irqhandler != NULL)
{
pic32mx_gpioirqenable(g_buttoncn[id]);
}
}
return oldhandler;
}
#endif

View File

@ -1,7 +1,7 @@
/****************************************************************************
* configs/ubw32/src/board_buttons.c
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -186,12 +186,14 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler)
if (id < NUM_BUTTONS)
{
pic32mx_gpioirqdisable(g_buttoncn[id]);
oldhandler = pic32mx_gpioattach(g_buttonset[id], g_buttoncn[id], irqhandler);
if (irqbuttron)
if (irqhandler)
{
pic32mx_gpioirqenable(g_buttoncn[id]);
}
}
return oldhandler;
}
#endif