![](/media/cache/profiles/af7fc8485f40dc495bc626d6dbe7faf1.50x50_q85.png)
Basic example showing the CMSIS-RTOS signals API
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@2:7dc6330b7848, 2012-11-23 (annotated)
- Committer:
- emilmont
- Date:
- Fri Nov 23 10:55:55 2012 +0000
- Revision:
- 2:7dc6330b7848
- Parent:
- 1:8281c17352c6
update libraries
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
emilmont | 1:8281c17352c6 | 1 | #include "mbed.h" |
emilmont | 1:8281c17352c6 | 2 | #include "cmsis_os.h" |
emilmont | 1:8281c17352c6 | 3 | |
emilmont | 1:8281c17352c6 | 4 | DigitalOut led(LED1); |
emilmont | 1:8281c17352c6 | 5 | |
emilmont | 2:7dc6330b7848 | 6 | void led_thread(void const *args) { |
emilmont | 1:8281c17352c6 | 7 | while (true) { |
emilmont | 1:8281c17352c6 | 8 | // Signal flags that are reported as event are automatically cleared. |
emilmont | 1:8281c17352c6 | 9 | osSignalWait(0x1, osWaitForever); |
emilmont | 1:8281c17352c6 | 10 | led = !led; |
emilmont | 1:8281c17352c6 | 11 | } |
emilmont | 1:8281c17352c6 | 12 | } |
emilmont | 1:8281c17352c6 | 13 | osThreadDef(led_thread, osPriorityNormal, DEFAULT_STACK_SIZE); |
emilmont | 1:8281c17352c6 | 14 | |
emilmont | 1:8281c17352c6 | 15 | int main (void) { |
emilmont | 1:8281c17352c6 | 16 | osThreadId tid = osThreadCreate(osThread(led_thread), NULL); |
emilmont | 1:8281c17352c6 | 17 | |
emilmont | 1:8281c17352c6 | 18 | while (true) { |
emilmont | 1:8281c17352c6 | 19 | osDelay(1000); |
emilmont | 1:8281c17352c6 | 20 | osSignalSet(tid, 0x1); |
emilmont | 1:8281c17352c6 | 21 | } |
emilmont | 1:8281c17352c6 | 22 | } |