David Jung
/
MAX32664C_MAXM86146_Mode1_Optical
Mode1 Optical Validation
Diff: main.cpp
- Revision:
- 30:77a30ea425da
- Parent:
- 29:a7dd81450b35
- Child:
- 31:92e1bcdb7b1e
--- a/main.cpp Thu Feb 03 02:32:05 2022 +0000 +++ b/main.cpp Fri Feb 04 02:37:39 2022 +0000 @@ -1,5 +1,5 @@ /******************************************************************************* -* Copyright (C) 2021 Maxim Integrated Products, Inc., All Rights Reserved. +* Copyright (C) 2021-22 Maxim Integrated Products, Inc., All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -37,7 +37,7 @@ /****************************************************************************** * https://os.mbed.com/users/phonemacro/code/MAX32664C_Example_Host_Code * Tera Term output is set to 115200 baud rate. -* ver: 211011 +* ver: 220203 ******************************************************************************/ /****************************************************************************** @@ -85,8 +85,8 @@ /*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*/ //#define RAW // define this if you only wnatAFE+accel data, no algorithm -//#define ALGO_ONLY 1 // define this if you only want algo data, comment out if you want raw sensor+algo data -#define EXTENDED_ALGO 1 // define this if you want the extended algo format +#define ALGO_ONLY 1 // define this if you only want algo data, comment out if you want raw sensor+algo data +//#define EXTENDED_ALGO 1 // define this if you want the extended algo format //#define AGC 1 // define this for AGC, otherwise the default is AEC #ifdef MAXREFDES103_CFG @@ -94,17 +94,10 @@ I2C sh_i2c_pmic(P5_7, P6_0); #endif -#ifdef MAXM86146_CFG - #define PPG_SZ 36 //maxm86146 -#else - #define PPG_SZ 18 //maxm86161, max86141 -#endif -#define ACCEL_SZ 6 // accel -#define SENSOR_SZ (PPG_SZ+ACCEL_SZ) - #if defined(MAXM86161_CFG) #define old_msbl 1 // 3x.12.0 or earlier; 32.9.x #endif + #ifdef old_msbl #ifdef EXTENDED_ALGO #define ALGO_SZ 52 // 52 bytes is the extended algo size for 3x.12.0 @@ -119,6 +112,16 @@ #endif #endif + +#ifdef MAXM86146_CFG + #define PPG_SZ 36 //maxm86146 +#else + #define PPG_SZ 18 //maxm86161, max86141 +#endif +#define ACCEL_SZ 6 // accel +#define SENSOR_SZ (PPG_SZ+ACCEL_SZ) + + #ifdef ALGO_ONLY #define TTL_SZ (ALGO_SZ) #else @@ -231,7 +234,6 @@ ppg[5] = (rsp[ptr+15] << 16) | (rsp[ptr+16] << 8) | (rsp[ptr+17]); pc.printf("%d,%d,%d,%d,", ppg[0], ppg[1], ppg[2], ppg[3]); #ifdef MAXM86146_CFG -#ifdef RAW pc.printf("%d,%d,", ppg[4], ppg[5]); ppg[6] = (rsp[ptr+18] << 16) | (rsp[ptr+19] << 8) | (rsp[ptr+20]); ppg[7] = (rsp[ptr+21] << 16) | (rsp[ptr+22] << 8) | (rsp[ptr+23]); @@ -241,7 +243,6 @@ ppg[11] = (rsp[ptr+33] << 16) | (rsp[ptr+34] << 8) | (rsp[ptr+35]); pc.printf("%d,%d,%d,%d,%d,%d,", ppg[6], ppg[7],ppg[8], ppg[9],ppg[10], ppg[11]); #endif -#endif accel[0] = (rsp[PPG_SZ+0] << 8) | (rsp[PPG_SZ+1]); accel[1] = (rsp[PPG_SZ+2] << 8) | (rsp[PPG_SZ+3]); accel[2] = (rsp[PPG_SZ+4] << 8) | (rsp[PPG_SZ+5]); @@ -481,13 +482,6 @@ sh_i2c.read(SH_ADDR, rsp, 1); mfio = 1; mfio = 0; wait_us(300); pc.printf("1.3 Status: %x\n\r", rsp[0]); -// 1.7 cont hr, spo2 - cmd[0] = 0x50; cmd[1] = 0x07; cmd[2] = 0x0A; 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("1.7 Status: %x\n\r", rsp[0]); // 1.8 AEC enable (default) cmd[0] = 0x50; cmd[1] = 0x07; cmd[2] = 0x0B; cmd[3] = 0x01; sh_i2c.write(SH_ADDR, cmd, 4); @@ -535,20 +529,22 @@ #endif #if defined(MAXM86161_CFG) //only use Red and IR -//1.20 Sec 4.1 map leds to slots for MAXM86146 +//1.20 Sec 4.1 map leds to slots cmd[0] = 0x50; cmd[1] = 0x07; cmd[2] = 0x19; cmd[3] = 0x23; cmd[4] = 0x00; cmd[5] = 0x00; sh_i2c.write(SH_ADDR, cmd, 6); 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("map leds to slots %x\n\r", rsp[0]); -//1.21 map HR inputs to slots +//1.21 map HR inputs to slots, default is 0x0073 for MAXM86161 +#if 0 // NA for MAXM86161 cmd[0] = 0x50; cmd[1] = 0x07; cmd[2] = 0x17; cmd[3] = 0x00; cmd[4] = 0x73; sh_i2c.write(SH_ADDR, cmd, 5); 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("map HR to slots/PDs %x\n\r", rsp[0]); +#endif //1.22 map SpO2 inputs to slots cmd[0] = 0x50; cmd[1] = 0x07; cmd[2] = 0x18; cmd[3] = 0x00; cmd[4] = 0x10; sh_i2c.write(SH_ADDR, cmd, 5); @@ -606,6 +602,13 @@ #endif #endif // MAXM86146_CFG +// 1.7 cont hr, spo2 + cmd[0] = 0x50; cmd[1] = 0x07; cmd[2] = 0x0A; 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("1.7 Status: %x\n\r", rsp[0]); #if 0 // MAXM86161 test new commands // LDO enable @@ -713,12 +716,32 @@ mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300); pc.printf("raw1.3 Status: %x\n\r", rsp[0]); // raw1.4 enable AFE - cmd[0] = 0x44; cmd[1] = 0x00; cmd[2] = 0x01; cmd[3] = 0x00; + cmd[0] = 0x44; cmd[1] = 0x00; cmd[2] = 0x01; // 3 bytes // tested on 33.13.12, 33.13.19 sh_i2c.write(SH_ADDR, cmd, 3); +// cmd[0] = 0x44; cmd[1] = 0x00; cmd[2] = 0x01; cmd[3] = 0x00; +// sh_i2c.write(SH_ADDR, cmd, 4); +// cmd[0] = 0x44; cmd[1] = 0xFF; cmd[2] = 0x02; cmd[3] = 0x04; cmd[4] = 0x01; cmd[5] = 0x00; cmd[6] = 0x00; cmd[7] = 0x01; cmd[8] = 0x00; +// sh_i2c.write(SH_ADDR, cmd, 9); mfio = 1; thread_sleep_for(250); mfio = 0; wait_us(300); sh_i2c.read(SH_ADDR, rsp, 1); mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300); pc.printf("raw1.4 Status: %x\n\r", rsp[0]); +#if 0 +// rd accel WHO reg + cmd[0] = 0x41; cmd[1] = 0x04; cmd[2] = 0x0F; + sh_i2c.write(SH_ADDR, cmd, 3); + mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300); + sh_i2c.read(SH_ADDR, rsp, 2); + mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300); + pc.printf("part id Status: %x %x\n\r", rsp[0], rsp[1]); +// rd AFE part id + cmd[0] = 0x41; cmd[1] = 0x00; cmd[2] = 0xFF; + sh_i2c.write(SH_ADDR, cmd, 3); + mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300); + sh_i2c.read(SH_ADDR, rsp, 2); + mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300); + pc.printf("part id Status: %x %x\n\r", rsp[0], rsp[1]); +#endif // raw1.5 sample rate 100 Hz, ave 1 cmd[0] = 0x40; cmd[1] = 0x00; cmd[2] = 0x12; cmd[3] = 0x18; // set AFE reg 0x12 to 100 Hz // cmd[0] = 0x40; cmd[1] = 0x00; cmd[2] = 0x12; cmd[3] = 0x20; // set AFE reg 0x12 to 200 Hz