3 channel_MUX

Dependencies:   BufferedSerial MAX30003 max32630fthr1 DS1307

Files at this revision

API Documentation at this revision

Comitter:
kidecha_rahul
Date:
Sat May 29 19:50:35 2021 +0000
Parent:
13:3a49fb19b94b
Commit message:
3 channal_MUX

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed May 26 00:06:00 2021 +0000
+++ b/main.cpp	Sat May 29 19:50:35 2021 +0000
@@ -17,16 +17,10 @@
  
 }  
 Timer timer1;
-//void MUX()
-//{
+
 DigitalOut EN(P1_7);
 DigitalOut A0(P1_4);
 DigitalOut A1(P7_2);
-//}
- bool mux1= false ;
- bool mux2= false ;
- bool mux3= false ;
-
  
 int main()
 {   
@@ -38,12 +32,11 @@
     const int FIFO_FAST_SAMPLE_MASK =  0x1;
     const int ETAG_BITS_MASK = 0x7;
     
-    int t=0;
- 
-   EN=0; 
-   EN=1;
-   A0=0;
-   A1=1;
+    int t=0; 
+    EN=0; 
+    EN=1;
+    A0=0;
+    A1=1;
     
     // Ports and serial connections
     Serial pc(P0_1,P0_0);            // Use USB debug probe for serial link
@@ -51,60 +44,25 @@
     DigitalOut bLed(LED3, 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
     ecgFIFO_int.fall(&ecgFIFO_callback);    // ecg FIFO almost full interrupt
     
    //SPI spiBus(SPI2_MOSI, SPI2_MISO, SPI2_SCK);     // SPI bus, P5_1 = MOSI, 
-                                                    // P5_2 = MISO, P5_0 = SCK
-    
-    
-   SPI spiBus(P5_1, P5_2, P5_0);
+                                                    // P5_2 = MISO, P5_0 = SCK    
+    SPI spiBus(P5_1, P5_2, P5_0);
     
     MAX30003 ecgAFE(spiBus, P5_3);          // New MAX30003 on spiBus, CS = P5_3 
     ecg_config(ecgAFE);                    // Config ECG 
      
     
-    ecgAFE.writeRegister( MAX30003::SYNCH , 0);
+    ecgAFE.writeRegister( MAX30003::SYNCH ,0);
     
     uint32_t ecgFIFO, readECGSamples, idx, ETAG[32], status;
     int16_t ecgSample[32];
-    int x=0;
+    
     while(1) {
- /*      
-   while (x<100 && mux1==false)   
-       {
-        // if (0<x<=1000 && mux1==false)
-      // { 
-       
-       EN = 0; 
-       EN = 1;
-       A0 = 0;
-       A1 = 0;
-       mux1= true ;
-       }
-     while (101<x<=200 && mux2==false)
-       { 
-       gLed = 1 ;
-       EN = 0;
-       EN = 1;
-       A0 = 1;
-       A1 = 0;
-         mux2=true ;
-       }
-       
-   while (201<x<=300 && mux3==false)
-       {
-     rLed = 1 ;  
-       EN = 0 ;      
-       EN = 1;
-       A0 = 0;
-       A1 = 1;
-       mux3=true;
-       } 
-         
-   */         
+        
         // Read back ECG samples from the FIFO 
         if( ecgFIFOIntFlag ) {
             timer1.start();
@@ -138,47 +96,40 @@
                 for( idx = 0; idx < readECGSamples; idx++ ) {
                     pc.printf("%6d\r\n", ecgSample[idx]);           
                  // pc.printf("%d\n",t);   
-                  
-                   x++;
-                   t++;  
+                    //bLed = !bLed;
+                    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>3000){
+                        EN = 0;
+                        EN = 1;
+                        A0 = 0;
+                        A1 = 0;
+                        DigitalOut bLed(LED3, LED_OFF);
+                        DigitalOut gLed(LED2, LED_ON); 
+                    }
+                    if (t>6000){  
+                        EN=0; 
+                        EN=1;
+                        A0=1;
+                        A1=0;
+                        DigitalOut gLed(LED2, LED_OFF);
+                        DigitalOut rLed(LED1, LED_ON);
+                    }
        
-       }
-       
-       if (t>9000)
-       
-       {  t=0;}
-       } 
-             //   bLed = ! bLed;
-             //   gLed = ! gLed;
-             //   rLed = ! rLed;
-                
-             
-                      
-                  //    if (x>300) 
-                      
-                  //    {x=0;}     
-              
-   
-       
-        }
+                    if (t>9000){ 
+                    DigitalOut rLed(LED1, LED_OFF);
+                    DigitalOut bLed(LED3, LED_ON);
+                    t=0;
+                    EN=0; 
+                    EN=1;
+                    A0=0;
+                    A1=1;                    
+                    }
+                }       
+            }
         }
         
-   }
+    }
 }