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