Arduino version , update and tested on NUCLEO-L073RZ

Dependencies:   mbed

Oximeter and pulse sensor, based on the Beer-Lambert gas absorption law

MAXREFDES117 ( MAX30102 ) from MAXIM, based on MAXIM library for Arduino

adaptation C.Dupaty 07-2017

Tested on STM32 NUCLEO-F411RE and NUCLEO-L073RZ

https://os.mbed.com/media/uploads/cdupaty/max30102.jpg

Files at this revision

API Documentation at this revision

Comitter:
cdupaty
Date:
Wed Jun 09 11:42:09 2021 +0000
Parent:
4:5273ab1085ab
Commit message:
Arduino version update for STM32 NUCLEO-L073RZ

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Thu May 19 22:04:06 2016 +0000
+++ b/main.cpp	Wed Jun 09 11:42:09 2021 +0000
@@ -71,6 +71,9 @@
 * \image html MAXREFDES117_firmware_Flowchart.png "MAXREFDES117# Firmware Flowchart"
 *
 */
+
+// STM32 NUCLEAO-F411RE adaptation C.Dupaty 07-2017
+
 #include "mbed.h"
 #include "algorithm.h"
 #include "MAX30102.h"
@@ -87,17 +90,22 @@
 uint8_t uch_dummy;
 
 Serial pc(USBTX, USBRX);    //initializes the serial port
-#ifdef TARGET_KL25Z 
-PwmOut led(PTB18);  //initializes the pwm output that connects to the on board LED
-DigitalIn INT(PTD1);  //pin PTD1 connects to the interrupt output pin of the MAX30102
-#endif
-#ifdef TARGET_K64F
-DigitalIn INT(PTD1);  //pin PTD1 connects to the interrupt output pin of the MAX30102
-#endif
-#ifdef TARGET_MAX32600MBED
-PwmOut led(LED_RED);    //initializes the pwm output that connects to the on board LED
-DigitalIn INT(P2_0);  //pin P20 connects to the interrupt output pin of the MAX30102
-#endif
+
+// STM32 version
+
+PwmOut led(LED1);    //initializes the pwm output that connects to the on board LED
+DigitalIn INT(PA_0);  //pin PA_0 connects to the interrupt output pin of the MAX30102
+                      // interrupt not use here, polling !
+void touche(void)
+{
+     //wait until the user presses a key
+    while(pc.readable()==0)
+    {
+        pc.printf("Press any key to continue\n\r");
+        wait(1);
+    }
+    uch_dummy=getchar();
+}
 
 // the setup routine runs once when you press reset:
 int main() { 
@@ -105,28 +113,21 @@
     int i;
     int32_t n_brightness;
     float f_temp;
+    float pulse;
     
     maxim_max30102_reset(); //resets the MAX30102
     // initialize serial communication at 115200 bits per second:
     pc.baud(115200);
     pc.format(8,SerialBase::None,1);
+    pc.printf("\x1B[2J");  //clear terminal program screen
+    pc.printf("-------- TEST MAXREFDES117# -----------\n\r");
+    pc.printf("-----  Version STM32-NUCLEO -----------\n\r");
+    pc.printf("---------------------------------------\n\r");
     wait(1);
-    
+    touche();
     //read and clear status register
     maxim_max30102_read_reg(0,&uch_dummy);
-    
-    //wait until the user presses a key
-    while(pc.readable()==0)
-    {
-        pc.printf("\x1B[2J");  //clear terminal program screen
-        pc.printf("Press any key to start conversion\n\r");
-        wait(1);
-    }
-    uch_dummy=getchar();
-    
     maxim_max30102_init();  //initializes the MAX30102
-        
-        
     n_brightness=0;
     un_min=0x3FFFF;
     un_max=0;
@@ -200,20 +201,20 @@
                 if(n_brightness>MAX_BRIGHTNESS)
                     n_brightness=MAX_BRIGHTNESS;
             }
-#if defined(TARGET_KL25Z) || defined(TARGET_MAX32600MBED)
-            led.write(1-(float)n_brightness/256);
-#endif
-            //send samples and calculation result to terminal program through UART
-            pc.printf("red=");
-            pc.printf("%i", aun_red_buffer[i]);
-            pc.printf(", ir=");
-            pc.printf("%i", aun_ir_buffer[i]);
-            pc.printf(", HR=%i, ", n_heart_rate); 
-            pc.printf("HRvalid=%i, ", ch_hr_valid);
-            pc.printf("SpO2=%i, ", n_sp02);
-            pc.printf("SPO2Valid=%i\n\r", ch_spo2_valid);
+
+            pulse=1-(float)n_brightness/256;
+            led.write(pulse);
+          
+             //send samples and calculation result to terminal program through UART
+            pc.printf("red=%i\t", aun_red_buffer[i]);
+            pc.printf("ir=%i\t", aun_ir_buffer[i]);
+            pc.printf("HR=%i\t", n_heart_rate); 
+            pc.printf("HROK=%i\t", ch_hr_valid);
+            pc.printf("SpO2=%i\t", n_sp02);
+            pc.printf("SPO2OK=%i\n\r", ch_spo2_valid);
         }
         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); 
+       // touche();
     }
 }
  
\ No newline at end of file
--- a/mbed.bld	Thu May 19 22:04:06 2016 +0000
+++ b/mbed.bld	Wed Jun 09 11:42:09 2021 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/6f327212ef96
\ No newline at end of file
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file