3 channel_MUX

Dependencies:   BufferedSerial MAX30003 max32630fthr1 DS1307

Files at this revision

API Documentation at this revision

Comitter:
parthsagar2010
Date:
Wed May 26 00:06:00 2021 +0000
Parent:
12:2f1730e0e638
Child:
14:2b140cea57b2
Commit message:
good_to_go_Ahmed

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue May 25 18:49:41 2021 +0000
+++ b/main.cpp	Wed May 26 00:06:00 2021 +0000
@@ -38,19 +38,19 @@
     const int FIFO_FAST_SAMPLE_MASK =  0x1;
     const int ETAG_BITS_MASK = 0x7;
     
-    
+    int t=0;
  
-  //  EN=0; 
-  //  EN=1;
-  //  A0=0;
-   // A1=0;
+   EN=0; 
+   EN=1;
+   A0=0;
+   A1=1;
     
     // Ports and serial connections
-    Serial pc(P0_0,P0_1);            // Use USB debug probe for serial link
+    Serial pc(P0_1,P0_0);            // Use USB debug probe for serial link
     pc.baud(230400);                    // Baud rate = 115200
     DigitalOut bLed(LED3, LED_ON);
-    DigitalOut gLed(LED2, LED_ON);
-    DigitalOut rLed(LED1, LED_ON);
+   // DigitalOut gLed(LED2, LED_ON);
+  //  DigitalOut rLed(LED1, LED_ON);
          // Debug LEDs
     
     InterruptIn ecgFIFO_int(P5_4);          // Config P5_4 as int. in for the
@@ -72,7 +72,7 @@
     int16_t ecgSample[32];
     int x=0;
     while(1) {
-       
+ /*      
    while (x<100 && mux1==false)   
        {
         // if (0<x<=1000 && mux1==false)
@@ -104,19 +104,20 @@
        mux3=true;
        } 
          
-            
+   */         
         // Read back ECG samples from the FIFO 
         if( ecgFIFOIntFlag ) {
             timer1.start();
-            
+          //  t=timer.read();
             ecgFIFOIntFlag = 0; 
+             
             status = ecgAFE.readRegister( MAX30003::STATUS );      // Read the STATUS register
              
             // Check if EINT interrupt asserted
             if ( ( status & EINT_STATUS_MASK ) == EINT_STATUS_MASK ) {     
             
                 readECGSamples = 0;                        // Reset sample counter
-                
+             
                 do {
                     ecgFIFO = ecgAFE.readRegister( MAX30003::ECG_FIFO );       // Read FIFO
                     ecgSample[readECGSamples] = ecgFIFO >> 8;                  // Isolate voltage data
@@ -136,20 +137,46 @@
                 // Print results 
                 for( idx = 0; idx < readECGSamples; idx++ ) {
                     pc.printf("%6d\r\n", ecgSample[idx]);           
-                  //   pc.printf("Hello\n");    
-                } 
+                 // pc.printf("%d\n",t);   
+                  
+                   x++;
+                   t++;  
+                   
+    if (t>3000)
+    {
+       EN = 0;
+       EN = 1;
+       A0 = 0;
+       A1 = 0;
+       }
+    if (t>6000)
+    
+    {  
+   EN=0; 
+   EN=1;
+   A0=0;
+   A1=1;
+       
+       }
+       
+       if (t>9000)
+       
+       {  t=0;}
+       } 
              //   bLed = ! bLed;
              //   gLed = ! gLed;
              //   rLed = ! rLed;
                 
              
-                     x++;   
-                      if (x>300) 
+                      
+                  //    if (x>300) 
                       
-                      {x=0;}     
-            }           
+                  //    {x=0;}     
+              
+   
+       
         }
-        
+        }
         
    }
 }