Mode1 Optical Validation

Dependencies:   max32630fthr

Committer:
phonemacro
Date:
Tue Jun 22 17:08:41 2021 +0000
Revision:
24:064478ff33d2
Parent:
23:e7ecf1416965
Child:
25:e790416e273e
add MAXREFDES1319 adaptor board configuration

Who changed what in which revision?

UserRevisionLine numberNew contents of line
phonemacro 0:6f65cae31c54 1 /*******************************************************************************
phonemacro 9:12720bbacfe2 2 * Copyright (C) 2021 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 4:4f1e9439f048 37 /******************************************************************************
phonemacro 16:ff1122f0624a 38 * https://os.mbed.com/users/phonemacro/code/MAX32664C_Example_Host_Code
phonemacro 16:ff1122f0624a 39 * Tera Term output is set to 115200 baud rate.
phonemacro 24:064478ff33d2 40 * ver: 210622
phonemacro 16:ff1122f0624a 41 ******************************************************************************/
phonemacro 16:ff1122f0624a 42
phonemacro 16:ff1122f0624a 43 /******************************************************************************
phonemacro 4:4f1e9439f048 44 * Warning, if using the either
phonemacro 4:4f1e9439f048 45 * MAX32630FTHR+MAXM86161_ADPTER_REVB+MAXM86146EVSYS sensor brd or
phonemacro 4:4f1e9439f048 46 * MAX32630FTHR+MAXM86161_ADPTER_REVB+MAXM86161EVSYS sensor brd,
phonemacro 4:4f1e9439f048 47 * The VLED is connected to USB power which is noisy. The VLED should be
phonemacro 4:4f1e9439f048 48 * connected to a regulated power supply if you are testing accuracy.
phonemacro 4:4f1e9439f048 49 *******************************************************************************
phonemacro 4:4f1e9439f048 50 */
phonemacro 5:7f5a012747a5 51
phonemacro 24:064478ff33d2 52 /*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*/
phonemacro 6:e1b7190d6cb5 53 // define one and only one of the following three platforms
phonemacro 21:67d58af1ec56 54 #define MAXM86146_CFG 1 // tested on MAXM86146EVSYS_sensorBrd+MAXM86161_ADAPTER_REVB+MAX32630FTHR 33.13.12
phonemacro 21:67d58af1ec56 55 //#define MAXREFDES103_CFG // not tested
phonemacro 21:67d58af1ec56 56 //#define MAXM86161_CFG 1 // tested on MAXM86161+MAX32630FTHR v32.9.22, 32.13.12
phonemacro 6:e1b7190d6cb5 57 /*****************************************************************************/
phonemacro 24:064478ff33d2 58
phonemacro 24:064478ff33d2 59 /*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*/
phonemacro 24:064478ff33d2 60 // define which adaptor board is being used
phonemacro 24:064478ff33d2 61 //#define MAXM86161_ADPTR_EVKIT_B
phonemacro 24:064478ff33d2 62 #define MAXREFDES1319
phonemacro 24:064478ff33d2 63 /******************************************************************************
phonemacro 24:064478ff33d2 64 * MAX32630FTHR GPIOs
phonemacro 24:064478ff33d2 65 ******************************************************************************/
phonemacro 24:064478ff33d2 66 #ifdef MAXM86161_ADPTR_EVKIT_B
phonemacro 24:064478ff33d2 67 #define RST_PIN P5_6
phonemacro 24:064478ff33d2 68 #define MFIO_PIN P5_4
phonemacro 24:064478ff33d2 69 #else
phonemacro 24:064478ff33d2 70 #ifdef MAXREFDES1319
phonemacro 24:064478ff33d2 71 #define RST_PIN P3_0
phonemacro 24:064478ff33d2 72 #define MFIO_PIN P5_2
phonemacro 24:064478ff33d2 73 #endif
phonemacro 24:064478ff33d2 74 #endif
phonemacro 24:064478ff33d2 75
phonemacro 24:064478ff33d2 76 DigitalOut rst(RST_PIN, PullUp);
phonemacro 24:064478ff33d2 77 DigitalOut mfio(MFIO_PIN, PullUp);
phonemacro 24:064478ff33d2 78 I2C sh_i2c(P3_4, P3_5);
phonemacro 24:064478ff33d2 79
phonemacro 24:064478ff33d2 80 /*****************************************************************************/
phonemacro 22:f6b366c3b954 81 #if defined(MAXM86161_CFG) //|| defined(MAXM86146_CFG) // don't need 3.3V for MAXM86146EVSYS_sensorBrd+MAXM86161_ADAPTER_REVB+MAX32630FTHR
phonemacro 17:0d6e99a0fd8d 82 #include "max32630fthr.h"
phonemacro 17:0d6e99a0fd8d 83 MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3); // Enable J1-pin2, 3.3V and set GPIO to 3.3v
phonemacro 21:67d58af1ec56 84 #endif
phonemacro 14:c8cc6d7fd5f9 85 //#define RAW // define this if you only AFE+accel data, no algo
phonemacro 14:c8cc6d7fd5f9 86 #define ALGO_ONLY 1 // define this if you only want algo data, comment out if you want raw sensor+algo data
phonemacro 12:17a0bf823462 87 //#define EXTENDED_ALGO 1 // define this if you want the extended algo format
phonemacro 13:1baccc6275a7 88 //#define AGC 1 // define this for AGC, otherwise the default is AEC
phonemacro 6:e1b7190d6cb5 89
phonemacro 6:e1b7190d6cb5 90 #ifdef MAXREFDES103_CFG
phonemacro 5:7f5a012747a5 91 #include "MAX20303.h"
phonemacro 6:e1b7190d6cb5 92 I2C sh_i2c_pmic(P5_7, P6_0);
phonemacro 5:7f5a012747a5 93 #endif
phonemacro 5:7f5a012747a5 94
phonemacro 2:563d90a111b3 95 #ifdef MAXM86146_CFG
phonemacro 0:6f65cae31c54 96 #define PPG_SZ 36 //maxm86146
phonemacro 0:6f65cae31c54 97 #else
phonemacro 0:6f65cae31c54 98 #define PPG_SZ 18 //maxm86161, max86141
phonemacro 0:6f65cae31c54 99 #endif
phonemacro 0:6f65cae31c54 100 #define ACCEL_SZ 6 // accel
phonemacro 0:6f65cae31c54 101 #define SENSOR_SZ (PPG_SZ+ACCEL_SZ)
phonemacro 18:f4c95b1c0efc 102
phonemacro 21:67d58af1ec56 103 //#define old_msbl 1 // 3x.12.0 or earlier
phonemacro 18:f4c95b1c0efc 104 #ifdef old_msbl
phonemacro 18:f4c95b1c0efc 105 #ifdef EXTENDED_ALGO
phonemacro 18:f4c95b1c0efc 106 #define ALGO_SZ 52 // 52 bytes is the extended algo size for 3x.12.0
phonemacro 18:f4c95b1c0efc 107 #else
phonemacro 18:f4c95b1c0efc 108 #define ALGO_SZ 20 // 20 bytes is the algo normal size for 3x.12.0
phonemacro 18:f4c95b1c0efc 109 #endif
phonemacro 12:17a0bf823462 110 #else
phonemacro 18:f4c95b1c0efc 111 #ifdef EXTENDED_ALGO
phonemacro 21:67d58af1ec56 112 #define ALGO_SZ 56 // 56 bytes is the extended algo size for 3x.13.x+
phonemacro 18:f4c95b1c0efc 113 #else
phonemacro 21:67d58af1ec56 114 #define ALGO_SZ 24 // 24 bytes is the algo normal size for 3x.13.x+
phonemacro 18:f4c95b1c0efc 115 #endif
phonemacro 12:17a0bf823462 116 #endif
phonemacro 18:f4c95b1c0efc 117
phonemacro 0:6f65cae31c54 118 #ifdef ALGO_ONLY
phonemacro 0:6f65cae31c54 119 #define TTL_SZ (ALGO_SZ)
phonemacro 0:6f65cae31c54 120 #else
phonemacro 14:c8cc6d7fd5f9 121 #ifdef RAW
phonemacro 14:c8cc6d7fd5f9 122 #define TTL_SZ (PPG_SZ+ACCEL_SZ)
phonemacro 14:c8cc6d7fd5f9 123 #else
phonemacro 14:c8cc6d7fd5f9 124 #define TTL_SZ (PPG_SZ+ACCEL_SZ+ALGO_SZ)
phonemacro 14:c8cc6d7fd5f9 125 #endif
phonemacro 0:6f65cae31c54 126 #endif
phonemacro 0:6f65cae31c54 127
phonemacro 3:da975696b936 128 Serial pc(USBTX, USBRX, 115200);
phonemacro 0:6f65cae31c54 129 DigitalOut rLED(LED1);
phonemacro 0:6f65cae31c54 130 DigitalOut gLED(LED2);
phonemacro 0:6f65cae31c54 131 DigitalOut bLED(LED3);
phonemacro 6:e1b7190d6cb5 132
phonemacro 6:e1b7190d6cb5 133 //#define thread_sleep_for(x) wait_ms(x) // for older versions of mbed
phonemacro 0:6f65cae31c54 134
phonemacro 5:7f5a012747a5 135
phonemacro 6:e1b7190d6cb5 136 const int SH_ADDR = 0xAA;//0x55;
phonemacro 0:6f65cae31c54 137 int32_t Time_to_Read_PPG = 0;
phonemacro 0:6f65cae31c54 138
phonemacro 0:6f65cae31c54 139 #define BLINKING_RATE_MS 1000ms
phonemacro 0:6f65cae31c54 140 void blink_timer(void) {
phonemacro 0:6f65cae31c54 141 gLED = !gLED; /* blink the green LED */
phonemacro 0:6f65cae31c54 142 }
phonemacro 0:6f65cae31c54 143
phonemacro 0:6f65cae31c54 144 void fifo_timer(void) {
phonemacro 0:6f65cae31c54 145 Time_to_Read_PPG = 1;
phonemacro 0:6f65cae31c54 146 }
phonemacro 0:6f65cae31c54 147
phonemacro 14:c8cc6d7fd5f9 148 /*****************************************************************************/
phonemacro 14:c8cc6d7fd5f9 149 // read_sh_fifo
phonemacro 14:c8cc6d7fd5f9 150 /*****************************************************************************/
phonemacro 10:192ea88e964b 151 void read_sh_fifo(void) {
phonemacro 0:6f65cae31c54 152 char cmd[8], i, j, samples;
phonemacro 0:6f65cae31c54 153 char rsp[3000];
phonemacro 0:6f65cae31c54 154 int32_t ppg[12];
phonemacro 5:7f5a012747a5 155 int16_t accel[3];
phonemacro 12:17a0bf823462 156 int32_t status, opmode, hr, hr_conf, ibi, ibi_conf;
phonemacro 12:17a0bf823462 157 #ifdef EXTENDED_ALGO
phonemacro 12:17a0bf823462 158 int32_t walk_stp, run_stp, energy, amr, iadj1_rqt, iadj1, iadj2_rqt, iadj2, iadj3_rqt, iadj3;
phonemacro 12:17a0bf823462 159 int32_t intadj_rqt, intadj, smpladj_rqt, smpladj, rqt_smplave, afestatehr, hr_motion;
phonemacro 12:17a0bf823462 160 #endif
phonemacro 12:17a0bf823462 161 int32_t act, r, spo2, spo2_conf;
phonemacro 4:4f1e9439f048 162 int32_t spo2_compl, spo2_lo, spo2_mo, spo2_lopi, spo2_unrel, spo2_state, ibi_offset, scd;
phonemacro 2:563d90a111b3 163 int32_t scnt = 0;
phonemacro 0:6f65cae31c54 164 int32_t ptr = 0;
phonemacro 0:6f65cae31c54 165 int32_t sptr = 0;
phonemacro 1:da792e46a385 166 mfio = 0; wait_us(300);
phonemacro 0:6f65cae31c54 167 Time_to_Read_PPG = 0;
phonemacro 22:f6b366c3b954 168 #if defined(MAXREFDES103_CFG) || defined(MAXM86161_CFG)
phonemacro 0:6f65cae31c54 169 // 2.1
phonemacro 4:4f1e9439f048 170 cmd[0] = 0x00; cmd[1] = 0x00;
phonemacro 6:e1b7190d6cb5 171 sh_i2c.write(SH_ADDR, cmd, 2);
phonemacro 22:f6b366c3b954 172 wait_us(100);
phonemacro 6:e1b7190d6cb5 173 sh_i2c.read(SH_ADDR, rsp, 2);
phonemacro 3:da975696b936 174 // pc.printf("2.1 Status: %x %x\n\r", rsp[0], rsp[1]);
phonemacro 22:f6b366c3b954 175 #else
phonemacro 22:f6b366c3b954 176 // testd 33.13.12 doesn't need 2.1
phonemacro 0:6f65cae31c54 177 #endif
phonemacro 0:6f65cae31c54 178 // 2.2
phonemacro 4:4f1e9439f048 179 cmd[0] = 0x12; cmd[1] = 0x00;
phonemacro 6:e1b7190d6cb5 180 sh_i2c.write(SH_ADDR, cmd, 2);
phonemacro 22:f6b366c3b954 181 wait_us(100);
phonemacro 6:e1b7190d6cb5 182 sh_i2c.read(SH_ADDR, rsp, 2);
phonemacro 3:da975696b936 183 // pc.printf("2.2 Status: %x %x\n\r", rsp[0], rsp[1]);
phonemacro 0:6f65cae31c54 184 samples = rsp[1];
phonemacro 3:da975696b936 185 // pc.printf("num samples %d, (num*ttl)+1 %d\n\r", rsp[1], TTL_SZ*samples+1);
phonemacro 3:da975696b936 186 // pc.printf("num smpls %d \n\r", samples);
phonemacro 0:6f65cae31c54 187 scnt = rsp[1];
phonemacro 0:6f65cae31c54 188 // 2.3
phonemacro 4:4f1e9439f048 189 cmd[0] = 0x12; cmd[1] = 0x01;
phonemacro 6:e1b7190d6cb5 190 sh_i2c.write(SH_ADDR, cmd, 2);
phonemacro 22:f6b366c3b954 191 wait_us(100);
phonemacro 6:e1b7190d6cb5 192 sh_i2c.read(SH_ADDR, rsp, 1+(TTL_SZ*samples));
phonemacro 22:f6b366c3b954 193 mfio = 1;
phonemacro 21:67d58af1ec56 194
phonemacro 0:6f65cae31c54 195 status = rsp[0];
phonemacro 5:7f5a012747a5 196
phonemacro 0:6f65cae31c54 197 sptr = 1;
phonemacro 0:6f65cae31c54 198 for (i = 0; i < scnt; i++) {
phonemacro 0:6f65cae31c54 199 #ifdef ALGO_ONLY
phonemacro 0:6f65cae31c54 200 ptr = sptr;
phonemacro 0:6f65cae31c54 201 #else
phonemacro 2:563d90a111b3 202 ptr = sptr;
phonemacro 2:563d90a111b3 203 ppg[0] = (rsp[ptr+0] << 16) | (rsp[ptr+1] << 8) | (rsp[ptr+2]);
phonemacro 2:563d90a111b3 204 ppg[1] = (rsp[ptr+3] << 16) | (rsp[ptr+4] << 8) | (rsp[ptr+5]);
phonemacro 2:563d90a111b3 205 ppg[2] = (rsp[ptr+6] << 16) | (rsp[ptr+7] << 8) | (rsp[ptr+8]);
phonemacro 3:da975696b936 206 ppg[3] = (rsp[ptr+9] << 16) | (rsp[ptr+10] << 8) | (rsp[ptr+11]);
phonemacro 4:4f1e9439f048 207 ppg[4] = (rsp[ptr+12] << 16) | (rsp[ptr+13] << 8) | (rsp[ptr+14]);
phonemacro 4:4f1e9439f048 208 ppg[5] = (rsp[ptr+15] << 16) | (rsp[ptr+16] << 8) | (rsp[ptr+17]);
phonemacro 3:da975696b936 209 pc.printf("%d,%d,%d,%d,", ppg[0], ppg[1], ppg[2], ppg[3]);
phonemacro 14:c8cc6d7fd5f9 210 #ifdef MAXM86146_CFG
phonemacro 14:c8cc6d7fd5f9 211 #ifdef RAW
phonemacro 14:c8cc6d7fd5f9 212 pc.printf("%d,%d,", ppg[4], ppg[5]);
phonemacro 14:c8cc6d7fd5f9 213 ppg[6] = (rsp[ptr+18] << 16) | (rsp[ptr+19] << 8) | (rsp[ptr+20]);
phonemacro 14:c8cc6d7fd5f9 214 ppg[7] = (rsp[ptr+21] << 16) | (rsp[ptr+22] << 8) | (rsp[ptr+23]);
phonemacro 14:c8cc6d7fd5f9 215 ppg[8] = (rsp[ptr+24] << 16) | (rsp[ptr+25] << 8) | (rsp[ptr+26]);
phonemacro 14:c8cc6d7fd5f9 216 ppg[9] = (rsp[ptr+27] << 16) | (rsp[ptr+28] << 8) | (rsp[ptr+29]);
phonemacro 14:c8cc6d7fd5f9 217 ppg[10] = (rsp[ptr+30] << 16) | (rsp[ptr+31] << 8) | (rsp[ptr+32]);
phonemacro 14:c8cc6d7fd5f9 218 ppg[11] = (rsp[ptr+33] << 16) | (rsp[ptr+34] << 8) | (rsp[ptr+35]);
phonemacro 14:c8cc6d7fd5f9 219 pc.printf("%d,%d,%d,%d,%d,%d,", ppg[6], ppg[7],ppg[8], ppg[9],ppg[10], ppg[11]);
phonemacro 14:c8cc6d7fd5f9 220 #endif
phonemacro 14:c8cc6d7fd5f9 221 #endif
phonemacro 5:7f5a012747a5 222 accel[0] = (rsp[PPG_SZ+0] << 8) | (rsp[PPG_SZ+1]);
phonemacro 5:7f5a012747a5 223 accel[1] = (rsp[PPG_SZ+2] << 8) | (rsp[PPG_SZ+3]);
phonemacro 5:7f5a012747a5 224 accel[2] = (rsp[PPG_SZ+4] << 8) | (rsp[PPG_SZ+5]);
phonemacro 5:7f5a012747a5 225 pc.printf("%d,%d,%d,", accel[0], accel[1], accel[2]);
phonemacro 5:7f5a012747a5 226
phonemacro 0:6f65cae31c54 227 ptr = sptr + SENSOR_SZ;
phonemacro 0:6f65cae31c54 228 #endif
phonemacro 14:c8cc6d7fd5f9 229 #ifndef RAW
phonemacro 12:17a0bf823462 230 #ifdef EXTENDED_ALGO
phonemacro 3:da975696b936 231 // pc.printf("ptr %d ttlsiz %d ", ptr, TTL_SZ);
phonemacro 0:6f65cae31c54 232 opmode = rsp[ptr];
phonemacro 0:6f65cae31c54 233 hr = (rsp[ptr+1] << 8) + rsp[ptr+2];
phonemacro 0:6f65cae31c54 234 hr_conf = rsp[ptr+3];
phonemacro 12:17a0bf823462 235 ibi = (rsp[ptr+4] << 8) + rsp[ptr+5];
phonemacro 12:17a0bf823462 236
phonemacro 12:17a0bf823462 237 ibi_conf = rsp[ptr+6];
phonemacro 12:17a0bf823462 238 act = rsp[ptr+7];
phonemacro 12:17a0bf823462 239 walk_stp = (rsp[ptr+8] << 24) + (rsp[ptr+9] << 16) + (rsp[ptr+10] << 8) + rsp[ptr+11];
phonemacro 12:17a0bf823462 240 run_stp = (rsp[ptr+12] << 24) + (rsp[ptr+13] << 16) + (rsp[ptr+14] << 8) + rsp[ptr+15];
phonemacro 12:17a0bf823462 241
phonemacro 12:17a0bf823462 242 energy = (rsp[ptr+16] << 24) + (rsp[ptr+17] << 16) + (rsp[ptr+18] << 8) + rsp[ptr+19];
phonemacro 12:17a0bf823462 243 amr = (rsp[ptr+20] << 24) + (rsp[ptr+21] << 16) + (rsp[ptr+22] << 8) + rsp[ptr+23];
phonemacro 12:17a0bf823462 244 iadj1_rqt = rsp[ptr+24];
phonemacro 12:17a0bf823462 245 iadj1 = (rsp[ptr+25] << 8) + rsp[ptr+26];
phonemacro 12:17a0bf823462 246
phonemacro 12:17a0bf823462 247 iadj2_rqt = rsp[ptr+27];
phonemacro 12:17a0bf823462 248 iadj2 = (rsp[ptr+28] << 8) + rsp[ptr+29];
phonemacro 12:17a0bf823462 249 iadj3_rqt = rsp[ptr+30];
phonemacro 12:17a0bf823462 250 iadj3 = (rsp[ptr+31] << 8) + rsp[ptr+32];
phonemacro 12:17a0bf823462 251
phonemacro 12:17a0bf823462 252 intadj_rqt = rsp[ptr+33];
phonemacro 12:17a0bf823462 253 intadj = rsp[ptr+34];
phonemacro 12:17a0bf823462 254 smpladj_rqt = rsp[ptr+35];
phonemacro 12:17a0bf823462 255 smpladj = rsp[ptr+36];
phonemacro 12:17a0bf823462 256
phonemacro 12:17a0bf823462 257 rqt_smplave = rsp[ptr+37];
phonemacro 12:17a0bf823462 258 afestatehr = rsp[ptr+38];
phonemacro 12:17a0bf823462 259 hr_motion = rsp[ptr+39];
phonemacro 12:17a0bf823462 260 scd = rsp[ptr+40];
phonemacro 12:17a0bf823462 261
phonemacro 12:17a0bf823462 262
phonemacro 12:17a0bf823462 263 r = (rsp[ptr+41] << 8) + rsp[ptr+42];
phonemacro 12:17a0bf823462 264 spo2_conf = rsp[ptr+43];
phonemacro 12:17a0bf823462 265
phonemacro 12:17a0bf823462 266 spo2 = (rsp[ptr+44] << 8) + rsp[ptr+45];
phonemacro 12:17a0bf823462 267 spo2_compl = rsp[ptr+46];
phonemacro 12:17a0bf823462 268 spo2_lo = rsp[ptr+47];
phonemacro 12:17a0bf823462 269 spo2_mo = rsp[ptr+48];
phonemacro 12:17a0bf823462 270
phonemacro 12:17a0bf823462 271 spo2_lopi = rsp[ptr+49];
phonemacro 12:17a0bf823462 272 spo2_unrel = rsp[ptr+50];
phonemacro 12:17a0bf823462 273 spo2_state = rsp[ptr+51];
phonemacro 12:17a0bf823462 274
phonemacro 12:17a0bf823462 275 ibi_offset = rsp[ptr+52];
phonemacro 12:17a0bf823462 276
phonemacro 12:17a0bf823462 277 sptr += (TTL_SZ);
phonemacro 12:17a0bf823462 278 #if 1
phonemacro 12:17a0bf823462 279 pc.printf("%d,%d,%d,%d,", opmode, hr, hr_conf, ibi);
phonemacro 12:17a0bf823462 280 pc.printf("%d,%d,", ibi_conf, act);
phonemacro 12:17a0bf823462 281 pc.printf("%d,%d,%d,", walk_stp, run_stp, energy);
phonemacro 12:17a0bf823462 282 pc.printf("%d,%d,%d,%d,", amr, iadj1_rqt, iadj1, iadj2_rqt);
phonemacro 12:17a0bf823462 283 pc.printf("%d,%d,%d,%d,", iadj2, iadj3_rqt, iadj3, intadj_rqt);
phonemacro 12:17a0bf823462 284 pc.printf("%d,%d,%d,%d,", intadj, smpladj_rqt, smpladj, rqt_smplave);
phonemacro 12:17a0bf823462 285 pc.printf("%d,%d,", afestatehr, hr_motion);
phonemacro 12:17a0bf823462 286 pc.printf("%d,", scd);
phonemacro 12:17a0bf823462 287 pc.printf("%d,%d,%d,%d,", spo2, spo2_compl, spo2_lo, spo2_mo);
phonemacro 12:17a0bf823462 288 pc.printf("%d,%d,%d,", spo2_lopi,spo2_unrel, spo2_state);
phonemacro 12:17a0bf823462 289 pc.printf("%d,", ibi_offset);
phonemacro 12:17a0bf823462 290 #else
phonemacro 12:17a0bf823462 291 pc.printf("%d,%d,", hr, hr_conf);
phonemacro 12:17a0bf823462 292 pc.printf("%d,%d,", spo2, spo2_conf);
phonemacro 16:ff1122f0624a 293 pc.printf("%d,%d,%d,", spo2_lo, spo2_mo, spo2_lopi);
phonemacro 12:17a0bf823462 294 pc.printf("%d,%d,", spo2_unrel, scd);
phonemacro 12:17a0bf823462 295 #endif
phonemacro 12:17a0bf823462 296 #else // normal algo size
phonemacro 12:17a0bf823462 297 // pc.printf("ptr %d ttlsiz %d ", ptr, TTL_SZ);
phonemacro 12:17a0bf823462 298 opmode = rsp[ptr];
phonemacro 12:17a0bf823462 299 hr = (rsp[ptr+1] << 8) + rsp[ptr+2];
phonemacro 12:17a0bf823462 300 hr_conf = rsp[ptr+3];
phonemacro 12:17a0bf823462 301 ibi = (rsp[ptr+4] << 8) + rsp[ptr+5];
phonemacro 4:4f1e9439f048 302
phonemacro 11:a16b6bf38841 303 ibi_conf = rsp[ptr+6];
phonemacro 3:da975696b936 304 act = rsp[ptr+7];
phonemacro 3:da975696b936 305 r = (rsp[ptr+8] << 8) + rsp[ptr+9];
phonemacro 0:6f65cae31c54 306 spo2_conf = rsp[ptr+10];
phonemacro 4:4f1e9439f048 307
phonemacro 0:6f65cae31c54 308 spo2 = (rsp[ptr+11] << 8) + rsp[ptr+12];
phonemacro 4:4f1e9439f048 309 spo2_compl = rsp[ptr+13];
phonemacro 4:4f1e9439f048 310 spo2_lo = rsp[ptr+14];
phonemacro 4:4f1e9439f048 311 spo2_mo = rsp[ptr+15];
phonemacro 4:4f1e9439f048 312
phonemacro 4:4f1e9439f048 313 spo2_lopi = rsp[ptr+16];
phonemacro 4:4f1e9439f048 314 spo2_unrel = rsp[ptr+17];
phonemacro 4:4f1e9439f048 315 spo2_state = rsp[ptr+18];
phonemacro 2:563d90a111b3 316 scd = rsp[ptr+19];
phonemacro 0:6f65cae31c54 317
phonemacro 4:4f1e9439f048 318 ibi_offset = rsp[ptr+20];
phonemacro 0:6f65cae31c54 319
phonemacro 4:4f1e9439f048 320 sptr += (TTL_SZ);
phonemacro 4:4f1e9439f048 321 #if 0
phonemacro 4:4f1e9439f048 322 pc.printf("%d,%d,%d,%d,", opmode, hr, hr_conf, ibi);
phonemacro 4:4f1e9439f048 323 pc.printf("%d,%d,%d,%d,", ibi_conf, act, r, spo2_conf);
phonemacro 4:4f1e9439f048 324 pc.printf("%d,%d,%d,%d,", spo2, spo2_compl, spo2_lo, spo2_mo);
phonemacro 4:4f1e9439f048 325 pc.printf("%d,%d,%d,%d,", spo2_lopi,spo2_unrel, spo2_state, scd);
phonemacro 4:4f1e9439f048 326 pc.printf("%d,", ibi_offset);
phonemacro 4:4f1e9439f048 327 #else
phonemacro 4:4f1e9439f048 328 pc.printf("%d,%d,", hr, hr_conf);
phonemacro 4:4f1e9439f048 329 pc.printf("%d,%d,", spo2, spo2_conf);
phonemacro 4:4f1e9439f048 330 pc.printf("%d,", spo2_lo);
phonemacro 4:4f1e9439f048 331 pc.printf("%d,%d,", spo2_unrel, scd);
phonemacro 4:4f1e9439f048 332 #endif
phonemacro 12:17a0bf823462 333 #endif // end normal algo size
phonemacro 14:c8cc6d7fd5f9 334 #endif // !RAW
phonemacro 4:4f1e9439f048 335
phonemacro 3:da975696b936 336 pc.printf("\n\r");
phonemacro 0:6f65cae31c54 337 }
phonemacro 0:6f65cae31c54 338 }
phonemacro 0:6f65cae31c54 339
phonemacro 6:e1b7190d6cb5 340 #ifdef MAXREFDES103_CFG
phonemacro 14:c8cc6d7fd5f9 341 /*****************************************************************************/
phonemacro 14:c8cc6d7fd5f9 342 // init_max20303_pmic
phonemacro 14:c8cc6d7fd5f9 343 /*****************************************************************************/
phonemacro 6:e1b7190d6cb5 344 void init_max20303_pmic(void) {
phonemacro 5:7f5a012747a5 345 /* Wait for pmic to settle down */
phonemacro 5:7f5a012747a5 346 thread_sleep_for(800);
phonemacro 5:7f5a012747a5 347
phonemacro 5:7f5a012747a5 348 //set_time(1544787300); // Set RTC time to Wed, 28 Oct 2009 11:35:37
phonemacro 6:e1b7190d6cb5 349 MAX20303 max20303(&sh_i2c);
phonemacro 5:7f5a012747a5 350 /*Set LDO1 to 1.8v*/
phonemacro 5:7f5a012747a5 351 max20303.LDO1Config();
phonemacro 5:7f5a012747a5 352
phonemacro 5:7f5a012747a5 353 /*Set LDO2 to 3v*/
phonemacro 5:7f5a012747a5 354 max20303.LDO2Config();
phonemacro 5:7f5a012747a5 355
phonemacro 5:7f5a012747a5 356 //max20303.BoostEnable();
phonemacro 5:7f5a012747a5 357 max20303.BuckBoostEnable();
phonemacro 5:7f5a012747a5 358
phonemacro 5:7f5a012747a5 359 max20303.led0on(0);
phonemacro 5:7f5a012747a5 360 max20303.led1on(0);
phonemacro 5:7f5a012747a5 361 max20303.led2on(0);
phonemacro 5:7f5a012747a5 362
phonemacro 5:7f5a012747a5 363 /* Wait for pmic to settle down */
phonemacro 5:7f5a012747a5 364 thread_sleep_for(200);
phonemacro 6:e1b7190d6cb5 365
phonemacro 5:7f5a012747a5 366 }
phonemacro 6:e1b7190d6cb5 367 #endif // MAXREFDES103_CFG
phonemacro 14:c8cc6d7fd5f9 368
phonemacro 14:c8cc6d7fd5f9 369 /*****************************************************************************/
phonemacro 14:c8cc6d7fd5f9 370 // init_sh_algo
phonemacro 14:c8cc6d7fd5f9 371 /*****************************************************************************/
phonemacro 14:c8cc6d7fd5f9 372 void init_sh_algo(void) {
phonemacro 14:c8cc6d7fd5f9 373 char cmd[8];
phonemacro 0:6f65cae31c54 374 char rsp[256];
phonemacro 10:192ea88e964b 375 // switch to application mode
phonemacro 0:6f65cae31c54 376 rst = 0;
phonemacro 0:6f65cae31c54 377 mfio = 1;
phonemacro 0:6f65cae31c54 378 thread_sleep_for(10);
phonemacro 0:6f65cae31c54 379 rst = 1;
phonemacro 0:6f65cae31c54 380 thread_sleep_for(1500);
phonemacro 10:192ea88e964b 381 #ifdef MAXREFDES103_CFG
phonemacro 10:192ea88e964b 382 init_max20303_pmic();
phonemacro 10:192ea88e964b 383 #endif
phonemacro 23:e7ecf1416965 384 #if 0 // 1.5s is ok for 33.13.12
phonemacro 23:e7ecf1416965 385 thread_sleep_for(250);
phonemacro 20:7fc26287beb7 386 #endif
phonemacro 0:6f65cae31c54 387
phonemacro 1:da792e46a385 388 mfio = 0; wait_us(300);
phonemacro 4:4f1e9439f048 389
phonemacro 4:4f1e9439f048 390 //read operating mode
phonemacro 4:4f1e9439f048 391 cmd[0] = 0x02; cmd[1] = 0x00;
phonemacro 6:e1b7190d6cb5 392 sh_i2c.write(SH_ADDR, cmd, 2);
phonemacro 1:da792e46a385 393 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 6:e1b7190d6cb5 394 sh_i2c.read(SH_ADDR, rsp, 2);
phonemacro 6:e1b7190d6cb5 395 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 6:e1b7190d6cb5 396 pc.printf("\n\r 0x02 0x00 Status, Read Operating Mode: %x %x\n\r", rsp[0], rsp[1]);
phonemacro 5:7f5a012747a5 397 //1.11 rd ver
phonemacro 4:4f1e9439f048 398 cmd[0] = 0xFF; cmd[1] = 0x03;
phonemacro 6:e1b7190d6cb5 399 sh_i2c.write(SH_ADDR, cmd, 2);
phonemacro 1:da792e46a385 400 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 6:e1b7190d6cb5 401 sh_i2c.read(SH_ADDR, rsp, 4);
phonemacro 1:da792e46a385 402 mfio = 1; mfio = 0; wait_us(300);
phonemacro 3:da975696b936 403 pc.printf("Ver: %d %d %d %d\n\r", rsp[0], rsp[1], rsp[2], rsp[3]);
phonemacro 0:6f65cae31c54 404
phonemacro 17:0d6e99a0fd8d 405 #if 0
phonemacro 17:0d6e99a0fd8d 406 // algo sz
phonemacro 17:0d6e99a0fd8d 407 cmd[0] = 0x11; cmd[1] = 0x06; cmd[2] = 0x01;
phonemacro 17:0d6e99a0fd8d 408 sh_i2c.write(SH_ADDR, cmd, 3);
phonemacro 17:0d6e99a0fd8d 409 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 17:0d6e99a0fd8d 410 sh_i2c.read(SH_ADDR, rsp, 2);
phonemacro 17:0d6e99a0fd8d 411 mfio = 1; mfio = 0; wait_us(300);
phonemacro 17:0d6e99a0fd8d 412 pc.printf("algo size: %d %d \n\r", rsp[0], rsp[1]);
phonemacro 17:0d6e99a0fd8d 413
phonemacro 17:0d6e99a0fd8d 414 // algo sz
phonemacro 17:0d6e99a0fd8d 415 cmd[0] = 0x11; cmd[1] = 0x06; cmd[2] = 0x02;
phonemacro 17:0d6e99a0fd8d 416 sh_i2c.write(SH_ADDR, cmd, 3);
phonemacro 17:0d6e99a0fd8d 417 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 17:0d6e99a0fd8d 418 sh_i2c.read(SH_ADDR, rsp, 2);
phonemacro 17:0d6e99a0fd8d 419 mfio = 1; mfio = 0; wait_us(300);
phonemacro 17:0d6e99a0fd8d 420 pc.printf("algo size: %d %d \n\r", rsp[0], rsp[1]);
phonemacro 17:0d6e99a0fd8d 421
phonemacro 17:0d6e99a0fd8d 422 // algo sz
phonemacro 17:0d6e99a0fd8d 423 cmd[0] = 0x11; cmd[1] = 0x06; cmd[2] = 0x03;
phonemacro 17:0d6e99a0fd8d 424 sh_i2c.write(SH_ADDR, cmd, 3);
phonemacro 17:0d6e99a0fd8d 425 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 17:0d6e99a0fd8d 426 sh_i2c.read(SH_ADDR, rsp, 2);
phonemacro 17:0d6e99a0fd8d 427 mfio = 1; mfio = 0; wait_us(300);
phonemacro 17:0d6e99a0fd8d 428 pc.printf("algo size: %d %d \n\r", rsp[0], rsp[1]);
phonemacro 17:0d6e99a0fd8d 429 #endif
phonemacro 17:0d6e99a0fd8d 430
phonemacro 17:0d6e99a0fd8d 431 #if 0
phonemacro 17:0d6e99a0fd8d 432 // set Perfusion Index threshold to .05 (3x.13.19+)
phonemacro 17:0d6e99a0fd8d 433 cmd[0] = 0x50; cmd[1] = 0x07; cmd[2] = 0x1D; cmd[3] = 50;
phonemacro 16:ff1122f0624a 434 sh_i2c.write(SH_ADDR, cmd, 4);
phonemacro 16:ff1122f0624a 435 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 16:ff1122f0624a 436 sh_i2c.read(SH_ADDR, rsp, 1);
phonemacro 16:ff1122f0624a 437 mfio = 1; mfio = 0; wait_us(300);
phonemacro 16:ff1122f0624a 438 pc.printf("pi set to 0x19 : %x \n\r", rsp[0]);
phonemacro 17:0d6e99a0fd8d 439 #endif
phonemacro 16:ff1122f0624a 440
phonemacro 0:6f65cae31c54 441 // 1.3 sensor and algo data
phonemacro 4:4f1e9439f048 442 cmd[0] = 0x10; cmd[1] = 0x00;
phonemacro 2:563d90a111b3 443 #ifdef ALGO_ONLY
phonemacro 0:6f65cae31c54 444 cmd[2] = 0x02; // algo data
phonemacro 4:4f1e9439f048 445 pc.printf("algo only \n\r");
phonemacro 2:563d90a111b3 446 #else
phonemacro 2:563d90a111b3 447 cmd[2] = 0x03; // sensor + algo data
phonemacro 4:4f1e9439f048 448 pc.printf("sens+algo \n\r");
phonemacro 2:563d90a111b3 449 #endif
phonemacro 6:e1b7190d6cb5 450 sh_i2c.write(SH_ADDR, cmd, 3);
phonemacro 1:da792e46a385 451 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 6:e1b7190d6cb5 452 sh_i2c.read(SH_ADDR, rsp, 1);
phonemacro 1:da792e46a385 453 mfio = 1; mfio = 0; wait_us(300);
phonemacro 3:da975696b936 454 pc.printf("1.3 Status: %x\n\r", rsp[0]);
phonemacro 3:da975696b936 455 // 1.7 cont hr, spo2
phonemacro 4:4f1e9439f048 456 cmd[0] = 0x50; cmd[1] = 0x07; cmd[2] = 0x0A; cmd[3] = 0x00;
phonemacro 6:e1b7190d6cb5 457 sh_i2c.write(SH_ADDR, cmd, 4);
phonemacro 3:da975696b936 458 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 6:e1b7190d6cb5 459 sh_i2c.read(SH_ADDR, rsp, 1);
phonemacro 3:da975696b936 460 mfio = 1; mfio = 0; wait_us(300);
phonemacro 3:da975696b936 461 pc.printf("1.7 Status: %x\n\r", rsp[0]);
phonemacro 4:4f1e9439f048 462 // 1.8 AEC enable (default)
phonemacro 4:4f1e9439f048 463 cmd[0] = 0x50; cmd[1] = 0x07; cmd[2] = 0x0B; cmd[3] = 0x01;
phonemacro 6:e1b7190d6cb5 464 sh_i2c.write(SH_ADDR, cmd, 4);
phonemacro 1:da792e46a385 465 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 6:e1b7190d6cb5 466 sh_i2c.read(SH_ADDR, rsp, 1);
phonemacro 1:da792e46a385 467 mfio = 1; mfio = 0; wait_us(300);
phonemacro 4:4f1e9439f048 468 pc.printf("1.8 Status: %x\n\r", rsp[0]);
phonemacro 13:1baccc6275a7 469 #if AGC
phonemacro 13:1baccc6275a7 470 // AGC1.8 Disable auto PD (default
phonemacro 13:1baccc6275a7 471 cmd[0] = 0x50; cmd[1] = 0x07; cmd[2] = 0x12; cmd[3] = 0x00;
phonemacro 13:1baccc6275a7 472 sh_i2c.write(SH_ADDR, cmd, 4);
phonemacro 13:1baccc6275a7 473 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 13:1baccc6275a7 474 sh_i2c.read(SH_ADDR, rsp, 1);
phonemacro 13:1baccc6275a7 475 mfio = 1; mfio = 0; wait_us(300);
phonemacro 13:1baccc6275a7 476 pc.printf("AGC1.8 Status: %x\n\r", rsp[0]);
phonemacro 13:1baccc6275a7 477 // AGC1.9 Disable SCD (default)
phonemacro 13:1baccc6275a7 478 cmd[0] = 0x50; cmd[1] = 0x07; cmd[2] = 0x0C; cmd[3] = 0x00;
phonemacro 13:1baccc6275a7 479 sh_i2c.write(SH_ADDR, cmd, 4);
phonemacro 13:1baccc6275a7 480 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 13:1baccc6275a7 481 sh_i2c.read(SH_ADDR, rsp, 1);
phonemacro 13:1baccc6275a7 482 mfio = 1; mfio = 0; wait_us(300);
phonemacro 13:1baccc6275a7 483 pc.printf("AGC1.9 Status: %x\n\r", rsp[0]);
phonemacro 13:1baccc6275a7 484 // AGC1.10 Set AGC target PD TO 10uA
phonemacro 13:1baccc6275a7 485 cmd[0] = 0x50; cmd[1] = 0x07; cmd[2] = 0x11; cmd[3] = 0x00; cmd[3] = 0x64;
phonemacro 13:1baccc6275a7 486 sh_i2c.write(SH_ADDR, cmd, 5);
phonemacro 13:1baccc6275a7 487 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 13:1baccc6275a7 488 sh_i2c.read(SH_ADDR, rsp, 1);
phonemacro 13:1baccc6275a7 489 mfio = 1; mfio = 0; wait_us(300);
phonemacro 13:1baccc6275a7 490 pc.printf("AGC1.10 Status: %x\n\r", rsp[0]);
phonemacro 13:1baccc6275a7 491 #else
phonemacro 4:4f1e9439f048 492 // 1.9 auto PD (default
phonemacro 4:4f1e9439f048 493 cmd[0] = 0x50; cmd[1] = 0x07; cmd[2] = 0x12; cmd[3] = 0x01;
phonemacro 6:e1b7190d6cb5 494 sh_i2c.write(SH_ADDR, cmd, 4);
phonemacro 1:da792e46a385 495 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 6:e1b7190d6cb5 496 sh_i2c.read(SH_ADDR, rsp, 1);
phonemacro 1:da792e46a385 497 mfio = 1; mfio = 0; wait_us(300);
phonemacro 4:4f1e9439f048 498 pc.printf("1.9 Status: %x\n\r", rsp[0]);
phonemacro 4:4f1e9439f048 499 // 1.10 SCD (default)
phonemacro 4:4f1e9439f048 500 cmd[0] = 0x50; cmd[1] = 0x07; cmd[2] = 0x0C; cmd[3] = 0x01;
phonemacro 6:e1b7190d6cb5 501 sh_i2c.write(SH_ADDR, cmd, 4);
phonemacro 4:4f1e9439f048 502 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 6:e1b7190d6cb5 503 sh_i2c.read(SH_ADDR, rsp, 1);
phonemacro 4:4f1e9439f048 504 mfio = 1; mfio = 0; wait_us(300);
phonemacro 4:4f1e9439f048 505 pc.printf("1.7 Status: %x\n\r", rsp[0]);
phonemacro 13:1baccc6275a7 506 #endif
phonemacro 3:da975696b936 507 #ifdef MAXM86146_CFG
phonemacro 3:da975696b936 508 //1.20 Sec 4.1 map leds to slots for MAXM86146
phonemacro 4:4f1e9439f048 509 cmd[0] = 0x50; cmd[1] = 0x07; cmd[2] = 0x19; cmd[3] = 0x13; cmd[4] = 0x56; cmd[5] = 0x00;
phonemacro 6:e1b7190d6cb5 510 sh_i2c.write(SH_ADDR, cmd, 6);
phonemacro 3:da975696b936 511 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 6:e1b7190d6cb5 512 sh_i2c.read(SH_ADDR, rsp, 1);
phonemacro 3:da975696b936 513 mfio = 1; mfio = 0; wait_us(300);
phonemacro 14:c8cc6d7fd5f9 514 pc.printf("map leds to slots %x\n\r", rsp[0]);
phonemacro 3:da975696b936 515 //1.21 map HR inputs to slots
phonemacro 4:4f1e9439f048 516 cmd[0] = 0x50; cmd[1] = 0x07; cmd[2] = 0x17; cmd[3] = 0x00; cmd[4] = 0x11;
phonemacro 6:e1b7190d6cb5 517 sh_i2c.write(SH_ADDR, cmd, 5);
phonemacro 3:da975696b936 518 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 6:e1b7190d6cb5 519 sh_i2c.read(SH_ADDR, rsp, 1);
phonemacro 3:da975696b936 520 mfio = 1; mfio = 0; wait_us(300);
phonemacro 3:da975696b936 521 pc.printf("map HR to slots/PDs %x\n\r", rsp[0]);
phonemacro 3:da975696b936 522 //1.22 map SpO2 inputs to slots
phonemacro 4:4f1e9439f048 523 cmd[0] = 0x50; cmd[1] = 0x07; cmd[2] = 0x18; cmd[3] = 0x30; cmd[4] = 0x20;
phonemacro 6:e1b7190d6cb5 524 sh_i2c.write(SH_ADDR, cmd, 5);
phonemacro 3:da975696b936 525 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 6:e1b7190d6cb5 526 sh_i2c.read(SH_ADDR, rsp, 1);
phonemacro 3:da975696b936 527 mfio = 1; mfio = 0; wait_us(300);
phonemacro 3:da975696b936 528 pc.printf("map SpO2 to slots/PDs %x\n\r", rsp[0]);
phonemacro 3:da975696b936 529 #if 0
phonemacro 2:563d90a111b3 530 //1.20 Sec 4.1 map leds to slots for MAXM86146
phonemacro 4:4f1e9439f048 531 cmd[0] = 0x50; cmd[1] = 0x07; cmd[2] = 0x19; cmd[3] = 0x15; cmd[4] = 0x60; cmd[5] = 0x00;
phonemacro 6:e1b7190d6cb5 532 sh_i2c.write(SH_ADDR, cmd, 6);
phonemacro 1:da792e46a385 533 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 6:e1b7190d6cb5 534 sh_i2c.read(SH_ADDR, rsp, 1);
phonemacro 1:da792e46a385 535 mfio = 1; mfio = 0; wait_us(300);
phonemacro 3:da975696b936 536 pc.printf("map leds to slots%x\n\r", rsp[0]);
phonemacro 2:563d90a111b3 537 //1.21 map HR inputs to slots
phonemacro 4:4f1e9439f048 538 cmd[0] = 0x50; cmd[1] = 0x07; cmd[2] = 0x17; cmd[3] = 0x00; cmd[4] = 0x01;
phonemacro 6:e1b7190d6cb5 539 sh_i2c.write(SH_ADDR, cmd, 5);
phonemacro 1:da792e46a385 540 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 6:e1b7190d6cb5 541 sh_i2c.read(SH_ADDR, rsp, 1);
phonemacro 1:da792e46a385 542 mfio = 1; mfio = 0; wait_us(300);
phonemacro 3:da975696b936 543 pc.printf("map HR to slots/PDs %x\n\r", rsp[0]);
phonemacro 2:563d90a111b3 544 //1.22 map SpO2 inputs to slots
phonemacro 4:4f1e9439f048 545 cmd[0] = 0x50; cmd[1] = 0x07; cmd[2] = 0x18; cmd[3] = 0x20; cmd[4] = 0x10;
phonemacro 6:e1b7190d6cb5 546 sh_i2c.write(SH_ADDR, cmd, 5);
phonemacro 1:da792e46a385 547 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 6:e1b7190d6cb5 548 sh_i2c.read(SH_ADDR, rsp, 1);
phonemacro 1:da792e46a385 549 mfio = 1; mfio = 0; wait_us(300);
phonemacro 3:da975696b936 550 pc.printf("map SpO2 to slots/PDs %x\n\r", rsp[0]);
phonemacro 3:da975696b936 551 #endif
phonemacro 3:da975696b936 552 #endif // MAXM86146_CFG
phonemacro 0:6f65cae31c54 553
phonemacro 4:4f1e9439f048 554 // 1.3 Enable HR, SpO2 algo
phonemacro 12:17a0bf823462 555 #ifdef EXTENDED_ALGO
phonemacro 12:17a0bf823462 556 cmd[0] = 0x52; cmd[1] = 0x07; cmd[2] = 0x02;
phonemacro 12:17a0bf823462 557 #else
phonemacro 4:4f1e9439f048 558 cmd[0] = 0x52; cmd[1] = 0x07; cmd[2] = 0x01;
phonemacro 12:17a0bf823462 559 #endif
phonemacro 6:e1b7190d6cb5 560 sh_i2c.write(SH_ADDR, cmd, 3);
phonemacro 0:6f65cae31c54 561 thread_sleep_for(465);
phonemacro 6:e1b7190d6cb5 562 sh_i2c.read(SH_ADDR, rsp, 1);
phonemacro 3:da975696b936 563 pc.printf("1.14 status: %x\n\r", rsp[0]);
phonemacro 0:6f65cae31c54 564 mfio = 1;
phonemacro 0:6f65cae31c54 565
phonemacro 4:4f1e9439f048 566 #if 1
phonemacro 4:4f1e9439f048 567 //1.31 rd AFE part id
phonemacro 4:4f1e9439f048 568 cmd[0] = 0x41; cmd[1] = 0x00; cmd[2] = 0xFF;
phonemacro 6:e1b7190d6cb5 569 sh_i2c.write(SH_ADDR, cmd, 3);
phonemacro 4:4f1e9439f048 570 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 6:e1b7190d6cb5 571 sh_i2c.read(SH_ADDR, rsp, 2);
phonemacro 4:4f1e9439f048 572 mfio = 1; mfio = 0; wait_us(300);
phonemacro 4:4f1e9439f048 573 pc.printf("1.31 part id afe %x %x\n\r", rsp[0], rsp[1]);
phonemacro 4:4f1e9439f048 574 //1.32 rd accel who
phonemacro 4:4f1e9439f048 575 cmd[0] = 0x41; cmd[1] = 0x04; cmd[2] = 0x0F;
phonemacro 6:e1b7190d6cb5 576 sh_i2c.write(SH_ADDR, cmd, 3);
phonemacro 4:4f1e9439f048 577 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 6:e1b7190d6cb5 578 sh_i2c.read(SH_ADDR, rsp, 2);
phonemacro 4:4f1e9439f048 579 mfio = 1; mfio = 0; wait_us(300);
phonemacro 4:4f1e9439f048 580 pc.printf("1.32 who accel %x %x\n\r", rsp[0], rsp[1]);
phonemacro 4:4f1e9439f048 581 #endif
phonemacro 10:192ea88e964b 582 }
phonemacro 10:192ea88e964b 583
phonemacro 14:c8cc6d7fd5f9 584 /*****************************************************************************/
phonemacro 14:c8cc6d7fd5f9 585 // init_sh_raw
phonemacro 14:c8cc6d7fd5f9 586 /*****************************************************************************/
phonemacro 14:c8cc6d7fd5f9 587 void init_sh_raw(void) {
phonemacro 14:c8cc6d7fd5f9 588 char cmd[8];
phonemacro 14:c8cc6d7fd5f9 589 char rsp[256];
phonemacro 14:c8cc6d7fd5f9 590 // switch to application mode
phonemacro 14:c8cc6d7fd5f9 591 rst = 0;
phonemacro 14:c8cc6d7fd5f9 592 mfio = 1;
phonemacro 14:c8cc6d7fd5f9 593 thread_sleep_for(10);
phonemacro 14:c8cc6d7fd5f9 594 rst = 1;
phonemacro 14:c8cc6d7fd5f9 595 thread_sleep_for(1500);
phonemacro 14:c8cc6d7fd5f9 596 #ifdef MAXREFDES103_CFG
phonemacro 14:c8cc6d7fd5f9 597 init_max20303_pmic();
phonemacro 14:c8cc6d7fd5f9 598 #endif
phonemacro 14:c8cc6d7fd5f9 599
phonemacro 14:c8cc6d7fd5f9 600 mfio = 0; wait_us(300);
phonemacro 14:c8cc6d7fd5f9 601
phonemacro 14:c8cc6d7fd5f9 602 //read operating mode
phonemacro 14:c8cc6d7fd5f9 603 cmd[0] = 0x02; cmd[1] = 0x00;
phonemacro 14:c8cc6d7fd5f9 604 sh_i2c.write(SH_ADDR, cmd, 2);
phonemacro 14:c8cc6d7fd5f9 605 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 14:c8cc6d7fd5f9 606 sh_i2c.read(SH_ADDR, rsp, 2);
phonemacro 14:c8cc6d7fd5f9 607 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 14:c8cc6d7fd5f9 608 pc.printf("\n\r 0x02 0x00 Status, Read Operating Mode: %x %x\n\r", rsp[0], rsp[1]);
phonemacro 14:c8cc6d7fd5f9 609 //1.11 rd ver
phonemacro 14:c8cc6d7fd5f9 610 cmd[0] = 0xFF; cmd[1] = 0x03;
phonemacro 14:c8cc6d7fd5f9 611 sh_i2c.write(SH_ADDR, cmd, 2);
phonemacro 14:c8cc6d7fd5f9 612 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 14:c8cc6d7fd5f9 613 sh_i2c.read(SH_ADDR, rsp, 4);
phonemacro 14:c8cc6d7fd5f9 614 mfio = 1; mfio = 0; wait_us(300);
phonemacro 14:c8cc6d7fd5f9 615 pc.printf("Ver: %d %d %d %d\n\r", rsp[0], rsp[1], rsp[2], rsp[3]);
phonemacro 14:c8cc6d7fd5f9 616
phonemacro 14:c8cc6d7fd5f9 617 // raw1.1 sensor data
phonemacro 14:c8cc6d7fd5f9 618 cmd[0] = 0x10; cmd[1] = 0x00; cmd[2] = 0x01;
phonemacro 14:c8cc6d7fd5f9 619 pc.printf("raw sensor data only \n\r");
phonemacro 14:c8cc6d7fd5f9 620 sh_i2c.write(SH_ADDR, cmd, 3);
phonemacro 14:c8cc6d7fd5f9 621 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 14:c8cc6d7fd5f9 622 sh_i2c.read(SH_ADDR, rsp, 1);
phonemacro 14:c8cc6d7fd5f9 623 mfio = 1; mfio = 0; wait_us(300);
phonemacro 14:c8cc6d7fd5f9 624 pc.printf("raw1.1 Status: %x\n\r", rsp[0]);
phonemacro 14:c8cc6d7fd5f9 625 // raw1.2 interrupt threshold
phonemacro 14:c8cc6d7fd5f9 626 cmd[0] = 0x10; cmd[1] = 0x01; cmd[2] = 0x01;
phonemacro 14:c8cc6d7fd5f9 627 sh_i2c.write(SH_ADDR, cmd, 3);
phonemacro 14:c8cc6d7fd5f9 628 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 14:c8cc6d7fd5f9 629 sh_i2c.read(SH_ADDR, rsp, 1);
phonemacro 14:c8cc6d7fd5f9 630 mfio = 1; mfio = 0; wait_us(300);
phonemacro 14:c8cc6d7fd5f9 631 pc.printf("raw1.2 Status: %x\n\r", rsp[0]);
phonemacro 14:c8cc6d7fd5f9 632 // raw1.3 enable sh accel
phonemacro 14:c8cc6d7fd5f9 633 cmd[0] = 0x44; cmd[1] = 0x04; cmd[2] = 0x01; cmd[3] = 0x00;
phonemacro 14:c8cc6d7fd5f9 634 sh_i2c.write(SH_ADDR, cmd, 4);
phonemacro 14:c8cc6d7fd5f9 635 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 14:c8cc6d7fd5f9 636 sh_i2c.read(SH_ADDR, rsp, 1);
phonemacro 14:c8cc6d7fd5f9 637 mfio = 1; thread_sleep_for(20); mfio = 0; wait_us(300);
phonemacro 14:c8cc6d7fd5f9 638 pc.printf("raw1.3 Status: %x\n\r", rsp[0]);
phonemacro 14:c8cc6d7fd5f9 639 // raw1.4 enable AFE
phonemacro 14:c8cc6d7fd5f9 640 cmd[0] = 0x44; cmd[1] = 0x00; cmd[2] = 0x01; cmd[3] = 0x00;
phonemacro 14:c8cc6d7fd5f9 641 sh_i2c.write(SH_ADDR, cmd, 4);
phonemacro 14:c8cc6d7fd5f9 642 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 14:c8cc6d7fd5f9 643 sh_i2c.read(SH_ADDR, rsp, 1);
phonemacro 14:c8cc6d7fd5f9 644 mfio = 1; thread_sleep_for(250); mfio = 0; wait_us(300);
phonemacro 14:c8cc6d7fd5f9 645 pc.printf("raw1.4 Status: %x\n\r", rsp[0]);
phonemacro 14:c8cc6d7fd5f9 646 // raw1.5 sample rate 100 Hz, ave 1
phonemacro 14:c8cc6d7fd5f9 647 cmd[0] = 0x40; cmd[1] = 0x00; cmd[2] = 0x12; cmd[3] = 0x18; // set AFE reg 0x12 to 100 Hz
phonemacro 14:c8cc6d7fd5f9 648 // cmd[0] = 0x40; cmd[1] = 0x00; cmd[2] = 0x12; cmd[3] = 0x20; // set AFE reg 0x12 to 200 Hz
phonemacro 14:c8cc6d7fd5f9 649 sh_i2c.write(SH_ADDR, cmd, 4);
phonemacro 14:c8cc6d7fd5f9 650 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 14:c8cc6d7fd5f9 651 sh_i2c.read(SH_ADDR, rsp, 1);
phonemacro 14:c8cc6d7fd5f9 652 mfio = 1; mfio = 0; wait_us(300);
phonemacro 14:c8cc6d7fd5f9 653 pc.printf("raw1.5 Status: %x\n\r", rsp[0]);
phonemacro 14:c8cc6d7fd5f9 654 // raw1.6 LED1 current
phonemacro 14:c8cc6d7fd5f9 655 cmd[0] = 0x40; cmd[1] = 0x00; cmd[2] = 0x23; cmd[3] = 0x7F;
phonemacro 14:c8cc6d7fd5f9 656 sh_i2c.write(SH_ADDR, cmd, 4);
phonemacro 14:c8cc6d7fd5f9 657 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 14:c8cc6d7fd5f9 658 sh_i2c.read(SH_ADDR, rsp, 1);
phonemacro 14:c8cc6d7fd5f9 659 mfio = 1; mfio = 0; wait_us(300);
phonemacro 14:c8cc6d7fd5f9 660 pc.printf("raw1.6 Status: %x\n\r", rsp[0]);
phonemacro 14:c8cc6d7fd5f9 661 #ifndef MAXM86146_CFG
phonemacro 14:c8cc6d7fd5f9 662 // raw1.7 LED2 current
phonemacro 14:c8cc6d7fd5f9 663 cmd[0] = 0x40; cmd[1] = 0x00; cmd[2] = 0x24; cmd[3] = 0x7F;
phonemacro 14:c8cc6d7fd5f9 664 sh_i2c.write(SH_ADDR, cmd, 4);
phonemacro 14:c8cc6d7fd5f9 665 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 14:c8cc6d7fd5f9 666 sh_i2c.read(SH_ADDR, rsp, 1);
phonemacro 14:c8cc6d7fd5f9 667 mfio = 1; mfio = 0; wait_us(300);
phonemacro 14:c8cc6d7fd5f9 668 pc.printf("raw1.7 Status: %x\n\r", rsp[0]);
phonemacro 14:c8cc6d7fd5f9 669 #endif
phonemacro 14:c8cc6d7fd5f9 670 // raw1.8 LED3 current
phonemacro 14:c8cc6d7fd5f9 671 cmd[0] = 0x40; cmd[1] = 0x00; cmd[2] = 0x25; cmd[3] = 0x7F;
phonemacro 14:c8cc6d7fd5f9 672 sh_i2c.write(SH_ADDR, cmd, 4);
phonemacro 14:c8cc6d7fd5f9 673 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 14:c8cc6d7fd5f9 674 sh_i2c.read(SH_ADDR, rsp, 1);
phonemacro 14:c8cc6d7fd5f9 675 mfio = 1; mfio = 0; wait_us(300);
phonemacro 14:c8cc6d7fd5f9 676 pc.printf("raw1.8 Status: %x\n\r", rsp[0]);
phonemacro 14:c8cc6d7fd5f9 677 #ifdef MAXM86146_CFG
phonemacro 14:c8cc6d7fd5f9 678 // LED5 current
phonemacro 14:c8cc6d7fd5f9 679 cmd[0] = 0x40; cmd[1] = 0x00; cmd[2] = 0x27; cmd[3] = 0x7F;
phonemacro 14:c8cc6d7fd5f9 680 sh_i2c.write(SH_ADDR, cmd, 4);
phonemacro 14:c8cc6d7fd5f9 681 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 14:c8cc6d7fd5f9 682 sh_i2c.read(SH_ADDR, rsp, 1);
phonemacro 14:c8cc6d7fd5f9 683 mfio = 1; mfio = 0; wait_us(300);
phonemacro 14:c8cc6d7fd5f9 684 pc.printf("led5 Status: %x\n\r", rsp[0]);
phonemacro 14:c8cc6d7fd5f9 685 // LED6 current
phonemacro 14:c8cc6d7fd5f9 686 cmd[0] = 0x40; cmd[1] = 0x00; cmd[2] = 0x27; cmd[3] = 0x7F;
phonemacro 14:c8cc6d7fd5f9 687 sh_i2c.write(SH_ADDR, cmd, 4);
phonemacro 14:c8cc6d7fd5f9 688 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 14:c8cc6d7fd5f9 689 sh_i2c.read(SH_ADDR, rsp, 1);
phonemacro 14:c8cc6d7fd5f9 690 mfio = 1; mfio = 0; wait_us(300);
phonemacro 14:c8cc6d7fd5f9 691 pc.printf("led6 Status: %x\n\r", rsp[0]);
phonemacro 14:c8cc6d7fd5f9 692
phonemacro 14:c8cc6d7fd5f9 693 // Set Seq cntrl1 LED2, LED1
phonemacro 14:c8cc6d7fd5f9 694 cmd[0] = 0x40; cmd[1] = 0x00; cmd[2] = 0x20; cmd[3] = 0x21;
phonemacro 14:c8cc6d7fd5f9 695 sh_i2c.write(SH_ADDR, cmd, 4);
phonemacro 14:c8cc6d7fd5f9 696 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 14:c8cc6d7fd5f9 697 sh_i2c.read(SH_ADDR, rsp, 1);
phonemacro 14:c8cc6d7fd5f9 698 mfio = 1; mfio = 0; wait_us(300);
phonemacro 14:c8cc6d7fd5f9 699 pc.printf("Seq cntrl1 Status: %x\n\r", rsp[0]);
phonemacro 14:c8cc6d7fd5f9 700 // Set Seq cntrl2 LED4, LED3
phonemacro 14:c8cc6d7fd5f9 701 cmd[0] = 0x40; cmd[1] = 0x00; cmd[2] = 0x21; cmd[3] = 0xA3;
phonemacro 14:c8cc6d7fd5f9 702 sh_i2c.write(SH_ADDR, cmd, 4);
phonemacro 14:c8cc6d7fd5f9 703 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 14:c8cc6d7fd5f9 704 sh_i2c.read(SH_ADDR, rsp, 1);
phonemacro 14:c8cc6d7fd5f9 705 mfio = 1; mfio = 0; wait_us(300);
phonemacro 14:c8cc6d7fd5f9 706 pc.printf("Seq cntrl2 Status: %x\n\r", rsp[0]);
phonemacro 14:c8cc6d7fd5f9 707 // Set Seq cntrl3 LED6, LED5
phonemacro 14:c8cc6d7fd5f9 708 cmd[0] = 0x40; cmd[1] = 0x00; cmd[2] = 0x22; cmd[3] = 0x21;
phonemacro 14:c8cc6d7fd5f9 709 // cmd[0] = 0x40; cmd[1] = 0x00; cmd[2] = 0x22; cmd[3] = 0x99; // Ambient
phonemacro 14:c8cc6d7fd5f9 710 sh_i2c.write(SH_ADDR, cmd, 4);
phonemacro 14:c8cc6d7fd5f9 711 mfio = 1; thread_sleep_for(2); mfio = 0; wait_us(300);
phonemacro 14:c8cc6d7fd5f9 712 sh_i2c.read(SH_ADDR, rsp, 1);
phonemacro 14:c8cc6d7fd5f9 713 mfio = 1; mfio = 0; wait_us(300);
phonemacro 14:c8cc6d7fd5f9 714 pc.printf("Seq cntrl3 Status: %x\n\r", rsp[0]);
phonemacro 14:c8cc6d7fd5f9 715
phonemacro 14:c8cc6d7fd5f9 716 #endif
phonemacro 14:c8cc6d7fd5f9 717 }
phonemacro 14:c8cc6d7fd5f9 718
phonemacro 14:c8cc6d7fd5f9 719 /*****************************************************************************/
phonemacro 14:c8cc6d7fd5f9 720 // main
phonemacro 14:c8cc6d7fd5f9 721 /*****************************************************************************/
phonemacro 10:192ea88e964b 722 int main()
phonemacro 10:192ea88e964b 723 {
phonemacro 10:192ea88e964b 724 sh_i2c.frequency(400000);
phonemacro 10:192ea88e964b 725 int32_t ledcnt = 0;
phonemacro 10:192ea88e964b 726 rLED = LED_OFF; gLED = LED_ON; bLED = LED_OFF;
phonemacro 10:192ea88e964b 727 Ticker ticker; // calls a callback repeatedly with a timeout
phonemacro 10:192ea88e964b 728 //ticker.attach(callback(&blink_timer), BLINKING_RATE_MS); /* set timer for one second */
phonemacro 14:c8cc6d7fd5f9 729 #ifdef RAW
phonemacro 14:c8cc6d7fd5f9 730 init_sh_raw();
phonemacro 14:c8cc6d7fd5f9 731 #else
phonemacro 14:c8cc6d7fd5f9 732 init_sh_algo();
phonemacro 14:c8cc6d7fd5f9 733 #endif
phonemacro 8:e6ae69cfecbf 734 #if defined(MAXREFDES103_CFG) || defined(MAXM86161_CFG) || defined(MAXM86146_CFG)
phonemacro 6:e1b7190d6cb5 735 Timer tmr1;
phonemacro 0:6f65cae31c54 736 while (1) {
phonemacro 6:e1b7190d6cb5 737 tmr1.start();
phonemacro 6:e1b7190d6cb5 738 if (tmr1.read_ms() > 40) {
phonemacro 7:23b067817ab8 739 tmr1.reset();
phonemacro 10:192ea88e964b 740 read_sh_fifo();
phonemacro 7:23b067817ab8 741 if ((ledcnt++ % 50) == 0)
phonemacro 6:e1b7190d6cb5 742 gLED = !gLED;
phonemacro 0:6f65cae31c54 743 }
phonemacro 0:6f65cae31c54 744 }
phonemacro 6:e1b7190d6cb5 745 #else
phonemacro 6:e1b7190d6cb5 746 ticker.attach(callback(&fifo_timer), 0.040f);
phonemacro 6:e1b7190d6cb5 747 while (1) {
phonemacro 6:e1b7190d6cb5 748 if (Time_to_Read_PPG) {
phonemacro 10:192ea88e964b 749 read_sh_fifo();
phonemacro 7:23b067817ab8 750 if ((ledcnt++ % 50) == 0)
phonemacro 6:e1b7190d6cb5 751 gLED = !gLED;
phonemacro 6:e1b7190d6cb5 752 }
phonemacro 6:e1b7190d6cb5 753 }
phonemacro 6:e1b7190d6cb5 754 #endif
phonemacro 0:6f65cae31c54 755 }