David Jung
/
MAX32664C_MAXM86146_Mode1_Optical
Mode1 Optical Validation
Diff: main.cpp
- Revision:
- 63:61f62564922c
- Parent:
- 62:21a7745d02e0
- Child:
- 64:10da950111dd
diff -r 21a7745d02e0 -r 61f62564922c main.cpp --- a/main.cpp Wed Jun 01 01:11:36 2022 +0000 +++ b/main.cpp Wed Jun 01 01:20:49 2022 +0000 @@ -93,11 +93,11 @@ //#define RAW_HZ 200 // Raw data rate //#define RAW_HZ 2004 // Raw data rate 200 Hz, ave 4 //#define SPO2_CAL_RPT 1 -#define MAXM86146_OPT_VALIDATION_GRN1 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 - +#define MAXM86146_OPT_VALIDATION_IR 1 // Optical validatation +//#define MAXM86146_OPT_VALIDATION_XTALK 1 // Optical validatation // Comment out both of the below for Normal Algorithm Samples Format //#define EXTENDED_ALGO 1 // define this if you want the extended algo samples report format @@ -980,7 +980,7 @@ pc.printf("wr afe reg Status: %x\n\r", rsp[0]); #endif #if defined(MAXM86146_OPT_VALIDATION_GRN2) - // Set Green1 current to 1uA, 10uA or 30uA + // Set Green1 current 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); @@ -996,8 +996,8 @@ 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; + // Set Green2 current to 1uA, 10uA or 30uA + cmd[0] = 0x40; cmd[1] = 0x00; cmd[2] = 0x25; 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); @@ -1028,25 +1028,98 @@ 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; +#if defined(MAXM86146_OPT_VALIDATION_RED) + // Set Green1 current + 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] = 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 to 1uA, 10uA or 30uA - cmd[0] = 0x40; cmd[1] = 0x00; cmd[2] = 0x24; cmd[3] = 0xA7; + // 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 to 1uA, 10uA or 30uA + cmd[0] = 0x40; cmd[1] = 0x00; cmd[2] = 0x27; 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); + 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 Green1 current + 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] = 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 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] = 0x25; cmd[3] = 0x0; + 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 to 1uA, 10uA or 30uA + cmd[0] = 0x40; cmd[1] = 0x00; cmd[2] = 0x28; 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); @@ -1054,32 +1127,6 @@ pc.printf("wr afe reg Status: %x\n\r", rsp[0]); #endif -#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); - 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] = 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 Red current to 1uA, 10uA or 30uA - cmd[0] = 0x40; cmd[1] = 0x00; cmd[2] = 0x25; cmd[3] = 0xA7; - 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_XTALK) // Set Green current cmd[0] = 0x40; cmd[1] = 0x00; cmd[2] = 0x23; cmd[3] = 0xFF;