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@0:a1297a50684e, 2022-03-17 (annotated)
- Committer:
- cspista
- Date:
- Thu Mar 17 12:56:18 2022 +0000
- Revision:
- 0:a1297a50684e
final version
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| cspista | 0:a1297a50684e | 1 | #include "mbed.h" |
| cspista | 0:a1297a50684e | 2 | #include "rtos.h" |
| cspista | 0:a1297a50684e | 3 | |
| cspista | 0:a1297a50684e | 4 | DigitalOut led(LED1); |
| cspista | 0:a1297a50684e | 5 | osThreadId mainThreadID; |
| cspista | 0:a1297a50684e | 6 | |
| cspista | 0:a1297a50684e | 7 | void signal_thread(void const *argument) { |
| cspista | 0:a1297a50684e | 8 | while (true) { |
| cspista | 0:a1297a50684e | 9 | Thread::wait(1000); |
| cspista | 0:a1297a50684e | 10 | osSignalSet(mainThreadID, 0x1); |
| cspista | 0:a1297a50684e | 11 | } |
| cspista | 0:a1297a50684e | 12 | } |
| cspista | 0:a1297a50684e | 13 | |
| cspista | 0:a1297a50684e | 14 | int main (void) { |
| cspista | 0:a1297a50684e | 15 | mainThreadID = Thread::gettid(); |
| cspista | 0:a1297a50684e | 16 | Thread thread(signal_thread); |
| cspista | 0:a1297a50684e | 17 | |
| cspista | 0:a1297a50684e | 18 | while (true) { |
| cspista | 0:a1297a50684e | 19 | // Signal flags that are reported as event are automatically cleared. |
| cspista | 0:a1297a50684e | 20 | osSignalWait(0x1, osWaitForever); |
| cspista | 0:a1297a50684e | 21 | led = !led; |
| cspista | 0:a1297a50684e | 22 | } |
| cspista | 0:a1297a50684e | 23 | } |