@@ -134,30 +134,30 @@ uint8_t SparkFun_Bio_Sensor_Hub::configBpm(uint8_t mode){
134
134
else return INCORR_PARAM;
135
135
136
136
statusChauf = setOutputMode (ALGO_DATA); // Just the data
137
- if ( statusChauf != SUCCESS )
137
+ if ( statusChauf != SFE_BIO_SUCCESS )
138
138
return statusChauf;
139
139
140
140
statusChauf = setFifoThreshold (0x01 ); // One sample before interrupt is fired.
141
- if ( statusChauf != SUCCESS )
141
+ if ( statusChauf != SFE_BIO_SUCCESS )
142
142
return statusChauf;
143
143
144
144
statusChauf = agcAlgoControl (ENABLE); // One sample before interrupt is fired.
145
- if ( statusChauf != SUCCESS )
145
+ if ( statusChauf != SFE_BIO_SUCCESS )
146
146
return statusChauf;
147
147
148
148
statusChauf = max30101Control (ENABLE);
149
- if ( statusChauf != SUCCESS )
149
+ if ( statusChauf != SFE_BIO_SUCCESS )
150
150
return statusChauf;
151
151
152
152
statusChauf = maximFastAlgoControl (mode);
153
- if ( statusChauf != SUCCESS )
153
+ if ( statusChauf != SFE_BIO_SUCCESS )
154
154
return statusChauf;
155
155
156
156
_userSelectedMode = mode;
157
157
_sampleRate = readAlgoSamples ();
158
158
159
159
delay (1000 );
160
- return SUCCESS ;
160
+ return SFE_BIO_SUCCESS ;
161
161
162
162
}
163
163
@@ -169,23 +169,23 @@ uint8_t SparkFun_Bio_Sensor_Hub::configSensor(){
169
169
uint8_t statusChauf; // Our status chauffeur
170
170
171
171
statusChauf = setOutputMode (SENSOR_DATA); // Just the sensor data (LED)
172
- if ( statusChauf != SUCCESS )
172
+ if ( statusChauf != SFE_BIO_SUCCESS )
173
173
return statusChauf;
174
174
175
175
statusChauf = setFifoThreshold (0x01 ); // One sample before interrupt is fired to the MAX32664
176
- if ( statusChauf != SUCCESS )
176
+ if ( statusChauf != SFE_BIO_SUCCESS )
177
177
return statusChauf;
178
178
179
179
statusChauf = max30101Control (ENABLE); // Enable Sensor.
180
- if ( statusChauf != SUCCESS )
180
+ if ( statusChauf != SFE_BIO_SUCCESS )
181
181
return statusChauf;
182
182
183
183
statusChauf = maximFastAlgoControl (MODE_ONE); // Enable algorithm
184
- if ( statusChauf != SUCCESS )
184
+ if ( statusChauf != SFE_BIO_SUCCESS )
185
185
return statusChauf;
186
186
187
187
delay (1000 );
188
- return SUCCESS ;
188
+ return SFE_BIO_SUCCESS ;
189
189
190
190
}
191
191
@@ -201,26 +201,26 @@ uint8_t SparkFun_Bio_Sensor_Hub::configSensorBpm(uint8_t mode){
201
201
else return INCORR_PARAM;
202
202
203
203
statusChauf = setOutputMode (SENSOR_AND_ALGORITHM); // Data and sensor data
204
- if ( statusChauf != SUCCESS )
204
+ if ( statusChauf != SFE_BIO_SUCCESS )
205
205
return statusChauf;
206
206
207
207
statusChauf = setFifoThreshold (0x01 ); // One sample before interrupt is fired to the MAX32664
208
- if ( statusChauf != SUCCESS )
208
+ if ( statusChauf != SFE_BIO_SUCCESS )
209
209
return statusChauf;
210
210
211
211
statusChauf = max30101Control (ENABLE); // Enable Sensor.
212
- if ( statusChauf != SUCCESS )
212
+ if ( statusChauf != SFE_BIO_SUCCESS )
213
213
return statusChauf;
214
214
215
215
statusChauf = maximFastAlgoControl (mode); // Enable algorithm
216
- if ( statusChauf != SUCCESS )
216
+ if ( statusChauf != SFE_BIO_SUCCESS )
217
217
return statusChauf;
218
218
219
219
_userSelectedMode = mode;
220
220
_sampleRate = readAlgoSamples ();
221
221
222
222
delay (1000 );
223
- return SUCCESS ;
223
+ return SFE_BIO_SUCCESS ;
224
224
225
225
}
226
226
@@ -476,7 +476,7 @@ uint8_t SparkFun_Bio_Sensor_Hub::setPulseWidth(uint16_t width){
476
476
regVal |= bits; // Add bits
477
477
writeRegisterMAX30101 (CONFIGURATION_REGISTER, regVal); // Write Register
478
478
479
- return SUCCESS ;
479
+ return SFE_BIO_SUCCESS ;
480
480
481
481
}
482
482
@@ -528,7 +528,7 @@ uint8_t SparkFun_Bio_Sensor_Hub::setSampleRate(uint16_t sampRate){
528
528
regVal |= (bits << 2 ); // Add bits but shift them first to correct position.
529
529
writeRegisterMAX30101 (CONFIGURATION_REGISTER, regVal); // Write Register
530
530
531
- return SUCCESS ;
531
+ return SFE_BIO_SUCCESS ;
532
532
}
533
533
534
534
// This function reads the CONFIGURATION_REGISTER (0x0A), bits [4:2] from the
@@ -579,7 +579,7 @@ uint8_t SparkFun_Bio_Sensor_Hub::setAdcRange(uint16_t adcVal){
579
579
580
580
writeRegisterMAX30101 (CONFIGURATION_REGISTER, regVal);
581
581
582
- return SUCCESS ;
582
+ return SFE_BIO_SUCCESS ;
583
583
}
584
584
585
585
// MAX30101 Register: CONFIGURATION_REGISTER (0x0A), bits [6:5]
@@ -606,13 +606,13 @@ uint16_t SparkFun_Bio_Sensor_Hub::readAdcRange(){
606
606
uint8_t SparkFun_Bio_Sensor_Hub::setOperatingMode (uint8_t selection) {
607
607
608
608
// Must be one of the three....
609
- if (selection == EXIT_BOOTLOADER || selection == RESET || selection == ENTER_BOOTLOADER)
609
+ if (selection == EXIT_BOOTLOADER || selection == SFE_BIO_RESET || selection == ENTER_BOOTLOADER)
610
610
{ }
611
611
else
612
612
return INCORR_PARAM;
613
613
614
614
uint8_t statusByte = writeByte (SET_DEVICE_MODE, 0x00 , selection);
615
- if (statusByte != SUCCESS )
615
+ if (statusByte != SFE_BIO_SUCCESS )
616
616
return statusByte;
617
617
618
618
// Here we'll check if the board made it into Bootloader mode...
@@ -628,7 +628,7 @@ uint8_t SparkFun_Bio_Sensor_Hub::setOperatingMode(uint8_t selection) {
628
628
uint8_t SparkFun_Bio_Sensor_Hub::getMcuType () {
629
629
630
630
uint8_t returnByte = readByte (IDENTITY, READ_MCU_TYPE, NO_WRITE);
631
- if ( returnByte != SUCCESS )
631
+ if ( returnByte != SFE_BIO_SUCCESS )
632
632
return ERR_UNKNOWN;
633
633
else
634
634
return returnByte;
@@ -669,10 +669,10 @@ uint8_t SparkFun_Bio_Sensor_Hub::max30101Control(uint8_t senSwitch) {
669
669
670
670
// Check that communication was successful, not that the sensor is enabled.
671
671
uint8_t statusByte = enableWrite (ENABLE_SENSOR, ENABLE_MAX30101, senSwitch);
672
- if ( statusByte != SUCCESS )
672
+ if ( statusByte != SFE_BIO_SUCCESS )
673
673
return statusByte;
674
674
else
675
- return SUCCESS ;
675
+ return SFE_BIO_SUCCESS ;
676
676
677
677
}
678
678
@@ -696,10 +696,10 @@ uint8_t SparkFun_Bio_Sensor_Hub::accelControl(uint8_t accelSwitch) {
696
696
697
697
// Check that communication was successful, not that the sensor is enabled.
698
698
uint8_t statusByte = enableWrite (ENABLE_SENSOR, ENABLE_ACCELEROMETER, accelSwitch);
699
- if ( statusByte != SUCCESS )
699
+ if ( statusByte != SFE_BIO_SUCCESS )
700
700
return statusByte;
701
701
else
702
- return SUCCESS ;
702
+ return SFE_BIO_SUCCESS ;
703
703
704
704
}
705
705
@@ -713,10 +713,10 @@ uint8_t SparkFun_Bio_Sensor_Hub::setOutputMode(uint8_t outputType) {
713
713
// Check that communication was successful, not that the IC is outputting
714
714
// correct format.
715
715
uint8_t statusByte = writeByte (OUTPUT_MODE, SET_FORMAT, outputType);
716
- if ( statusByte != SUCCESS )
716
+ if ( statusByte != SFE_BIO_SUCCESS )
717
717
return statusByte;
718
718
else
719
- return SUCCESS ;
719
+ return SFE_BIO_SUCCESS ;
720
720
721
721
}
722
722
@@ -730,10 +730,10 @@ uint8_t SparkFun_Bio_Sensor_Hub::setFifoThreshold(uint8_t intThresh) {
730
730
// Checks that there was succesful communcation, not that the threshold was
731
731
// set correctly.
732
732
uint8_t statusByte = writeByte (OUTPUT_MODE, WRITE_SET_THRESHOLD, intThresh);
733
- if ( statusByte != SUCCESS )
733
+ if ( statusByte != SFE_BIO_SUCCESS )
734
734
return statusByte;
735
735
else
736
- return SUCCESS ;
736
+ return SFE_BIO_SUCCESS ;
737
737
738
738
}
739
739
@@ -886,10 +886,10 @@ uint8_t SparkFun_Bio_Sensor_Hub::setAlgoRange(uint8_t perc) {
886
886
887
887
// Successful communication or no?
888
888
uint8_t statusByte = writeByte (CHANGE_ALGORITHM_CONFIG, SET_TARG_PERC, AGC_GAIN_ID, perc);
889
- if ( statusByte != SUCCESS )
889
+ if ( statusByte != SFE_BIO_SUCCESS )
890
890
return statusByte;
891
891
else
892
- return SUCCESS ;
892
+ return SFE_BIO_SUCCESS ;
893
893
894
894
}
895
895
@@ -904,10 +904,10 @@ uint8_t SparkFun_Bio_Sensor_Hub::setAlgoStepSize(uint8_t step) {
904
904
905
905
// Successful communication or no?
906
906
uint8_t statusByte = writeByte (CHANGE_ALGORITHM_CONFIG, SET_STEP_SIZE, AGC_STEP_SIZE_ID, step);
907
- if ( statusByte != SUCCESS )
907
+ if ( statusByte != SFE_BIO_SUCCESS )
908
908
return statusByte;
909
909
else
910
- return SUCCESS ;
910
+ return SFE_BIO_SUCCESS ;
911
911
912
912
}
913
913
@@ -921,10 +921,10 @@ uint8_t SparkFun_Bio_Sensor_Hub::setAlgoSensitivity(uint8_t sense) {
921
921
922
922
// Successful communication or no?
923
923
uint8_t statusByte = writeByte (CHANGE_ALGORITHM_CONFIG, SET_SENSITIVITY, AGC_SENSITIVITY_ID, sense);
924
- if ( statusByte != SUCCESS )
924
+ if ( statusByte != SFE_BIO_SUCCESS )
925
925
return statusByte;
926
926
else
927
- return SUCCESS ;
927
+ return SFE_BIO_SUCCESS ;
928
928
929
929
}
930
930
@@ -936,10 +936,10 @@ uint8_t SparkFun_Bio_Sensor_Hub::setAlgoSamples(uint8_t avg) {
936
936
937
937
// Successful communication or no?
938
938
uint8_t statusByte = writeByte (CHANGE_ALGORITHM_CONFIG, SET_AVG_SAMPLES, AGC_NUM_SAMP_ID, avg);
939
- if ( statusByte != SUCCESS )
939
+ if ( statusByte != SFE_BIO_SUCCESS )
940
940
return statusByte;
941
941
else
942
- return SUCCESS ;
942
+ return SFE_BIO_SUCCESS ;
943
943
944
944
}
945
945
@@ -955,10 +955,10 @@ uint8_t SparkFun_Bio_Sensor_Hub::setMaximFastCoef(int32_t coef1, int32_t coef2,
955
955
956
956
uint8_t statusByte = writeLongBytes (CHANGE_ALGORITHM_CONFIG, SET_PULSE_OX_COEF,\
957
957
MAXIMFAST_COEF_ID, coefArr, numCoefVals);
958
- if ( statusByte != SUCCESS )
958
+ if ( statusByte != SFE_BIO_SUCCESS )
959
959
return statusByte;
960
960
else
961
- return SUCCESS ;
961
+ return SFE_BIO_SUCCESS ;
962
962
963
963
}
964
964
@@ -1029,10 +1029,10 @@ uint8_t SparkFun_Bio_Sensor_Hub::agcAlgoControl(uint8_t enable) {
1029
1029
return INCORR_PARAM;
1030
1030
1031
1031
uint8_t statusByte = enableWrite (ENABLE_ALGORITHM, ENABLE_AGC_ALGO, enable);
1032
- if (statusByte != SUCCESS )
1032
+ if (statusByte != SFE_BIO_SUCCESS )
1033
1033
return statusByte;
1034
1034
else
1035
- return SUCCESS ;
1035
+ return SFE_BIO_SUCCESS ;
1036
1036
1037
1037
}
1038
1038
@@ -1047,10 +1047,10 @@ uint8_t SparkFun_Bio_Sensor_Hub::maximFastAlgoControl(uint8_t mode) {
1047
1047
return INCORR_PARAM;
1048
1048
1049
1049
uint8_t statusByte = enableWrite (ENABLE_ALGORITHM, ENABLE_WHRM_ALGO, mode);
1050
- if (statusByte != SUCCESS )
1050
+ if (statusByte != SFE_BIO_SUCCESS )
1051
1051
return statusByte;
1052
1052
else
1053
- return SUCCESS ;
1053
+ return SFE_BIO_SUCCESS ;
1054
1054
1055
1055
}
1056
1056
@@ -1100,7 +1100,7 @@ version SparkFun_Bio_Sensor_Hub::readBootloaderVers(){
1100
1100
1101
1101
_i2cPort->requestFrom (_address, static_cast <uint8_t >(4 ));
1102
1102
uint8_t statusByte = _i2cPort->read ();
1103
- if (statusByte) { // Pass through if SUCCESS (0x00).
1103
+ if (statusByte) { // Pass through if SFE_BIO_SUCCESS (0x00).
1104
1104
booVers.major = 0 ;
1105
1105
booVers.minor = 0 ;
1106
1106
booVers.revision = 0 ;
@@ -1127,7 +1127,7 @@ version SparkFun_Bio_Sensor_Hub::readSensorHubVersion(){
1127
1127
1128
1128
_i2cPort->requestFrom (_address, static_cast <uint8_t >(4 ));
1129
1129
uint8_t statusByte = _i2cPort->read ();
1130
- if (statusByte){ // Pass through if SUCCESS (0x00).
1130
+ if (statusByte){ // Pass through if SFE_BIO_SUCCESS (0x00).
1131
1131
bioHubVers.major = 0 ;
1132
1132
bioHubVers.minor = 0 ;
1133
1133
bioHubVers.revision = 0 ;
@@ -1154,7 +1154,7 @@ version SparkFun_Bio_Sensor_Hub::readAlgorithmVersion(){
1154
1154
1155
1155
_i2cPort->requestFrom (_address, static_cast <uint8_t >(4 ));
1156
1156
uint8_t statusByte = _i2cPort->read ();
1157
- if (statusByte){ // Pass through if SUCCESS (0x00).
1157
+ if (statusByte){ // Pass through if SFE_BIO_SUCCESS (0x00).
1158
1158
libAlgoVers.major = 0 ;
1159
1159
libAlgoVers.minor = 0 ;
1160
1160
libAlgoVers.revision = 0 ;
@@ -1312,7 +1312,13 @@ uint8_t SparkFun_Bio_Sensor_Hub::enableWrite(uint8_t _familyByte, uint8_t _index
1312
1312
_i2cPort->write (_indexByte);
1313
1313
_i2cPort->write (_enableByte);
1314
1314
_i2cPort->endTransmission ();
1315
- delay (ENABLE_CMD_DELAY);
1315
+
1316
+ if ( _familyByte == ENABLE_SENSOR && _indexByte == ENABLE_MAX30101)
1317
+ delay (ENABLE_CMD_DELAY);
1318
+ if ( _familyByte == ENABLE_ALGORITHM && _indexByte == ENABLE_AGC_ALGO)
1319
+ delay (ALGO_CMD_DELAY_SHORT);
1320
+ if ( _familyByte == ENABLE_ALGORITHM && _indexByte == ENABLE_WHRM_ALGO)
1321
+ delay (ALGO_CMD_DELAY_LONG);
1316
1322
1317
1323
// Status Byte, success or no? 0x00 is a successful transmit
1318
1324
_i2cPort->requestFrom (_address, static_cast <uint8_t >(1 ));
@@ -1467,7 +1473,7 @@ uint8_t SparkFun_Bio_Sensor_Hub::readByte(uint8_t _familyByte, uint8_t _indexByt
1467
1473
1468
1474
_i2cPort->requestFrom (_address, static_cast <uint8_t >(sizeof (returnByte) + sizeof (statusByte)));
1469
1475
statusByte = _i2cPort->read ();
1470
- if ( statusByte )// SUCCESS (0x00) - how do I know its
1476
+ if ( statusByte )// SFE_BIO_SUCCESS (0x00) - how do I know its
1471
1477
return statusByte; // Return the error, see: READ_STATUS_BYTE_VALUE
1472
1478
1473
1479
returnByte = _i2cPort->read ();
@@ -1498,7 +1504,7 @@ uint8_t SparkFun_Bio_Sensor_Hub::readByte(uint8_t _familyByte, uint8_t _indexBy
1498
1504
1499
1505
_i2cPort->requestFrom (_address, static_cast <uint8_t >(sizeof (returnByte) + sizeof (statusByte)));
1500
1506
statusByte = _i2cPort->read ();
1501
- if ( statusByte )// SUCCESS (0x00)
1507
+ if ( statusByte )// SFE_BIO_SUCCESS (0x00)
1502
1508
return statusByte; // Return the error, see: READ_STATUS_BYTE_VALUE
1503
1509
1504
1510
returnByte = _i2cPort->read ();
@@ -1520,7 +1526,7 @@ uint8_t SparkFun_Bio_Sensor_Hub::readFillArray(uint8_t _familyByte, uint8_t _ind
1520
1526
1521
1527
_i2cPort->requestFrom (_address, static_cast <uint8_t >(_numOfReads + sizeof (statusByte)));
1522
1528
statusByte = _i2cPort->read ();
1523
- if ( statusByte ){// SUCCESS : 0x00
1529
+ if ( statusByte ){// SFE_BIO_SUCCESS : 0x00
1524
1530
for (size_t i = 0 ; i < _numOfReads; i++){
1525
1531
array[i] = 0 ;
1526
1532
}
@@ -1555,7 +1561,7 @@ uint16_t SparkFun_Bio_Sensor_Hub::readIntByte(uint8_t _familyByte, uint8_t _inde
1555
1561
1556
1562
_i2cPort->requestFrom (_address, static_cast <uint8_t >(sizeof (returnByte) + sizeof (statusByte)));
1557
1563
statusByte = _i2cPort->read ();
1558
- if ( statusByte ) // Pass through if SUCCESS (0x00).
1564
+ if ( statusByte ) // Pass through if SFE_BIO_SUCCESS (0x00).
1559
1565
return statusByte; // Return the error, see: READ_STATUS_BYTE_VALUE
1560
1566
1561
1567
returnByte = (_i2cPort->read () << 8 );
@@ -1587,7 +1593,7 @@ uint8_t SparkFun_Bio_Sensor_Hub::readMultipleBytes(uint8_t _familyByte, uint8_t
1587
1593
1588
1594
_i2cPort->requestFrom (_address, static_cast <uint8_t >(sizeof (int32_t ) * _numOfReads + sizeof (statusByte)));
1589
1595
statusByte = _i2cPort->read ();
1590
- if ( statusByte ) // Pass through if SUCCESS (0x00).
1596
+ if ( statusByte ) // Pass through if SFE_BIO_SUCCESS (0x00).
1591
1597
return statusByte;
1592
1598
else {
1593
1599
for (size_t i = 0 ; i < (sizeof (int32_t ) * _numOfReads); i++){
@@ -1622,7 +1628,7 @@ uint8_t SparkFun_Bio_Sensor_Hub::readMultipleBytes(uint8_t _familyByte, uint8_t
1622
1628
1623
1629
_i2cPort->requestFrom (_address, static_cast <uint8_t >(_numOfReads + sizeof (statusByte)));
1624
1630
statusByte = _i2cPort->read ();
1625
- if ( statusByte ) // Pass through if SUCCESS (0x00).
1631
+ if ( statusByte ) // Pass through if SFE_BIO_SUCCESS (0x00).
1626
1632
return statusByte;
1627
1633
else {
1628
1634
for (size_t i = 0 ; i < _numOfReads; i++){
0 commit comments