@@ -353,44 +353,44 @@ bioData SparkFun_Bio_Sensor_Hub::readSensorBpm(){
353
353
MAXFAST_ARRAY_SIZE + MAX30101_LED_ARRAY + MAXFAST_EXTENDED_DATA, bpmSenArrTwo);
354
354
355
355
// Value of LED one....
356
- libLedBpm.irLed = uint32_t (bpmSenArr [0 ]) << 16 ;
357
- libLedBpm.irLed |= uint32_t (bpmSenArr [1 ]) << 8 ;
358
- libLedBpm.irLed |= bpmSenArr [2 ];
356
+ libLedBpm.irLed = uint32_t (bpmSenArrTwo [0 ]) << 16 ;
357
+ libLedBpm.irLed |= uint32_t (bpmSenArrTwo [1 ]) << 8 ;
358
+ libLedBpm.irLed |= bpmSenArrTwo [2 ];
359
359
360
360
// Value of LED two...
361
- libLedBpm.redLed = uint32_t (bpmSenArr [3 ]) << 16 ;
362
- libLedBpm.redLed |= uint32_t (bpmSenArr [4 ]) << 8 ;
363
- libLedBpm.redLed |= bpmSenArr [5 ];
361
+ libLedBpm.redLed = uint32_t (bpmSenArrTwo [3 ]) << 16 ;
362
+ libLedBpm.redLed |= uint32_t (bpmSenArrTwo [4 ]) << 8 ;
363
+ libLedBpm.redLed |= bpmSenArrTwo [5 ];
364
364
365
365
// -- What happened here? -- There are two uint32_t values that are given by
366
366
// the sensor for LEDs that do not exists on the MAX30101. So we have to
367
367
// request those empty values because they occupy the buffer:
368
- // bpmSenArr [6-11].
368
+ // bpmSenArrTwo [6-11].
369
369
370
370
// Heart rate formatting
371
- libLedBpm.heartRate = (uint16_t (bpmSenArr [12 ]) << 8 );
372
- libLedBpm.heartRate |= (bpmSenArr [13 ]);
371
+ libLedBpm.heartRate = (uint16_t (bpmSenArrTwo [12 ]) << 8 );
372
+ libLedBpm.heartRate |= (bpmSenArrTwo [13 ]);
373
373
libLedBpm.heartRate /= 10 ;
374
374
375
375
// Confidence formatting
376
- libLedBpm.confidence = bpmSenArr [14 ];
376
+ libLedBpm.confidence = bpmSenArrTwo [14 ];
377
377
378
378
// Blood oxygen level formatting
379
- libLedBpm.oxygen = uint16_t (bpmSenArr [15 ]) << 8 ;
380
- libLedBpm.oxygen |= bpmSenArr [16 ];
379
+ libLedBpm.oxygen = uint16_t (bpmSenArrTwo [15 ]) << 8 ;
380
+ libLedBpm.oxygen |= bpmSenArrTwo [16 ];
381
381
libLedBpm.oxygen /= 10 ;
382
382
383
383
// "Machine State" - has a finger been detected?
384
- libLedBpm.status = bpmSenArr [17 ];
384
+ libLedBpm.status = bpmSenArrTwo [17 ];
385
385
386
386
// Sp02 r Value formatting
387
- uint16_t tempVal = uint16_t (bpmArrTwo[ 6 ]) << 8 ;
388
- tempVal |= bpmArrTwo[ 7 ];
387
+ uint16_t tempVal = uint16_t (bpmSenArrTwo[ 18 ]) << 8 ;
388
+ tempVal |= bpmSenArrTwo[ 19 ];
389
389
libLedBpm.rValue = tempVal;
390
- libLedBpm.rValue /= 10 ;
390
+ libLedBpm.rValue /= 10.0 ;
391
391
392
392
// Extended Machine State formatting
393
- libLedBpm.extStatus = bpmArrTwo [20 ];
393
+ libLedBpm.extStatus = bpmSenArrTwo [20 ];
394
394
395
395
// There are two additional bytes of data that were requested but that
396
396
// have not been implemented in firmware 10.1 so will not be saved to
@@ -427,7 +427,6 @@ bioData SparkFun_Bio_Sensor_Hub::readSensorBpm(){
427
427
uint8_t SparkFun_Bio_Sensor_Hub::setPulseWidth (uint16_t width){
428
428
429
429
uint8_t bits;
430
- uint8_t statusByte;
431
430
uint8_t regVal;
432
431
433
432
// Make sure the correct pulse width is selected.
@@ -476,7 +475,6 @@ uint16_t SparkFun_Bio_Sensor_Hub::readPulseWidth(){
476
475
uint8_t SparkFun_Bio_Sensor_Hub::setSampleRate (uint16_t sampRate){
477
476
478
477
uint8_t bits;
479
- uint8_t statusByte;
480
478
uint8_t regVal;
481
479
482
480
// Make sure the correct sample rate was picked
@@ -532,7 +530,6 @@ uint16_t SparkFun_Bio_Sensor_Hub::readSampleRate(){
532
530
// 62.5pA - 16384nA
533
531
uint8_t SparkFun_Bio_Sensor_Hub::setAdcRange (uint16_t adcVal){
534
532
535
- uint8_t statusByte;
536
533
uint8_t regVal;
537
534
uint8_t bits;
538
535
@@ -544,7 +541,7 @@ uint8_t SparkFun_Bio_Sensor_Hub::setAdcRange(uint16_t adcVal){
544
541
545
542
regVal = readRegisterMAX30101 (CONFIGURATION_REGISTER);
546
543
regVal &= ADC_MASK;
547
- regVal |= (adcVal << 5 ) ;
544
+ regVal |= bits << 5 ;
548
545
549
546
writeRegisterMAX30101 (CONFIGURATION_REGISTER, regVal);
550
547
@@ -611,7 +608,7 @@ uint8_t SparkFun_Bio_Sensor_Hub::getMcuType() {
611
608
int32_t SparkFun_Bio_Sensor_Hub::getBootloaderInf () {
612
609
613
610
int32_t bootVers = 0 ;
614
- int32_t * revNum;
611
+ int32_t revNum[ 4 ] = { 0 } ;
615
612
readMultipleBytes (BOOTLOADER_INFO, BOOTLOADER_VERS, 0x00 , 4 , revNum);
616
613
617
614
if ( revNum[1 ] != SUCCESS )
@@ -675,7 +672,7 @@ uint8_t SparkFun_Bio_Sensor_Hub::accelControl(uint8_t accelSwitch) {
675
672
// Write Byte : outputType (Parameter values in OUTPUT_MODE_WRITE_BYTE)
676
673
uint8_t SparkFun_Bio_Sensor_Hub::setOutputMode (uint8_t outputType) {
677
674
678
- if (outputType < PAUSE || outputType > SENSOR_ALGO_COUNTER) // Bytes between 0x00 and 0x07
675
+ if ( outputType > SENSOR_ALGO_COUNTER ) // Bytes between 0x00 and 0x07
679
676
return INCORR_PARAM;
680
677
681
678
// Check that communication was successful, not that the IC is outputting
@@ -695,9 +692,6 @@ uint8_t SparkFun_Bio_Sensor_Hub::setOutputMode(uint8_t outputType) {
695
692
// (begin).
696
693
uint8_t SparkFun_Bio_Sensor_Hub::setFifoThreshold (uint8_t intThresh) {
697
694
698
- if ( intThresh < 0 || intThresh > 255 )
699
- return INCORR_PARAM;
700
-
701
695
// Checks that there was succesful communcation, not that the threshold was
702
696
// set correctly.
703
697
uint8_t statusByte = writeByte (OUTPUT_MODE, WRITE_SET_THRESHOLD, intThresh);
@@ -851,7 +845,7 @@ uint8_t* SparkFun_Bio_Sensor_Hub::dumpRegisterAccelerometer(uint8_t numReg, uint
851
845
// 100 percent.
852
846
uint8_t SparkFun_Bio_Sensor_Hub::setAlgoRange (uint8_t perc) {
853
847
854
- if ( perc < 0 || perc > 100 )
848
+ if ( perc > 100 )
855
849
return INCORR_PARAM;
856
850
857
851
// Successful communication or no?
@@ -869,7 +863,7 @@ uint8_t SparkFun_Bio_Sensor_Hub::setAlgoRange(uint8_t perc) {
869
863
// It takes a paramater of zero to 100 percent.
870
864
uint8_t SparkFun_Bio_Sensor_Hub::setAlgoStepSize (uint8_t step) {
871
865
872
- if ( step < 0 || step > 100 )
866
+ if ( step > 100 )
873
867
return INCORR_PARAM;
874
868
875
869
// Successful communication or no?
@@ -886,7 +880,7 @@ uint8_t SparkFun_Bio_Sensor_Hub::setAlgoStepSize(uint8_t step) {
886
880
// This function changes the sensitivity of the AGC algorithm.
887
881
uint8_t SparkFun_Bio_Sensor_Hub::setAlgoSensitivity (uint8_t sense) {
888
882
889
- if ( sense < 0 || sense > 100 )
883
+ if ( sense > 100 )
890
884
return INCORR_PARAM;
891
885
892
886
// Successful communication or no?
@@ -904,9 +898,6 @@ uint8_t SparkFun_Bio_Sensor_Hub::setAlgoSensitivity(uint8_t sense) {
904
898
// It takes a paramater of zero to 255.
905
899
uint8_t SparkFun_Bio_Sensor_Hub::setAlgoSamples (uint8_t avg) {
906
900
907
- if ( avg < 0 || avg > 255 )
908
- return INCORR_PARAM;
909
-
910
901
// Successful communication or no?
911
902
uint8_t statusByte = writeByte (CHANGE_ALGORITHM_CONFIG, SET_AVG_SAMPLES, AGC_SENSITIVITY_ID, avg);
912
903
if ( statusByte != SUCCESS )
@@ -1391,7 +1382,7 @@ uint32_t SparkFun_Bio_Sensor_Hub::readLongByte(uint8_t _familyByte, uint8_t _ind
1391
1382
uint8_t _writeByte)
1392
1383
{
1393
1384
1394
- uint32_t returnByte;
1385
+ uint32_t returnByte = 0 ;
1395
1386
uint8_t statusByte;
1396
1387
1397
1388
_i2cPort->beginTransmission (_address);
@@ -1404,7 +1395,7 @@ uint32_t SparkFun_Bio_Sensor_Hub::readLongByte(uint8_t _familyByte, uint8_t _ind
1404
1395
_i2cPort->requestFrom (_address, (sizeof (returnByte) * 3 ) + sizeof (statusByte) );
1405
1396
statusByte = _i2cPort->read ();
1406
1397
if ( statusByte ) // Pass through if SUCCESS (0x00).
1407
- return statusByte; // Return the error, see: READ_STATUS_BYTE_VALUE
1398
+ return ( uint32_t ) statusByte; // Return the error, see: READ_STATUS_BYTE_VALUE
1408
1399
1409
1400
for (uint8_t i = 0 ; i < (sizeof (returnByte) * 3 ); i++){ // Reading three long bytes
1410
1401
returnByte |= (_i2cPort->read () << 24 );
0 commit comments