NXP
/
example-blinky-lpc55s69
Blinking LED example with system statistics printed to terminal
main.cpp@0:03c15e688f62, 2019-03-25 (annotated)
- Committer:
- maclobdell
- Date:
- Mon Mar 25 22:28:40 2019 -0500
- Revision:
- 0:03c15e688f62
blinky app that uses mbed os 5.12 release candidate
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
maclobdell | 0:03c15e688f62 | 1 | /* mbed Microcontroller Library |
maclobdell | 0:03c15e688f62 | 2 | * Copyright (c) 2018 ARM Limited |
maclobdell | 0:03c15e688f62 | 3 | * SPDX-License-Identifier: Apache-2.0 |
maclobdell | 0:03c15e688f62 | 4 | */ |
maclobdell | 0:03c15e688f62 | 5 | |
maclobdell | 0:03c15e688f62 | 6 | #include "mbed.h" |
maclobdell | 0:03c15e688f62 | 7 | #include "stats_report.h" |
maclobdell | 0:03c15e688f62 | 8 | |
maclobdell | 0:03c15e688f62 | 9 | DigitalOut led1(LED1); |
maclobdell | 0:03c15e688f62 | 10 | |
maclobdell | 0:03c15e688f62 | 11 | #define SLEEP_TIME 500 // (msec) |
maclobdell | 0:03c15e688f62 | 12 | #define PRINT_AFTER_N_LOOPS 20 |
maclobdell | 0:03c15e688f62 | 13 | |
maclobdell | 0:03c15e688f62 | 14 | // main() runs in its own thread in the OS |
maclobdell | 0:03c15e688f62 | 15 | int main() |
maclobdell | 0:03c15e688f62 | 16 | { |
maclobdell | 0:03c15e688f62 | 17 | SystemReport sys_state( SLEEP_TIME * PRINT_AFTER_N_LOOPS /* Loop delay time in ms */); |
maclobdell | 0:03c15e688f62 | 18 | |
maclobdell | 0:03c15e688f62 | 19 | int count = 0; |
maclobdell | 0:03c15e688f62 | 20 | while (true) { |
maclobdell | 0:03c15e688f62 | 21 | // Blink LED and wait 0.5 seconds |
maclobdell | 0:03c15e688f62 | 22 | led1 = !led1; |
maclobdell | 0:03c15e688f62 | 23 | wait_ms(SLEEP_TIME); |
maclobdell | 0:03c15e688f62 | 24 | |
maclobdell | 0:03c15e688f62 | 25 | if ((0 == count) || (PRINT_AFTER_N_LOOPS == count)) { |
maclobdell | 0:03c15e688f62 | 26 | // Following the main thread wait, report on the current system status |
maclobdell | 0:03c15e688f62 | 27 | sys_state.report_state(); |
maclobdell | 0:03c15e688f62 | 28 | count = 0; |
maclobdell | 0:03c15e688f62 | 29 | } |
maclobdell | 0:03c15e688f62 | 30 | ++count; |
maclobdell | 0:03c15e688f62 | 31 | } |
maclobdell | 0:03c15e688f62 | 32 | } |