summaryrefslogtreecommitdiff
path: root/nuttx/configs/sam4e-ek
diff options
context:
space:
mode:
Diffstat (limited to 'nuttx/configs/sam4e-ek')
-rw-r--r--nuttx/configs/sam4e-ek/src/sam_buttons.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/nuttx/configs/sam4e-ek/src/sam_buttons.c b/nuttx/configs/sam4e-ek/src/sam_buttons.c
index 9f6283878..72ef722a5 100644
--- a/nuttx/configs/sam4e-ek/src/sam_buttons.c
+++ b/nuttx/configs/sam4e-ek/src/sam_buttons.c
@@ -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) */