From c095e73a319fcae1fa96abe3335bcbe34acd5451 Mon Sep 17 00:00:00 2001 From: wisecatdev <49599082+wisecatdev@users.noreply.github.com> Date: Sat, 29 Feb 2020 10:21:17 -0500 Subject: [PATCH] Fixed "i2c_address * 2" bug TODO in python_lib\vl53l0x_python.c mentioned bug resulting in output of VL53L0X_SetDeviceAddress() having to multiple desired i2c_address by 2 in order to get correct address assigned to the sensor. Located bug in the API function where the device address was being arbitrarily being divided by 2 before being assigned to the sensor. --- Api/core/src/vl53l0x_api.c | 2 +- Api/core/src/vl53l0x_api.c.bak | 2 +- python_lib/vl53l0x_python.c | 5 +---- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Api/core/src/vl53l0x_api.c b/Api/core/src/vl53l0x_api.c index 8a80095..cacbd6f 100644 --- a/Api/core/src/vl53l0x_api.c +++ b/Api/core/src/vl53l0x_api.c @@ -358,7 +358,7 @@ VL53L0X_Error VL53L0X_SetDeviceAddress(VL53L0X_DEV Dev, uint8_t DeviceAddress) LOG_FUNCTION_START(""); Status = VL53L0X_WrByte(Dev, VL53L0X_REG_I2C_SLAVE_DEVICE_ADDRESS, - DeviceAddress / 2); + DeviceAddress); LOG_FUNCTION_END(Status); return Status; diff --git a/Api/core/src/vl53l0x_api.c.bak b/Api/core/src/vl53l0x_api.c.bak index 841d940..37eb447 100644 --- a/Api/core/src/vl53l0x_api.c.bak +++ b/Api/core/src/vl53l0x_api.c.bak @@ -358,7 +358,7 @@ VL53L0X_Error VL53L0X_SetDeviceAddress(VL53L0X_DEV Dev, uint8_t DeviceAddress) LOG_FUNCTION_START(""); Status = VL53L0X_WrByte(Dev, VL53L0X_REG_I2C_SLAVE_DEVICE_ADDRESS, - DeviceAddress / 2); + DeviceAddress); LOG_FUNCTION_END(Status); return Status; diff --git a/python_lib/vl53l0x_python.c b/python_lib/vl53l0x_python.c index 20495aa..834b5e7 100644 --- a/python_lib/vl53l0x_python.c +++ b/python_lib/vl53l0x_python.c @@ -194,10 +194,7 @@ void startRanging(int object_number, int mode, uint8_t i2c_address, uint8_t TCA9 // Address requested not default so set the address. // This assumes that the shutdown pin has been controlled // externally to this function. - // TODO: Why does this function divide the address by 2? To get - // the address we want we have to mutiply by 2 in the call so - // it gets set right - Status = VL53L0X_SetDeviceAddress(pMyDevice[object_number], (i2c_address * 2)); + Status = VL53L0X_SetDeviceAddress(pMyDevice[object_number], (i2c_address)); pMyDevice[object_number]->I2cDevAddr = i2c_address; }