mbed-src updated for BMD-200 evaluation board. Just pin numbers are updated.
Dependents: mbed_blinky-bmd-200 bmd-200_accel_demo firstRig
Fork of mbed-src by
Replacement for the "mbed" or "mbed-src" library when using the BMD-200 Evaluation kit. This library only remaps the pin names (i.e. LED1 points to p0.01 instead of p0.18, etc) as used by the BMD-200 Evaluation board (select the nRF51822_mkit platform). All other code is untouched.
Diff: common/InterruptIn.cpp
- Revision:
- 15:4892fe388435
- Parent:
- 13:0645d8841f51
- Child:
- 35:371630885ad6
--- a/common/InterruptIn.cpp Mon Aug 05 14:54:27 2013 +0000 +++ b/common/InterruptIn.cpp Wed Aug 07 16:43:59 2013 +0300 @@ -36,22 +36,58 @@ gpio_mode(&gpio, pull); } -void InterruptIn::rise(void (*fptr)(void)) { +pFunctionPointer_t InterruptIn::rise(void (*fptr)(void)) { + pFunctionPointer_t pf = NULL; + _rise.clear(); if (fptr) { - _rise.attach(fptr); + pf = _rise.add(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; } -void InterruptIn::fall(void (*fptr)(void)) { +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(); if (fptr) { - _fall.attach(fptr); + pf = _fall.add(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) {