Skip to content

Commit 30d0555

Browse files
committed
Fixes warnings from compiler about conversion issues when using requestFrom
* the number of bytes can only ever be 32 bytes before it exceeds Arduino's buffer and so requestFrom expects a uint8_t. It was being provided a uint16_t.
1 parent 93a75cf commit 30d0555

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/SparkFun_Qwiic_KX13X.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ float QwiicKX13xCore::readOutputDataRate(){
180180
readRegister(&tempRegVal, KX13X_ODCNTL);
181181
tempRegVal &= 0x0F;
182182
tempRegVal = (float)tempRegVal;
183-
return (0.78 * (pow(2,tempRegVal));
183+
return (0.78 * (pow(2,tempRegVal)));
184184

185185
}
186186

@@ -468,7 +468,7 @@ KX13X_STATUS_t QwiicKX13xCore::readMultipleRegisters(uint8_t reg, uint8_t dataBu
468468
if( i2cResult != 0 )
469469
return KX13X_I2C_ERROR; //Error: Sensor did not ack
470470

471-
i2cResult = _i2cPort->requestFrom(static_cast<uint8_t>(_deviceAddress), numBytes, false);
471+
i2cResult = _i2cPort->requestFrom(_deviceAddress, uint8_t(numBytes), uint8_t(false));
472472
if( i2cResult == 0 )
473473
return KX13X_I2C_ERROR;
474474
for(size_t i = 0; i < numBytes; i++) {
@@ -499,7 +499,7 @@ KX13X_STATUS_t QwiicKX13xCore::overBufLenI2CRead(uint8_t reg, uint8_t dataBuffer
499499
else
500500
resizedRead = numBytes;
501501

502-
i2cResult = _i2cPort->requestFrom(static_cast<uint8_t>(_deviceAddress), resizedRead, false); //false = repeated start
502+
i2cResult = _i2cPort->requestFrom(_deviceAddress, resizedRead, uint8_t(false)); //false = repeated start
503503
if( i2cResult == 0 )
504504
return KX13X_I2C_ERROR;
505505
for(size_t i = 0; i < resizedRead; i++) {

0 commit comments

Comments
 (0)