David Jung
/
MAX32664C_MAXM86146_Mode1_Optical
Mode1 Optical Validation
Diff: main.cpp
- Revision:
- 1:da792e46a385
- Parent:
- 0:6f65cae31c54
- Child:
- 2:563d90a111b3
--- a/main.cpp Wed Mar 17 04:16:03 2021 +0000 +++ b/main.cpp Thu Mar 18 01:01:42 2021 +0000 @@ -84,9 +84,8 @@ int32_t ptr = 0; int32_t sptr = 0; - mfio = 0; + mfio = 0; wait_us(300); Time_to_Read_PPG = 0; - wait_us(300); #if 0 // 2.1 cmd[0] = 0x00; @@ -167,24 +166,30 @@ rst = 1; thread_sleep_for(50); + mfio = 0; wait_us(300); cmd[0] = 0x02; cmd[1] = 0x00; i2c.write(addr, cmd, 2); + mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300); thread_sleep_for(2); rsp[0] = 0x00; rsp[1] = 0x00; i2c.read(addr, rsp, 2); + mfio = 1; mfio = 0; wait_us(300); printf("02 00 Status, Operating Mode: %x %x\n", rsp[0], rsp[1]); + // rd BL ver cmd[0] = 0x81; cmd[1] = 0x00; i2c.write(addr, cmd, 2); + mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300); thread_sleep_for(2); rsp[0] = 0xAA; rsp[1] = 0xAA; rsp[2] = 0xAA; rsp[3] = 0xAA; i2c.read(addr, rsp, 4); + mfio = 1; mfio = 0; wait_us(300); printf("Ver: %d %d %d %d\n", rsp[0], rsp[1], rsp[2], rsp[3]); // application @@ -194,38 +199,28 @@ rst = 1; thread_sleep_for(1500); - mfio = 0; - wait_us(300); - + mfio = 1; mfio = 0; wait_us(300); cmd[0] = 0x02; cmd[1] = 0x00; i2c.write(addr, cmd, 2); - mfio = 1; - thread_sleep_for(2); - mfio = 0; - wait_us(300); + mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300); rsp[0] = 0x00; rsp[1] = 0x00; i2c.read(addr, rsp, 2); - mfio = 1; + mfio = 1; mfio = 0; wait_us(300); printf("02 00 Status, Operating Mode: %x %x\n", rsp[0], rsp[1]); // rd ver - mfio = 0; - wait_us(300); cmd[0] = 0xFF; cmd[1] = 0x03; i2c.write(addr, cmd, 2); - mfio = 1; - thread_sleep_for(2); - mfio = 0; - wait_us(300); + mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300); rsp[0] = 0xAA; rsp[1] = 0xAA; rsp[2] = 0xAA; rsp[3] = 0xAA; i2c.read(addr, rsp, 4); + printf("Ver: %d %d %d %d\n", rsp[0], rsp[1], rsp[2], rsp[3]); mfio = 1; - printf("Ver: %d %d %d %d\n", rsp[0], rsp[1], rsp[2], rsp[3]); // BL @@ -238,22 +233,24 @@ cmd[0] = 0x02; cmd[1] = 0x00; i2c.write(addr, cmd, 2); - thread_sleep_for(2); + mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300); rsp[0] = 0xAA; rsp[1] = 0xAA; i2c.read(addr, rsp, 2); printf("02 00 Status, Operating Mode: %x %x\n", rsp[0], rsp[1]); // rd BL ver + mfio = 1; mfio = 0; wait_us(300); cmd[0] = 0x81; cmd[1] = 0x00; i2c.write(addr, cmd, 2); - thread_sleep_for(2); + mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300); rsp[0] = 0xAA; rsp[1] = 0xAA; rsp[2] = 0xAA; rsp[3] = 0xAA; i2c.read(addr, rsp, 4); printf("Ver: %d %d %d %d\n", rsp[0], rsp[1], rsp[2], rsp[3]); + mfio = 1; #endif // end BL app switching //========================================== // application @@ -263,68 +260,60 @@ rst = 1; thread_sleep_for(1500); - mfio = 0; - wait_us(300); - + mfio = 0; wait_us(300); cmd[0] = 0x02; cmd[1] = 0x00; i2c.write(addr, cmd, 2); - mfio = 1; - thread_sleep_for(2); - mfio = 0; - wait_us(300); + mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300); rsp[0] = 0xAA; rsp[1] = 0xAA; i2c.read(addr, rsp, 2); - mfio = 1; + mfio = 1; mfio = 0; wait_us(300); printf("02 00 Status, Operating Mode: %x %x\n", rsp[0], rsp[1]); // rd ver - mfio = 0; - wait_us(300); cmd[0] = 0xFF; cmd[1] = 0x03; i2c.write(addr, cmd, 2); - mfio = 1; - thread_sleep_for(2); - mfio = 0; + mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300); wait_us(300); rsp[0] = 0xAA; rsp[1] = 0xAA; rsp[2] = 0xAA; rsp[3] = 0xAA; i2c.read(addr, rsp, 4); - mfio = 1; + mfio = 1; mfio = 0; wait_us(300); printf("Ver: %d %d %d %d\n", rsp[0], rsp[1], rsp[2], rsp[3]); // aec mode // 1.3 sensor and algo data - mfio = 0; - wait_us(300); cmd[0] = 0x10; cmd[1] = 0x00; // cmd[2] = 0x03; // sensor + algo data cmd[2] = 0x02; // algo data i2c.write(addr, cmd, 3); - thread_sleep_for(2); + mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300); rsp[0] = 0xAA; i2c.read(addr, rsp, 1); + mfio = 1; mfio = 0; wait_us(300); printf("1.3 Status: %x\n", rsp[0]); //1.11 rd AFE part id cmd[0] = 0x41; cmd[1] = 0x00; cmd[2] = 0xFF; i2c.write(addr, cmd, 3); - thread_sleep_for(2); + mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300); i2c.read(addr, rsp, 2); + mfio = 1; mfio = 0; wait_us(300); printf("1.11 part id afe %x %x\n", rsp[0], rsp[1]); //1.13 rd accel who cmd[0] = 0x41; cmd[1] = 0x04; cmd[2] = 0x0F; i2c.write(addr, cmd, 3); - thread_sleep_for(2); + mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300); i2c.read(addr, rsp, 2); + 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 @@ -335,8 +324,9 @@ cmd[4] = 0x56; cmd[5] = 0x00; i2c.write(addr, cmd, 6); - thread_sleep_for(2); + 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 cmd[0] = 0x50; @@ -345,8 +335,9 @@ cmd[3] = 0x00; cmd[4] = 0x11; i2c.write(addr, cmd, 5); - thread_sleep_for(2); + 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 @@ -356,8 +347,9 @@ cmd[3] = 0x30; cmd[4] = 0x20; i2c.write(addr, cmd, 5); - thread_sleep_for(2); + 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 @@ -378,6 +370,4 @@ read_ppg(); } } - - } \ No newline at end of file