Mode1 Optical Validation

Dependencies:   max32630fthr

Revision:
62:21a7745d02e0
Parent:
61:a2e73c5b87e7
Child:
63:61f62564922c
--- a/main.cpp	Wed Jun 01 01:03:55 2022 +0000
+++ b/main.cpp	Wed Jun 01 01:11:36 2022 +0000
@@ -35,7 +35,7 @@
 #include "platform/mbed_thread.h"
 #include "mbed.h"
 /******************************************************************************
-* https://os.mbed.com/users/phonemacro/code/MAX32664C_Example_Host_Code
+* https://os.mbed.com/users/phonemacro/code/MAX32664C_MAXM86146_Mode1_Optical
 * Tera Term output is set to 115200 baud rate.
 * ver: 220531
 ******************************************************************************/
@@ -93,9 +93,10 @@
   //#define RAW_HZ 200   // Raw data rate
   //#define RAW_HZ 2004   // Raw data rate 200 Hz, ave 4
 //#define SPO2_CAL_RPT 1
-#define MAXM86161_OPT_VALIDATION_GRN 1 // Optical validatation
-//#define MAXM86161_OPT_VALIDATION_IR 1 // Optical validatation
-//#define MAXM86161_OPT_VALIDATION_RED 1 // Optical validatation
+#define MAXM86146_OPT_VALIDATION_GRN1 1 // Optical validatation
+//#define MAXM86146_OPT_VALIDATION_GRN2 1 // Optical validatation
+//#define MAXM86146_OPT_VALIDATION_IR 1 // Optical validatation
+//#define MAXM86146_OPT_VALIDATION_RED 1 // Optical validatation
 
 
 // Comment out both of the below for Normal Algorithm Samples Format
@@ -929,9 +930,9 @@
     mfio = 1; mfio = 0; wait_us(300);
     pc.printf("wr afe reg Status: %x\n\r", rsp[0]);
 
-#if defined(MAXM86161_OPT_VALIDATION_GRN)
+#if defined(MAXM86146_OPT_VALIDATION_GRN1)
     // Set Green1 current to 1uA, 10uA or 30uA
-    cmd[0] = 0x40; cmd[1] = 0x00; cmd[2] = 0x23; cmd[3] = 0xA7;
+    cmd[0] = 0x40; cmd[1] = 0x00; cmd[2] = 0x23; cmd[3] = 0x29;
     sh_i2c.write(SH_ADDR, cmd, 4);
     mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
     sh_i2c.read(SH_ADDR, rsp, 1);
@@ -978,7 +979,56 @@
     mfio = 1; mfio = 0; wait_us(300);
     pc.printf("wr afe reg Status: %x\n\r", rsp[0]);
 #endif
-#if defined(MAXM86161_OPT_VALIDATION_IR)
+#if defined(MAXM86146_OPT_VALIDATION_GRN2)
+    // Set Green1 current to 1uA, 10uA or 30uA
+    cmd[0] = 0x40; cmd[1] = 0x00; cmd[2] = 0x23; cmd[3] = 0x00;
+    sh_i2c.write(SH_ADDR, cmd, 4);
+    mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
+    sh_i2c.read(SH_ADDR, rsp, 1);
+    mfio = 1; mfio = 0; wait_us(300);
+    pc.printf("wr afe reg Status: %x\n\r", rsp[0]);
+ 
+    // Set LED2 current
+    cmd[0] = 0x40; cmd[1] = 0x00; cmd[2] = 0x24; cmd[3] = 0x0;
+    sh_i2c.write(SH_ADDR, cmd, 4);
+    mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
+    sh_i2c.read(SH_ADDR, rsp, 1);
+    mfio = 1; mfio = 0; wait_us(300);
+    pc.printf("wr afe reg Status: %x\n\r", rsp[0]);
+
+    // Set Green2 current
+    cmd[0] = 0x40; cmd[1] = 0x00; cmd[2] = 0x25; cmd[3] = 0x53;
+    sh_i2c.write(SH_ADDR, cmd, 4);
+    mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
+    sh_i2c.read(SH_ADDR, rsp, 1);
+    mfio = 1; mfio = 0; wait_us(300);
+    pc.printf("wr afe reg Status: %x\n\r", rsp[0]);
+ 
+    // Set LED4 current
+    cmd[0] = 0x40; cmd[1] = 0x00; cmd[2] = 0x26; cmd[3] = 0x0;
+    sh_i2c.write(SH_ADDR, cmd, 4);
+    mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
+    sh_i2c.read(SH_ADDR, rsp, 1);
+    mfio = 1; mfio = 0; wait_us(300);
+    pc.printf("wr afe reg Status: %x\n\r", rsp[0]);
+
+    // Set Red current
+    cmd[0] = 0x40; cmd[1] = 0x00; cmd[2] = 0x27; cmd[3] = 0x0;
+    sh_i2c.write(SH_ADDR, cmd, 4);
+    mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
+    sh_i2c.read(SH_ADDR, rsp, 1);
+    mfio = 1; mfio = 0; wait_us(300);
+    pc.printf("wr afe reg Status: %x\n\r", rsp[0]);
+
+    // Set IR current
+    cmd[0] = 0x40; cmd[1] = 0x00; cmd[2] = 0x28; cmd[3] = 0x0;
+    sh_i2c.write(SH_ADDR, cmd, 4);
+    mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
+    sh_i2c.read(SH_ADDR, rsp, 1);
+    mfio = 1; mfio = 0; wait_us(300);
+    pc.printf("wr afe reg Status: %x\n\r", rsp[0]);
+#endif
+#if defined(MAXM86146_OPT_VALIDATION_IR)
     // Set Green current 
     cmd[0] = 0x40; cmd[1] = 0x00; cmd[2] = 0x23; cmd[3] = 0x0;
     sh_i2c.write(SH_ADDR, cmd, 4);
@@ -1004,7 +1054,7 @@
     pc.printf("wr afe reg Status: %x\n\r", rsp[0]);
 #endif
  
-#if defined(MAXM86161_OPT_VALIDATION_RED)
+#if defined(MAXM86146_OPT_VALIDATION_RED)
     // Set Green current 
     cmd[0] = 0x40; cmd[1] = 0x00; cmd[2] = 0x23; cmd[3] = 0x0;
     sh_i2c.write(SH_ADDR, cmd, 4);
@@ -1030,7 +1080,7 @@
     pc.printf("wr afe reg Status: %x\n\r", rsp[0]);
  
 #endif
-#if defined(MAXM86161_OPT_VALIDATION_XTALK)
+#if defined(MAXM86146_OPT_VALIDATION_XTALK)
     // Set Green current 
     cmd[0] = 0x40; cmd[1] = 0x00; cmd[2] = 0x23; cmd[3] = 0xFF;
     sh_i2c.write(SH_ADDR, cmd, 4);