Ryuichiro Ohira / Mbed 2 deprecated rtos-test

Dependencies:   mbed-rtos mbed

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 DigitalOut led1(LED1);
00005 DigitalOut led2(LED2);
00006 Serial pc(USBTX , USBRX);
00007     
00008 void led2_thread(void const *args){
00009     while (true) {
00010         led2 = !led2;
00011         osDelay(1000);
00012     }
00013 }
00014 
00015 void serial_thread(const void *args){
00016     pc.baud(115200);
00017     while(true){
00018         pc.putc(pc.getc());
00019     }
00020 }
00021 
00022 osThreadDef(serial_thread, osPriorityNormal, DEFAULT_STACK_SIZE);
00023 osThreadDef(led2_thread, osPriorityNormal, DEFAULT_STACK_SIZE);
00024 
00025 int main() {
00026     osThreadCreate(osThread(led2_thread), NULL);
00027     osThreadCreate(osThread(serial_thread), NULL);
00028     while(true);
00029 }