Wilson Tang
/
HSP_RPC_GUI
Fork of the offical HSP_RPC_GUI firmware
Fork of MAXREFDES100 firmware for MAX32620HSP
HSP/Devices/MAX30101/MAX30101_RPC.cpp@0:e4a10ed6eb92, 2016-10-25 (annotated)
- Committer:
- jbradshaw
- Date:
- Tue Oct 25 15:22:11 2016 +0000
- Revision:
- 0:e4a10ed6eb92
- Child:
- 1:9490836294ea
tewt
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 | #include "MAX30101_RPC.h" |
jbradshaw | 0:e4a10ed6eb92 | 34 | #include "StringHelper.h" |
jbradshaw | 0:e4a10ed6eb92 | 35 | #include "MAX30101.h" |
jbradshaw | 0:e4a10ed6eb92 | 36 | #include "Streaming.h" |
jbradshaw | 0:e4a10ed6eb92 | 37 | #include "RpcFifo.h" |
jbradshaw | 0:e4a10ed6eb92 | 38 | #include "RpcServer.h" |
jbradshaw | 0:e4a10ed6eb92 | 39 | #include "StringInOut.h" |
jbradshaw | 0:e4a10ed6eb92 | 40 | #include "MAX30101_helper.h" |
jbradshaw | 0:e4a10ed6eb92 | 41 | #include "LIS2DH.h" |
jbradshaw | 0:e4a10ed6eb92 | 42 | #include "Peripherals.h" |
jbradshaw | 0:e4a10ed6eb92 | 43 | #include "DataLoggingService.h" |
jbradshaw | 0:e4a10ed6eb92 | 44 | |
jbradshaw | 0:e4a10ed6eb92 | 45 | //****************************************************************************** |
jbradshaw | 0:e4a10ed6eb92 | 46 | int MAX30101_WriteReg(char argStrs[32][32], char replyStrs[32][32]) { |
jbradshaw | 0:e4a10ed6eb92 | 47 | uint8_t args[2]; |
jbradshaw | 0:e4a10ed6eb92 | 48 | uint8_t reply[1]; |
jbradshaw | 0:e4a10ed6eb92 | 49 | ProcessArgs(argStrs, args, sizeof(args)); |
jbradshaw | 0:e4a10ed6eb92 | 50 | // Peripherals::max30101()->writeReg(args[0] , args[1]); // pass in the register address and the data |
jbradshaw | 0:e4a10ed6eb92 | 51 | reply[0] = 0x80; |
jbradshaw | 0:e4a10ed6eb92 | 52 | FormatReply(reply, sizeof(reply), replyStrs); |
jbradshaw | 0:e4a10ed6eb92 | 53 | return 0; |
jbradshaw | 0:e4a10ed6eb92 | 54 | } |
jbradshaw | 0:e4a10ed6eb92 | 55 | |
jbradshaw | 0:e4a10ed6eb92 | 56 | //****************************************************************************** |
jbradshaw | 0:e4a10ed6eb92 | 57 | int MAX30101_ReadReg(char argStrs[32][32], char replyStrs[32][32]) { |
jbradshaw | 0:e4a10ed6eb92 | 58 | uint8_t args[1]; |
jbradshaw | 0:e4a10ed6eb92 | 59 | uint8_t reply[1]; |
jbradshaw | 0:e4a10ed6eb92 | 60 | char value; |
jbradshaw | 0:e4a10ed6eb92 | 61 | ProcessArgs(argStrs, args, sizeof(args)); |
jbradshaw | 0:e4a10ed6eb92 | 62 | // Peripherals::max30101()->readReg(args[0] , &value, 1); |
jbradshaw | 0:e4a10ed6eb92 | 63 | reply[0] = (uint8_t)value; |
jbradshaw | 0:e4a10ed6eb92 | 64 | FormatReply(reply, sizeof(reply), replyStrs); |
jbradshaw | 0:e4a10ed6eb92 | 65 | return 0; |
jbradshaw | 0:e4a10ed6eb92 | 66 | } |
jbradshaw | 0:e4a10ed6eb92 | 67 | |
jbradshaw | 0:e4a10ed6eb92 | 68 | //****************************************************************************** |
jbradshaw | 0:e4a10ed6eb92 | 69 | int MAX30101_COMMinit(char argStrs[32][32], char replyStrs[32][32]) |
jbradshaw | 0:e4a10ed6eb92 | 70 | { |
jbradshaw | 0:e4a10ed6eb92 | 71 | uint8_t args[4]; |
jbradshaw | 0:e4a10ed6eb92 | 72 | uint8_t return_value; |
jbradshaw | 0:e4a10ed6eb92 | 73 | ProcessArgs(argStrs,args,sizeof(args)); |
jbradshaw | 0:e4a10ed6eb92 | 74 | |
jbradshaw | 0:e4a10ed6eb92 | 75 | //return_value = max30101_COMMinit(args[0], args[1], args[2], args[3]); |
jbradshaw | 0:e4a10ed6eb92 | 76 | |
jbradshaw | 0:e4a10ed6eb92 | 77 | strcpy(replyStrs[0],"80"); |
jbradshaw | 0:e4a10ed6eb92 | 78 | return return_value; |
jbradshaw | 0:e4a10ed6eb92 | 79 | } |
jbradshaw | 0:e4a10ed6eb92 | 80 | |
jbradshaw | 0:e4a10ed6eb92 | 81 | //****************************************************************************** |
jbradshaw | 0:e4a10ed6eb92 | 82 | int MAX30101_SpO2mode_stop(char argStrs[32][32], char replyStrs[32][32]) |
jbradshaw | 0:e4a10ed6eb92 | 83 | { |
jbradshaw | 0:e4a10ed6eb92 | 84 | uint8_t args[4]; |
jbradshaw | 0:e4a10ed6eb92 | 85 | uint8_t return_value; |
jbradshaw | 0:e4a10ed6eb92 | 86 | ProcessArgs(argStrs,args,sizeof(args)); |
jbradshaw | 0:e4a10ed6eb92 | 87 | |
jbradshaw | 0:e4a10ed6eb92 | 88 | //lis2dh_Stop(); |
jbradshaw | 0:e4a10ed6eb92 | 89 | //max30101_SpO2mode_stop(); |
jbradshaw | 0:e4a10ed6eb92 | 90 | Peripherals::max30101()->SpO2mode_stop(); |
jbradshaw | 0:e4a10ed6eb92 | 91 | |
jbradshaw | 0:e4a10ed6eb92 | 92 | strcpy(replyStrs[0],"80"); |
jbradshaw | 0:e4a10ed6eb92 | 93 | return return_value; |
jbradshaw | 0:e4a10ed6eb92 | 94 | } |
jbradshaw | 0:e4a10ed6eb92 | 95 | |
jbradshaw | 0:e4a10ed6eb92 | 96 | //****************************************************************************** |
jbradshaw | 0:e4a10ed6eb92 | 97 | int MAX30101_HRmode_stop(char argStrs[32][32], char replyStrs[32][32]) |
jbradshaw | 0:e4a10ed6eb92 | 98 | { |
jbradshaw | 0:e4a10ed6eb92 | 99 | uint8_t args[4]; |
jbradshaw | 0:e4a10ed6eb92 | 100 | ProcessArgs(argStrs,args,sizeof(args)); |
jbradshaw | 0:e4a10ed6eb92 | 101 | |
jbradshaw | 0:e4a10ed6eb92 | 102 | //lis2dh_Stop(); |
jbradshaw | 0:e4a10ed6eb92 | 103 | Peripherals::max30101()->HRmode_stop(); |
jbradshaw | 0:e4a10ed6eb92 | 104 | |
jbradshaw | 0:e4a10ed6eb92 | 105 | strcpy(replyStrs[0],"80"); |
jbradshaw | 0:e4a10ed6eb92 | 106 | return 0; |
jbradshaw | 0:e4a10ed6eb92 | 107 | } |
jbradshaw | 0:e4a10ed6eb92 | 108 | |
jbradshaw | 0:e4a10ed6eb92 | 109 | //****************************************************************************** |
jbradshaw | 0:e4a10ed6eb92 | 110 | int MAX30101_Multimode_stop(char argStrs[32][32], char replyStrs[32][32]) |
jbradshaw | 0:e4a10ed6eb92 | 111 | { |
jbradshaw | 0:e4a10ed6eb92 | 112 | uint8_t args[4]; |
jbradshaw | 0:e4a10ed6eb92 | 113 | ProcessArgs(argStrs,args,sizeof(args)); |
jbradshaw | 0:e4a10ed6eb92 | 114 | |
jbradshaw | 0:e4a10ed6eb92 | 115 | //lis2dh_Stop(); |
jbradshaw | 0:e4a10ed6eb92 | 116 | Peripherals::max30101()->Multimode_stop(); |
jbradshaw | 0:e4a10ed6eb92 | 117 | |
jbradshaw | 0:e4a10ed6eb92 | 118 | strcpy(replyStrs[0],"80"); |
jbradshaw | 0:e4a10ed6eb92 | 119 | return 0; |
jbradshaw | 0:e4a10ed6eb92 | 120 | } |
jbradshaw | 0:e4a10ed6eb92 | 121 | |
jbradshaw | 0:e4a10ed6eb92 | 122 | //****************************************************************************** |
jbradshaw | 0:e4a10ed6eb92 | 123 | void ClearInOutFifos() { |
jbradshaw | 0:e4a10ed6eb92 | 124 | fifo_clear(GetStreamOutFifo()); // clear stream out fifo |
jbradshaw | 0:e4a10ed6eb92 | 125 | fifo_clear(GetUSBIncomingFifo()); // clear USB serial incoming fifo |
jbradshaw | 0:e4a10ed6eb92 | 126 | } |
jbradshaw | 0:e4a10ed6eb92 | 127 | |
jbradshaw | 0:e4a10ed6eb92 | 128 | int highDataRate = 0; |
jbradshaw | 0:e4a10ed6eb92 | 129 | #define MAX30101_200HZ 2 |
jbradshaw | 0:e4a10ed6eb92 | 130 | #define MAX30101_400HZ 3 |
jbradshaw | 0:e4a10ed6eb92 | 131 | |
jbradshaw | 0:e4a10ed6eb92 | 132 | /** |
jbradshaw | 0:e4a10ed6eb92 | 133 | * Adjust the threshold of the Accel based on the data rate |
jbradshaw | 0:e4a10ed6eb92 | 134 | * @lis2dhDataRate Data rate of the accel to determine what would be a good threshold value |
jbradshaw | 0:e4a10ed6eb92 | 135 | */ |
jbradshaw | 0:e4a10ed6eb92 | 136 | static int adjustAccelThreshold(int lis2dhDataRate) { |
jbradshaw | 0:e4a10ed6eb92 | 137 | int lis2dhFifoThreshold; |
jbradshaw | 0:e4a10ed6eb92 | 138 | lis2dhFifoThreshold = 31; |
jbradshaw | 0:e4a10ed6eb92 | 139 | if (lis2dhDataRate <= LIS2DH_DATARATE_50HZ) lis2dhFifoThreshold = 4; |
jbradshaw | 0:e4a10ed6eb92 | 140 | if (lis2dhDataRate == LIS2DH_DATARATE_100HZ) lis2dhFifoThreshold = 8; |
jbradshaw | 0:e4a10ed6eb92 | 141 | return lis2dhFifoThreshold; |
jbradshaw | 0:e4a10ed6eb92 | 142 | } |
jbradshaw | 0:e4a10ed6eb92 | 143 | |
jbradshaw | 0:e4a10ed6eb92 | 144 | /** |
jbradshaw | 0:e4a10ed6eb92 | 145 | * Evaluate the data rate of the Accel to see if we should stream using a high data rate mode |
jbradshaw | 0:e4a10ed6eb92 | 146 | * @lis2dhDataRate Data rate of the accel to determine if this is a high data rate |
jbradshaw | 0:e4a10ed6eb92 | 147 | */ |
jbradshaw | 0:e4a10ed6eb92 | 148 | static void adjustHighDataRate(int lis2dhDataRate) { |
jbradshaw | 0:e4a10ed6eb92 | 149 | highDataRate = 0; |
jbradshaw | 0:e4a10ed6eb92 | 150 | if (lis2dhDataRate >= LIS2DH_DATARATE_200HZ) highDataRate = 1; |
jbradshaw | 0:e4a10ed6eb92 | 151 | } |
jbradshaw | 0:e4a10ed6eb92 | 152 | |
jbradshaw | 0:e4a10ed6eb92 | 153 | //****************************************************************************** |
jbradshaw | 0:e4a10ed6eb92 | 154 | int MAX30101_SpO2mode_init(char argStrs[32][32], char replyStrs[32][32]) |
jbradshaw | 0:e4a10ed6eb92 | 155 | { |
jbradshaw | 0:e4a10ed6eb92 | 156 | uint8_t args[7]; |
jbradshaw | 0:e4a10ed6eb92 | 157 | uint8_t lis2dhDataRate; |
jbradshaw | 0:e4a10ed6eb92 | 158 | uint8_t lis2dhFifoThreshold; |
jbradshaw | 0:e4a10ed6eb92 | 159 | ProcessArgs(argStrs, args, sizeof(args)); |
jbradshaw | 0:e4a10ed6eb92 | 160 | |
jbradshaw | 0:e4a10ed6eb92 | 161 | ClearInOutFifos(); |
jbradshaw | 0:e4a10ed6eb92 | 162 | MAX30101_Helper_SetStreamingFlag(eStreaming_SPO2,1); |
jbradshaw | 0:e4a10ed6eb92 | 163 | Peripherals::max30101()->SpO2mode_init(args[0], args[1], args[2], args[3], args[4], args[5]); |
jbradshaw | 0:e4a10ed6eb92 | 164 | |
jbradshaw | 0:e4a10ed6eb92 | 165 | lis2dhDataRate = args[6]; |
jbradshaw | 0:e4a10ed6eb92 | 166 | lis2dhFifoThreshold = adjustAccelThreshold(lis2dhDataRate); |
jbradshaw | 0:e4a10ed6eb92 | 167 | adjustHighDataRate(lis2dhDataRate); |
jbradshaw | 0:e4a10ed6eb92 | 168 | |
jbradshaw | 0:e4a10ed6eb92 | 169 | Peripherals::lis2dh()->initStart(lis2dhDataRate,lis2dhFifoThreshold); |
jbradshaw | 0:e4a10ed6eb92 | 170 | LoggingService_StartLoggingUsb(); |
jbradshaw | 0:e4a10ed6eb92 | 171 | |
jbradshaw | 0:e4a10ed6eb92 | 172 | strcpy(replyStrs[0],"80"); |
jbradshaw | 0:e4a10ed6eb92 | 173 | return 0; |
jbradshaw | 0:e4a10ed6eb92 | 174 | } |
jbradshaw | 0:e4a10ed6eb92 | 175 | |
jbradshaw | 0:e4a10ed6eb92 | 176 | //****************************************************************************** |
jbradshaw | 0:e4a10ed6eb92 | 177 | int MAX30101_SpO2mode_InitStart(char argStrs[32][32], char replyStrs[32][32]) |
jbradshaw | 0:e4a10ed6eb92 | 178 | { |
jbradshaw | 0:e4a10ed6eb92 | 179 | uint8_t args[6]; // Size |
jbradshaw | 0:e4a10ed6eb92 | 180 | ProcessArgs(argStrs, args, sizeof(args)); |
jbradshaw | 0:e4a10ed6eb92 | 181 | |
jbradshaw | 0:e4a10ed6eb92 | 182 | ClearInOutFifos(); |
jbradshaw | 0:e4a10ed6eb92 | 183 | MAX30101_Helper_SetStreamingFlag(eStreaming_SPO2,1); |
jbradshaw | 0:e4a10ed6eb92 | 184 | if (args[2] >= MAX30101_200HZ) highDataRate = 1; |
jbradshaw | 0:e4a10ed6eb92 | 185 | Peripherals::max30101()->SpO2mode_init(args[0], args[1], args[2], args[3], args[4], args[5]); |
jbradshaw | 0:e4a10ed6eb92 | 186 | |
jbradshaw | 0:e4a10ed6eb92 | 187 | strcpy(replyStrs[0],"80"); |
jbradshaw | 0:e4a10ed6eb92 | 188 | return 0; |
jbradshaw | 0:e4a10ed6eb92 | 189 | } |
jbradshaw | 0:e4a10ed6eb92 | 190 | |
jbradshaw | 0:e4a10ed6eb92 | 191 | //****************************************************************************** |
jbradshaw | 0:e4a10ed6eb92 | 192 | int MAX30101_HRmode_init(char argStrs[32][32], char replyStrs[32][32]) |
jbradshaw | 0:e4a10ed6eb92 | 193 | { |
jbradshaw | 0:e4a10ed6eb92 | 194 | uint8_t args[6]; |
jbradshaw | 0:e4a10ed6eb92 | 195 | uint8_t lis2dhDataRate; |
jbradshaw | 0:e4a10ed6eb92 | 196 | uint8_t lis2dhFifoThreshold; |
jbradshaw | 0:e4a10ed6eb92 | 197 | ProcessArgs(argStrs, args, sizeof(args)); |
jbradshaw | 0:e4a10ed6eb92 | 198 | |
jbradshaw | 0:e4a10ed6eb92 | 199 | ClearInOutFifos(); |
jbradshaw | 0:e4a10ed6eb92 | 200 | MAX30101_Helper_SetStreamingFlag(eStreaming_HR,1); |
jbradshaw | 0:e4a10ed6eb92 | 201 | Peripherals::max30101()->HRmode_init(args[0], args[1], args[2], args[3], args[4]); |
jbradshaw | 0:e4a10ed6eb92 | 202 | |
jbradshaw | 0:e4a10ed6eb92 | 203 | lis2dhDataRate = args[5]; |
jbradshaw | 0:e4a10ed6eb92 | 204 | lis2dhFifoThreshold = adjustAccelThreshold(lis2dhDataRate); |
jbradshaw | 0:e4a10ed6eb92 | 205 | adjustHighDataRate(lis2dhDataRate); |
jbradshaw | 0:e4a10ed6eb92 | 206 | |
jbradshaw | 0:e4a10ed6eb92 | 207 | Peripherals::lis2dh()->initStart(lis2dhDataRate,lis2dhFifoThreshold); |
jbradshaw | 0:e4a10ed6eb92 | 208 | LoggingService_StartLoggingUsb(); |
jbradshaw | 0:e4a10ed6eb92 | 209 | strcpy(replyStrs[0],"80"); |
jbradshaw | 0:e4a10ed6eb92 | 210 | return 0; |
jbradshaw | 0:e4a10ed6eb92 | 211 | } |
jbradshaw | 0:e4a10ed6eb92 | 212 | |
jbradshaw | 0:e4a10ed6eb92 | 213 | //****************************************************************************** |
jbradshaw | 0:e4a10ed6eb92 | 214 | int MAX30101_HRmode_InitStart(char argStrs[32][32], char replyStrs[32][32]) |
jbradshaw | 0:e4a10ed6eb92 | 215 | { |
jbradshaw | 0:e4a10ed6eb92 | 216 | uint8_t args[5]; |
jbradshaw | 0:e4a10ed6eb92 | 217 | ProcessArgs(argStrs, args, sizeof(args)); |
jbradshaw | 0:e4a10ed6eb92 | 218 | |
jbradshaw | 0:e4a10ed6eb92 | 219 | ClearInOutFifos(); |
jbradshaw | 0:e4a10ed6eb92 | 220 | MAX30101_Helper_SetStreamingFlag(eStreaming_HR,1); |
jbradshaw | 0:e4a10ed6eb92 | 221 | if (args[2] >= MAX30101_200HZ) highDataRate = 1; |
jbradshaw | 0:e4a10ed6eb92 | 222 | Peripherals::max30101()->HRmode_init(args[0], args[1], args[2], args[3], args[4]); |
jbradshaw | 0:e4a10ed6eb92 | 223 | strcpy(replyStrs[0],"80"); |
jbradshaw | 0:e4a10ed6eb92 | 224 | return 0; |
jbradshaw | 0:e4a10ed6eb92 | 225 | } |
jbradshaw | 0:e4a10ed6eb92 | 226 | |
jbradshaw | 0:e4a10ed6eb92 | 227 | //****************************************************************************** |
jbradshaw | 0:e4a10ed6eb92 | 228 | int MAX30101_Multimode_init(char argStrs[32][32], char replyStrs[32][32]) |
jbradshaw | 0:e4a10ed6eb92 | 229 | { |
jbradshaw | 0:e4a10ed6eb92 | 230 | uint8_t args[12]; |
jbradshaw | 0:e4a10ed6eb92 | 231 | uint8_t lis2dhDataRate; |
jbradshaw | 0:e4a10ed6eb92 | 232 | uint8_t lis2dhFifoThreshold; |
jbradshaw | 0:e4a10ed6eb92 | 233 | ProcessArgs(argStrs, args, sizeof(args)); |
jbradshaw | 0:e4a10ed6eb92 | 234 | |
jbradshaw | 0:e4a10ed6eb92 | 235 | ClearInOutFifos(); |
jbradshaw | 0:e4a10ed6eb92 | 236 | |
jbradshaw | 0:e4a10ed6eb92 | 237 | lis2dhDataRate = args[11]; |
jbradshaw | 0:e4a10ed6eb92 | 238 | lis2dhFifoThreshold = adjustAccelThreshold(lis2dhDataRate); |
jbradshaw | 0:e4a10ed6eb92 | 239 | adjustHighDataRate(lis2dhDataRate); |
jbradshaw | 0:e4a10ed6eb92 | 240 | |
jbradshaw | 0:e4a10ed6eb92 | 241 | Peripherals::lis2dh()->initStart(lis2dhDataRate,lis2dhFifoThreshold); |
jbradshaw | 0:e4a10ed6eb92 | 242 | |
jbradshaw | 0:e4a10ed6eb92 | 243 | wait(0.1f); |
jbradshaw | 0:e4a10ed6eb92 | 244 | MAX30101_Helper_SetStreamingFlag(eStreaming_MULTI, 1); |
jbradshaw | 0:e4a10ed6eb92 | 245 | Peripherals::max30101()->Multimode_init(args[0], args[1], args[2], |
jbradshaw | 0:e4a10ed6eb92 | 246 | args[3], args[4], args[5], args[6], |
jbradshaw | 0:e4a10ed6eb92 | 247 | args[7], args[8], args[9], args[10]); |
jbradshaw | 0:e4a10ed6eb92 | 248 | LoggingService_StartLoggingUsb(); |
jbradshaw | 0:e4a10ed6eb92 | 249 | |
jbradshaw | 0:e4a10ed6eb92 | 250 | strcpy(replyStrs[0],"80"); |
jbradshaw | 0:e4a10ed6eb92 | 251 | return 0; |
jbradshaw | 0:e4a10ed6eb92 | 252 | } |
jbradshaw | 0:e4a10ed6eb92 | 253 | |
jbradshaw | 0:e4a10ed6eb92 | 254 | //****************************************************************************** |
jbradshaw | 0:e4a10ed6eb92 | 255 | int MAX30101_Multimode_InitStart(char argStrs[32][32], char replyStrs[32][32]) |
jbradshaw | 0:e4a10ed6eb92 | 256 | { |
jbradshaw | 0:e4a10ed6eb92 | 257 | uint8_t args[11]; |
jbradshaw | 0:e4a10ed6eb92 | 258 | ProcessArgs(argStrs, args, sizeof(args)); |
jbradshaw | 0:e4a10ed6eb92 | 259 | |
jbradshaw | 0:e4a10ed6eb92 | 260 | ClearInOutFifos(); |
jbradshaw | 0:e4a10ed6eb92 | 261 | MAX30101_Helper_SetStreamingFlag(eStreaming_MULTI, 1); |
jbradshaw | 0:e4a10ed6eb92 | 262 | if (args[2] >= MAX30101_200HZ) highDataRate = 1; |
jbradshaw | 0:e4a10ed6eb92 | 263 | Peripherals::max30101()->Multimode_init(args[0], args[1], args[2], |
jbradshaw | 0:e4a10ed6eb92 | 264 | args[3], args[4], args[5], args[6], |
jbradshaw | 0:e4a10ed6eb92 | 265 | args[7], args[8], args[9], args[10]); |
jbradshaw | 0:e4a10ed6eb92 | 266 | |
jbradshaw | 0:e4a10ed6eb92 | 267 | strcpy(replyStrs[0],"80"); |
jbradshaw | 0:e4a10ed6eb92 | 268 | return 0; |
jbradshaw | 0:e4a10ed6eb92 | 269 | } |
jbradshaw | 0:e4a10ed6eb92 | 270 | |
jbradshaw | 0:e4a10ed6eb92 | 271 | |
jbradshaw | 0:e4a10ed6eb92 | 272 |