Devchannel Team
/
TestsRTOS
Learn how to use embedded RTOS (Beta version RTOS)
Diff: main.cpp
- Revision:
- 0:5bd42710f2e7
- Child:
- 1:4d067c712d03
diff -r 000000000000 -r 5bd42710f2e7 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Sep 03 00:06:32 2015 +0000 @@ -0,0 +1,36 @@ +#include "mbed.h" +#include "rtos.h" + +//------------------------------------ +// Serial configuration (Put on hyperterminal or Putty) +// 115200 bauds, 8-bit data, no parity +//------------------------------------ + +Serial serialIO(SERIAL_TX, SERIAL_RX); + +DigitalOut led1(LED1); +DigitalOut led2(LED2); + +void led2_thread(void const *args) { + while (true) { + led2 = !led2; + Thread::wait(800); + } +} + +int main() +{ + int i = 1; + // Configure the serial speed. + serialIO.baud(115200); + serialIO.printf("Learning Microcontrollers with mbed !\n"); + + // Start a thread to togle the led + Thread thread(led2_thread); + // Lock forever here... + while(1) { + wait(1); + serialIO.printf("This program runs since %d seconds.\n", i++); + led1 = !led1; + } +}