diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-06-15 12:55:48 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2014-06-15 12:55:48 -0600 |
commit | 70b01d5396e2931ade9452925dc1e96be2318012 (patch) | |
tree | 0386113962e015a8484ba62d7a7bdfd7c99646a3 /nuttx/configs/sam3u-ek/src | |
parent | 7636dea84eff349751d95712a43b385d1ddd9346 (diff) | |
download | px4-nuttx-70b01d5396e2931ade9452925dc1e96be2318012.tar.gz px4-nuttx-70b01d5396e2931ade9452925dc1e96be2318012.tar.bz2 px4-nuttx-70b01d5396e2931ade9452925dc1e96be2318012.zip |
Several other interrupt button implementations had the same problem as did the sam4s-xplained
Diffstat (limited to 'nuttx/configs/sam3u-ek/src')
-rw-r--r-- | nuttx/configs/sam3u-ek/src/up_buttons.c | 21 |
1 files changed, 17 insertions, 4 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) */ |