summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nuttx/configs/sam3u-ek/src/up_buttons.c21
-rw-r--r--nuttx/configs/sam4e-ek/src/sam_buttons.c21
-rw-r--r--nuttx/configs/sam4l-xplained/src/sam_buttons.c21
-rw-r--r--nuttx/configs/sure-pic32mx/src/pic32mx_buttons.c6
-rw-r--r--nuttx/configs/ubw32/src/up_buttons.c6
5 files changed, 59 insertions, 16 deletions
diff --git a/nuttx/configs/sam3u-ek/src/up_buttons.c b/nuttx/configs/sam3u-ek/src/up_buttons.c
index 8406025de..f188d396e 100644
--- a/nuttx/configs/sam3u-ek/src/up_buttons.c
+++ b/nuttx/configs/sam3u-ek/src/up_buttons.c
@@ -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) */
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) */
diff --git a/nuttx/configs/sam4l-xplained/src/sam_buttons.c b/nuttx/configs/sam4l-xplained/src/sam_buttons.c
index 13401d3ac..f0e7459fe 100644
--- a/nuttx/configs/sam4l-xplained/src/sam_buttons.c
+++ b/nuttx/configs/sam4l-xplained/src/sam_buttons.c
@@ -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);
}
diff --git a/nuttx/configs/sure-pic32mx/src/pic32mx_buttons.c b/nuttx/configs/sure-pic32mx/src/pic32mx_buttons.c
index 2e91cf193..b29bb73fa 100644
--- a/nuttx/configs/sure-pic32mx/src/pic32mx_buttons.c
+++ b/nuttx/configs/sure-pic32mx/src/pic32mx_buttons.c
@@ -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
diff --git a/nuttx/configs/ubw32/src/up_buttons.c b/nuttx/configs/ubw32/src/up_buttons.c
index abc6e70f9..c1fa1125b 100644
--- a/nuttx/configs/ubw32/src/up_buttons.c
+++ b/nuttx/configs/ubw32/src/up_buttons.c
@@ -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