Zhe Hu
/
interruptTest2
interrupt rising/falling edge test
Revision 0:bdf893fb0228, committed 2010-07-22
- Comitter:
- iamhuzhe
- Date:
- Thu Jul 22 01:35:19 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 |
diff -r 000000000000 -r bdf893fb0228 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Jul 22 01:35:19 2010 +0000 @@ -0,0 +1,32 @@ +#include "mbed.h" + +BusOut leds( LED4, LED3, LED2, LED1 ); +char count; + +InterruptIn button( p16 ); // interrupt instance for the button +Timer t; // To manage debounce by menchanical switch + +#define DEBOUNCING_INTERVAL 20 // Debouncing interval (in mili-seconds) + +void isr_buton( void ) { + if ( t.read_ms() > DEBOUNCING_INTERVAL ) { + leds = (count++) & 0xF; + } + t.reset(); // timer reset +} + +void isr_button2(void) { + if ( t.read_ms() > DEBOUNCING_INTERVAL ) { + leds = (count--) & 0xF; + } + t.reset(); // timer reset +} + +int main() { + count = 0; + t.start(); // timer start + button.rise( &isr_buton ); + button.fall(&isr_button2); + while ( 1 ) { + } +} \ No newline at end of file
diff -r 000000000000 -r bdf893fb0228 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Jul 22 01:35:19 2010 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9114680c05da