4848#include " vl53l0x_types.h"
4949
5050#ifndef UNUSED
51- #define UNUSED (x ) x
51+ #define UNUSED (x ) ( void ) x
5252#endif
5353
5454
@@ -387,7 +387,7 @@ VL53L0X_Error VL53L0X::VL53L0X_get_offset_calibration_data_micro_meter(VL53L0X_D
387387{
388388 VL53L0X_Error Status = VL53L0X_ERROR_NONE;
389389 uint16_t RangeOffsetRegister;
390- int16_t cMaxOffset = 2047 ;
390+ uint16_t cMaxOffset = 2047 ;
391391 int16_t cOffsetRange = 4096 ;
392392
393393 /* Note that offset has 10.2 format */
@@ -2287,14 +2287,14 @@ VL53L0X_Error VL53L0X::VL53L0X_GetInterruptThresholds(VL53L0X_DEV Dev,
22872287
22882288 Status = VL53L0X_RdWord (Dev, VL53L0X_REG_SYSTEM_THRESH_LOW, &Threshold16);
22892289 /* Need to multiply by 2 because the FW will apply a x2 */
2290- *pThresholdLow = (FixPoint1616_t)( (0x00fff & Threshold16) << 17 );
2290+ *pThresholdLow = (( FixPoint1616_t)(0x00fff & Threshold16) << 17 );
22912291
22922292 if (Status == VL53L0X_ERROR_NONE) {
22932293 Status = VL53L0X_RdWord (Dev, VL53L0X_REG_SYSTEM_THRESH_HIGH,
22942294 &Threshold16);
22952295 /* Need to multiply by 2 because the FW will apply a x2 */
22962296 *pThresholdHigh =
2297- (FixPoint1616_t)( (0x00fff & Threshold16) << 17 );
2297+ (( FixPoint1616_t)(0x00fff & Threshold16) << 17 );
22982298 }
22992299
23002300 LOG_FUNCTION_END (Status);
@@ -2391,8 +2391,8 @@ VL53L0X_Error VL53L0X::VL53L0X_CheckAndLoadInterruptSettings(VL53L0X_DEV Dev,
23912391 uint8_t StartNotStopFlag)
23922392{
23932393 uint8_t InterruptConfig;
2394- FixPoint1616_t ThresholdLow;
2395- FixPoint1616_t ThresholdHigh;
2394+ FixPoint1616_t ThresholdLow = 0 ;
2395+ FixPoint1616_t ThresholdHigh = 0 ;
23962396 VL53L0X_Error Status = VL53L0X_ERROR_NONE;
23972397
23982398 InterruptConfig = VL53L0X_GETDEVICESPECIFICPARAMETER (Dev,
@@ -2409,9 +2409,9 @@ VL53L0X_Error VL53L0X::VL53L0X_CheckAndLoadInterruptSettings(VL53L0X_DEV Dev,
24092409 VL53L0X_DEVICEMODE_CONTINUOUS_RANGING,
24102410 &ThresholdLow, &ThresholdHigh);
24112411
2412- if (((ThresholdLow > 255 * 65536 ) ||
2413- (ThresholdHigh > 255 *65536 )) &&
2414- (Status == VL53L0X_ERROR_NONE )) {
2412+ if ((Status == VL53L0X_ERROR_NONE) &&
2413+ ((ThresholdLow > 255 *65536 ) ||
2414+ (ThresholdHigh > 255 * 65536 ) )) {
24152415
24162416 if (StartNotStopFlag != 0 ) {
24172417 Status = VL53L0X_load_tuning_settings (Dev,
@@ -2646,7 +2646,7 @@ uint32_t VL53L0X::VL53L0X_isqrt(uint32_t num)
26462646 */
26472647
26482648 uint32_t res = 0 ;
2649- uint32_t bit = 1 << 30 ;
2649+ uint32_t bit = ( uint32_t ) 1 << 30 ;
26502650 /* The second-to-top bit is set:
26512651 * 1 << 14 for 16-bits, 1 << 30 for 32 bits */
26522652
@@ -3056,7 +3056,7 @@ VL53L0X_Error VL53L0X::VL53L0X_calc_sigma_estimate(VL53L0X_DEV Dev,
30563056 xTalkCorrection <<= 8 ;
30573057
30583058 if (pRangingMeasurementData->RangeStatus != 0 ){
3059- pwMult = 1 << 16 ;
3059+ pwMult = (FixPoint1616_t) 1 << 16 ;
30603060 } else {
30613061 /* FixPoint1616/uint32 = FixPoint1616 */
30623062 pwMult = deltaT_ps/cVcselPulseWidth_ps; /* smaller than 1.0f */
@@ -3066,13 +3066,13 @@ VL53L0X_Error VL53L0X::VL53L0X_calc_sigma_estimate(VL53L0X_DEV Dev,
30663066 * values are small enough such that32 bits will not be
30673067 * exceeded.
30683068 */
3069- pwMult *= ((1 << 16 ) - xTalkCorrection);
3069+ pwMult *= (((FixPoint1616_t) 1 << 16 ) - xTalkCorrection);
30703070
30713071 /* (FixPoint3232 >> 16) = FixPoint1616 */
30723072 pwMult = (pwMult + c16BitRoundingParam) >> 16 ;
30733073
30743074 /* FixPoint1616 + FixPoint1616 = FixPoint1616 */
3075- pwMult += (1 << 16 );
3075+ pwMult += ((FixPoint1616_t) 1 << 16 );
30763076
30773077 /*
30783078 * At this point the value will be 1.xx, therefore if we square
@@ -3422,7 +3422,7 @@ VL53L0X_Error VL53L0X::VL53L0X_GetRangingMeasurementData(VL53L0X_DEV Dev,
34223422 VL53L0X_Error Status = VL53L0X_ERROR_NONE;
34233423 uint8_t DeviceRangeStatus;
34243424 uint8_t RangeFractionalEnable;
3425- uint8_t PalRangeStatus;
3425+ uint8_t PalRangeStatus = 255 ;
34263426 uint8_t XTalkCompensationEnable;
34273427 uint16_t AmbientRate;
34283428 FixPoint1616_t SignalRate;
@@ -4997,7 +4997,7 @@ VL53L0X_Error VL53L0X::VL53L0X_RdDWord(VL53L0X_DEV Dev, uint8_t index, uint32_t
49974997 status = VL53L0X_I2CRead (Dev->I2cDevAddr , index, buffer, 4 );
49984998 if (!status)
49994999 {
5000- *data = (buffer[0 ] << 24 ) + (buffer[1 ] << 16 ) + (buffer[2 ] << 8 ) + buffer[3 ];
5000+ *data = (( uint32_t ) buffer[0 ] << 24 ) + (( uint32_t ) buffer[1 ] << 16 ) + (( uint32_t ) buffer[2 ] << 8 ) + ( uint32_t ) buffer[3 ];
50015001 }
50025002 return status;
50035003
@@ -5023,7 +5023,7 @@ VL53L0X_Error VL53L0X::VL53L0X_I2CWrite(uint8_t DeviceAddr, uint8_t RegisterAddr
50235023 dev_i2c->beginTransmission (((uint8_t )(((DeviceAddr) >> 1 ) & 0x7F )));
50245024
50255025 dev_i2c->write (RegisterAddr);
5026- for (int i = 0 ; i < NumByteToWrite ; i++)
5026+ for (uint16_t i = 0 ; i < NumByteToWrite ; i++)
50275027 dev_i2c->write (pBuffer[i]);
50285028
50295029 dev_i2c->endTransmission (true );
0 commit comments