Greg Toth / Mbed OS MAX30101WING_HR_SPO2

Dependencies:   MAX30101 MAX32620FTHR

Revision:
15:d9f7d0d5fc4e
Parent:
14:b47461092164
Child:
16:07842c9f55cc
diff -r b47461092164 -r d9f7d0d5fc4e main.cpp
--- a/main.cpp	Wed Oct 21 15:53:52 2020 +0000
+++ b/main.cpp	Wed Oct 21 18:07:10 2020 +0000
@@ -87,6 +87,10 @@
 {
     Serial pc(USBTX, USBRX);            // Use USB debug probe for serial link
     pc.baud(115200);                    // Baud rate = 115200
+    
+    //Serial uart2(P3_1, P3_0);
+    RawSerial uart2(P3_1, P3_0);
+    uart2.baud(115200);
 
     DigitalOut rLed(LED1, LED_OFF);     // Debug LED
 
@@ -128,16 +132,18 @@
                 //to clear interrupt
 
                 // Confirms proper read prior to executing
-                if((rc == 0)) {
+                if(rc == 0) {
                     // Read FIFO
                     rc = op_sensor.readFIFO(MAX30101::ThreeLedChannels, fifoData, readBytes);
+                    //pc.printf("op_sensor.readFIFO() returned readBytes=%u, rc=%d\r\n", readBytes, rc);
 
                     if(rc == 0) {
 
                         // Convert read bytes into samples
                         for (idx = 0; idx < readBytes; idx+=9) {
                                          if (r >= 500 || ir >= 500 || g >= 500) {
-                                                pc.printf("Overflow!");
+                                                pc.printf("Overflow! ");
+                                                pc.printf("readBytes=%u, idx=%u, r=%d, ir=%d, g=%d\r\n", readBytes, idx, r, ir, g);
                                          }
                                          redData[r++] = ((fifoData[idx] << 16) | (fifoData[idx + 1] << 8) | (fifoData[idx + 2])) & 0x03FFFF;
 
@@ -148,7 +154,7 @@
 
 
 
-                        if(r>=500 && ir>=500 && g>500)//checks to make sure there are 500
+                        if(r>=500 && ir>=500 && g>=500)//checks to make sure there are 500
                             //samples in data buffers
                         {
 
@@ -170,11 +176,13 @@
                             if(DRdy==1) {
                                 pc.printf("Heart Rate = %i\r\n",HRbpm2);
                                 pc.printf("SPO2 = %i\r\n",SpO2B);
+                                uart2.printf("SPO2 = %i (SpO2B)\r\n", SpO2B);
                             }
                             else if (HRTemp!=0)//if a valid heart was calculated at all, it is printed
                             {
                                 pc.printf("Heart Rate = %i\r\n",HRTemp);
                                 pc.printf("SPO2 = %i\r\n",spo2Temp);
+                                uart2.printf("SPO2 = %i (spo2Temp)\r\n", spo2Temp);
                             }
                             else
                             {