CITY1082 code example

Committer:
reedas
Date:
Tue Nov 05 09:15:05 2019 +0000
Revision:
102:17e6fc7c4be0
Parent:
100:ec006d6f3cb6
Child:
103:decc5a1b2e80
5 LED Blinky

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 82:abf1b1785bd7 1 /* mbed Microcontroller Library
mbed_official 82:abf1b1785bd7 2 * Copyright (c) 2018 ARM Limited
mbed_official 82:abf1b1785bd7 3 * SPDX-License-Identifier: Apache-2.0
mbed_official 82:abf1b1785bd7 4 */
mbed_official 82:abf1b1785bd7 5
Jonathan Austin 0:2757d7abb7d9 6 #include "mbed.h"
mbed_official 100:ec006d6f3cb6 7 #include "platform/mbed_thread.h"
mbed_official 82:abf1b1785bd7 8 #include "stats_report.h"
Jonathan Austin 0:2757d7abb7d9 9
reedas 102:17e6fc7c4be0 10 DigitalOut RedLED(LED1);
reedas 102:17e6fc7c4be0 11 DigitalOut GreenLED(LED2);
reedas 102:17e6fc7c4be0 12 DigitalOut BlueLED(LED3);
reedas 102:17e6fc7c4be0 13 DigitalOut led1(LED4);
reedas 102:17e6fc7c4be0 14 DigitalOut led2(LED5);
Jonathan Austin 0:2757d7abb7d9 15
mbed_official 88:bea4f2daa48c 16 #define SLEEP_TIME 500 // (msec)
mbed_official 88:bea4f2daa48c 17 #define PRINT_AFTER_N_LOOPS 20
mbed_official 88:bea4f2daa48c 18
Jonathan Austin 1:846c97078558 19 // main() runs in its own thread in the OS
mbed_official 82:abf1b1785bd7 20 int main()
mbed_official 82:abf1b1785bd7 21 {
mbed_official 88:bea4f2daa48c 22 SystemReport sys_state( SLEEP_TIME * PRINT_AFTER_N_LOOPS /* Loop delay time in ms */);
mbed_official 82:abf1b1785bd7 23
mbed_official 88:bea4f2daa48c 24 int count = 0;
Jonathan Austin 0:2757d7abb7d9 25 while (true) {
mbed_official 82:abf1b1785bd7 26 // Blink LED and wait 0.5 seconds
Jonathan Austin 0:2757d7abb7d9 27 led1 = !led1;
reedas 102:17e6fc7c4be0 28 led2 = !led2;
reedas 102:17e6fc7c4be0 29 RedLED = !RedLED;
reedas 102:17e6fc7c4be0 30 GreenLED = !GreenLED;
reedas 102:17e6fc7c4be0 31 BlueLED = !BlueLED;
mbed_official 100:ec006d6f3cb6 32 thread_sleep_for(SLEEP_TIME);
mbed_official 82:abf1b1785bd7 33
mbed_official 88:bea4f2daa48c 34 if ((0 == count) || (PRINT_AFTER_N_LOOPS == count)) {
mbed_official 88:bea4f2daa48c 35 // Following the main thread wait, report on the current system status
mbed_official 88:bea4f2daa48c 36 sys_state.report_state();
mbed_official 88:bea4f2daa48c 37 count = 0;
mbed_official 88:bea4f2daa48c 38 }
mbed_official 88:bea4f2daa48c 39 ++count;
Jonathan Austin 0:2757d7abb7d9 40 }
Jonathan Austin 0:2757d7abb7d9 41 }