Krisna Chhouk / Mbed OS BLEHeartRateMon

Files at this revision

API Documentation at this revision

Comitter:
kchhouk
Date:
Sat Jan 25 20:41:56 2020 +0000
Parent:
49:5be03f287022
Commit message:
BLE, not required

Changed in this revision

source/main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/source/main.cpp	Mon Dec 11 16:22:50 2017 +0000
+++ b/source/main.cpp	Sat Jan 25 20:41:56 2020 +0000
@@ -24,7 +24,7 @@
 
 #define MAX_BRIGHTNESS 255
 
-
+Serial pc(USBTX, USBRX);
 
 DigitalOut led2(LED2, 1);
 
@@ -44,7 +44,7 @@
 
 
 #ifdef TARGET_MAX32630FTHR
-PwmOut led1(LED_RED);    //initializes the pwm output that connects to the on board LED
+PwmOut led1(LED3);    //initializes the pwm output that connects to the on board LED
 DigitalIn INT(P3_0);  //pin P30 connects to the interrupt output pin of the MAX30102
 #endif
 
@@ -83,7 +83,7 @@
     for(i=400;i<500;i++)
     {
         un_prev_data=aun_red_buffer[i-1];
-        while(INT.read()==1);
+        //while(INT.read()==1);
         maxim_max30102_read_fifo((aun_red_buffer+i), (aun_ir_buffer+i));
         
         if(aun_red_buffer[i]>un_prev_data)
@@ -193,8 +193,11 @@
 
 int main()
 {
+    pc.baud(9600);
     maxim_max30102_reset(); //resets the MAX30102
 
+    pc.printf("Init...\n %ld\n", n_heart_rate);
+
     
     //read and clear status register
     maxim_max30102_read_reg(0,&uch_dummy);
@@ -211,7 +214,7 @@
     //read the first 500 samples, and determine the signal range
     for(i=0;i<n_ir_buffer_length;i++)
     {
-        while(INT.read()==1);   //wait until the interrupt pin asserts
+        //while(INT.read()==1);   //wait until the interrupt pin asserts
         
         maxim_max30102_read_fifo((aun_red_buffer+i), (aun_ir_buffer+i));  //read from MAX30102 FIFO
             
@@ -222,21 +225,28 @@
             
     }
     un_prev_data=aun_red_buffer[i];
+    //pc.printf("%ld\n", un_prev_data);
     
     //calculate heart rate and SpO2 after first 500 samples (first 5 seconds of samples)
     maxim_heart_rate_and_oxygen_saturation(aun_ir_buffer, n_ir_buffer_length, aun_red_buffer, &n_sp02, &ch_spo2_valid, &n_heart_rate, &ch_hr_valid); 
     
     
+    //pc.printf(pn_heart_rate);
+    //pch_hr_valid --> 1 if heart rate value is valid
+    
     while(1)
     {
         
-        eventQueue.call_every(500, periodicCallback);
+        //eventQueue.call_every(500, periodicCallback);
  
-        BLE &ble = BLE::Instance();
-        ble.onEventsToProcess(scheduleBleEventsProcessing);
-        ble.init(bleInitComplete);
+        //BLE &ble = BLE::Instance();
+        //ble.onEventsToProcess(scheduleBleEventsProcessing);
+        //ble.init(bleInitComplete);
+        //pc.printf("%ld", un_prev_data);
+        pc.printf("%ld\n", n_heart_rate);
+
         
-        eventQueue.dispatch_forever();
+        //eventQueue.dispatch_forever();
              
         
     }