Joscha Ihl
/
Nucleo_rtos_basic
test
Diff: main.cpp
- Revision:
- 0:ddc3e2b74e99
diff -r 000000000000 -r ddc3e2b74e99 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Oct 17 07:27:07 2017 +0000 @@ -0,0 +1,38 @@ +#include "mbed.h" +#include "rtos.h" + +void print_char(char c = '*') +{ + printf("%c", c); + fflush(stdout); +} + +DigitalOut led1(LED1); +DigitalOut led1(LED2); + +void print_thread(void const *argument) +{ + while (true) { + Thread::wait(1000); + printf("Hallo Welt!!!\r\n"); + fflush(stdout); + } +} + +void t2(void const *arg) { + while(true) { + Thread::wait(100); + led2 = !led2; + } +} + +int main() +{ + printf("\n\n*** RTOS basic example ***\n"); + Thread thread(print_thread, NULL, osPriorityNormal, DEFAULT_STACK_SIZE); + Thread thread(t2, NULL, osPriorityNormal, DEFAULT_STACK_SIZE); + while (true) { + led1 = !led1; + Thread::wait(500); + } +}