Zhe Hu
/
interruptTest
interrupt trigger on both rising and falling edge (for level sensitive triggering)
main.cpp
- Committer:
- iamhuzhe
- Date:
- 2010-07-22
- Revision:
- 0:caf032e2b330
File content as of revision 0:caf032e2b330:
#include "mbed.h" InterruptIn button(p8); DigitalIn bb(p8); DigitalOut led(LED4); DigitalOut flash(LED3); Timeout t1; Timeout t2; int b1; int b2; void flip_again() { if (bb==1) { led = 1; } b1 = 0; } void flip_again2() { if (bb==0) { led = 0; } b2 = 0; } void flip() { if (b1 == 0) { b1 = 1; t1.attach_us(&flip_again,100); } } void flip2() { if (b2 == 0) { b2 = 1; t2.attach_us(&flip_again2,100); } } int main() { button.mode(PullDown); button.rise(&flip); // attach the address of the flip function to the rising edge button.fall(&flip2); while (1) { // wait around, interrupts will interrupt this! flash = !flash; wait(1); } }