Basic example showing the Signals API
mbed 2 and mbed OS 5
This is an mbed 2 example. mbed OS 5 has intergrated the mbed library with mbed-rtos. For an mbed-os example, please see:
Import programrtos_signals
signals example
main.cpp
- Committer:
- mbed_official
- Date:
- 2017-02-15
- Revision:
- 6:8359b29626dc
- Parent:
- 5:476186ff82cf
File content as of revision 6:8359b29626dc:
#include "mbed.h" #include "rtos.h" DigitalOut led(LED1); void led_thread() { while (true) { // Signal flags that are reported as event are automatically cleared. Thread::signal_wait(0x1); led = !led; } } int main (void) { Thread thread; thread.start(callback(led_thread)); while (true) { Thread::wait(1000); thread.signal_set(0x1); } }