Nuvoton
/
NuMaker-mbed-GPIO_Interrupt
NuMaker GPIO Interrupt with Debounce Setting
main.cpp@6:b3369ce1a600, 2017-05-04 (annotated)
- Committer:
- ccli8
- Date:
- Thu May 04 14:28:12 2017 +0800
- Revision:
- 6:b3369ce1a600
- Parent:
- 5:b9b7cd06aaf0
- Child:
- 8:a479ab0a14ef
[NUC472/M453] Support debounce setting for separate pin
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ccli8 |
6:b3369ce1a600 | 1 | // GPIO interrupt to set led on/off |
rkuo2000 | 0:29e056412215 | 2 | #include "mbed.h" |
shliu1 |
5:b9b7cd06aaf0 | 3 | #if defined(TARGET_NUMAKER_PFM_NUC472) |
ccli8 |
2:15b06747ce59 | 4 | InterruptIn button(SW1); // Button SW1 |
ccli8 |
6:b3369ce1a600 | 5 | DigitalOut led(LED1); // Flash LED1 |
shliu1 |
5:b9b7cd06aaf0 | 6 | #elif defined(TARGET_NUMAKER_PFM_M453) |
ccli8 |
6:b3369ce1a600 | 7 | InterruptIn button(SW2); // Button SW2 |
ccli8 |
6:b3369ce1a600 | 8 | DigitalOut led(LED1); // Flash LED1 |
shliu1 |
5:b9b7cd06aaf0 | 9 | #endif |
rkuo2000 | 0:29e056412215 | 10 | |
rkuo2000 | 0:29e056412215 | 11 | void flip() { |
rkuo2000 | 0:29e056412215 | 12 | led = !led; |
rkuo2000 | 0:29e056412215 | 13 | } |
rkuo2000 | 0:29e056412215 | 14 | |
rkuo2000 | 0:29e056412215 | 15 | int main() { |
ccli8 |
2:15b06747ce59 | 16 | button.rise(&flip); |
rkuo2000 | 0:29e056412215 | 17 | } |