Basic example showing the CMSIS-RTOS signals API

Dependencies:   mbed mbed-rtos

mbed 2 and mbed OS 5

This is an mbed 2 example. mbed OS 5 has integrated the mbed library with mbed-rtos. For an mbed-os example, please see:

Import programrtos_signals

signals example

main.cpp

Committer:
emilmont
Date:
2012-07-13
Revision:
1:8281c17352c6
Parent:
0:9197b24e0e31
Child:
2:7dc6330b7848

File content as of revision 1:8281c17352c6:

#include "mbed.h"
#include "cmsis_os.h"

DigitalOut led(LED1);

void led_thread(void const *argument) {
    while (true) {
        // Signal flags that are reported as event are automatically cleared.
        osSignalWait(0x1, osWaitForever);
        led = !led;
    }
}
osThreadDef(led_thread, osPriorityNormal, DEFAULT_STACK_SIZE);

int main (void) {
    osThreadId tid = osThreadCreate(osThread(led_thread), NULL);
    
    while (true) {
        osDelay(1000);
        osSignalSet(tid, 0x1);
    }
}