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.
Dependencies: MPU9250_SPI
Fork of WearableDevice_Nucleo by
main.cpp@0:73cd0cb02330, 2017-10-11 (annotated)
- Committer:
- gusteibolt
- Date:
- Wed Oct 11 14:12:46 2017 +0000
- Revision:
- 0:73cd0cb02330
- Child:
- 1:a6dc717fb060
Initial
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gusteibolt | 0:73cd0cb02330 | 1 | #include "mbed.h" |
gusteibolt | 0:73cd0cb02330 | 2 | #include "rtos.h" |
gusteibolt | 0:73cd0cb02330 | 3 | |
gusteibolt | 0:73cd0cb02330 | 4 | void print_char(char c = '*') |
gusteibolt | 0:73cd0cb02330 | 5 | { |
gusteibolt | 0:73cd0cb02330 | 6 | printf("%c", c); |
gusteibolt | 0:73cd0cb02330 | 7 | fflush(stdout); |
gusteibolt | 0:73cd0cb02330 | 8 | } |
gusteibolt | 0:73cd0cb02330 | 9 | |
gusteibolt | 0:73cd0cb02330 | 10 | DigitalOut led1(LED1); |
gusteibolt | 0:73cd0cb02330 | 11 | |
gusteibolt | 0:73cd0cb02330 | 12 | void print_thread(void const *argument) |
gusteibolt | 0:73cd0cb02330 | 13 | { |
gusteibolt | 0:73cd0cb02330 | 14 | while (true) { |
gusteibolt | 0:73cd0cb02330 | 15 | Thread::wait(1000); |
gusteibolt | 0:73cd0cb02330 | 16 | print_char(); |
gusteibolt | 0:73cd0cb02330 | 17 | } |
gusteibolt | 0:73cd0cb02330 | 18 | } |
gusteibolt | 0:73cd0cb02330 | 19 | |
gusteibolt | 0:73cd0cb02330 | 20 | int main() |
gusteibolt | 0:73cd0cb02330 | 21 | { |
gusteibolt | 0:73cd0cb02330 | 22 | printf("\n\n*** RTOS basic example ***\n"); |
gusteibolt | 0:73cd0cb02330 | 23 | Thread thread(print_thread, NULL, osPriorityNormal, DEFAULT_STACK_SIZE); |
gusteibolt | 0:73cd0cb02330 | 24 | while (true) { |
gusteibolt | 0:73cd0cb02330 | 25 | led1 = !led1; |
gusteibolt | 0:73cd0cb02330 | 26 | Thread::wait(500); |
gusteibolt | 0:73cd0cb02330 | 27 | } |
gusteibolt | 0:73cd0cb02330 | 28 | } |