David Jung
/
MAX32664C_MAXM86146_Mode1_Optical
Mode1 Optical Validation
Diff: main.cpp
- Revision:
- 2:563d90a111b3
- Parent:
- 1:da792e46a385
- Child:
- 3:da975696b936
--- a/main.cpp Thu Mar 18 01:01:42 2021 +0000 +++ b/main.cpp Thu Mar 18 20:48:49 2021 +0000 @@ -36,8 +36,8 @@ #include "mbed.h" #include "platform/mbed_thread.h" -#define OB07 1 -#ifdef OB07 +#define MAXM86146_CFG 1 +#ifdef MAXM86146_CFG #define PPG_SZ 36 //maxm86146 #else #define PPG_SZ 18 //maxm86161, max86141 @@ -45,8 +45,8 @@ #define ACCEL_SZ 6 // accel #define SENSOR_SZ (PPG_SZ+ACCEL_SZ) #define ALGO_SZ 20 // 24 bytes is the algo normal size for 3x.12.0 -//#define ALGO_SZ 24 // 24 bytes is the algo normal size fifo output -#define ALGO_ONLY 1 +//#define ALGO_SZ 24 // 24 bytes is the algo normal size for 3x.13.x +//#define ALGO_ONLY 1 #ifdef ALGO_ONLY #define TTL_SZ (ALGO_SZ) #else @@ -79,11 +79,10 @@ char rsp[3000]; int32_t ppg[12]; int32_t accel[3]; - int32_t status, opmode, hr, hr_conf, spo2, spo2_conf; - int32_t scnt = 0; // sample set count + int32_t status, opmode, hr, hr_conf, spo2, spo2_conf, scd; + int32_t scnt = 0; int32_t ptr = 0; int32_t sptr = 0; - mfio = 0; wait_us(300); Time_to_Read_PPG = 0; #if 0 @@ -121,22 +120,27 @@ sptr = 1; for (i = 0; i < scnt; i++) { -// printf("ptr %d ttlsiz %d ", ptr, TTL_SZ); #ifdef ALGO_ONLY ptr = sptr; #else + ptr = sptr; + ppg[0] = (rsp[ptr+0] << 16) | (rsp[ptr+1] << 8) | (rsp[ptr+2]); + ppg[1] = (rsp[ptr+3] << 16) | (rsp[ptr+4] << 8) | (rsp[ptr+5]); + ppg[2] = (rsp[ptr+6] << 16) | (rsp[ptr+7] << 8) | (rsp[ptr+8]); + printf("%d,%d,%d,", ppg[0], ppg[1], ppg[2]); ptr = sptr + SENSOR_SZ; #endif +// printf("ptr %d ttlsiz %d ", ptr, TTL_SZ); opmode = rsp[ptr]; hr = (rsp[ptr+1] << 8) + rsp[ptr+2]; hr_conf = rsp[ptr+3]; spo2_conf = rsp[ptr+10]; spo2 = (rsp[ptr+11] << 8) + rsp[ptr+12]; + scd = rsp[ptr+19]; sptr += (TTL_SZ); -// printf("HR %d, HR Conf %d, SpO2 %d, Spo2 Conf %d,", hr, hr_conf, spo2, spo2_conf); - printf("%d, %d, %d, %d,", hr, hr_conf, spo2, spo2_conf); + printf("%d,%d,%d,%d,%d", hr, hr_conf, spo2, spo2_conf, scd); printf("\n"); } mfio = 1; @@ -289,8 +293,11 @@ // 1.3 sensor and algo data cmd[0] = 0x10; cmd[1] = 0x00; -// cmd[2] = 0x03; // sensor + algo data +#ifdef ALGO_ONLY cmd[2] = 0x02; // algo data +#else + cmd[2] = 0x03; // sensor + algo data +#endif i2c.write(addr, cmd, 3); mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300); rsp[0] = 0xAA; @@ -316,43 +323,43 @@ mfio = 1; mfio = 0; wait_us(300); printf("1.12 who accel %x %x\n", rsp[0], rsp[1]); -//Sec 4.1 map leds to slots for MAXM86146 +//1.20 Sec 4.1 map leds to slots for MAXM86146 cmd[0] = 0x50; cmd[1] = 0x07; cmd[2] = 0x19; - cmd[3] = 0x13; - cmd[4] = 0x56; + cmd[3] = 0x15; + cmd[4] = 0x60; cmd[5] = 0x00; i2c.write(addr, cmd, 6); mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300); i2c.read(addr, rsp, 1); mfio = 1; mfio = 0; wait_us(300); printf("map leds to slots%x\n", rsp[0]); -// map HR inputs to slots +//1.21 map HR inputs to slots cmd[0] = 0x50; cmd[1] = 0x07; cmd[2] = 0x17; cmd[3] = 0x00; - cmd[4] = 0x11; + cmd[4] = 0x01; i2c.write(addr, cmd, 5); mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300); i2c.read(addr, rsp, 1); mfio = 1; mfio = 0; wait_us(300); printf("map HR to slots/PDs %x\n", rsp[0]); -// map SpO2 inputs to slots +//1.22 map SpO2 inputs to slots cmd[0] = 0x50; cmd[1] = 0x07; cmd[2] = 0x18; - cmd[3] = 0x30; - cmd[4] = 0x20; + cmd[3] = 0x20; + cmd[4] = 0x10; i2c.write(addr, cmd, 5); mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300); i2c.read(addr, rsp, 1); mfio = 1; mfio = 0; wait_us(300); printf("map SpO2 to slots/PDs %x\n", rsp[0]); -// 1.14 +// 1.3 cmd[0] = 0x52; cmd[1] = 0x07; cmd[2] = 0x01;