Rtos API example

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "cmsis_os.h"
00003 
00004 #if defined(MBED_RTOS_SINGLE_THREAD)
00005   #error [NOT_SUPPORTED] test not supported
00006 #endif
00007 
00008 DigitalOut led1(LED1);
00009 DigitalOut led2(LED2);
00010 
00011 void led2_thread(void const *argument) {
00012     while (true) {
00013         led2 = !led2;
00014         osDelay(1000);
00015     }
00016 }
00017 osThreadDef(led2_thread, osPriorityNormal, DEFAULT_STACK_SIZE);
00018 
00019 int main() {
00020     osThreadCreate(osThread(led2_thread), NULL);
00021 
00022     while (true) {
00023         led1 = !led1;
00024         osDelay(500);
00025     }
00026 }