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/sam4l-xplained | |
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/sam4l-xplained')
-rw-r--r-- | nuttx/configs/sam4l-xplained/src/sam_buttons.c | 21 |
1 files changed, 17 insertions, 4 deletions
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); } |