István Cserny / Mbed 2 deprecated Lab08_signals_to_main

Dependencies:   mbed mbed-rtos

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "rtos.h"
00003  
00004 DigitalOut led(LED1);
00005 osThreadId mainThreadID;
00006  
00007 void signal_thread(void const *argument) {
00008     while (true) {
00009         Thread::wait(1000);
00010         osSignalSet(mainThreadID, 0x1);
00011     }
00012 }
00013  
00014 int main (void) {
00015     mainThreadID = Thread::gettid();
00016     Thread thread(signal_thread);
00017     
00018     while (true) {
00019         // Signal flags that are reported as event are automatically cleared.
00020         osSignalWait(0x1, osWaitForever);
00021         led = !led;
00022     }
00023 }