Rolando Pelayo
/
blink_led_threading
Blink two LEDs using RTOS
Diff: main.cpp
- Revision:
- 0:390b0a20e899
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Nov 21 20:12:41 2017 +0000 @@ -0,0 +1,33 @@ +#include "mbed.h" + +DigitalOut GENLED(PC_7); //LED for AD9833 output +DigitalOut DDSLED(PC_13); //LED for AD9850 output + +Thread GENthread; //create thread to allow simultaneous LED blink and DDS output +Thread LEDthread; + +//AD9833 LED thread +void GENBlinkThread() { + while (true) { + GENLED = !GENLED; + Thread::wait(1000); + } +} + +//AD9850 LED thread +void DDSBlinkThread() { + while (true) { + DDSLED = !DDSLED; + Thread::wait(500); + } +} + +int main() { + GENthread.start(callback(GENBlinkThread)); + LEDthread.start(callback(DDSBlinkThread)); + + GENthread.join(); //wait for the threads to finish + LEDthread.join(); + + while(1); +}