Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-src by
Diff: common/InterruptIn.cpp
- Revision:
- 36:ab3ee77451e7
- Parent:
- 35:371630885ad6
- Child:
- 113:65a335a675de
--- a/common/InterruptIn.cpp Mon Oct 21 11:45:04 2013 +0100 +++ b/common/InterruptIn.cpp Wed Oct 23 14:15:04 2013 +0100 @@ -36,58 +36,22 @@ gpio_mode(&gpio, pull); } -pFunctionPointer_t InterruptIn::rise(void (*fptr)(void)) { - pFunctionPointer_t pf = NULL; - _rise.clear(); +void InterruptIn::rise(void (*fptr)(void)) { if (fptr) { - pf = _rise.add(fptr); + _rise.attach(fptr); gpio_irq_set(&gpio_irq, IRQ_RISE, 1); } else { gpio_irq_set(&gpio_irq, IRQ_RISE, 0); } - return pf; -} - -pFunctionPointer_t InterruptIn::rise_add_common(void (*fptr)(void), bool front) { - if (NULL == fptr) - return NULL; - pFunctionPointer_t pf = front ? _rise.add_front(fptr) : _rise.add(fptr); - gpio_irq_set(&gpio_irq, IRQ_RISE, 1); - return pf; } -bool InterruptIn::rise_remove(pFunctionPointer_t pf) { - bool res = _rise.remove(pf); - if (res && _rise.size() == 0) - gpio_irq_set(&gpio_irq, IRQ_RISE, 0); - return res; -} - -pFunctionPointer_t InterruptIn::fall(void (*fptr)(void)) { - pFunctionPointer_t pf = NULL; - _fall.clear(); +void InterruptIn::fall(void (*fptr)(void)) { if (fptr) { - pf = _fall.add(fptr); + _fall.attach(fptr); gpio_irq_set(&gpio_irq, IRQ_FALL, 1); } else { gpio_irq_set(&gpio_irq, IRQ_FALL, 0); } - return pf; -} - -pFunctionPointer_t InterruptIn::fall_add_common(void (*fptr)(void), bool front) { - if (NULL == fptr) - return NULL; - pFunctionPointer_t pf = front ? _fall.add_front(fptr) : _fall.add(fptr); - gpio_irq_set(&gpio_irq, IRQ_FALL, 1); - return pf; -} - -bool InterruptIn::fall_remove(pFunctionPointer_t pf) { - bool res = _fall.remove(pf); - if (res && _fall.size() == 0) - gpio_irq_set(&gpio_irq, IRQ_FALL, 0); - return res; } void InterruptIn::_irq_handler(uint32_t id, gpio_irq_event event) {