repo time
Dependencies: mbed MAX14720 MAX30205 USBDevice
e4a10ed6eb92/HSP/Devices/MAX30001/MAX30001_RPC.cpp@20:6d2af70c92ab, 2021-04-06 (annotated)
- Committer:
- darienf
- Date:
- Tue Apr 06 06:41:40 2021 +0000
- Revision:
- 20:6d2af70c92ab
another repo
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
darienf | 20:6d2af70c92ab | 1 | /******************************************************************************* |
darienf | 20:6d2af70c92ab | 2 | * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. |
darienf | 20:6d2af70c92ab | 3 | * |
darienf | 20:6d2af70c92ab | 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
darienf | 20:6d2af70c92ab | 5 | * copy of this software and associated documentation files (the "Software"), |
darienf | 20:6d2af70c92ab | 6 | * to deal in the Software without restriction, including without limitation |
darienf | 20:6d2af70c92ab | 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
darienf | 20:6d2af70c92ab | 8 | * and/or sell copies of the Software, and to permit persons to whom the |
darienf | 20:6d2af70c92ab | 9 | * Software is furnished to do so, subject to the following conditions: |
darienf | 20:6d2af70c92ab | 10 | * |
darienf | 20:6d2af70c92ab | 11 | * The above copyright notice and this permission notice shall be included |
darienf | 20:6d2af70c92ab | 12 | * in all copies or substantial portions of the Software. |
darienf | 20:6d2af70c92ab | 13 | * |
darienf | 20:6d2af70c92ab | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
darienf | 20:6d2af70c92ab | 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
darienf | 20:6d2af70c92ab | 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
darienf | 20:6d2af70c92ab | 17 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
darienf | 20:6d2af70c92ab | 18 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
darienf | 20:6d2af70c92ab | 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
darienf | 20:6d2af70c92ab | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
darienf | 20:6d2af70c92ab | 21 | * |
darienf | 20:6d2af70c92ab | 22 | * Except as contained in this notice, the name of Maxim Integrated |
darienf | 20:6d2af70c92ab | 23 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
darienf | 20:6d2af70c92ab | 24 | * Products, Inc. Branding Policy. |
darienf | 20:6d2af70c92ab | 25 | * |
darienf | 20:6d2af70c92ab | 26 | * The mere transfer of this software does not imply any licenses |
darienf | 20:6d2af70c92ab | 27 | * of trade secrets, proprietary technology, copyrights, patents, |
darienf | 20:6d2af70c92ab | 28 | * trademarks, maskwork rights, or any other form of intellectual |
darienf | 20:6d2af70c92ab | 29 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
darienf | 20:6d2af70c92ab | 30 | * ownership rights. |
darienf | 20:6d2af70c92ab | 31 | ******************************************************************************* |
darienf | 20:6d2af70c92ab | 32 | */ |
darienf | 20:6d2af70c92ab | 33 | |
darienf | 20:6d2af70c92ab | 34 | #include <stdio.h> |
darienf | 20:6d2af70c92ab | 35 | #include "StringHelper.h" |
darienf | 20:6d2af70c92ab | 36 | #include "MAX30001.h" |
darienf | 20:6d2af70c92ab | 37 | #include "Streaming.h" |
darienf | 20:6d2af70c92ab | 38 | #include "StringInOut.h" |
darienf | 20:6d2af70c92ab | 39 | #include "MAX30001_helper.h" |
darienf | 20:6d2af70c92ab | 40 | #include "RpcFifo.h" |
darienf | 20:6d2af70c92ab | 41 | #include "RpcServer.h" |
darienf | 20:6d2af70c92ab | 42 | #include "Peripherals.h" |
darienf | 20:6d2af70c92ab | 43 | #include "DataLoggingService.h" |
darienf | 20:6d2af70c92ab | 44 | |
darienf | 20:6d2af70c92ab | 45 | /*static int startedEcg = 0; |
darienf | 20:6d2af70c92ab | 46 | static int startedBioz = 0; |
darienf | 20:6d2af70c92ab | 47 | static int startedCal = 0; |
darienf | 20:6d2af70c92ab | 48 | static int startedPace = 0; |
darienf | 20:6d2af70c92ab | 49 | static int startedRtor = 0; |
darienf | 20:6d2af70c92ab | 50 | static void StopAll(); |
darienf | 20:6d2af70c92ab | 51 | */ |
darienf | 20:6d2af70c92ab | 52 | |
darienf | 20:6d2af70c92ab | 53 | extern int highDataRate; |
darienf | 20:6d2af70c92ab | 54 | |
darienf | 20:6d2af70c92ab | 55 | uint32_t max30001_RegRead(MAX30001::MAX30001_REG_map_t addr) { |
darienf | 20:6d2af70c92ab | 56 | uint32_t data; |
darienf | 20:6d2af70c92ab | 57 | Peripherals::max30001()->max30001_reg_read(addr, &data); |
darienf | 20:6d2af70c92ab | 58 | return data; |
darienf | 20:6d2af70c92ab | 59 | } |
darienf | 20:6d2af70c92ab | 60 | |
darienf | 20:6d2af70c92ab | 61 | void max30001_RegWrite(MAX30001::MAX30001_REG_map_t addr, uint32_t data) { |
darienf | 20:6d2af70c92ab | 62 | Peripherals::max30001()->max30001_reg_write(addr, data); |
darienf | 20:6d2af70c92ab | 63 | } |
darienf | 20:6d2af70c92ab | 64 | |
darienf | 20:6d2af70c92ab | 65 | int MAX30001_WriteReg(char argStrs[32][32], char replyStrs[32][32]) { |
darienf | 20:6d2af70c92ab | 66 | uint32_t args[2]; |
darienf | 20:6d2af70c92ab | 67 | uint32_t reply[1]; |
darienf | 20:6d2af70c92ab | 68 | uint32_t value; |
darienf | 20:6d2af70c92ab | 69 | ProcessArgs32(argStrs, args, sizeof(args) / sizeof(uint32_t)); |
darienf | 20:6d2af70c92ab | 70 | |
darienf | 20:6d2af70c92ab | 71 | max30001_RegWrite((MAX30001::MAX30001_REG_map_t)args[0], args[1]); |
darienf | 20:6d2af70c92ab | 72 | reply[0] = 0x80; |
darienf | 20:6d2af70c92ab | 73 | FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs); |
darienf | 20:6d2af70c92ab | 74 | return 0; |
darienf | 20:6d2af70c92ab | 75 | } |
darienf | 20:6d2af70c92ab | 76 | |
darienf | 20:6d2af70c92ab | 77 | int MAX30001_ReadReg(char argStrs[32][32], char replyStrs[32][32]) { |
darienf | 20:6d2af70c92ab | 78 | uint32_t args[1]; |
darienf | 20:6d2af70c92ab | 79 | uint32_t reply[1]; |
darienf | 20:6d2af70c92ab | 80 | uint32_t value; |
darienf | 20:6d2af70c92ab | 81 | ProcessArgs32(argStrs, args, sizeof(args) / sizeof(uint32_t)); |
darienf | 20:6d2af70c92ab | 82 | value = max30001_RegRead((MAX30001::MAX30001_REG_map_t)args[0]); |
darienf | 20:6d2af70c92ab | 83 | reply[0] = value; |
darienf | 20:6d2af70c92ab | 84 | FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs); |
darienf | 20:6d2af70c92ab | 85 | return 0; |
darienf | 20:6d2af70c92ab | 86 | } |
darienf | 20:6d2af70c92ab | 87 | |
darienf | 20:6d2af70c92ab | 88 | int MAX30001_Rbias_FMSTR_Init(char argStrs[32][32], char replyStrs[32][32]) { |
darienf | 20:6d2af70c92ab | 89 | uint32_t args[5]; |
darienf | 20:6d2af70c92ab | 90 | uint32_t reply[1]; |
darienf | 20:6d2af70c92ab | 91 | uint32_t value; |
darienf | 20:6d2af70c92ab | 92 | ProcessArgs32(argStrs, args, sizeof(args) / sizeof(uint32_t)); |
darienf | 20:6d2af70c92ab | 93 | |
darienf | 20:6d2af70c92ab | 94 | value = Peripherals::max30001()->max30001_Rbias_FMSTR_Init(args[0], // En_rbias |
darienf | 20:6d2af70c92ab | 95 | args[1], // Rbiasv |
darienf | 20:6d2af70c92ab | 96 | args[2], // Rbiasp |
darienf | 20:6d2af70c92ab | 97 | args[3], // Rbiasn |
darienf | 20:6d2af70c92ab | 98 | args[4]); // Fmstr |
darienf | 20:6d2af70c92ab | 99 | |
darienf | 20:6d2af70c92ab | 100 | reply[0] = value; |
darienf | 20:6d2af70c92ab | 101 | FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs); |
darienf | 20:6d2af70c92ab | 102 | return 0; |
darienf | 20:6d2af70c92ab | 103 | } |
darienf | 20:6d2af70c92ab | 104 | |
darienf | 20:6d2af70c92ab | 105 | int MAX30001_CAL_InitStart(char argStrs[32][32], char replyStrs[32][32]) { |
darienf | 20:6d2af70c92ab | 106 | uint32_t args[6]; |
darienf | 20:6d2af70c92ab | 107 | uint32_t reply[1]; |
darienf | 20:6d2af70c92ab | 108 | uint32_t value; |
darienf | 20:6d2af70c92ab | 109 | ProcessArgs32(argStrs, args, sizeof(args) / sizeof(uint32_t)); |
darienf | 20:6d2af70c92ab | 110 | |
darienf | 20:6d2af70c92ab | 111 | // Peripherals::serial()->printf("MAX30001_CAL_InitStart 0 "); |
darienf | 20:6d2af70c92ab | 112 | value = Peripherals::max30001()->max30001_CAL_InitStart(args[0], // En_Vcal |
darienf | 20:6d2af70c92ab | 113 | args[1], // Vmag |
darienf | 20:6d2af70c92ab | 114 | args[2], // Fcal |
darienf | 20:6d2af70c92ab | 115 | args[3], // Thigh |
darienf | 20:6d2af70c92ab | 116 | args[4], // Fifty |
darienf | 20:6d2af70c92ab | 117 | args[5]); // Vmode |
darienf | 20:6d2af70c92ab | 118 | |
darienf | 20:6d2af70c92ab | 119 | reply[0] = value; |
darienf | 20:6d2af70c92ab | 120 | FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs); |
darienf | 20:6d2af70c92ab | 121 | return 0; |
darienf | 20:6d2af70c92ab | 122 | } |
darienf | 20:6d2af70c92ab | 123 | |
darienf | 20:6d2af70c92ab | 124 | int MAX30001_ECG_InitStart(char argStrs[32][32], char replyStrs[32][32]) { |
darienf | 20:6d2af70c92ab | 125 | uint32_t args[11]; |
darienf | 20:6d2af70c92ab | 126 | uint32_t reply[1]; |
darienf | 20:6d2af70c92ab | 127 | uint32_t value; |
darienf | 20:6d2af70c92ab | 128 | ProcessArgs32(argStrs, args, sizeof(args) / sizeof(uint32_t)); |
darienf | 20:6d2af70c92ab | 129 | |
darienf | 20:6d2af70c92ab | 130 | // Peripherals::serial()->printf("MAX30001_ECG_InitStart 0 "); |
darienf | 20:6d2af70c92ab | 131 | value = Peripherals::max30001()->max30001_ECG_InitStart(args[0], // En_ecg |
darienf | 20:6d2af70c92ab | 132 | args[1], // Openp |
darienf | 20:6d2af70c92ab | 133 | args[2], // Openn |
darienf | 20:6d2af70c92ab | 134 | args[3], // Pol |
darienf | 20:6d2af70c92ab | 135 | args[4], // Calp_sel |
darienf | 20:6d2af70c92ab | 136 | args[5], // Caln_sel |
darienf | 20:6d2af70c92ab | 137 | args[6], // E_fit |
darienf | 20:6d2af70c92ab | 138 | args[7], // Rate |
darienf | 20:6d2af70c92ab | 139 | args[8], // Gain |
darienf | 20:6d2af70c92ab | 140 | args[9], // Dhpf |
darienf | 20:6d2af70c92ab | 141 | args[10]); // Dlpf |
darienf | 20:6d2af70c92ab | 142 | // Peripherals::serial()->printf("MAX30001_ECG_InitStart 1 "); |
darienf | 20:6d2af70c92ab | 143 | MAX30001_Helper_SetStreamingFlag(eStreaming_ECG, 1); |
darienf | 20:6d2af70c92ab | 144 | reply[0] = value; |
darienf | 20:6d2af70c92ab | 145 | FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs); |
darienf | 20:6d2af70c92ab | 146 | return 0; |
darienf | 20:6d2af70c92ab | 147 | } |
darienf | 20:6d2af70c92ab | 148 | |
darienf | 20:6d2af70c92ab | 149 | int MAX30001_ECGFast_Init(char argStrs[32][32], char replyStrs[32][32]) { |
darienf | 20:6d2af70c92ab | 150 | uint32_t args[3]; |
darienf | 20:6d2af70c92ab | 151 | uint32_t reply[1]; |
darienf | 20:6d2af70c92ab | 152 | uint32_t value; |
darienf | 20:6d2af70c92ab | 153 | ProcessArgs32(argStrs, args, sizeof(args) / sizeof(uint32_t)); |
darienf | 20:6d2af70c92ab | 154 | |
darienf | 20:6d2af70c92ab | 155 | value = Peripherals::max30001()->max30001_ECGFast_Init(args[0], // Clr_Fast |
darienf | 20:6d2af70c92ab | 156 | args[1], // Fast |
darienf | 20:6d2af70c92ab | 157 | args[2]); // Fast_Th |
darienf | 20:6d2af70c92ab | 158 | |
darienf | 20:6d2af70c92ab | 159 | reply[0] = value; |
darienf | 20:6d2af70c92ab | 160 | FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs); |
darienf | 20:6d2af70c92ab | 161 | return 0; |
darienf | 20:6d2af70c92ab | 162 | } |
darienf | 20:6d2af70c92ab | 163 | |
darienf | 20:6d2af70c92ab | 164 | int MAX30001_PACE_InitStart(char argStrs[32][32], char replyStrs[32][32]) { |
darienf | 20:6d2af70c92ab | 165 | uint32_t args[9]; |
darienf | 20:6d2af70c92ab | 166 | uint32_t reply[1]; |
darienf | 20:6d2af70c92ab | 167 | uint32_t value; |
darienf | 20:6d2af70c92ab | 168 | ProcessArgs32(argStrs, args, sizeof(args) / sizeof(uint32_t)); |
darienf | 20:6d2af70c92ab | 169 | |
darienf | 20:6d2af70c92ab | 170 | value = |
darienf | 20:6d2af70c92ab | 171 | Peripherals::max30001()->max30001_PACE_InitStart(args[0], // En_pace |
darienf | 20:6d2af70c92ab | 172 | args[1], // Clr_pedge |
darienf | 20:6d2af70c92ab | 173 | args[2], // Pol |
darienf | 20:6d2af70c92ab | 174 | args[3], // Gn_diff_off |
darienf | 20:6d2af70c92ab | 175 | args[4], // Gain |
darienf | 20:6d2af70c92ab | 176 | args[5], // Aout_lbw |
darienf | 20:6d2af70c92ab | 177 | args[6], // Aout |
darienf | 20:6d2af70c92ab | 178 | args[7], // Dacp |
darienf | 20:6d2af70c92ab | 179 | args[8]); // Dacn |
darienf | 20:6d2af70c92ab | 180 | |
darienf | 20:6d2af70c92ab | 181 | MAX30001_Helper_SetStreamingFlag(eStreaming_PACE, 1); |
darienf | 20:6d2af70c92ab | 182 | reply[0] = value; |
darienf | 20:6d2af70c92ab | 183 | FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs); |
darienf | 20:6d2af70c92ab | 184 | return 0; |
darienf | 20:6d2af70c92ab | 185 | } |
darienf | 20:6d2af70c92ab | 186 | |
darienf | 20:6d2af70c92ab | 187 | int MAX30001_BIOZ_InitStart(char argStrs[32][32], char replyStrs[32][32]) { |
darienf | 20:6d2af70c92ab | 188 | uint32_t args[17]; |
darienf | 20:6d2af70c92ab | 189 | uint32_t reply[1]; |
darienf | 20:6d2af70c92ab | 190 | uint32_t value; |
darienf | 20:6d2af70c92ab | 191 | ProcessArgs32(argStrs, args, sizeof(args) / sizeof(uint32_t)); |
darienf | 20:6d2af70c92ab | 192 | |
darienf | 20:6d2af70c92ab | 193 | value = Peripherals::max30001()->max30001_BIOZ_InitStart(args[0], // En_bioz |
darienf | 20:6d2af70c92ab | 194 | args[1], // Openp |
darienf | 20:6d2af70c92ab | 195 | args[2], // Openn |
darienf | 20:6d2af70c92ab | 196 | args[3], // Calp_sel |
darienf | 20:6d2af70c92ab | 197 | args[4], // Caln_sel |
darienf | 20:6d2af70c92ab | 198 | args[5], // CG_mode |
darienf | 20:6d2af70c92ab | 199 | args[6], // B_fit |
darienf | 20:6d2af70c92ab | 200 | args[7], // Rate |
darienf | 20:6d2af70c92ab | 201 | args[8], // Ahpf |
darienf | 20:6d2af70c92ab | 202 | args[9], // Ext_rbias |
darienf | 20:6d2af70c92ab | 203 | args[10], // Gain |
darienf | 20:6d2af70c92ab | 204 | args[11], // Dhpf |
darienf | 20:6d2af70c92ab | 205 | args[12], // Dlpf |
darienf | 20:6d2af70c92ab | 206 | args[13], // Fcgen |
darienf | 20:6d2af70c92ab | 207 | args[14], // Cgmon |
darienf | 20:6d2af70c92ab | 208 | args[15], // Cgmag |
darienf | 20:6d2af70c92ab | 209 | args[16]); // Phoff |
darienf | 20:6d2af70c92ab | 210 | |
darienf | 20:6d2af70c92ab | 211 | MAX30001_Helper_SetStreamingFlag(eStreaming_BIOZ, 1); |
darienf | 20:6d2af70c92ab | 212 | reply[0] = value; |
darienf | 20:6d2af70c92ab | 213 | FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs); |
darienf | 20:6d2af70c92ab | 214 | return 0; |
darienf | 20:6d2af70c92ab | 215 | } |
darienf | 20:6d2af70c92ab | 216 | |
darienf | 20:6d2af70c92ab | 217 | int MAX30001_RtoR_InitStart(char argStrs[32][32], char replyStrs[32][32]) { |
darienf | 20:6d2af70c92ab | 218 | uint32_t args[9]; |
darienf | 20:6d2af70c92ab | 219 | uint32_t reply[1]; |
darienf | 20:6d2af70c92ab | 220 | uint32_t value; |
darienf | 20:6d2af70c92ab | 221 | ProcessArgs32(argStrs, args, sizeof(args) / sizeof(uint32_t)); |
darienf | 20:6d2af70c92ab | 222 | |
darienf | 20:6d2af70c92ab | 223 | value = Peripherals::max30001()->max30001_RtoR_InitStart(args[0], // En_rtor |
darienf | 20:6d2af70c92ab | 224 | args[1], // Wndw |
darienf | 20:6d2af70c92ab | 225 | args[2], // Gain |
darienf | 20:6d2af70c92ab | 226 | args[3], // Pavg |
darienf | 20:6d2af70c92ab | 227 | args[4], // Ptsf |
darienf | 20:6d2af70c92ab | 228 | args[5], // Hoff |
darienf | 20:6d2af70c92ab | 229 | args[6], // Ravg |
darienf | 20:6d2af70c92ab | 230 | args[7], // Rhsf |
darienf | 20:6d2af70c92ab | 231 | args[8]); // Clr_rrint |
darienf | 20:6d2af70c92ab | 232 | |
darienf | 20:6d2af70c92ab | 233 | MAX30001_Helper_SetStreamingFlag(eStreaming_RtoR, 1); |
darienf | 20:6d2af70c92ab | 234 | reply[0] = value; |
darienf | 20:6d2af70c92ab | 235 | FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs); |
darienf | 20:6d2af70c92ab | 236 | return 0; |
darienf | 20:6d2af70c92ab | 237 | } |
darienf | 20:6d2af70c92ab | 238 | |
darienf | 20:6d2af70c92ab | 239 | int MAX30001_Stop_ECG(char argStrs[32][32], char replyStrs[32][32]) { |
darienf | 20:6d2af70c92ab | 240 | uint32_t reply[1]; |
darienf | 20:6d2af70c92ab | 241 | Peripherals::max30001()->max30001_Stop_ECG(); |
darienf | 20:6d2af70c92ab | 242 | reply[0] = 0x80; |
darienf | 20:6d2af70c92ab | 243 | FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs); |
darienf | 20:6d2af70c92ab | 244 | return 0; |
darienf | 20:6d2af70c92ab | 245 | } |
darienf | 20:6d2af70c92ab | 246 | int MAX30001_Stop_PACE(char argStrs[32][32], char replyStrs[32][32]) { |
darienf | 20:6d2af70c92ab | 247 | uint32_t reply[1]; |
darienf | 20:6d2af70c92ab | 248 | Peripherals::max30001()->max30001_Stop_PACE(); |
darienf | 20:6d2af70c92ab | 249 | reply[0] = 0x80; |
darienf | 20:6d2af70c92ab | 250 | FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs); |
darienf | 20:6d2af70c92ab | 251 | return 0; |
darienf | 20:6d2af70c92ab | 252 | } |
darienf | 20:6d2af70c92ab | 253 | int MAX30001_Stop_BIOZ(char argStrs[32][32], char replyStrs[32][32]) { |
darienf | 20:6d2af70c92ab | 254 | uint32_t reply[1]; |
darienf | 20:6d2af70c92ab | 255 | Peripherals::max30001()->max30001_Stop_BIOZ(); |
darienf | 20:6d2af70c92ab | 256 | reply[0] = 0x80; |
darienf | 20:6d2af70c92ab | 257 | FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs); |
darienf | 20:6d2af70c92ab | 258 | return 0; |
darienf | 20:6d2af70c92ab | 259 | } |
darienf | 20:6d2af70c92ab | 260 | int MAX30001_Stop_RtoR(char argStrs[32][32], char replyStrs[32][32]) { |
darienf | 20:6d2af70c92ab | 261 | uint32_t reply[1]; |
darienf | 20:6d2af70c92ab | 262 | Peripherals::max30001()->max30001_Stop_RtoR(); |
darienf | 20:6d2af70c92ab | 263 | reply[0] = 0x80; |
darienf | 20:6d2af70c92ab | 264 | FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs); |
darienf | 20:6d2af70c92ab | 265 | return 0; |
darienf | 20:6d2af70c92ab | 266 | } |
darienf | 20:6d2af70c92ab | 267 | int MAX30001_Stop_Cal(char argStrs[32][32], char replyStrs[32][32]) { |
darienf | 20:6d2af70c92ab | 268 | uint32_t reply[1]; |
darienf | 20:6d2af70c92ab | 269 | // max30001_Stop_Cal(); |
darienf | 20:6d2af70c92ab | 270 | reply[0] = 0x80; |
darienf | 20:6d2af70c92ab | 271 | FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs); |
darienf | 20:6d2af70c92ab | 272 | return 0; |
darienf | 20:6d2af70c92ab | 273 | } |
darienf | 20:6d2af70c92ab | 274 | |
darienf | 20:6d2af70c92ab | 275 | void max30001_ServiceStreaming() { |
darienf | 20:6d2af70c92ab | 276 | char ch; |
darienf | 20:6d2af70c92ab | 277 | uint32_t val; |
darienf | 20:6d2af70c92ab | 278 | USBSerial *usbSerial = Peripherals::usbSerial(); |
darienf | 20:6d2af70c92ab | 279 | |
darienf | 20:6d2af70c92ab | 280 | fifo_clear(GetStreamOutFifo()); |
darienf | 20:6d2af70c92ab | 281 | |
darienf | 20:6d2af70c92ab | 282 | SetStreaming(TRUE); |
darienf | 20:6d2af70c92ab | 283 | clearOutReadFifo(); |
darienf | 20:6d2af70c92ab | 284 | while (IsStreaming() == TRUE) { |
darienf | 20:6d2af70c92ab | 285 | |
darienf | 20:6d2af70c92ab | 286 | if (fifo_empty(GetStreamOutFifo()) == 0) { |
darienf | 20:6d2af70c92ab | 287 | fifo_get32(GetStreamOutFifo(), &val); |
darienf | 20:6d2af70c92ab | 288 | |
darienf | 20:6d2af70c92ab | 289 | usbSerial->printf("%02X ", val); |
darienf | 20:6d2af70c92ab | 290 | |
darienf | 20:6d2af70c92ab | 291 | } |
darienf | 20:6d2af70c92ab | 292 | if (usbSerial->available()) { |
darienf | 20:6d2af70c92ab | 293 | ch = usbSerial->_getc(); |
darienf | 20:6d2af70c92ab | 294 | |
darienf | 20:6d2af70c92ab | 295 | MAX30001_Helper_Stop(); |
darienf | 20:6d2af70c92ab | 296 | SetStreaming(FALSE); |
darienf | 20:6d2af70c92ab | 297 | fifo_clear(GetUSBIncomingFifo()); // clear USB serial incoming fifo |
darienf | 20:6d2af70c92ab | 298 | fifo_clear(GetStreamOutFifo()); |
darienf | 20:6d2af70c92ab | 299 | } |
darienf | 20:6d2af70c92ab | 300 | |
darienf | 20:6d2af70c92ab | 301 | } |
darienf | 20:6d2af70c92ab | 302 | } |
darienf | 20:6d2af70c92ab | 303 | |
darienf | 20:6d2af70c92ab | 304 | int MAX30001_Start(char argStrs[32][32], char replyStrs[32][32]) { |
darienf | 20:6d2af70c92ab | 305 | uint32_t reply[1]; |
darienf | 20:6d2af70c92ab | 306 | uint32_t all; |
darienf | 20:6d2af70c92ab | 307 | fifo_clear(GetUSBIncomingFifo()); |
darienf | 20:6d2af70c92ab | 308 | Peripherals::max30001()->max30001_synch(); |
darienf | 20:6d2af70c92ab | 309 | // max30001_ServiceStreaming(); |
darienf | 20:6d2af70c92ab | 310 | highDataRate = 0; |
darienf | 20:6d2af70c92ab | 311 | Peripherals::max30001()->max30001_reg_read(MAX30001::STATUS, &all); |
darienf | 20:6d2af70c92ab | 312 | LoggingService_StartLoggingUsb(); |
darienf | 20:6d2af70c92ab | 313 | |
darienf | 20:6d2af70c92ab | 314 | reply[0] = 0x80; |
darienf | 20:6d2af70c92ab | 315 | FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs); |
darienf | 20:6d2af70c92ab | 316 | return 0; |
darienf | 20:6d2af70c92ab | 317 | } |
darienf | 20:6d2af70c92ab | 318 | |
darienf | 20:6d2af70c92ab | 319 | int MAX30001_Stop(char argStrs[32][32], char replyStrs[32][32]) { |
darienf | 20:6d2af70c92ab | 320 | /* uint32_t args[1]; |
darienf | 20:6d2af70c92ab | 321 | uint32_t reply[1]; |
darienf | 20:6d2af70c92ab | 322 | uint32_t value; |
darienf | 20:6d2af70c92ab | 323 | //ProcessArgs32(argStrs, args, sizeof(args) / sizeof(uint32_t)); |
darienf | 20:6d2af70c92ab | 324 | max30001_StopTest(); |
darienf | 20:6d2af70c92ab | 325 | reply[0] = 0x80; |
darienf | 20:6d2af70c92ab | 326 | FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs);*/ |
darienf | 20:6d2af70c92ab | 327 | return 0; |
darienf | 20:6d2af70c92ab | 328 | } |
darienf | 20:6d2af70c92ab | 329 | |
darienf | 20:6d2af70c92ab | 330 | int MAX30001_INT_assignment(char argStrs[32][32], char replyStrs[32][32]) { |
darienf | 20:6d2af70c92ab | 331 | uint32_t args[17]; |
darienf | 20:6d2af70c92ab | 332 | uint32_t reply[1]; |
darienf | 20:6d2af70c92ab | 333 | ProcessArgs32(argStrs, args, sizeof(args) / sizeof(uint32_t)); |
darienf | 20:6d2af70c92ab | 334 | /* |
darienf | 20:6d2af70c92ab | 335 | printf("MAX30001_INT_assignment "); |
darienf | 20:6d2af70c92ab | 336 | printf("%d ",args[0]); |
darienf | 20:6d2af70c92ab | 337 | printf("%d ",args[1]); |
darienf | 20:6d2af70c92ab | 338 | printf("%d ",args[2]); |
darienf | 20:6d2af70c92ab | 339 | printf("%d ",args[3]); |
darienf | 20:6d2af70c92ab | 340 | printf("%d ",args[4]); |
darienf | 20:6d2af70c92ab | 341 | printf("%d ",args[5]); |
darienf | 20:6d2af70c92ab | 342 | printf("%d ",args[6]); |
darienf | 20:6d2af70c92ab | 343 | printf("%d ",args[7]); |
darienf | 20:6d2af70c92ab | 344 | printf("%d ",args[8]); |
darienf | 20:6d2af70c92ab | 345 | printf("%d ",args[9]); |
darienf | 20:6d2af70c92ab | 346 | printf("%d ",args[10]); |
darienf | 20:6d2af70c92ab | 347 | printf("%d ",args[11]); |
darienf | 20:6d2af70c92ab | 348 | printf("%d ",args[12]); |
darienf | 20:6d2af70c92ab | 349 | printf("%d ",args[13]); |
darienf | 20:6d2af70c92ab | 350 | printf("%d ",args[14]); |
darienf | 20:6d2af70c92ab | 351 | printf("%d ",args[15]); |
darienf | 20:6d2af70c92ab | 352 | printf("%d ",args[16]); |
darienf | 20:6d2af70c92ab | 353 | printf("\n"); |
darienf | 20:6d2af70c92ab | 354 | fflush(stdout); |
darienf | 20:6d2af70c92ab | 355 | */ |
darienf | 20:6d2af70c92ab | 356 | |
darienf | 20:6d2af70c92ab | 357 | Peripherals::max30001()->max30001_INT_assignment( |
darienf | 20:6d2af70c92ab | 358 | (MAX30001::max30001_intrpt_Location_t)args[0], |
darienf | 20:6d2af70c92ab | 359 | (MAX30001::max30001_intrpt_Location_t)args[1], |
darienf | 20:6d2af70c92ab | 360 | (MAX30001::max30001_intrpt_Location_t)args[2], |
darienf | 20:6d2af70c92ab | 361 | (MAX30001::max30001_intrpt_Location_t)args[3], |
darienf | 20:6d2af70c92ab | 362 | (MAX30001::max30001_intrpt_Location_t)args[4], |
darienf | 20:6d2af70c92ab | 363 | (MAX30001::max30001_intrpt_Location_t)args[5], |
darienf | 20:6d2af70c92ab | 364 | (MAX30001::max30001_intrpt_Location_t)args[6], |
darienf | 20:6d2af70c92ab | 365 | (MAX30001::max30001_intrpt_Location_t)args[7], |
darienf | 20:6d2af70c92ab | 366 | (MAX30001::max30001_intrpt_Location_t)args[8], |
darienf | 20:6d2af70c92ab | 367 | (MAX30001::max30001_intrpt_Location_t)args[9], |
darienf | 20:6d2af70c92ab | 368 | (MAX30001::max30001_intrpt_Location_t)args[10], |
darienf | 20:6d2af70c92ab | 369 | (MAX30001::max30001_intrpt_Location_t)args[11], |
darienf | 20:6d2af70c92ab | 370 | (MAX30001::max30001_intrpt_Location_t)args[12], |
darienf | 20:6d2af70c92ab | 371 | (MAX30001::max30001_intrpt_Location_t)args[13], |
darienf | 20:6d2af70c92ab | 372 | (MAX30001::max30001_intrpt_Location_t)args[14], |
darienf | 20:6d2af70c92ab | 373 | (MAX30001::max30001_intrpt_type_t)args[15], |
darienf | 20:6d2af70c92ab | 374 | (MAX30001::max30001_intrpt_type_t)args[16]); |
darienf | 20:6d2af70c92ab | 375 | reply[0] = 0x80; |
darienf | 20:6d2af70c92ab | 376 | FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs); |
darienf | 20:6d2af70c92ab | 377 | return 0; |
darienf | 20:6d2af70c92ab | 378 | } |
darienf | 20:6d2af70c92ab | 379 | |
darienf | 20:6d2af70c92ab | 380 | int MAX30001_StartTest(char argStrs[32][32], char replyStrs[32][32]) { |
darienf | 20:6d2af70c92ab | 381 | uint32_t reply[1]; |
darienf | 20:6d2af70c92ab | 382 | // ProcessArgs32(argStrs, args, sizeof(args) / sizeof(uint32_t)); |
darienf | 20:6d2af70c92ab | 383 | |
darienf | 20:6d2af70c92ab | 384 | /*** Set FMSTR over here ****/ |
darienf | 20:6d2af70c92ab | 385 | |
darienf | 20:6d2af70c92ab | 386 | /*** Set and Start the VCAL input ***/ |
darienf | 20:6d2af70c92ab | 387 | /* NOTE VCAL must be set first if VCAL is to be used */ |
darienf | 20:6d2af70c92ab | 388 | Peripherals::max30001()->max30001_CAL_InitStart(0b1, 0b1, 0b1, 0b011, 0x7FF, 0b0); |
darienf | 20:6d2af70c92ab | 389 | |
darienf | 20:6d2af70c92ab | 390 | /**** ECG Initialization ****/ |
darienf | 20:6d2af70c92ab | 391 | Peripherals::max30001()->max30001_ECG_InitStart(0b1, 0b1, 0b1, 0b0, 0b10, 0b11, 31, 0b00, 0b00, 0b0, 0b01); |
darienf | 20:6d2af70c92ab | 392 | |
darienf | 20:6d2af70c92ab | 393 | /***** PACE Initialization ***/ |
darienf | 20:6d2af70c92ab | 394 | Peripherals::max30001()->max30001_PACE_InitStart(0b1, 0b0, 0b0, 0b1, 0b000, 0b0, 0b00, 0b0, 0b0); |
darienf | 20:6d2af70c92ab | 395 | |
darienf | 20:6d2af70c92ab | 396 | /**** BIOZ Initialization ****/ |
darienf | 20:6d2af70c92ab | 397 | Peripherals::max30001()->max30001_BIOZ_InitStart( |
darienf | 20:6d2af70c92ab | 398 | 0b1, 0b1, 0b1, 0b10, 0b11, 0b00, 7, 0b0, 0b111, 0b0, 0b10, 0b00, 0b00, 0b0001, 0b0, 0b111, 0b0000); |
darienf | 20:6d2af70c92ab | 399 | |
darienf | 20:6d2af70c92ab | 400 | /*** Set RtoR registers ***/ |
darienf | 20:6d2af70c92ab | 401 | Peripherals::max30001()->max30001_RtoR_InitStart( |
darienf | 20:6d2af70c92ab | 402 | 0b1, 0b0011, 0b1111, 0b00, 0b0011, 0b000001, 0b00, 0b000, 0b01); |
darienf | 20:6d2af70c92ab | 403 | |
darienf | 20:6d2af70c92ab | 404 | /*** Set Rbias & FMSTR over here ****/ |
darienf | 20:6d2af70c92ab | 405 | Peripherals::max30001()->max30001_Rbias_FMSTR_Init(0b01, 0b10, 0b1, 0b1, 0b00); |
darienf | 20:6d2af70c92ab | 406 | |
darienf | 20:6d2af70c92ab | 407 | /**** Interrupt Setting ****/ |
darienf | 20:6d2af70c92ab | 408 | |
darienf | 20:6d2af70c92ab | 409 | /*** Set ECG Lead ON/OFF ***/ |
darienf | 20:6d2af70c92ab | 410 | // max30001_ECG_LeadOnOff(); |
darienf | 20:6d2af70c92ab | 411 | |
darienf | 20:6d2af70c92ab | 412 | /*** Set BIOZ Lead ON/OFF ***/ |
darienf | 20:6d2af70c92ab | 413 | // max30001_BIOZ_LeadOnOff(); Does not work yet... |
darienf | 20:6d2af70c92ab | 414 | |
darienf | 20:6d2af70c92ab | 415 | /**** Do a Synch ****/ |
darienf | 20:6d2af70c92ab | 416 | Peripherals::max30001()->max30001_synch(); |
darienf | 20:6d2af70c92ab | 417 | |
darienf | 20:6d2af70c92ab | 418 | fifo_clear(GetUSBIncomingFifo()); |
darienf | 20:6d2af70c92ab | 419 | max30001_ServiceStreaming(); |
darienf | 20:6d2af70c92ab | 420 | |
darienf | 20:6d2af70c92ab | 421 | reply[0] = 0x80; |
darienf | 20:6d2af70c92ab | 422 | FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs); |
darienf | 20:6d2af70c92ab | 423 | return 0; |
darienf | 20:6d2af70c92ab | 424 | } |
darienf | 20:6d2af70c92ab | 425 | /* |
darienf | 20:6d2af70c92ab | 426 | static void StopAll() { |
darienf | 20:6d2af70c92ab | 427 | if (startedEcg == 1) { |
darienf | 20:6d2af70c92ab | 428 | max30001_Stop_ECG(); |
darienf | 20:6d2af70c92ab | 429 | } |
darienf | 20:6d2af70c92ab | 430 | if (startedCal == 1) { |
darienf | 20:6d2af70c92ab | 431 | } |
darienf | 20:6d2af70c92ab | 432 | if (startedBioz == 1) { |
darienf | 20:6d2af70c92ab | 433 | max30001_Stop_BIOZ(); |
darienf | 20:6d2af70c92ab | 434 | } |
darienf | 20:6d2af70c92ab | 435 | if (startedPace == 1) { |
darienf | 20:6d2af70c92ab | 436 | max30001_Stop_PACE(); |
darienf | 20:6d2af70c92ab | 437 | } |
darienf | 20:6d2af70c92ab | 438 | if (startedRtor == 1) { |
darienf | 20:6d2af70c92ab | 439 | max30001_Stop_RtoR(); |
darienf | 20:6d2af70c92ab | 440 | } |
darienf | 20:6d2af70c92ab | 441 | startedEcg = 0; |
darienf | 20:6d2af70c92ab | 442 | startedBioz = 0; |
darienf | 20:6d2af70c92ab | 443 | startedCal = 0; |
darienf | 20:6d2af70c92ab | 444 | startedPace = 0; |
darienf | 20:6d2af70c92ab | 445 | startedRtor = 0; |
darienf | 20:6d2af70c92ab | 446 | } |
darienf | 20:6d2af70c92ab | 447 | */ |
darienf | 20:6d2af70c92ab | 448 | /* |
darienf | 20:6d2af70c92ab | 449 | // switch to ECG DC Lead ON |
darienf | 20:6d2af70c92ab | 450 | max30001_Enable_LeadON(0b01); |
darienf | 20:6d2af70c92ab | 451 | // switch to BIOZ DC Lead ON |
darienf | 20:6d2af70c92ab | 452 | max30001_Enable_LeadON(0b10); |
darienf | 20:6d2af70c92ab | 453 | */ |
darienf | 20:6d2af70c92ab | 454 | int MAX30001_Enable_ECG_LeadON(char argStrs[32][32], char replyStrs[32][32]) { |
darienf | 20:6d2af70c92ab | 455 | uint32_t reply[1]; |
darienf | 20:6d2af70c92ab | 456 | // switch to ECG DC Lead ON |
darienf | 20:6d2af70c92ab | 457 | Peripherals::max30001()->max30001_Enable_LeadON(0b01); |
darienf | 20:6d2af70c92ab | 458 | reply[0] = 0x80; |
darienf | 20:6d2af70c92ab | 459 | FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs); |
darienf | 20:6d2af70c92ab | 460 | return 0; |
darienf | 20:6d2af70c92ab | 461 | } |
darienf | 20:6d2af70c92ab | 462 | int MAX30001_Enable_BIOZ_LeadON(char argStrs[32][32], char replyStrs[32][32]) { |
darienf | 20:6d2af70c92ab | 463 | uint32_t reply[1]; |
darienf | 20:6d2af70c92ab | 464 | // switch to BIOZ DC Lead ON |
darienf | 20:6d2af70c92ab | 465 | Peripherals::max30001()->max30001_Enable_LeadON(0b10); |
darienf | 20:6d2af70c92ab | 466 | reply[0] = 0x80; |
darienf | 20:6d2af70c92ab | 467 | FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs); |
darienf | 20:6d2af70c92ab | 468 | return 0; |
darienf | 20:6d2af70c92ab | 469 | } |
darienf | 20:6d2af70c92ab | 470 | // uint32_t max30001_LeadOn; // This holds the LeadOn data, BIT1 = BIOZ Lead ON, BIT0 = ECG Lead ON |
darienf | 20:6d2af70c92ab | 471 | int MAX30001_Read_LeadON(char argStrs[32][32], char replyStrs[32][32]) { |
darienf | 20:6d2af70c92ab | 472 | uint32_t reply[1]; |
darienf | 20:6d2af70c92ab | 473 | // return the max30001_LeadOn var from the MAX30001 driver |
darienf | 20:6d2af70c92ab | 474 | reply[0] = Peripherals::max30001()->max30001_LeadOn; |
darienf | 20:6d2af70c92ab | 475 | FormatReply32(reply, sizeof(reply) / sizeof(uint32_t), replyStrs); |
darienf | 20:6d2af70c92ab | 476 | return 0; |
darienf | 20:6d2af70c92ab | 477 | } |