NuMaker GPIO Interrupt with Debounce Setting

Committer:
cyliang
Date:
Thu Oct 24 09:46:38 2019 +0000
Revision:
17:707b60147ca6
Parent:
15:d825021a7e5b
Child:
18:a53eb3c1d7b7
Upgrade code, config & OS for NuMaker-IoT-M263A

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);
cyliang 17:707b60147ca6 22 #elif defined(TARGET_NUMAKER_IOT_M263A)
cyliang 17:707b60147ca6 23 InterruptIn button(PG_4); // Button1 (SW10)
cyliang 17:707b60147ca6 24 DigitalOut led(LED1);
shliu1 5:b9b7cd06aaf0 25 #endif
rkuo2000 0:29e056412215 26
rkuo2000 0:29e056412215 27 void flip() {
rkuo2000 0:29e056412215 28 led = !led;
rkuo2000 0:29e056412215 29 }
rkuo2000 0:29e056412215 30
rkuo2000 0:29e056412215 31 int main() {
ccli8 2:15b06747ce59 32 button.rise(&flip);
rkuo2000 0:29e056412215 33 }