GigaDevice
/
GD32_example_blinky
This a fork of https://developer.mbed.org/teams/mbed-os-examples/code/mbed-os-example-blinky/
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2018 ARM Limited 00003 * SPDX-License-Identifier: Apache-2.0 00004 */ 00005 00006 #include "mbed.h" 00007 #include "stats_report.h" 00008 00009 DigitalOut led1(LED1); 00010 00011 #define SLEEP_TIME 500 // (msec) 00012 #define PRINT_AFTER_N_LOOPS 20 00013 00014 // main() runs in its own thread in the OS 00015 int main() 00016 { 00017 SystemReport sys_state( SLEEP_TIME * PRINT_AFTER_N_LOOPS /* Loop delay time in ms */); 00018 00019 int count = 0; 00020 while (true) { 00021 // Blink LED and wait 0.5 seconds 00022 led1 = !led1; 00023 wait_ms(SLEEP_TIME); 00024 00025 if ((0 == count) || (PRINT_AFTER_N_LOOPS == count)) { 00026 // Following the main thread wait, report on the current system status 00027 sys_state.report_state(); 00028 count = 0; 00029 } 00030 ++count; 00031 } 00032 }
Generated on Thu Jul 14 2022 00:45:43 by 1.7.2