NuMaker GPIO Interrupt with Debounce Setting

Committer:
ccli8
Date:
Mon Oct 15 15:38:34 2018 +0800
Revision:
15:d825021a7e5b
Parent:
10:286c71f85d6f
Child:
17:707b60147ca6
Support NUMAKER_IOT_M487 and NUMAKER_PFM_M2351

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ccli8 6:b3369ce1a600 1 // GPIO interrupt to set led on/off
rkuo2000 0:29e056412215 2 #include "mbed.h"
ccli8 8:a479ab0a14ef 3
shliu1 5:b9b7cd06aaf0 4 #if defined(TARGET_NUMAKER_PFM_NUC472)
ccli8 8:a479ab0a14ef 5 InterruptIn button(SW1);
ccli8 8:a479ab0a14ef 6 DigitalOut led(LED1);
shliu1 5:b9b7cd06aaf0 7 #elif defined(TARGET_NUMAKER_PFM_M453)
ccli8 8:a479ab0a14ef 8 InterruptIn button(SW2);
ccli8 8:a479ab0a14ef 9 DigitalOut led(LED1);
ccli8 8:a479ab0a14ef 10 #elif defined(TARGET_NUMAKER_PFM_M487)
ccli8 8:a479ab0a14ef 11 InterruptIn button(SW2);
ccli8 8:a479ab0a14ef 12 DigitalOut led(LED1);
ccli8 15:d825021a7e5b 13 #elif defined(TARGET_NUMAKER_IOT_M487)
ccli8 15:d825021a7e5b 14 InterruptIn button(SW2);
ccli8 15:d825021a7e5b 15 DigitalOut led(LED1);
ccchang 10:286c71f85d6f 16 #elif defined(TARGET_NUMAKER_PFM_NANO130)
ccchang 10:286c71f85d6f 17 InterruptIn button(SW2);
ccchang 10:286c71f85d6f 18 DigitalOut led(LED1);
ccli8 15:d825021a7e5b 19 #elif defined(TARGET_NUMAKER_PFM_M2351)
ccli8 15:d825021a7e5b 20 InterruptIn button(SW2);
ccli8 15:d825021a7e5b 21 DigitalOut led(LED1);
shliu1 5:b9b7cd06aaf0 22 #endif
rkuo2000 0:29e056412215 23
rkuo2000 0:29e056412215 24 void flip() {
rkuo2000 0:29e056412215 25 led = !led;
rkuo2000 0:29e056412215 26 }
rkuo2000 0:29e056412215 27
rkuo2000 0:29e056412215 28 int main() {
ccli8 2:15b06747ce59 29 button.rise(&flip);
rkuo2000 0:29e056412215 30 }