Skip to content

Commit 7ac032f

Browse files
authored
Merge pull request #28 from sparkfun/v1.1
V1.1
2 parents 93aedf8 + f250bb3 commit 7ac032f

File tree

5 files changed

+66
-58
lines changed

5 files changed

+66
-58
lines changed

Documents/MAX32664_REV4.pdf

348 KB
Binary file not shown.
1.02 MB
Binary file not shown.

examples/Example1_config_BPM_Mode1/Example1_config_BPM_Mode1.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
// Reset pin, MFIO pin
3131
int resPin = 4;
32-
int mfioPin = 5;
32+
int mfioPin = 13;
3333

3434
// Takes address, reset pin, and MFIO pin.
3535
SparkFun_Bio_Sensor_Hub bioHub(resPin, mfioPin);

src/SparkFun_Bio_Sensor_Hub_Library.cpp

Lines changed: 60 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -134,30 +134,30 @@ uint8_t SparkFun_Bio_Sensor_Hub::configBpm(uint8_t mode){
134134
else return INCORR_PARAM;
135135

136136
statusChauf = setOutputMode(ALGO_DATA); // Just the data
137-
if( statusChauf != SUCCESS )
137+
if( statusChauf != SFE_BIO_SUCCESS )
138138
return statusChauf;
139139

140140
statusChauf = setFifoThreshold(0x01); // One sample before interrupt is fired.
141-
if( statusChauf != SUCCESS )
141+
if( statusChauf != SFE_BIO_SUCCESS )
142142
return statusChauf;
143143

144144
statusChauf = agcAlgoControl(ENABLE); // One sample before interrupt is fired.
145-
if( statusChauf != SUCCESS )
145+
if( statusChauf != SFE_BIO_SUCCESS )
146146
return statusChauf;
147147

148148
statusChauf = max30101Control(ENABLE);
149-
if( statusChauf != SUCCESS )
149+
if( statusChauf != SFE_BIO_SUCCESS )
150150
return statusChauf;
151151

152152
statusChauf = maximFastAlgoControl(mode);
153-
if( statusChauf != SUCCESS )
153+
if( statusChauf != SFE_BIO_SUCCESS )
154154
return statusChauf;
155155

156156
_userSelectedMode = mode;
157157
_sampleRate = readAlgoSamples();
158158

159159
delay(1000);
160-
return SUCCESS;
160+
return SFE_BIO_SUCCESS;
161161

162162
}
163163

@@ -169,23 +169,23 @@ uint8_t SparkFun_Bio_Sensor_Hub::configSensor(){
169169
uint8_t statusChauf; // Our status chauffeur
170170

171171
statusChauf = setOutputMode(SENSOR_DATA); // Just the sensor data (LED)
172-
if( statusChauf != SUCCESS )
172+
if( statusChauf != SFE_BIO_SUCCESS )
173173
return statusChauf;
174174

175175
statusChauf = setFifoThreshold(0x01); // One sample before interrupt is fired to the MAX32664
176-
if( statusChauf != SUCCESS )
176+
if( statusChauf != SFE_BIO_SUCCESS )
177177
return statusChauf;
178178

179179
statusChauf = max30101Control(ENABLE); //Enable Sensor.
180-
if( statusChauf != SUCCESS )
180+
if( statusChauf != SFE_BIO_SUCCESS )
181181
return statusChauf;
182182

183183
statusChauf = maximFastAlgoControl(MODE_ONE); //Enable algorithm
184-
if( statusChauf != SUCCESS )
184+
if( statusChauf != SFE_BIO_SUCCESS )
185185
return statusChauf;
186186

187187
delay(1000);
188-
return SUCCESS;
188+
return SFE_BIO_SUCCESS;
189189

190190
}
191191

@@ -201,26 +201,26 @@ uint8_t SparkFun_Bio_Sensor_Hub::configSensorBpm(uint8_t mode){
201201
else return INCORR_PARAM;
202202

203203
statusChauf = setOutputMode(SENSOR_AND_ALGORITHM); // Data and sensor data
204-
if( statusChauf != SUCCESS )
204+
if( statusChauf != SFE_BIO_SUCCESS )
205205
return statusChauf;
206206

207207
statusChauf = setFifoThreshold(0x01); // One sample before interrupt is fired to the MAX32664
208-
if( statusChauf != SUCCESS )
208+
if( statusChauf != SFE_BIO_SUCCESS )
209209
return statusChauf;
210210

211211
statusChauf = max30101Control(ENABLE); //Enable Sensor.
212-
if( statusChauf != SUCCESS )
212+
if( statusChauf != SFE_BIO_SUCCESS )
213213
return statusChauf;
214214

215215
statusChauf = maximFastAlgoControl(mode); //Enable algorithm
216-
if( statusChauf != SUCCESS )
216+
if( statusChauf != SFE_BIO_SUCCESS )
217217
return statusChauf;
218218

219219
_userSelectedMode = mode;
220220
_sampleRate = readAlgoSamples();
221221

222222
delay(1000);
223-
return SUCCESS;
223+
return SFE_BIO_SUCCESS;
224224

225225
}
226226

@@ -476,7 +476,7 @@ uint8_t SparkFun_Bio_Sensor_Hub::setPulseWidth(uint16_t width){
476476
regVal |= bits; // Add bits
477477
writeRegisterMAX30101(CONFIGURATION_REGISTER, regVal); // Write Register
478478

479-
return SUCCESS;
479+
return SFE_BIO_SUCCESS;
480480

481481
}
482482

@@ -528,7 +528,7 @@ uint8_t SparkFun_Bio_Sensor_Hub::setSampleRate(uint16_t sampRate){
528528
regVal |= (bits << 2); // Add bits but shift them first to correct position.
529529
writeRegisterMAX30101(CONFIGURATION_REGISTER, regVal); // Write Register
530530

531-
return SUCCESS;
531+
return SFE_BIO_SUCCESS;
532532
}
533533

534534
// 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){
579579

580580
writeRegisterMAX30101(CONFIGURATION_REGISTER, regVal);
581581

582-
return SUCCESS;
582+
return SFE_BIO_SUCCESS;
583583
}
584584

585585
// MAX30101 Register: CONFIGURATION_REGISTER (0x0A), bits [6:5]
@@ -606,13 +606,13 @@ uint16_t SparkFun_Bio_Sensor_Hub::readAdcRange(){
606606
uint8_t SparkFun_Bio_Sensor_Hub::setOperatingMode(uint8_t selection) {
607607

608608
// 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)
610610
{ }
611611
else
612612
return INCORR_PARAM;
613613

614614
uint8_t statusByte = writeByte(SET_DEVICE_MODE, 0x00, selection);
615-
if (statusByte != SUCCESS )
615+
if (statusByte != SFE_BIO_SUCCESS )
616616
return statusByte;
617617

618618
// 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) {
628628
uint8_t SparkFun_Bio_Sensor_Hub::getMcuType() {
629629

630630
uint8_t returnByte = readByte(IDENTITY, READ_MCU_TYPE, NO_WRITE);
631-
if( returnByte != SUCCESS)
631+
if( returnByte != SFE_BIO_SUCCESS)
632632
return ERR_UNKNOWN;
633633
else
634634
return returnByte;
@@ -669,10 +669,10 @@ uint8_t SparkFun_Bio_Sensor_Hub::max30101Control(uint8_t senSwitch) {
669669

670670
// Check that communication was successful, not that the sensor is enabled.
671671
uint8_t statusByte = enableWrite(ENABLE_SENSOR, ENABLE_MAX30101, senSwitch);
672-
if( statusByte != SUCCESS )
672+
if( statusByte != SFE_BIO_SUCCESS )
673673
return statusByte;
674674
else
675-
return SUCCESS;
675+
return SFE_BIO_SUCCESS;
676676

677677
}
678678

@@ -696,10 +696,10 @@ uint8_t SparkFun_Bio_Sensor_Hub::accelControl(uint8_t accelSwitch) {
696696

697697
// Check that communication was successful, not that the sensor is enabled.
698698
uint8_t statusByte = enableWrite(ENABLE_SENSOR, ENABLE_ACCELEROMETER, accelSwitch);
699-
if( statusByte != SUCCESS )
699+
if( statusByte != SFE_BIO_SUCCESS )
700700
return statusByte;
701701
else
702-
return SUCCESS;
702+
return SFE_BIO_SUCCESS;
703703

704704
}
705705

@@ -713,10 +713,10 @@ uint8_t SparkFun_Bio_Sensor_Hub::setOutputMode(uint8_t outputType) {
713713
// Check that communication was successful, not that the IC is outputting
714714
// correct format.
715715
uint8_t statusByte = writeByte(OUTPUT_MODE, SET_FORMAT, outputType);
716-
if( statusByte != SUCCESS)
716+
if( statusByte != SFE_BIO_SUCCESS)
717717
return statusByte;
718718
else
719-
return SUCCESS;
719+
return SFE_BIO_SUCCESS;
720720

721721
}
722722

@@ -730,10 +730,10 @@ uint8_t SparkFun_Bio_Sensor_Hub::setFifoThreshold(uint8_t intThresh) {
730730
// Checks that there was succesful communcation, not that the threshold was
731731
// set correctly.
732732
uint8_t statusByte = writeByte(OUTPUT_MODE, WRITE_SET_THRESHOLD, intThresh);
733-
if( statusByte != SUCCESS)
733+
if( statusByte != SFE_BIO_SUCCESS)
734734
return statusByte;
735735
else
736-
return SUCCESS;
736+
return SFE_BIO_SUCCESS;
737737

738738
}
739739

@@ -886,10 +886,10 @@ uint8_t SparkFun_Bio_Sensor_Hub::setAlgoRange(uint8_t perc) {
886886

887887
// Successful communication or no?
888888
uint8_t statusByte = writeByte(CHANGE_ALGORITHM_CONFIG, SET_TARG_PERC, AGC_GAIN_ID, perc);
889-
if( statusByte != SUCCESS )
889+
if( statusByte != SFE_BIO_SUCCESS )
890890
return statusByte;
891891
else
892-
return SUCCESS;
892+
return SFE_BIO_SUCCESS;
893893

894894
}
895895

@@ -904,10 +904,10 @@ uint8_t SparkFun_Bio_Sensor_Hub::setAlgoStepSize(uint8_t step) {
904904

905905
// Successful communication or no?
906906
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 )
908908
return statusByte;
909909
else
910-
return SUCCESS;
910+
return SFE_BIO_SUCCESS;
911911

912912
}
913913

@@ -921,10 +921,10 @@ uint8_t SparkFun_Bio_Sensor_Hub::setAlgoSensitivity(uint8_t sense) {
921921

922922
// Successful communication or no?
923923
uint8_t statusByte = writeByte(CHANGE_ALGORITHM_CONFIG, SET_SENSITIVITY, AGC_SENSITIVITY_ID, sense);
924-
if( statusByte != SUCCESS )
924+
if( statusByte != SFE_BIO_SUCCESS )
925925
return statusByte;
926926
else
927-
return SUCCESS;
927+
return SFE_BIO_SUCCESS;
928928

929929
}
930930

@@ -936,10 +936,10 @@ uint8_t SparkFun_Bio_Sensor_Hub::setAlgoSamples(uint8_t avg) {
936936

937937
// Successful communication or no?
938938
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 )
940940
return statusByte;
941941
else
942-
return SUCCESS;
942+
return SFE_BIO_SUCCESS;
943943

944944
}
945945

@@ -955,10 +955,10 @@ uint8_t SparkFun_Bio_Sensor_Hub::setMaximFastCoef(int32_t coef1, int32_t coef2,
955955

956956
uint8_t statusByte = writeLongBytes(CHANGE_ALGORITHM_CONFIG, SET_PULSE_OX_COEF,\
957957
MAXIMFAST_COEF_ID, coefArr, numCoefVals);
958-
if( statusByte != SUCCESS)
958+
if( statusByte != SFE_BIO_SUCCESS)
959959
return statusByte;
960960
else
961-
return SUCCESS;
961+
return SFE_BIO_SUCCESS;
962962

963963
}
964964

@@ -1029,10 +1029,10 @@ uint8_t SparkFun_Bio_Sensor_Hub::agcAlgoControl(uint8_t enable) {
10291029
return INCORR_PARAM;
10301030

10311031
uint8_t statusByte = enableWrite(ENABLE_ALGORITHM, ENABLE_AGC_ALGO, enable);
1032-
if (statusByte != SUCCESS)
1032+
if (statusByte != SFE_BIO_SUCCESS)
10331033
return statusByte;
10341034
else
1035-
return SUCCESS;
1035+
return SFE_BIO_SUCCESS;
10361036

10371037
}
10381038

@@ -1047,10 +1047,10 @@ uint8_t SparkFun_Bio_Sensor_Hub::maximFastAlgoControl(uint8_t mode) {
10471047
return INCORR_PARAM;
10481048

10491049
uint8_t statusByte = enableWrite(ENABLE_ALGORITHM, ENABLE_WHRM_ALGO, mode);
1050-
if (statusByte != SUCCESS)
1050+
if (statusByte != SFE_BIO_SUCCESS)
10511051
return statusByte;
10521052
else
1053-
return SUCCESS;
1053+
return SFE_BIO_SUCCESS;
10541054

10551055
}
10561056

@@ -1100,7 +1100,7 @@ version SparkFun_Bio_Sensor_Hub::readBootloaderVers(){
11001100

11011101
_i2cPort->requestFrom(_address, static_cast<uint8_t>(4));
11021102
uint8_t statusByte = _i2cPort->read();
1103-
if (statusByte) { // Pass through if SUCCESS (0x00).
1103+
if (statusByte) { // Pass through if SFE_BIO_SUCCESS (0x00).
11041104
booVers.major = 0;
11051105
booVers.minor = 0;
11061106
booVers.revision = 0;
@@ -1127,7 +1127,7 @@ version SparkFun_Bio_Sensor_Hub::readSensorHubVersion(){
11271127

11281128
_i2cPort->requestFrom(_address, static_cast<uint8_t>(4));
11291129
uint8_t statusByte = _i2cPort->read();
1130-
if (statusByte){ // Pass through if SUCCESS (0x00).
1130+
if (statusByte){ // Pass through if SFE_BIO_SUCCESS (0x00).
11311131
bioHubVers.major = 0;
11321132
bioHubVers.minor = 0;
11331133
bioHubVers.revision = 0;
@@ -1154,7 +1154,7 @@ version SparkFun_Bio_Sensor_Hub::readAlgorithmVersion(){
11541154

11551155
_i2cPort->requestFrom(_address, static_cast<uint8_t>(4));
11561156
uint8_t statusByte = _i2cPort->read();
1157-
if (statusByte){ // Pass through if SUCCESS (0x00).
1157+
if (statusByte){ // Pass through if SFE_BIO_SUCCESS (0x00).
11581158
libAlgoVers.major = 0;
11591159
libAlgoVers.minor = 0;
11601160
libAlgoVers.revision = 0;
@@ -1312,7 +1312,13 @@ uint8_t SparkFun_Bio_Sensor_Hub::enableWrite(uint8_t _familyByte, uint8_t _index
13121312
_i2cPort->write(_indexByte);
13131313
_i2cPort->write(_enableByte);
13141314
_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);
13161322

13171323
// Status Byte, success or no? 0x00 is a successful transmit
13181324
_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
14671473

14681474
_i2cPort->requestFrom(_address, static_cast<uint8_t>(sizeof(returnByte) + sizeof(statusByte)));
14691475
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
14711477
return statusByte; // Return the error, see: READ_STATUS_BYTE_VALUE
14721478

14731479
returnByte = _i2cPort->read();
@@ -1498,7 +1504,7 @@ uint8_t SparkFun_Bio_Sensor_Hub::readByte(uint8_t _familyByte, uint8_t _indexBy
14981504

14991505
_i2cPort->requestFrom(_address, static_cast<uint8_t>(sizeof(returnByte) + sizeof(statusByte)));
15001506
statusByte = _i2cPort->read();
1501-
if( statusByte )// SUCCESS (0x00)
1507+
if( statusByte )// SFE_BIO_SUCCESS (0x00)
15021508
return statusByte; // Return the error, see: READ_STATUS_BYTE_VALUE
15031509

15041510
returnByte = _i2cPort->read();
@@ -1520,7 +1526,7 @@ uint8_t SparkFun_Bio_Sensor_Hub::readFillArray(uint8_t _familyByte, uint8_t _ind
15201526

15211527
_i2cPort->requestFrom(_address, static_cast<uint8_t>(_numOfReads + sizeof(statusByte)));
15221528
statusByte = _i2cPort->read();
1523-
if( statusByte ){// SUCCESS: 0x00
1529+
if( statusByte ){// SFE_BIO_SUCCESS: 0x00
15241530
for(size_t i = 0; i < _numOfReads; i++){
15251531
array[i] = 0;
15261532
}
@@ -1555,7 +1561,7 @@ uint16_t SparkFun_Bio_Sensor_Hub::readIntByte(uint8_t _familyByte, uint8_t _inde
15551561

15561562
_i2cPort->requestFrom(_address, static_cast<uint8_t>(sizeof(returnByte) + sizeof(statusByte)));
15571563
statusByte = _i2cPort->read();
1558-
if( statusByte ) // Pass through if SUCCESS (0x00).
1564+
if( statusByte ) // Pass through if SFE_BIO_SUCCESS (0x00).
15591565
return statusByte; // Return the error, see: READ_STATUS_BYTE_VALUE
15601566

15611567
returnByte = (_i2cPort->read() << 8);
@@ -1587,7 +1593,7 @@ uint8_t SparkFun_Bio_Sensor_Hub::readMultipleBytes(uint8_t _familyByte, uint8_t
15871593

15881594
_i2cPort->requestFrom(_address, static_cast<uint8_t>(sizeof(int32_t) * _numOfReads + sizeof(statusByte)));
15891595
statusByte = _i2cPort->read();
1590-
if( statusByte ) // Pass through if SUCCESS (0x00).
1596+
if( statusByte ) // Pass through if SFE_BIO_SUCCESS (0x00).
15911597
return statusByte;
15921598
else {
15931599
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
16221628

16231629
_i2cPort->requestFrom(_address, static_cast<uint8_t>(_numOfReads + sizeof(statusByte)));
16241630
statusByte = _i2cPort->read();
1625-
if( statusByte ) // Pass through if SUCCESS (0x00).
1631+
if( statusByte ) // Pass through if SFE_BIO_SUCCESS (0x00).
16261632
return statusByte;
16271633
else {
16281634
for(size_t i = 0; i < _numOfReads; i++){

0 commit comments

Comments
 (0)