mbed_example
/
rtos_threading_with_callback
simple threading example with callback
main.cpp
- Committer:
- sarahmarshy
- Date:
- 2017-06-23
- Revision:
- 1:5938bdb7b0bb
- Parent:
- 0:d4b2a035ffe3
File content as of revision 1:5938bdb7b0bb:
#include "mbed.h" Thread thread; DigitalOut led1(LED1); volatile bool running = true; // Blink function toggles the led in a long running loop void blink(DigitalOut *led) { while (running) { *led = !*led; wait(1); } } // Spawns a thread to run blink for 5 seconds int main() { thread.start(callback(blink, &led1)); wait(5); running = false; thread.join(); }