David Jung
/
MAX32664C_MAXM86146_Mode1_Optical
Mode1 Optical Validation
Diff: main.cpp
- Revision:
- 12:17a0bf823462
- Parent:
- 11:a16b6bf38841
- Child:
- 13:1baccc6275a7
--- a/main.cpp Wed Mar 31 23:35:27 2021 +0000 +++ b/main.cpp Thu Apr 01 01:51:52 2021 +0000 @@ -50,11 +50,12 @@ /*****************************************************************************/ // define one and only one of the following three platforms #define MAXM86146_CFG 1 // tested on MAXM86146EVSYS_sensorBrd+MAXM86161_ADAPTER_REVB+MAX32630FTHR -//#define MAXREFDES103_CFG +//#define MAXREFDES103_CFG //#define MAX86161_CFG 1 /*****************************************************************************/ #define ALGO_ONLY 1 // define this if you only want the algo data, comment out if you want raw sensor+algo data +//#define EXTENDED_ALGO 1 // define this if you want the extended algo format #ifdef MAXREFDES103_CFG @@ -69,8 +70,13 @@ #endif #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 for 3x.13.x +#ifdef EXTENDED_ALGO + //#define ALGO_SZ 52 // 52 bytes is the extended algo size for 3x.12.0 + #define ALGO_SZ 56 // 56 bytes is the extended algo size for 3x.13.x +#else + //#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 for 3x.13.x +#endif #ifdef ALGO_ONLY #define TTL_SZ (ALGO_SZ) #else @@ -110,7 +116,12 @@ char rsp[3000]; int32_t ppg[12]; int16_t accel[3]; - int32_t status, opmode, hr, hr_conf, ibi, ibi_conf, act, r, spo2, spo2_conf; + int32_t status, opmode, hr, hr_conf, ibi, ibi_conf; +#ifdef EXTENDED_ALGO + int32_t walk_stp, run_stp, energy, amr, iadj1_rqt, iadj1, iadj2_rqt, iadj2, iadj3_rqt, iadj3; + int32_t intadj_rqt, intadj, smpladj_rqt, smpladj, rqt_smplave, afestatehr, hr_motion; +#endif + int32_t act, r, spo2, spo2_conf; int32_t spo2_compl, spo2_lo, spo2_mo, spo2_lopi, spo2_unrel, spo2_state, ibi_offset, scd; int32_t scnt = 0; int32_t ptr = 0; @@ -164,11 +175,78 @@ ptr = sptr + SENSOR_SZ; #endif +#ifdef EXTENDED_ALGO // pc.printf("ptr %d ttlsiz %d ", ptr, TTL_SZ); opmode = rsp[ptr]; hr = (rsp[ptr+1] << 8) + rsp[ptr+2]; hr_conf = rsp[ptr+3]; - ibi = (rsp[ptr+5] << 8) + rsp[ptr+4]; + ibi = (rsp[ptr+4] << 8) + rsp[ptr+5]; + + ibi_conf = rsp[ptr+6]; + act = rsp[ptr+7]; + walk_stp = (rsp[ptr+8] << 24) + (rsp[ptr+9] << 16) + (rsp[ptr+10] << 8) + rsp[ptr+11]; + run_stp = (rsp[ptr+12] << 24) + (rsp[ptr+13] << 16) + (rsp[ptr+14] << 8) + rsp[ptr+15]; + + energy = (rsp[ptr+16] << 24) + (rsp[ptr+17] << 16) + (rsp[ptr+18] << 8) + rsp[ptr+19]; + amr = (rsp[ptr+20] << 24) + (rsp[ptr+21] << 16) + (rsp[ptr+22] << 8) + rsp[ptr+23]; + iadj1_rqt = rsp[ptr+24]; + iadj1 = (rsp[ptr+25] << 8) + rsp[ptr+26]; + + iadj2_rqt = rsp[ptr+27]; + iadj2 = (rsp[ptr+28] << 8) + rsp[ptr+29]; + iadj3_rqt = rsp[ptr+30]; + iadj3 = (rsp[ptr+31] << 8) + rsp[ptr+32]; + + intadj_rqt = rsp[ptr+33]; + intadj = rsp[ptr+34]; + smpladj_rqt = rsp[ptr+35]; + smpladj = rsp[ptr+36]; + + rqt_smplave = rsp[ptr+37]; + afestatehr = rsp[ptr+38]; + hr_motion = rsp[ptr+39]; + scd = rsp[ptr+40]; + + + r = (rsp[ptr+41] << 8) + rsp[ptr+42]; + spo2_conf = rsp[ptr+43]; + + spo2 = (rsp[ptr+44] << 8) + rsp[ptr+45]; + spo2_compl = rsp[ptr+46]; + spo2_lo = rsp[ptr+47]; + spo2_mo = rsp[ptr+48]; + + spo2_lopi = rsp[ptr+49]; + spo2_unrel = rsp[ptr+50]; + spo2_state = rsp[ptr+51]; + + ibi_offset = rsp[ptr+52]; + + sptr += (TTL_SZ); +#if 1 + pc.printf("%d,%d,%d,%d,", opmode, hr, hr_conf, ibi); + pc.printf("%d,%d,", ibi_conf, act); + pc.printf("%d,%d,%d,", walk_stp, run_stp, energy); + pc.printf("%d,%d,%d,%d,", amr, iadj1_rqt, iadj1, iadj2_rqt); + pc.printf("%d,%d,%d,%d,", iadj2, iadj3_rqt, iadj3, intadj_rqt); + pc.printf("%d,%d,%d,%d,", intadj, smpladj_rqt, smpladj, rqt_smplave); + pc.printf("%d,%d,", afestatehr, hr_motion); + pc.printf("%d,", scd); + pc.printf("%d,%d,%d,%d,", spo2, spo2_compl, spo2_lo, spo2_mo); + pc.printf("%d,%d,%d,", spo2_lopi,spo2_unrel, spo2_state); + pc.printf("%d,", ibi_offset); +#else + pc.printf("%d,%d,", hr, hr_conf); + pc.printf("%d,%d,", spo2, spo2_conf); + pc.printf("%d,", spo2_lo); + pc.printf("%d,%d,", spo2_unrel, scd); +#endif +#else // normal algo size +// pc.printf("ptr %d ttlsiz %d ", ptr, TTL_SZ); + opmode = rsp[ptr]; + hr = (rsp[ptr+1] << 8) + rsp[ptr+2]; + hr_conf = rsp[ptr+3]; + ibi = (rsp[ptr+4] << 8) + rsp[ptr+5]; ibi_conf = rsp[ptr+6]; act = rsp[ptr+7]; @@ -200,6 +278,7 @@ pc.printf("%d,", spo2_lo); pc.printf("%d,%d,", spo2_unrel, scd); #endif +#endif // end normal algo size pc.printf("\n\r"); @@ -352,7 +431,11 @@ #endif // MAXM86146_CFG // 1.3 Enable HR, SpO2 algo +#ifdef EXTENDED_ALGO + cmd[0] = 0x52; cmd[1] = 0x07; cmd[2] = 0x02; +#else cmd[0] = 0x52; cmd[1] = 0x07; cmd[2] = 0x01; +#endif sh_i2c.write(SH_ADDR, cmd, 3); thread_sleep_for(465); sh_i2c.read(SH_ADDR, rsp, 1);