dhgdh

Dependencies:   MAX44000 PWM_Tone_Library nexpaq_mdk

Fork of LED_Demo by joey shelton

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "test_env.h"
00003 
00004 Timeout timer;
00005 DigitalOut led(LED1);
00006 
00007 namespace {
00008     const int MS_INTERVALS = 1000;
00009 }
00010 
00011 void print_char(char c = '*') {
00012     printf("%c", c);
00013     fflush(stdout);
00014 }
00015 
00016 void toggleOff(void);
00017 
00018 void toggleOn(void) {
00019     static int toggle_counter = 0;
00020     if (toggle_counter == MS_INTERVALS) {
00021         led = !led;
00022         print_char();
00023         toggle_counter = 0;
00024     }
00025     toggle_counter++;
00026     timer.attach_us(toggleOff, 500);
00027 }
00028 
00029 void toggleOff(void) {
00030     timer.attach_us(toggleOn, 500);
00031 }
00032 
00033 int main() {
00034     MBED_HOSTTEST_TIMEOUT(15);
00035     MBED_HOSTTEST_SELECT(wait_us_auto);
00036     MBED_HOSTTEST_DESCRIPTION(Timeout Int us);
00037     MBED_HOSTTEST_START("MBED_24");
00038 
00039     toggleOn();
00040 
00041     while (1);
00042 }