Zhe Hu
/
interruptTest
interrupt trigger on both rising and falling edge (for level sensitive triggering)
Revision 0:caf032e2b330, committed 2010-07-22
- Comitter:
- iamhuzhe
- Date:
- Thu Jul 22 02:33:32 2010 +0000
- Commit message:
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Jul 22 02:33:32 2010 +0000 @@ -0,0 +1,60 @@ +#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); + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Jul 22 02:33:32 2010 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9114680c05da