IEC60601-1-8 Audible Alert Generator

Dependencies:   mbed

See here for more info.

Committer:
wim
Date:
Fri May 18 19:51:12 2012 +0000
Revision:
0:07767204347b
First Release

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wim 0:07767204347b 1 /******************************************************************************
wim 0:07767204347b 2 * Tones_demo:
wim 0:07767204347b 3 *
wim 0:07767204347b 4 * This module contains the "main" function for the IEC60601-1-8 alarm tone
wim 0:07767204347b 5 * synthesizer. The main function initializes peripherals and variables and
wim 0:07767204347b 6 * provides for a command test in the main loop to handle incoming commands.
wim 0:07767204347b 7 *
wim 0:07767204347b 8 * Copyright(C) 2007, NXP Semiconductor
wim 0:07767204347b 9 * All rights reserved.
wim 0:07767204347b 10 *
wim 0:07767204347b 11 * Port to mbed 2012 (WH)
wim 0:07767204347b 12 ******************************************************************************/
wim 0:07767204347b 13
wim 0:07767204347b 14 #include "mbed.h"
wim 0:07767204347b 15 #include "commands.h"
wim 0:07767204347b 16 #include "IEC60601-1-8.h"
wim 0:07767204347b 17
wim 0:07767204347b 18 IEC60601 IEC_Alarm;
wim 0:07767204347b 19
wim 0:07767204347b 20 Serial pc(USBTX, USBRX); // tx, rx
wim 0:07767204347b 21
wim 0:07767204347b 22 // Variables to control Audio generator
wim 0:07767204347b 23 bool running=true;
wim 0:07767204347b 24 char command;
wim 0:07767204347b 25
wim 0:07767204347b 26 // Variables for Heartbeat and Status
wim 0:07767204347b 27 Ticker heartbeat;
wim 0:07767204347b 28 bool heartbeatflag=false;
wim 0:07767204347b 29
wim 0:07767204347b 30 DigitalOut MyLed1(LED1);
wim 0:07767204347b 31 DigitalOut MyLed2(LED2);
wim 0:07767204347b 32 DigitalOut MyLed3(LED3);
wim 0:07767204347b 33 DigitalOut MyLed4(LED4);
wim 0:07767204347b 34
wim 0:07767204347b 35
wim 0:07767204347b 36 // Heartbeat monitor
wim 0:07767204347b 37 void pulse() {
wim 0:07767204347b 38 MyLed4 = !MyLed4;
wim 0:07767204347b 39 }
wim 0:07767204347b 40
wim 0:07767204347b 41
wim 0:07767204347b 42 void heartbeat_start() {
wim 0:07767204347b 43 heartbeat.attach(&pulse, 0.5);
wim 0:07767204347b 44
wim 0:07767204347b 45 heartbeatflag = true;
wim 0:07767204347b 46 }
wim 0:07767204347b 47
wim 0:07767204347b 48 void heartbeat_stop() {
wim 0:07767204347b 49 heartbeat.detach();
wim 0:07767204347b 50 heartbeatflag = false;
wim 0:07767204347b 51 }
wim 0:07767204347b 52
wim 0:07767204347b 53
wim 0:07767204347b 54 int main() {
wim 0:07767204347b 55
wim 0:07767204347b 56 pc.printf("Hello World!\n\r");
wim 0:07767204347b 57
wim 0:07767204347b 58 heartbeat_start();
wim 0:07767204347b 59
wim 0:07767204347b 60 InitCommand();
wim 0:07767204347b 61
wim 0:07767204347b 62 ShowMenu();
wim 0:07767204347b 63 while(running) {
wim 0:07767204347b 64 if(pc.readable()) { // poll for command
wim 0:07767204347b 65 command = pc.getc();
wim 0:07767204347b 66 // pc.printf("Command= %c \n\r", command);
wim 0:07767204347b 67 DecodeCommand(command);
wim 0:07767204347b 68 ShowMenu();
wim 0:07767204347b 69 } // if
wim 0:07767204347b 70 } //while
wim 0:07767204347b 71
wim 0:07767204347b 72 pc.printf("Bye World!\n\r");
wim 0:07767204347b 73 }