Wim Huiskamp / Mbed 2 deprecated mbed_audio_alert

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /******************************************************************************
00002 *   Tones_demo:                         
00003 *
00004 *      This module contains the "main" function for the IEC60601-1-8 alarm tone                                                                      
00005 *      synthesizer. The main function initializes peripherals and variables and                                                           
00006 *      provides for a command test in the main loop to handle incoming commands.
00007 *  
00008 *   Copyright(C) 2007, NXP Semiconductor
00009 *   All rights reserved. 
00010 *
00011 *   Port to mbed 2012 (WH)
00012 ******************************************************************************/
00013 
00014 #include "mbed.h"
00015 #include "commands.h"
00016 #include "IEC60601-1-8.h"
00017 
00018 IEC60601 IEC_Alarm;
00019 
00020 Serial pc(USBTX, USBRX); // tx, rx
00021 
00022 // Variables to control Audio generator
00023 bool running=true;
00024 char command;
00025 
00026 // Variables for Heartbeat and Status
00027 Ticker heartbeat;
00028 bool heartbeatflag=false;
00029 
00030 DigitalOut MyLed1(LED1);
00031 DigitalOut MyLed2(LED2);
00032 DigitalOut MyLed3(LED3);
00033 DigitalOut MyLed4(LED4);
00034 
00035 
00036 // Heartbeat monitor
00037 void pulse() {
00038   MyLed4 = !MyLed4;                                          
00039 }
00040 
00041 
00042 void heartbeat_start() {
00043   heartbeat.attach(&pulse, 0.5);
00044   
00045   heartbeatflag = true;
00046 }
00047 
00048 void heartbeat_stop() {
00049   heartbeat.detach();
00050   heartbeatflag = false;
00051 }
00052 
00053 
00054 int main() {
00055 
00056     pc.printf("Hello World!\n\r");
00057 
00058     heartbeat_start();
00059                          
00060     InitCommand();
00061 
00062     ShowMenu();
00063     while(running) {
00064        if(pc.readable()) {        // poll for command          
00065          command = pc.getc();       
00066 //         pc.printf("Command= %c \n\r", command);         
00067          DecodeCommand(command);
00068          ShowMenu();
00069        } // if   
00070     } //while 
00071 
00072    pc.printf("Bye World!\n\r");                          
00073 }