@@ -1134,7 +1134,11 @@ version SparkFun_Bio_Sensor_Hub::readAlgorithmVersion(){
1134
1134
return libAlgoVers;
1135
1135
1136
1136
}
1137
+
1137
1138
// ------------------Function Below for MAX32664 Version D (Blood Pressure) ----
1139
+
1140
+ // Family Byte: CHANGE_ALGORITHM_CONFIG (0x50), Index Byte: BPT_CONFIG (0x04),
1141
+ // Write Byte: BPT_MEDICATION (0x00)
1138
1142
uint8_t SparkFun_Bio_Sensor_Hub::isPatientBPMedication (uint8_t medication){
1139
1143
1140
1144
if (medication != 0x01 || medication != 0x00 )
@@ -1145,13 +1149,17 @@ uint8_t SparkFun_Bio_Sensor_Hub::isPatientBPMedication(uint8_t medication){
1145
1149
1146
1150
}
1147
1151
1152
+ // Family Byte: CHANGE_ALGORITHM_CONFIG (0x50), Index Byte: BPT_CONFIG (0x04),
1153
+ // Write Byte: BPT_MEDICATION (0x00)
1148
1154
uint8_t SparkFun_Bio_Sensor_Hub::isPatientBPMedication (){
1149
1155
1150
1156
uint8_t medication = readByte (CHANGE_ALGORITHM_CONFIG, BPT_CONFIG, BPT_MEDICATION);
1151
1157
return medication;
1152
1158
1153
1159
}
1154
1160
1161
+ // Family Byte: CHANGE_ALGORITHM_CONFIG (0x50), Index Byte: BPT_CONFIG (0x04),
1162
+ // Write Byte: SYSTOLIC_VALUE (0x01)
1155
1163
uint8_t SparkFun_Bio_Sensor_Hub::writeSystolicVals (uint8_t sysVal1, uint8_t sysVal2, uint8_t sysVal3){
1156
1164
1157
1165
const size_t numSysVals = 3 ;
@@ -1162,9 +1170,18 @@ uint8_t SparkFun_Bio_Sensor_Hub::writeSystolicVals(uint8_t sysVal1, uint8_t sysV
1162
1170
1163
1171
}
1164
1172
1165
- uint8_t SparkFun_Bio_Sensor_Hub::readSystolicVals (){
1173
+ // Family Byte: CHANGE_ALGORITHM_CONFIG (0x50), Index Byte: BPT_CONFIG (0x04),
1174
+ // Write Byte: SYSTOLIC_VALUE (0x01)
1175
+ uint8_t SparkFun_Bio_Sensor_Hub::readSystolicVals (uint8_t userArray[]){
1176
+
1177
+ const size_t numSysVals = 3 ;
1178
+ uint8_t status = readMultipleBytes (CHANGE_ALGORITHM_CONFIG, BPT_CONFIG, SYSTOLIC_VALUE, numSysVals, userArray);
1179
+
1180
+ return status;
1166
1181
}
1167
1182
1183
+ // Family Byte: CHANGE_ALGORITHM_CONFIG (0x50), Index Byte: BPT_CONFIG (0x04),
1184
+ // Write Byte: DIASTOLIC_VALUE (0x02)
1168
1185
uint8_t SparkFun_Bio_Sensor_Hub::writeDiastolicVals (uint8_t diasVal1, uint8_t diasVal2, uint8_t diasVal3){
1169
1186
1170
1187
const size_t numDiasVals = 3 ;
@@ -1175,14 +1192,18 @@ uint8_t SparkFun_Bio_Sensor_Hub::writeDiastolicVals(uint8_t diasVal1, uint8_t di
1175
1192
1176
1193
}
1177
1194
1178
- uint8_t SparkFun_Bio_Sensor_Hub::readDiastolicVals (uint8_t userProvidedArray[]){
1195
+ // Family Byte: CHANGE_ALGORITHM_CONFIG (0x50), Index Byte: BPT_CONFIG (0x04),
1196
+ // Write Byte: DIASTOLIC_VALUE (0x02)
1197
+ uint8_t SparkFun_Bio_Sensor_Hub::readDiastolicVals (uint8_t userArray[]){
1179
1198
1180
1199
const size_t numDiasVals = 3 ;
1181
- uint8_t status = readMultipleBytes (CHANGE_ALGORITHM_CONFIG, BPT_CONFIG, DIASTOLIC_VALUE, numDiasVals, userProvidedArray );
1200
+ uint8_t status = readMultipleBytes (CHANGE_ALGORITHM_CONFIG, BPT_CONFIG, DIASTOLIC_VALUE, numDiasVals, userArray );
1182
1201
return status;
1183
1202
1184
1203
}
1185
1204
1205
+ // Family Byte: CHANGE_ALGORITHM_CONFIG (0x50), Index Byte: BPT_CONFIG (0x04),
1206
+ // Write Byte: BPT_CALIB_DATA (0x03)
1186
1207
uint8_t SparkFun_Bio_Sensor_Hub::writeBPTAlgoData (uint8_t bptCalibData[]){
1187
1208
1188
1209
const size_t numCalibVals = 824 ;
@@ -1191,39 +1212,55 @@ uint8_t SparkFun_Bio_Sensor_Hub::writeBPTAlgoData(uint8_t bptCalibData[]){
1191
1212
1192
1213
}
1193
1214
1194
- uint8_t SparkFun_Bio_Sensor_Hub::readBPTAlgoData (){
1215
+ // Family Byte: CHANGE_ALGORITHM_CONFIG (0x50), Index Byte: BPT_CONFIG (0x04),
1216
+ // Write Byte: BPT_CALIB_DATA (0x03)
1217
+ uint8_t SparkFun_Bio_Sensor_Hub::readBPTAlgoData (uint8_t userArray[]){
1218
+
1219
+ const size_t numCalibVals = 824 ;
1220
+ uint8_t status = readMultipleBytes (CHANGE_ALGORITHM_CONFIG, BPT_CONFIG, BPT_CALIB_DATA, numCalibVals, userArray);
1221
+ return status;
1222
+
1195
1223
}
1196
1224
1225
+ // Family Byte: CHANGE_ALGORITHM_CONFIG (0x50), Index Byte: BPT_CONFIG (0x04),
1226
+ // Write Byte: PATIENT_RESTING (0x05)
1197
1227
uint8_t SparkFun_Bio_Sensor_Hub::isPatientResting (uint8_t resting){ //
1198
1228
1199
1229
if (resting != 0x00 || resting != 0x01 )
1200
1230
return INCORR_PARAM;
1201
1231
1202
- uint8_t status = writeByte (CHANGE_ALGORITHM_CONFIG, BPT_CALIB_DATA , PATIENT_RESTING, resting);
1232
+ uint8_t status = writeByte (CHANGE_ALGORITHM_CONFIG, BPT_CONFIG , PATIENT_RESTING, resting);
1203
1233
return status;
1204
1234
1205
1235
}
1206
1236
1237
+ // Family Byte: CHANGE_ALGORITHM_CONFIG (0x50), Index Byte: BPT_CONFIG (0x04),
1238
+ // Write Byte: PATIENT_RESTING (0x05)
1207
1239
uint8_t SparkFun_Bio_Sensor_Hub::isPatientResting (){
1208
1240
1209
- uint8_t resting = writeByte (CHANGE_ALGORITHM_CONFIG, BPT_CALIB_DATA , PATIENT_RESTING);
1241
+ uint8_t resting = writeByte (CHANGE_ALGORITHM_CONFIG, BPT_CONFIG , PATIENT_RESTING);
1210
1242
return resting;
1211
1243
1212
1244
}
1213
1245
1246
+ // Family Byte: CHANGE_ALGORITHM_CONFIG (0x50), Index Byte: BPT_CONFIG (0x04),
1247
+ // Write Byte: AGC_SP02_COEFS (0x0B)
1214
1248
uint8_t SparkFun_Bio_Sensor_Hub::writeSP02AlgoCoef (int32_t intA, int32_t intB, int32_t intC){
1215
1249
1216
1250
1217
1251
const size_t numCoefVals = 3 ;
1218
1252
int32_t coefVals[numCoefVals] = {intA, intB, intC};
1219
- uint8_t status = writeLongBytes (CHANGE_ALGORITHM_CONFIG, BPT_CALIB_DATA , AGC_SP02_COEFS, coefVals, numCoefVals);
1253
+ uint8_t status = writeLongBytes (CHANGE_ALGORITHM_CONFIG, BPT_CONFIG , AGC_SP02_COEFS, coefVals, numCoefVals);
1220
1254
return status;
1221
1255
1222
1256
}
1223
1257
1224
- uint8_t SparkFun_Bio_Sensor_Hub::readSP02AlgoCoef (){ // Have the user provide their own array here and pass the pointer to it
1258
+ // Family Byte: CHANGE_ALGORITHM_CONFIG (0x50), Index Byte: BPT_CONFIG (0x04),
1259
+ // Write Byte: AGC_SP02_COEFS (0x0B)
1260
+ uint8_t SparkFun_Bio_Sensor_Hub::readSP02AlgoCoef (int32_t userArray[]){ // Have the user provide their own array here and pass the pointer to it
1225
1261
1226
- uint8_t status = readLongByte (CHANGE_ALGORITHM_CONFIG, BPT_CALIB_DATA, AGC_SP02_COEFS);
1262
+ const size_t numOfReads = 3 ;
1263
+ uint8_t status = readMultipleBytes ( CHANGE_ALGORITHM_CONFIG, BPT_CONFIG, AGC_SP02_COEFS, numOfReads, userArray);
1227
1264
return status;
1228
1265
1229
1266
}
@@ -1425,7 +1462,7 @@ uint8_t SparkFun_Bio_Sensor_Hub::readByte(uint8_t _familyByte, uint8_t _indexBy
1425
1462
_i2cPort->endTransmission ();
1426
1463
delay (CMD_DELAY);
1427
1464
1428
- _i2cPort->requestFrom (_address, sizeof (returnByte) + sizeof (statusByte));
1465
+ _i2cPort->requestFrom (_address, static_cast < uint8_t >( sizeof (returnByte) + sizeof (statusByte) ));
1429
1466
statusByte = _i2cPort->read ();
1430
1467
if ( statusByte )// SUCCESS (0x00)
1431
1468
return statusByte; // Return the error, see: READ_STATUS_BYTE_VALUE
@@ -1494,40 +1531,6 @@ uint16_t SparkFun_Bio_Sensor_Hub::readIntByte(uint8_t _familyByte, uint8_t _inde
1494
1531
1495
1532
}
1496
1533
1497
- // This function handles all read commands or stated another way, all information
1498
- // requests. It starts a request by writing the family byte, an index byte, and
1499
- // a write byte and then then delays 60 microseconds, during which the MAX32664
1500
- // retrieves the requested information. An I-squared-C request is then issued,
1501
- // and the information is read. This differs from the above read commands in
1502
- // that it returns three, four byte (uint32_t) integer instead of a single byte.
1503
- uint32_t SparkFun_Bio_Sensor_Hub::readLongByte (uint8_t _familyByte, uint8_t _indexByte,\
1504
- uint8_t _writeByte)
1505
- {
1506
-
1507
- uint32_t returnByte = 0 ;
1508
- uint8_t statusByte;
1509
-
1510
- _i2cPort->beginTransmission (_address);
1511
- _i2cPort->write (_familyByte);
1512
- _i2cPort->write (_indexByte);
1513
- _i2cPort->write (_writeByte);
1514
- _i2cPort->endTransmission ();
1515
- delay (CMD_DELAY);
1516
-
1517
- _i2cPort->requestFrom (_address, (sizeof (returnByte) * 3 ) + sizeof (statusByte) );
1518
- statusByte = _i2cPort->read ();
1519
- if ( statusByte ) // Pass through if SUCCESS (0x00).
1520
- return (uint32_t )statusByte; // Return the error, see: READ_STATUS_BYTE_VALUE
1521
-
1522
- for (uint8_t i = 0 ; i < (sizeof (returnByte) * 3 ); i++){ // Reading three long bytes
1523
- returnByte |= (_i2cPort->read () << 24 );
1524
- returnByte |= (_i2cPort->read () << 16 );
1525
- returnByte |= (_i2cPort->read () << 8 );
1526
- returnByte |= _i2cPort->read ();
1527
- }
1528
- return returnByte;
1529
-
1530
- }
1531
1534
// This function handles all read commands or stated another way, all information
1532
1535
// requests. It starts a request by writing the family byte, an index byte, and
1533
1536
// a write byte and then then delays 60 microseconds, during which the MAX32664
@@ -1550,18 +1553,17 @@ uint8_t SparkFun_Bio_Sensor_Hub::readMultipleBytes(uint8_t _familyByte, uint8_t
1550
1553
1551
1554
_i2cPort->requestFrom (_address, static_cast <uint8_t >(sizeof (int32_t ) * _numOfReads + sizeof (statusByte)));
1552
1555
statusByte = _i2cPort->read ();
1553
- if ( statusByte ){ // Pass through if SUCCESS (0x00).
1556
+ if ( statusByte ) // Pass through if SUCCESS (0x00).
1557
+ return statusByte;
1558
+ else {
1554
1559
for (size_t i = 0 ; i < (sizeof (int32_t ) * _numOfReads); i++){
1555
- userArray[i] = 0 ;
1556
- userArray[i] = 0 ;
1557
- userArray[i] = 0 ;
1558
- userArray[i] = 0 ;
1560
+ userArray[i] = _i2cPort-> read () << 24 ;
1561
+ userArray[i] |= _i2cPort-> read () << 16 ;
1562
+ userArray[i] |= _i2cPort-> read () << 8 ;
1563
+ userArray[i] |= _i2cPort-> read () ;
1559
1564
}
1560
1565
return statusByte;
1561
1566
}
1562
-
1563
- else
1564
- return statusByte;
1565
1567
}
1566
1568
1567
1569
// This function handles all read commands or stated another way, all information
@@ -1584,18 +1586,14 @@ uint8_t SparkFun_Bio_Sensor_Hub::readMultipleBytes(uint8_t _familyByte, uint8_t
1584
1586
_i2cPort->endTransmission ();
1585
1587
delay (CMD_DELAY);
1586
1588
1587
- _i2cPort->requestFrom (_address, static_cast <uint8_t >(sizeof ( int32_t ) * _numOfReads + sizeof (statusByte)));
1589
+ _i2cPort->requestFrom (_address, static_cast <uint8_t >(_numOfReads + sizeof (statusByte)));
1588
1590
statusByte = _i2cPort->read ();
1589
- if ( statusByte ){ // Pass through if SUCCESS (0x00).
1590
- for (size_t i = 0 ; i < (sizeof (uint8_t ) * _numOfReads); i++){
1591
- userArray[i] = 0 ;
1592
- userArray[i] = 0 ;
1593
- userArray[i] = 0 ;
1594
- userArray[i] = 0 ;
1591
+ if ( statusByte ) // Pass through if SUCCESS (0x00).
1592
+ return statusByte;
1593
+ else {
1594
+ for (size_t i = 0 ; i < _numOfReads; i++){
1595
+ userArray[i] = _i2cPort->read ();
1595
1596
}
1596
1597
return statusByte;
1597
1598
}
1598
-
1599
- else
1600
- return statusByte;
1601
1599
}
0 commit comments