ECG Study Group / Mbed 2 deprecated Programacao_marco

Dependencies:   mbed

Revision:
1:94681b7c2565
Parent:
0:d3db149c4040
Child:
2:769c937f9228
diff -r d3db149c4040 -r 94681b7c2565 main.cpp
--- a/main.cpp	Thu Apr 16 21:14:25 2015 +0000
+++ b/main.cpp	Fri Apr 17 13:01:00 2015 +0000
@@ -29,25 +29,25 @@
 Ticker t0;
 Serial pc(USBTX,USBRX);
 
+
 /*------HANDLES THE TIMER INTERRUPTIONS------------*/
 
 void t0_handler(void);
 void rx_Handler(void);
+char test = 0;  // Tests the data received from the computer in order to start the reading 
+bool Valor=0;      
 
 /*------------BUFFER TO STORE DATA------------------*/
 
-float buffer[4] = {0,0,0,0};
+int buffer[4] = {0,0,0,0};
 
 
 
 int main() {
     pc.attach(&rx_Handler, pc.RxIrq);
-    t0.attach(&t0_handler,0.001); //Data read in a 1kHz freq.
-    while(1) {
-       
-       
-       
-    }
+    
+    
+
 }
 
 /*----------------------FUNCTIONS-----------------------*/
@@ -55,16 +55,24 @@
     //Reads and send data to the computer 
 
 void t0_handler(void){
-    buffer[ECG1] = Ecg1.read();
-    buffer[ECG2] = Ecg2.read();
-    buffer[RESP] = Resp.read();
-    buffer[PPG] = Ppg.read();       
-    pc.printf("%f,%f,%f,%f\n",buffer[ECG1],buffer[ECG2],buffer[RESP],buffer[PPG]);
+    buffer[ECG1] = Ecg1.read_u16();
+    buffer[ECG2] = Ecg2.read_u16();
+    buffer[RESP] = Resp.read_u16();
+    buffer[PPG] = Ppg.read_u16();       
+    pc.printf("%i,%i,%i,%i\n",buffer[ECG1],buffer[ECG2],buffer[RESP],buffer[PPG]);
     }
 
     //This function must 
 
 void rx_Handler(void){
-    
-    
-    }
+   test = pc.getc();    // it gets the received character
+   if (test=='s'|| test == 'S')
+    {   // wake up routine
+    t0.attach(&t0_handler,0.001); //start counting ----Data read in a 1kHz freq. (1mS)  
+        return;
+    }else if (test=='e'|| test == 'E')
+        {
+    t0.detach();
+        }
+   
+}