Tyari Taylor
/
Ticke_ISR_OS
operational with OS5
Revision 67:ac8bdee1a3ef, committed 2018-08-23
- Comitter:
- Tyari21
- Date:
- Thu Aug 23 14:07:48 2018 +0000
- Parent:
- 66:0a43d8aeeb76
- Commit message:
- Ticker operational with OS5
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Jun 26 17:52:09 2018 +0000 +++ b/main.cpp Thu Aug 23 14:07:48 2018 +0000 @@ -1,14 +1,20 @@ #include "mbed.h" - + +Ticker flipper; DigitalOut led1(LED1); - -// main() runs in its own thread in the OS +DigitalOut led2(LED2); + +void flip() { + led2 = !led2; +} + int main() { - while (true) { - led1 = !led1; - wait(0.02); + led2 = 1; + flipper.attach(&flip, 0.2); // the address of the function to be attached (flip) and the interval (2 seconds) + + // spin in a main loop. flipper will interrupt it to call flip + while(1) { led1 = !led1; - wait(0.02); + wait(2.0); // A long delay here shows the interrupts occur during a wait statement } -} - +} \ No newline at end of file