Mode1 Optical Validation

Dependencies:   max32630fthr

Committer:
phonemacro
Date:
Fri Mar 19 00:14:42 2021 +0000
Revision:
3:da975696b936
Parent:
2:563d90a111b3
Child:
4:4f1e9439f048
change serial baud to 115200;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
phonemacro 0:6f65cae31c54 1 /*******************************************************************************
phonemacro 0:6f65cae31c54 2 * Copyright (C) 2018 Maxim Integrated Products, Inc., All Rights Reserved.
phonemacro 0:6f65cae31c54 3 *
phonemacro 0:6f65cae31c54 4 * Permission is hereby granted, free of charge, to any person obtaining a
phonemacro 0:6f65cae31c54 5 * copy of this software and associated documentation files (the "Software"),
phonemacro 0:6f65cae31c54 6 * to deal in the Software without restriction, including without limitation
phonemacro 0:6f65cae31c54 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
phonemacro 0:6f65cae31c54 8 * and/or sell copies of the Software, and to permit persons to whom the
phonemacro 0:6f65cae31c54 9 * Software is furnished to do so, subject to the following conditions:
phonemacro 0:6f65cae31c54 10 *
phonemacro 0:6f65cae31c54 11 * The above copyright notice and this permission notice shall be included
phonemacro 0:6f65cae31c54 12 * in all copies or substantial portions of the Software.
phonemacro 0:6f65cae31c54 13 *
phonemacro 0:6f65cae31c54 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
phonemacro 0:6f65cae31c54 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
phonemacro 0:6f65cae31c54 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
phonemacro 0:6f65cae31c54 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
phonemacro 0:6f65cae31c54 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
phonemacro 0:6f65cae31c54 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
phonemacro 0:6f65cae31c54 20 * OTHER DEALINGS IN THE SOFTWARE.
phonemacro 0:6f65cae31c54 21 *
phonemacro 0:6f65cae31c54 22 * Except as contained in this notice, the name of Maxim Integrated
phonemacro 0:6f65cae31c54 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
phonemacro 0:6f65cae31c54 24 * Products, Inc. Branding Policy.
phonemacro 0:6f65cae31c54 25 *
phonemacro 0:6f65cae31c54 26 * The mere transfer of this software does not imply any licenses
phonemacro 0:6f65cae31c54 27 * of trade secrets, proprietary technology, copyrights, patents,
phonemacro 0:6f65cae31c54 28 * trademarks, maskwork rights, or any other form of intellectual
phonemacro 0:6f65cae31c54 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
phonemacro 0:6f65cae31c54 30 * ownership rights.
phonemacro 0:6f65cae31c54 31 *******************************************************************************
phonemacro 0:6f65cae31c54 32 */
phonemacro 0:6f65cae31c54 33
phonemacro 0:6f65cae31c54 34 #include "mbed.h"
phonemacro 0:6f65cae31c54 35 #include "platform/mbed_thread.h"
phonemacro 3:da975696b936 36 #include "mbed.h"
phonemacro 0:6f65cae31c54 37
phonemacro 2:563d90a111b3 38 #define MAXM86146_CFG 1
phonemacro 2:563d90a111b3 39 #ifdef MAXM86146_CFG
phonemacro 0:6f65cae31c54 40 #define PPG_SZ 36 //maxm86146
phonemacro 0:6f65cae31c54 41 #else
phonemacro 0:6f65cae31c54 42 #define PPG_SZ 18 //maxm86161, max86141
phonemacro 0:6f65cae31c54 43 #endif
phonemacro 0:6f65cae31c54 44 #define ACCEL_SZ 6 // accel
phonemacro 0:6f65cae31c54 45 #define SENSOR_SZ (PPG_SZ+ACCEL_SZ)
phonemacro 3:da975696b936 46 //#define ALGO_SZ 20 // 24 bytes is the algo normal size for 3x.12.0
phonemacro 3:da975696b936 47 #define ALGO_SZ 24 // 24 bytes is the algo normal size for 3x.13.x
phonemacro 2:563d90a111b3 48 //#define ALGO_ONLY 1
phonemacro 0:6f65cae31c54 49 #ifdef ALGO_ONLY
phonemacro 0:6f65cae31c54 50 #define TTL_SZ (ALGO_SZ)
phonemacro 0:6f65cae31c54 51 #else
phonemacro 0:6f65cae31c54 52 #define TTL_SZ (PPG_SZ+ACCEL_SZ+ALGO_SZ)
phonemacro 0:6f65cae31c54 53 #endif
phonemacro 0:6f65cae31c54 54
phonemacro 3:da975696b936 55 Serial pc(USBTX, USBRX, 115200);
phonemacro 0:6f65cae31c54 56 DigitalOut rLED(LED1);
phonemacro 0:6f65cae31c54 57 DigitalOut gLED(LED2);
phonemacro 0:6f65cae31c54 58 DigitalOut bLED(LED3);
phonemacro 0:6f65cae31c54 59 #define RST_PIN P5_6
phonemacro 0:6f65cae31c54 60 #define MFIO_PIN P5_4
phonemacro 0:6f65cae31c54 61 DigitalOut rst(RST_PIN, PullUp);
phonemacro 0:6f65cae31c54 62 DigitalOut mfio(MFIO_PIN, PullUp);
phonemacro 0:6f65cae31c54 63 I2C i2c(P3_4, P3_5);
phonemacro 0:6f65cae31c54 64
phonemacro 0:6f65cae31c54 65 const int addr = 0xAA;//0x55;
phonemacro 0:6f65cae31c54 66 int32_t Time_to_Read_PPG = 0;
phonemacro 0:6f65cae31c54 67
phonemacro 0:6f65cae31c54 68 #define BLINKING_RATE_MS 1000ms
phonemacro 0:6f65cae31c54 69 void blink_timer(void) {
phonemacro 0:6f65cae31c54 70 gLED = !gLED; /* blink the green LED */
phonemacro 0:6f65cae31c54 71 }
phonemacro 0:6f65cae31c54 72
phonemacro 0:6f65cae31c54 73 void fifo_timer(void) {
phonemacro 0:6f65cae31c54 74 Time_to_Read_PPG = 1;
phonemacro 0:6f65cae31c54 75 }
phonemacro 0:6f65cae31c54 76
phonemacro 0:6f65cae31c54 77 void read_ppg(void) {
phonemacro 0:6f65cae31c54 78 char cmd[8], i, j, samples;
phonemacro 0:6f65cae31c54 79 char rsp[3000];
phonemacro 0:6f65cae31c54 80 int32_t ppg[12];
phonemacro 0:6f65cae31c54 81 int32_t accel[3];
phonemacro 3:da975696b936 82 int32_t status, opmode, hr, hr_conf, ibi, ibi_conf, act, r, spo2, spo2_conf, scd;
phonemacro 2:563d90a111b3 83 int32_t scnt = 0;
phonemacro 0:6f65cae31c54 84 int32_t ptr = 0;
phonemacro 0:6f65cae31c54 85 int32_t sptr = 0;
phonemacro 1:da792e46a385 86 mfio = 0; wait_us(300);
phonemacro 0:6f65cae31c54 87 Time_to_Read_PPG = 0;
phonemacro 0:6f65cae31c54 88 #if 0
phonemacro 0:6f65cae31c54 89 // 2.1
phonemacro 0:6f65cae31c54 90 cmd[0] = 0x00;
phonemacro 0:6f65cae31c54 91 cmd[1] = 0x00;
phonemacro 0:6f65cae31c54 92 i2c.write(addr, cmd, 2);
phonemacro 0:6f65cae31c54 93 wait_us(100);
phonemacro 0:6f65cae31c54 94 i2c.read(addr, rsp, 2);
phonemacro 3:da975696b936 95 // pc.printf("2.1 Status: %x %x\n\r", rsp[0], rsp[1]);
phonemacro 0:6f65cae31c54 96 #endif
phonemacro 0:6f65cae31c54 97 // 2.2
phonemacro 0:6f65cae31c54 98 cmd[0] = 0x12;
phonemacro 0:6f65cae31c54 99 cmd[1] = 0x00;
phonemacro 0:6f65cae31c54 100 i2c.write(addr, cmd, 2);
phonemacro 0:6f65cae31c54 101 wait_us(100);
phonemacro 0:6f65cae31c54 102 i2c.read(addr, rsp, 2);
phonemacro 3:da975696b936 103 // pc.printf("2.2 Status: %x %x\n\r", rsp[0], rsp[1]);
phonemacro 0:6f65cae31c54 104 samples = rsp[1];
phonemacro 3:da975696b936 105 // pc.printf("num samples %d, (num*ttl)+1 %d\n\r", rsp[1], TTL_SZ*samples+1);
phonemacro 3:da975696b936 106 // pc.printf("num smpls %d \n\r", samples);
phonemacro 0:6f65cae31c54 107 scnt = rsp[1];
phonemacro 0:6f65cae31c54 108 // 2.3
phonemacro 0:6f65cae31c54 109 cmd[0] = 0x12;
phonemacro 0:6f65cae31c54 110 cmd[1] = 0x01;
phonemacro 0:6f65cae31c54 111 i2c.write(addr, cmd, 2);
phonemacro 0:6f65cae31c54 112 wait_us(100);
phonemacro 0:6f65cae31c54 113 // thread_sleep_for(1);
phonemacro 0:6f65cae31c54 114 i2c.read(addr, rsp, 1+(TTL_SZ*samples));
phonemacro 0:6f65cae31c54 115 status = rsp[0];
phonemacro 0:6f65cae31c54 116
phonemacro 0:6f65cae31c54 117 sptr = 1;
phonemacro 0:6f65cae31c54 118 for (i = 0; i < scnt; i++) {
phonemacro 0:6f65cae31c54 119 #ifdef ALGO_ONLY
phonemacro 0:6f65cae31c54 120 ptr = sptr;
phonemacro 0:6f65cae31c54 121 #else
phonemacro 2:563d90a111b3 122 ptr = sptr;
phonemacro 2:563d90a111b3 123 ppg[0] = (rsp[ptr+0] << 16) | (rsp[ptr+1] << 8) | (rsp[ptr+2]);
phonemacro 2:563d90a111b3 124 ppg[1] = (rsp[ptr+3] << 16) | (rsp[ptr+4] << 8) | (rsp[ptr+5]);
phonemacro 2:563d90a111b3 125 ppg[2] = (rsp[ptr+6] << 16) | (rsp[ptr+7] << 8) | (rsp[ptr+8]);
phonemacro 3:da975696b936 126 ppg[3] = (rsp[ptr+9] << 16) | (rsp[ptr+10] << 8) | (rsp[ptr+11]);
phonemacro 3:da975696b936 127 pc.printf("%d,%d,%d,%d,", ppg[0], ppg[1], ppg[2], ppg[3]);
phonemacro 0:6f65cae31c54 128 ptr = sptr + SENSOR_SZ;
phonemacro 0:6f65cae31c54 129 #endif
phonemacro 3:da975696b936 130 // pc.printf("ptr %d ttlsiz %d ", ptr, TTL_SZ);
phonemacro 0:6f65cae31c54 131 opmode = rsp[ptr];
phonemacro 0:6f65cae31c54 132 hr = (rsp[ptr+1] << 8) + rsp[ptr+2];
phonemacro 0:6f65cae31c54 133 hr_conf = rsp[ptr+3];
phonemacro 3:da975696b936 134 ibi = rsp[ptr+4];
phonemacro 3:da975696b936 135 ibi_conf = (rsp[ptr+5] << 8) + rsp[ptr+6];
phonemacro 3:da975696b936 136 act = rsp[ptr+7];
phonemacro 3:da975696b936 137 r = (rsp[ptr+8] << 8) + rsp[ptr+9];
phonemacro 0:6f65cae31c54 138 spo2_conf = rsp[ptr+10];
phonemacro 0:6f65cae31c54 139 spo2 = (rsp[ptr+11] << 8) + rsp[ptr+12];
phonemacro 2:563d90a111b3 140 scd = rsp[ptr+19];
phonemacro 0:6f65cae31c54 141
phonemacro 0:6f65cae31c54 142 sptr += (TTL_SZ);
phonemacro 0:6f65cae31c54 143
phonemacro 3:da975696b936 144 pc.printf("%d,%d,%d,%d,%d", hr, hr_conf, spo2, spo2_conf, scd);
phonemacro 3:da975696b936 145 pc.printf("\n\r");
phonemacro 0:6f65cae31c54 146 }
phonemacro 0:6f65cae31c54 147 mfio = 1;
phonemacro 0:6f65cae31c54 148 }
phonemacro 0:6f65cae31c54 149
phonemacro 0:6f65cae31c54 150 int main()
phonemacro 0:6f65cae31c54 151 {
phonemacro 3:da975696b936 152 i2c.frequency(400000);
phonemacro 0:6f65cae31c54 153 char cmd[8], i, j;
phonemacro 0:6f65cae31c54 154 char rsp[256];
phonemacro 0:6f65cae31c54 155 int32_t ppg[12];
phonemacro 3:da975696b936 156
phonemacro 0:6f65cae31c54 157 rLED = LED_OFF;
phonemacro 0:6f65cae31c54 158 gLED = LED_ON;
phonemacro 0:6f65cae31c54 159 bLED = LED_OFF;
phonemacro 0:6f65cae31c54 160 Ticker ticker; // calls a callback repeatedly with a timeout
phonemacro 0:6f65cae31c54 161 //ticker.attach(callback(&blink_timer), BLINKING_RATE_MS); /* set timer for one second */
phonemacro 0:6f65cae31c54 162
phonemacro 0:6f65cae31c54 163 // application
phonemacro 0:6f65cae31c54 164 rst = 0;
phonemacro 0:6f65cae31c54 165 mfio = 1;
phonemacro 0:6f65cae31c54 166 thread_sleep_for(10);
phonemacro 0:6f65cae31c54 167 rst = 1;
phonemacro 0:6f65cae31c54 168 thread_sleep_for(1500);
phonemacro 0:6f65cae31c54 169
phonemacro 1:da792e46a385 170 mfio = 0; wait_us(300);
phonemacro 0:6f65cae31c54 171 cmd[0] = 0x02;
phonemacro 0:6f65cae31c54 172 cmd[1] = 0x00;
phonemacro 0:6f65cae31c54 173 i2c.write(addr, cmd, 2);
phonemacro 1:da792e46a385 174 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 0:6f65cae31c54 175 i2c.read(addr, rsp, 2);
phonemacro 1:da792e46a385 176 mfio = 1; mfio = 0; wait_us(300);
phonemacro 3:da975696b936 177 pc.printf("02 00 Status, Operating Mode: %x %x\n\r", rsp[0], rsp[1]);
phonemacro 0:6f65cae31c54 178 // rd ver
phonemacro 0:6f65cae31c54 179 cmd[0] = 0xFF;
phonemacro 0:6f65cae31c54 180 cmd[1] = 0x03;
phonemacro 0:6f65cae31c54 181 i2c.write(addr, cmd, 2);
phonemacro 1:da792e46a385 182 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 0:6f65cae31c54 183 wait_us(300);
phonemacro 0:6f65cae31c54 184 i2c.read(addr, rsp, 4);
phonemacro 1:da792e46a385 185 mfio = 1; mfio = 0; wait_us(300);
phonemacro 3:da975696b936 186 pc.printf("Ver: %d %d %d %d\n\r", rsp[0], rsp[1], rsp[2], rsp[3]);
phonemacro 0:6f65cae31c54 187
phonemacro 0:6f65cae31c54 188 // 1.3 sensor and algo data
phonemacro 0:6f65cae31c54 189 cmd[0] = 0x10;
phonemacro 0:6f65cae31c54 190 cmd[1] = 0x00;
phonemacro 2:563d90a111b3 191 #ifdef ALGO_ONLY
phonemacro 0:6f65cae31c54 192 cmd[2] = 0x02; // algo data
phonemacro 2:563d90a111b3 193 #else
phonemacro 2:563d90a111b3 194 cmd[2] = 0x03; // sensor + algo data
phonemacro 2:563d90a111b3 195 #endif
phonemacro 0:6f65cae31c54 196 i2c.write(addr, cmd, 3);
phonemacro 1:da792e46a385 197 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 0:6f65cae31c54 198 i2c.read(addr, rsp, 1);
phonemacro 1:da792e46a385 199 mfio = 1; mfio = 0; wait_us(300);
phonemacro 3:da975696b936 200 pc.printf("1.3 Status: %x\n\r", rsp[0]);
phonemacro 3:da975696b936 201 // 1.7 cont hr, spo2
phonemacro 3:da975696b936 202 cmd[0] = 0x50;
phonemacro 3:da975696b936 203 cmd[1] = 0x07;
phonemacro 3:da975696b936 204 cmd[2] = 0x0A;
phonemacro 3:da975696b936 205 cmd[3] = 0x00;
phonemacro 3:da975696b936 206 i2c.write(addr, cmd, 4);
phonemacro 3:da975696b936 207 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 3:da975696b936 208 i2c.read(addr, rsp, 1);
phonemacro 3:da975696b936 209 mfio = 1; mfio = 0; wait_us(300);
phonemacro 3:da975696b936 210 pc.printf("1.7 Status: %x\n\r", rsp[0]);
phonemacro 0:6f65cae31c54 211 //1.11 rd AFE part id
phonemacro 0:6f65cae31c54 212 cmd[0] = 0x41;
phonemacro 0:6f65cae31c54 213 cmd[1] = 0x00;
phonemacro 0:6f65cae31c54 214 cmd[2] = 0xFF;
phonemacro 0:6f65cae31c54 215 i2c.write(addr, cmd, 3);
phonemacro 1:da792e46a385 216 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 0:6f65cae31c54 217 i2c.read(addr, rsp, 2);
phonemacro 1:da792e46a385 218 mfio = 1; mfio = 0; wait_us(300);
phonemacro 3:da975696b936 219 pc.printf("1.11 part id afe %x %x\n\r", rsp[0], rsp[1]);
phonemacro 0:6f65cae31c54 220 //1.13 rd accel who
phonemacro 0:6f65cae31c54 221 cmd[0] = 0x41;
phonemacro 0:6f65cae31c54 222 cmd[1] = 0x04;
phonemacro 0:6f65cae31c54 223 cmd[2] = 0x0F;
phonemacro 0:6f65cae31c54 224 i2c.write(addr, cmd, 3);
phonemacro 1:da792e46a385 225 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 0:6f65cae31c54 226 i2c.read(addr, rsp, 2);
phonemacro 1:da792e46a385 227 mfio = 1; mfio = 0; wait_us(300);
phonemacro 3:da975696b936 228 pc.printf("1.12 who accel %x %x\n\r", rsp[0], rsp[1]);
phonemacro 3:da975696b936 229 #ifdef MAXM86146_CFG
phonemacro 3:da975696b936 230 #if 1
phonemacro 3:da975696b936 231 //1.20 Sec 4.1 map leds to slots for MAXM86146
phonemacro 3:da975696b936 232 cmd[0] = 0x50;
phonemacro 3:da975696b936 233 cmd[1] = 0x07;
phonemacro 3:da975696b936 234 cmd[2] = 0x19;
phonemacro 3:da975696b936 235 cmd[3] = 0x13;
phonemacro 3:da975696b936 236 cmd[4] = 0x56;
phonemacro 3:da975696b936 237 cmd[5] = 0x00;
phonemacro 3:da975696b936 238 i2c.write(addr, cmd, 6);
phonemacro 3:da975696b936 239 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 3:da975696b936 240 i2c.read(addr, rsp, 1);
phonemacro 3:da975696b936 241 mfio = 1; mfio = 0; wait_us(300);
phonemacro 3:da975696b936 242 pc.printf("map leds to slots%x\n\r", rsp[0]);
phonemacro 3:da975696b936 243 //1.21 map HR inputs to slots
phonemacro 3:da975696b936 244 cmd[0] = 0x50;
phonemacro 3:da975696b936 245 cmd[1] = 0x07;
phonemacro 3:da975696b936 246 cmd[2] = 0x17;
phonemacro 3:da975696b936 247 cmd[3] = 0x00;
phonemacro 3:da975696b936 248 cmd[4] = 0x11;
phonemacro 3:da975696b936 249 i2c.write(addr, cmd, 5);
phonemacro 3:da975696b936 250 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 3:da975696b936 251 i2c.read(addr, rsp, 1);
phonemacro 3:da975696b936 252 mfio = 1; mfio = 0; wait_us(300);
phonemacro 3:da975696b936 253 pc.printf("map HR to slots/PDs %x\n\r", rsp[0]);
phonemacro 3:da975696b936 254 //1.22 map SpO2 inputs to slots
phonemacro 3:da975696b936 255 cmd[0] = 0x50;
phonemacro 3:da975696b936 256 cmd[1] = 0x07;
phonemacro 3:da975696b936 257 cmd[2] = 0x18;
phonemacro 3:da975696b936 258 cmd[3] = 0x30;
phonemacro 3:da975696b936 259 cmd[4] = 0x20;
phonemacro 3:da975696b936 260 i2c.write(addr, cmd, 5);
phonemacro 3:da975696b936 261 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 3:da975696b936 262 i2c.read(addr, rsp, 1);
phonemacro 3:da975696b936 263 mfio = 1; mfio = 0; wait_us(300);
phonemacro 3:da975696b936 264 pc.printf("map SpO2 to slots/PDs %x\n\r", rsp[0]);
phonemacro 3:da975696b936 265 #endif
phonemacro 3:da975696b936 266 #if 0
phonemacro 2:563d90a111b3 267 //1.20 Sec 4.1 map leds to slots for MAXM86146
phonemacro 0:6f65cae31c54 268 cmd[0] = 0x50;
phonemacro 0:6f65cae31c54 269 cmd[1] = 0x07;
phonemacro 0:6f65cae31c54 270 cmd[2] = 0x19;
phonemacro 2:563d90a111b3 271 cmd[3] = 0x15;
phonemacro 2:563d90a111b3 272 cmd[4] = 0x60;
phonemacro 0:6f65cae31c54 273 cmd[5] = 0x00;
phonemacro 0:6f65cae31c54 274 i2c.write(addr, cmd, 6);
phonemacro 1:da792e46a385 275 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 0:6f65cae31c54 276 i2c.read(addr, rsp, 1);
phonemacro 1:da792e46a385 277 mfio = 1; mfio = 0; wait_us(300);
phonemacro 3:da975696b936 278 pc.printf("map leds to slots%x\n\r", rsp[0]);
phonemacro 2:563d90a111b3 279 //1.21 map HR inputs to slots
phonemacro 0:6f65cae31c54 280 cmd[0] = 0x50;
phonemacro 0:6f65cae31c54 281 cmd[1] = 0x07;
phonemacro 0:6f65cae31c54 282 cmd[2] = 0x17;
phonemacro 0:6f65cae31c54 283 cmd[3] = 0x00;
phonemacro 2:563d90a111b3 284 cmd[4] = 0x01;
phonemacro 0:6f65cae31c54 285 i2c.write(addr, cmd, 5);
phonemacro 1:da792e46a385 286 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 0:6f65cae31c54 287 i2c.read(addr, rsp, 1);
phonemacro 1:da792e46a385 288 mfio = 1; mfio = 0; wait_us(300);
phonemacro 3:da975696b936 289 pc.printf("map HR to slots/PDs %x\n\r", rsp[0]);
phonemacro 2:563d90a111b3 290 //1.22 map SpO2 inputs to slots
phonemacro 0:6f65cae31c54 291 cmd[0] = 0x50;
phonemacro 0:6f65cae31c54 292 cmd[1] = 0x07;
phonemacro 0:6f65cae31c54 293 cmd[2] = 0x18;
phonemacro 2:563d90a111b3 294 cmd[3] = 0x20;
phonemacro 2:563d90a111b3 295 cmd[4] = 0x10;
phonemacro 0:6f65cae31c54 296 i2c.write(addr, cmd, 5);
phonemacro 1:da792e46a385 297 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 0:6f65cae31c54 298 i2c.read(addr, rsp, 1);
phonemacro 1:da792e46a385 299 mfio = 1; mfio = 0; wait_us(300);
phonemacro 3:da975696b936 300 pc.printf("map SpO2 to slots/PDs %x\n\r", rsp[0]);
phonemacro 3:da975696b936 301 #endif
phonemacro 3:da975696b936 302 #endif // MAXM86146_CFG
phonemacro 0:6f65cae31c54 303
phonemacro 2:563d90a111b3 304 // 1.3
phonemacro 0:6f65cae31c54 305 cmd[0] = 0x52;
phonemacro 0:6f65cae31c54 306 cmd[1] = 0x07;
phonemacro 0:6f65cae31c54 307 cmd[2] = 0x01;
phonemacro 0:6f65cae31c54 308 i2c.write(addr, cmd, 3);
phonemacro 0:6f65cae31c54 309 thread_sleep_for(465);
phonemacro 0:6f65cae31c54 310 i2c.read(addr, rsp, 1);
phonemacro 3:da975696b936 311 pc.printf("1.14 status: %x\n\r", rsp[0]);
phonemacro 0:6f65cae31c54 312 mfio = 1;
phonemacro 0:6f65cae31c54 313
phonemacro 3:da975696b936 314 ticker.attach(callback(&fifo_timer), 0.040f);
phonemacro 3:da975696b936 315 // Timer tmr1;
phonemacro 0:6f65cae31c54 316 while (1) {
phonemacro 0:6f65cae31c54 317 if (Time_to_Read_PPG) {
phonemacro 0:6f65cae31c54 318 read_ppg();
phonemacro 0:6f65cae31c54 319 }
phonemacro 0:6f65cae31c54 320 }
phonemacro 0:6f65cae31c54 321 }