mbed library sources, mbed-dev only for TYBLE16
Fork of mbed-dev by
Please refer flowing link.
/users/kenjiArai/notebook/tyble16-module-will-become-a-mbed-family--mbedliza/
Diff: drivers/InterruptIn.cpp
- Revision:
- 175:af195413fb11
- Parent:
- 160:d5399cc887bb
--- a/drivers/InterruptIn.cpp Mon Oct 02 15:33:19 2017 +0100 +++ b/drivers/InterruptIn.cpp Wed Oct 11 12:45:49 2017 +0100 @@ -19,17 +19,12 @@ namespace mbed { -static void donothing() {} - InterruptIn::InterruptIn(PinName pin) : gpio(), gpio_irq(), - _rise(), - _fall() { + _rise(NULL), + _fall(NULL) { // No lock needed in the constructor - _rise = donothing; - _fall = donothing; - gpio_irq_init(&gpio_irq, pin, (&InterruptIn::_irq_handler), (uint32_t)this); gpio_init_in(&gpio, pin); } @@ -56,7 +51,7 @@ _rise = func; gpio_irq_set(&gpio_irq, IRQ_RISE, 1); } else { - _rise = donothing; + _rise = NULL; gpio_irq_set(&gpio_irq, IRQ_RISE, 0); } core_util_critical_section_exit(); @@ -68,7 +63,7 @@ _fall = func; gpio_irq_set(&gpio_irq, IRQ_FALL, 1); } else { - _fall = donothing; + _fall = NULL; gpio_irq_set(&gpio_irq, IRQ_FALL, 0); } core_util_critical_section_exit(); @@ -77,8 +72,16 @@ void InterruptIn::_irq_handler(uint32_t id, gpio_irq_event event) { InterruptIn *handler = (InterruptIn*)id; switch (event) { - case IRQ_RISE: handler->_rise(); break; - case IRQ_FALL: handler->_fall(); break; + case IRQ_RISE: + if (handler->_rise) { + handler->_rise(); + } + break; + case IRQ_FALL: + if (handler->_fall) { + handler->_fall(); + } + break; case IRQ_NONE: break; } }