Skip to content

Commit 0015d81

Browse files
authored
Merge pull request #5 from YuyaIwata/compile_errors_fix
Compile errors fix
2 parents 8d30bef + c88e5b7 commit 0015d81

File tree

1 file changed

+25
-34
lines changed

1 file changed

+25
-34
lines changed

src/SparkFun_Bio_Sensor_Hub_Library.cpp

Lines changed: 25 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -353,44 +353,44 @@ bioData SparkFun_Bio_Sensor_Hub::readSensorBpm(){
353353
MAXFAST_ARRAY_SIZE + MAX30101_LED_ARRAY + MAXFAST_EXTENDED_DATA, bpmSenArrTwo);
354354

355355
// 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];
359359

360360
// 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];
364364

365365
// -- What happened here? -- There are two uint32_t values that are given by
366366
// the sensor for LEDs that do not exists on the MAX30101. So we have to
367367
// request those empty values because they occupy the buffer:
368-
// bpmSenArr[6-11].
368+
// bpmSenArrTwo[6-11].
369369

370370
// 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]);
373373
libLedBpm.heartRate /= 10;
374374

375375
// Confidence formatting
376-
libLedBpm.confidence = bpmSenArr[14];
376+
libLedBpm.confidence = bpmSenArrTwo[14];
377377

378378
//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];
381381
libLedBpm.oxygen /= 10;
382382

383383
//"Machine State" - has a finger been detected?
384-
libLedBpm.status = bpmSenArr[17];
384+
libLedBpm.status = bpmSenArrTwo[17];
385385

386386
//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];
389389
libLedBpm.rValue = tempVal;
390-
libLedBpm.rValue /= 10;
390+
libLedBpm.rValue /= 10.0;
391391

392392
//Extended Machine State formatting
393-
libLedBpm.extStatus = bpmArrTwo[20];
393+
libLedBpm.extStatus = bpmSenArrTwo[20];
394394

395395
// There are two additional bytes of data that were requested but that
396396
// have not been implemented in firmware 10.1 so will not be saved to
@@ -427,7 +427,6 @@ bioData SparkFun_Bio_Sensor_Hub::readSensorBpm(){
427427
uint8_t SparkFun_Bio_Sensor_Hub::setPulseWidth(uint16_t width){
428428

429429
uint8_t bits;
430-
uint8_t statusByte;
431430
uint8_t regVal;
432431

433432
// Make sure the correct pulse width is selected.
@@ -476,7 +475,6 @@ uint16_t SparkFun_Bio_Sensor_Hub::readPulseWidth(){
476475
uint8_t SparkFun_Bio_Sensor_Hub::setSampleRate(uint16_t sampRate){
477476

478477
uint8_t bits;
479-
uint8_t statusByte;
480478
uint8_t regVal;
481479

482480
// Make sure the correct sample rate was picked
@@ -532,7 +530,6 @@ uint16_t SparkFun_Bio_Sensor_Hub::readSampleRate(){
532530
// 62.5pA - 16384nA
533531
uint8_t SparkFun_Bio_Sensor_Hub::setAdcRange(uint16_t adcVal){
534532

535-
uint8_t statusByte;
536533
uint8_t regVal;
537534
uint8_t bits;
538535

@@ -544,7 +541,7 @@ uint8_t SparkFun_Bio_Sensor_Hub::setAdcRange(uint16_t adcVal){
544541

545542
regVal = readRegisterMAX30101(CONFIGURATION_REGISTER);
546543
regVal &= ADC_MASK;
547-
regVal |= (adcVal << 5);
544+
regVal |= bits << 5;
548545

549546
writeRegisterMAX30101(CONFIGURATION_REGISTER, regVal);
550547

@@ -611,7 +608,7 @@ uint8_t SparkFun_Bio_Sensor_Hub::getMcuType() {
611608
int32_t SparkFun_Bio_Sensor_Hub::getBootloaderInf() {
612609

613610
int32_t bootVers = 0;
614-
int32_t* revNum;
611+
int32_t revNum[4] = {0};
615612
readMultipleBytes(BOOTLOADER_INFO, BOOTLOADER_VERS, 0x00, 4, revNum);
616613

617614
if( revNum[1] != SUCCESS )
@@ -675,7 +672,7 @@ uint8_t SparkFun_Bio_Sensor_Hub::accelControl(uint8_t accelSwitch) {
675672
// Write Byte : outputType (Parameter values in OUTPUT_MODE_WRITE_BYTE)
676673
uint8_t SparkFun_Bio_Sensor_Hub::setOutputMode(uint8_t outputType) {
677674

678-
if (outputType < PAUSE || outputType > SENSOR_ALGO_COUNTER) // Bytes between 0x00 and 0x07
675+
if ( outputType > SENSOR_ALGO_COUNTER ) // Bytes between 0x00 and 0x07
679676
return INCORR_PARAM;
680677

681678
// 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) {
695692
// (begin).
696693
uint8_t SparkFun_Bio_Sensor_Hub::setFifoThreshold(uint8_t intThresh) {
697694

698-
if( intThresh < 0 || intThresh > 255)
699-
return INCORR_PARAM;
700-
701695
// Checks that there was succesful communcation, not that the threshold was
702696
// set correctly.
703697
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
851845
// 100 percent.
852846
uint8_t SparkFun_Bio_Sensor_Hub::setAlgoRange(uint8_t perc) {
853847

854-
if( perc < 0 || perc > 100)
848+
if( perc > 100)
855849
return INCORR_PARAM;
856850

857851
// Successful communication or no?
@@ -869,7 +863,7 @@ uint8_t SparkFun_Bio_Sensor_Hub::setAlgoRange(uint8_t perc) {
869863
// It takes a paramater of zero to 100 percent.
870864
uint8_t SparkFun_Bio_Sensor_Hub::setAlgoStepSize(uint8_t step) {
871865

872-
if( step < 0 || step > 100)
866+
if( step > 100 )
873867
return INCORR_PARAM;
874868

875869
// Successful communication or no?
@@ -886,7 +880,7 @@ uint8_t SparkFun_Bio_Sensor_Hub::setAlgoStepSize(uint8_t step) {
886880
// This function changes the sensitivity of the AGC algorithm.
887881
uint8_t SparkFun_Bio_Sensor_Hub::setAlgoSensitivity(uint8_t sense) {
888882

889-
if( sense < 0 || sense > 100 )
883+
if( sense > 100 )
890884
return INCORR_PARAM;
891885

892886
// Successful communication or no?
@@ -904,9 +898,6 @@ uint8_t SparkFun_Bio_Sensor_Hub::setAlgoSensitivity(uint8_t sense) {
904898
// It takes a paramater of zero to 255.
905899
uint8_t SparkFun_Bio_Sensor_Hub::setAlgoSamples(uint8_t avg) {
906900

907-
if( avg < 0 || avg > 255 )
908-
return INCORR_PARAM;
909-
910901
// Successful communication or no?
911902
uint8_t statusByte = writeByte(CHANGE_ALGORITHM_CONFIG, SET_AVG_SAMPLES, AGC_SENSITIVITY_ID, avg);
912903
if( statusByte != SUCCESS )
@@ -1391,7 +1382,7 @@ uint32_t SparkFun_Bio_Sensor_Hub::readLongByte(uint8_t _familyByte, uint8_t _ind
13911382
uint8_t _writeByte)
13921383
{
13931384

1394-
uint32_t returnByte;
1385+
uint32_t returnByte = 0;
13951386
uint8_t statusByte;
13961387

13971388
_i2cPort->beginTransmission(_address);
@@ -1404,7 +1395,7 @@ uint32_t SparkFun_Bio_Sensor_Hub::readLongByte(uint8_t _familyByte, uint8_t _ind
14041395
_i2cPort->requestFrom(_address, (sizeof(returnByte) * 3) + sizeof(statusByte) );
14051396
statusByte = _i2cPort->read();
14061397
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
14081399

14091400
for(uint8_t i = 0; i < (sizeof(returnByte) * 3); i++){ // Reading three long bytes
14101401
returnByte |= (_i2cPort->read() << 24);

0 commit comments

Comments
 (0)