k

Dependencies:   MAX30003 max32630fthr

Revision:
19:7a084dc2f09d
Parent:
18:101042d225ef
Child:
20:2e999e6568c1
--- a/main.cpp	Fri Jun 11 23:20:20 2021 +0000
+++ b/main.cpp	Thu Jun 17 13:49:11 2021 +0000
@@ -21,9 +21,17 @@
 void task_fast(void);
 //DigitalOut ledA(LED2);
 
-DigitalOut EN(P1_7);
-DigitalOut A0(P1_4);
-DigitalOut A1(P7_2);
+//DigitalOut EN(P1_7);
+//DigitalOut A0(P1_4);
+//DigitalOut A1(P7_2);
+
+
+DigitalOut S0(P5_6);
+DigitalOut S1(P5_5);
+DigitalOut S2(P3_3);
+DigitalOut S3(P3_2);
+
+
 
 void ecg_config(MAX30003 &ecgAFE);
 //BufferedSerial pc(P3_1,P3_0);            // Use USB debug probe for serial link static Unbuffered
@@ -60,14 +68,19 @@
 int main(void)
 {   
  int t=0;
- 
-   EN=0; 
-   EN=1;
-   A0=0;
-   A1=1;
-   
+// 
+//   EN=0; 
+//   EN=1;
+//   A0=0;
+//   A1=1;
+
+      S0=0; 
+      S1=0;
+      S2=0;
+      S3=0;
 
 
+   
    // Constants
     const int EINT_STATUS_MASK =  1 << 23;
     const int FIFO_OVF_MASK =  0x7;
@@ -82,14 +95,14 @@
  uint16_t rtn_val;
  
  //time = 12:00:00 AM 12hr mode
- ds3231_time_t time = {25,20,9,1, 0};  // seconds, min, hours, am_pm, mode
+ ds3231_time_t time = {45,45,15,1, 0};  // seconds, min, hours, am_pm, mode
 
  
 rtn_val = rtc.set_time(time);
  
   
   //see datasheet for calendar format
- ds3231_calendar_t calendar = {6, 11, 6, 21}; // day date month year
+ ds3231_calendar_t calendar = {4, 16, 6, 21}; // day date month year
 
 
  rtn_val = rtc.set_calendar(calendar);
@@ -154,6 +167,7 @@
     uint8_t cksm_1 = 0;
     uint8_t cksm_2 = 0;
     uint8_t header_device_id[3] = {0,0,210};
+   // uint8_t header_device_id[3] = {0,0,1};     //for rahul
     uint8_t header_packet_type[2] = {0,2};
     
     uint8_t ending[5] = {'@','#','%','!','7'};
@@ -168,6 +182,7 @@
        bool timestamp_reader = false;
        
        
+//---------------------------------hardware RTC check---------------------------------------------//
        time_t epoch_time;  
        
            do {
@@ -178,14 +193,14 @@
      
     packet_1 = epoch_time;
       }while((epoch_time % 60)!=0);   // come out at the start of minute
-  
+      
+      
   
 while(1) 
     {
-       
-    
+           
     if ((onesec_counter>=125))
-    {
+    { t++;
      //t.start();
      //ledA = !ledA;   
       pc.write((uint8_t *)header_device_id, sizeof(header_device_id));     // device ID
@@ -236,6 +251,36 @@
        // printf("Timer time: %lu ms \n", (time_taken*100));
       // t.reset();
     //  timer_fast.reset();
+    
+    if (t==10)       //C1    
+     {
+      S0=1; 
+      S1=0;
+      S2=0;
+      S3=0;
+   //  channel_num[1]= {2};
+     } 
+     if (t==20)    //C2
+     {
+      S0=0; 
+      S1=1;
+      S2=0;
+      S3=0;
+  //    channel_num[1]= {3};
+      }
+         
+     if (t==30)          // C0  
+     {
+      S0=0; 
+      S1=0;
+      S2=0;
+      S3=0;
+   //  channel_num[1]= {1};
+     t=0;} 
+    
+    
+    
+    
        } 
         // Read back ECG samples from the FIFO 
         else if( (ecgFIFOIntFlag==1))// && (timerflag == 0))