Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 #include "mbed.h" 00002 #include "rtos.h" 00003 00004 DigitalOut led(LED1); 00005 00006 void led_thread(void const *argument) { 00007 while (true) { 00008 // Signal flags that are reported as event are automatically cleared. 00009 osEvent evt = Thread::signal_wait(0); //Wait for any signal 00010 switch(evt.status) { 00011 case osOK: 00012 printf("osOK\n"); //no error or event occurred 00013 break; 00014 case osEventSignal: 00015 printf("osEventSignal = %#05x\n",evt.value.signals); //signal event occurred 00016 break; 00017 case osEventTimeout: 00018 printf("osEventTimeout\n"); //timeout occurred 00019 break; 00020 case osErrorValue: 00021 printf("osErrorValue\n"); //value of a parameter is out of range 00022 break; 00023 default: 00024 printf("Unknown error flag: %#08x\n",(uint32_t)evt.status); 00025 break; 00026 }; 00027 led = !led; 00028 } 00029 } 00030 00031 int main (void) { 00032 int32_t signal_mask = 0x1; 00033 Thread thread2(led_thread); 00034 while (true) { 00035 Thread::wait(1000); 00036 thread2.signal_set(signal_mask); 00037 signal_mask <<=1; 00038 if(signal_mask > 0x8000) signal_mask=0x1; 00039 } 00040 }
Generated on Thu Aug 25 2022 01:37:37 by
1.7.2