The VL53L1CB proximity sensor, based on ST’s FlightSense™, Time-of-Flight technology.
Dependencies: X_NUCLEO_COMMON ST_INTERFACES
Dependents: VL53L1CB_noshield_1sensor_polls_auton VL53L1CB_noshield_1sensor_interrupt_auton X_NUCLEO_53L1A2
Based on VL53L1 library, this is a library for the VL53L1CB ToF chip.
Revision 18:0696efe39d08, committed 2021-07-21
- Comitter:
- lugandc
- Date:
- Wed Jul 21 17:06:38 2021 +0200
- Parent:
- 17:ca0ce4daf573
- Commit message:
- Cleanup i2c functions, removed all bad references to L1X
Cleanup VL53L1CB class:
- i2c device object is passed in a consistent way in MyDevice structure
- removed useless functions
Updated VL53L1CB component driver with bare driver release 6.6.7 content
Changed in this revision
--- a/inc/ToF_I2C.h Wed Jun 23 12:57:26 2021 +0000 +++ b/inc/ToF_I2C.h Wed Jul 21 17:06:38 2021 +0200 @@ -8,8 +8,6 @@ #include "pinmap.h" -static int mutex =0; - //Class replacing DevI2C class as it was not implementing a 16bit address registers class ToF_DevI2C : public I2C { @@ -34,75 +32,7 @@ * @note On some devices if NumByteToWrite is greater * than one, the RegisterAddr must be masked correctly! */ - /* - int v53l1x_i2c_write(uint8_t* pBuffer, uint8_t DeviceAddr, uint16_t RegisterAddr, - uint16_t NumByteToWrite) { - int ret; - uint8_t tmp[TEMP_BUF_SIZE]; - - if(NumByteToWrite >= TEMP_BUF_SIZE) return -2; - - // First, send device address. Then, send data and STOP condition - tmp[0] = RegisterAddr >> 8; - tmp[1] = RegisterAddr & 0x0FF; - memcpy(tmp+2, pBuffer, NumByteToWrite); - while ( mutex ) - { - wait_ms(1); - } - mutex = 1; - - ret = write(DeviceAddr, (const char*)tmp, NumByteToWrite+2, false); - mutex = 0; - if(ret) - { - wait_ms(1); - ret = write(DeviceAddr, (const char*)tmp, NumByteToWrite+2, false); - if(ret) - { - printf("***************** v53l1x_i2c_write twice times %d %d %d %d\n",DeviceAddr,RegisterAddr,NumByteToWrite,ret); - } - // printf("v53l1x_i2c_write %d %d %d %d\n",DeviceAddr,RegisterAddr,NumByteToWrite,ret); - return -1; - } - return 0; - } - */ - - /** - * @brief Reads a buffer from the I2C peripheral device. - * @param pBuffer pointer to the byte-array to read data in to - * @param DeviceAddr specifies the peripheral device slave address. - * @param RegisterAddr specifies the internal address register - * where to start reading from (must be correctly masked). - * @param NumByteToRead number of bytes to be read. - * @retval 0 if ok, - * @retval -1 if an I2C error has occured - * @note On some devices if NumByteToWrite is greater - * than one, the RegisterAddr must be masked correctly! - */ - /* - int v53l1x_i2c_read(uint8_t* pBuffer, uint8_t DeviceAddr, uint16_t RegisterAddr, - uint16_t NumByteToRead) { - int ret; - - - // Read data, with STOP condition - ret = read(DeviceAddr, (char*)pBuffer, NumByteToRead, false); - - // printf("class v53l1x_i2c_read read %d %d %d\n",pBuffer[0],pBuffer[1],pBuffer[2]); - - - if(ret) - { - printf("********************* class v53l1x_i2c_read %d %d %d %d\n",DeviceAddr,RegisterAddr,NumByteToRead,ret); - return -1; - } - return 0; - } - */ - - int ToF_i2c_write(uint8_t* pBuffer, uint8_t DeviceAddr, uint16_t RegisterAddr, + int ToF_i2c_write(uint8_t* pBuffer, uint8_t DeviceAddr, uint16_t RegisterAddr, uint16_t NumByteToWrite) { int ret; uint8_t tmp[TEMP_BUF_SIZE]; @@ -153,4 +83,4 @@ static const unsigned int TEMP_BUF_SIZE = 256; }; -#endif /* __DEV_53L1X_I2C_H */ \ No newline at end of file +#endif /* __DEV_ToF_I2C_H */
--- a/inc/VL53L1CB.h Wed Jun 23 12:57:26 2021 +0000 +++ b/inc/VL53L1CB.h Wed Jul 21 17:06:38 2021 +0200 @@ -1,11 +1,11 @@ /******************************************************************************* - * @file vl53l1x_class.h + * @file vl53l1cb_class.h * @author JS * @version V0.0.1 * @date 15-January-2019 * @brief Header file for VL53L1 sensor component ****************************************************************************** - Copyright Ãâé 2019, STMicroelectronics International N.V. + Copyright © 2021, STMicroelectronics International N.V. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -35,13 +35,13 @@ #ifdef _MSC_VER -# ifdef VL53L1X_API_EXPORTS -# define VL53L1X_API __declspec(dllexport) +# ifdef VL53L1CB_API_EXPORTS +# define VL53L1CB_API __declspec(dllexport) # else -# define VL53L1X_API +# define VL53L1CB_API # endif #else -# define VL53L1X_API +# define VL53L1CB_API #endif @@ -56,93 +56,29 @@ #include "vl53l1_error_codes.h" #include "vl53l1_platform_user_data.h" -//#include "DevI2C.h" #include "ToF_I2C.h" /**********************************************************/ #include "vl53l1_def.h" /***********************************************************/ -#define VL53L1_IMPLEMENTATION_VER_MAJOR 1 -#define VL53L1_IMPLEMENTATION_VER_MINOR 0 -#define VL53L1_IMPLEMENTATION_VER_SUB 1 -#define VL53L1_IMPLEMENTATION_VER_REVISION 0000 +#define VL53L1CB_IMPLEMENTATION_VER_MAJOR 1 +#define VL53L1CB_IMPLEMENTATION_VER_MINOR 0 +#define VL53L1CB_IMPLEMENTATION_VER_SUB 2 +#define VL53L1CB_IMPLEMENTATION_VER_REVISION 0000 typedef int8_t VL53L1CB_ERROR; -//#define SOFT_RESET 0x0000 -#define VL53L1_I2C_SLAVE__DEVICE_ADDRESS 0x0001 -#define VL53L1_VHV_CONFIG__TIMEOUT_MACROP_LOOP_BOUND 0x0008 -#define ALGO__CROSSTALK_COMPENSATION_PLANE_OFFSET_KCPS 0x0016 -#define ALGO__CROSSTALK_COMPENSATION_X_PLANE_GRADIENT_KCPS 0x0018 -#define ALGO__CROSSTALK_COMPENSATION_Y_PLANE_GRADIENT_KCPS 0x001A -#define ALGO__PART_TO_PART_RANGE_OFFSET_MM 0x001E -#define MM_CONFIG__INNER_OFFSET_MM 0x0020 -#define MM_CONFIG__OUTER_OFFSET_MM 0x0022 -#define GPIO_HV_MUX__CTRL 0x0030 -#define GPIO__TIO_HV_STATUS 0x0031 -#define SYSTEM__INTERRUPT_CONFIG_GPIO 0x0046 -#define PHASECAL_CONFIG__TIMEOUT_MACROP 0x004B -#define RANGE_CONFIG__TIMEOUT_MACROP_A_HI 0x005E -#define RANGE_CONFIG__VCSEL_PERIOD_A 0x0060 -#define RANGE_CONFIG__VCSEL_PERIOD_B 0x0063 -#define RANGE_CONFIG__TIMEOUT_MACROP_B_HI 0x0061 -#define RANGE_CONFIG__TIMEOUT_MACROP_B_LO 0x0062 -#define RANGE_CONFIG__SIGMA_THRESH 0x0064 -#define RANGE_CONFIG__MIN_COUNT_RATE_RTN_LIMIT_MCPS 0x0066 -#define RANGE_CONFIG__VALID_PHASE_HIGH 0x0069 -#define VL53L1_SYSTEM__INTERMEASUREMENT_PERIOD 0x006C -#define SYSTEM__THRESH_HIGH 0x0072 -#define SYSTEM__THRESH_LOW 0x0074 -#define SD_CONFIG__WOI_SD0 0x0078 -#define SD_CONFIG__INITIAL_PHASE_SD0 0x007A -#define ROI_CONFIG__USER_ROI_CENTRE_SPAD 0x007F -#define ROI_CONFIG__USER_ROI_REQUESTED_GLOBAL_XY_SIZE 0x0080 -#define SYSTEM__SEQUENCE_CONFIG 0x0081 -#define VL53L1_SYSTEM__GROUPED_PARAMETER_HOLD 0x0082 -#define SYSTEM__INTERRUPT_CLEAR 0x0086 -#define SYSTEM__MODE_START 0x0087 -#define VL53L1_RESULT__RANGE_STATUS 0x0089 -#define VL53L1_RESULT__DSS_ACTUAL_EFFECTIVE_SPADS_SD0 0x008C -#define RESULT__AMBIENT_COUNT_RATE_MCPS_SD 0x0090 -#define VL53L1_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0 0x0096 -#define VL53L1_RESULT__PEAK_SIGNAL_COUNT_RATE_CROSSTALK_CORRECTED_MCPS_SD0 0x0098 -#define VL53L1_RESULT__OSC_CALIBRATE_VAL 0x00DE -#define VL53L1_FIRMWARE__SYSTEM_STATUS 0x00E5 -#define VL53L1_IDENTIFICATION__MODEL_ID 0x010F -#define VL53L1_ROI_CONFIG__MODE_ROI_CENTRE_SPAD 0x013E - - -#define VL53L1_DEFAULT_DEVICE_ADDRESS 0x52 - -#define VL53L1_REG_IDENTIFICATION_MODEL_ID 0x010F - -/**************************************** - * PRIVATE define do not edit - ****************************************/ - -/** - * @brief defines SW Version - */ -//typedef struct { - // uint8_t major; /*!< major number */ -// uint8_t minor; /*!< minor number */ -// uint8_t build; /*!< build number */ -// uint32_t revision; /*!< revision number */ -//} VL53L1X_Version_t; - +#define VL53L1_DEFAULT_DEVICE_ADDRESS 0x52 +#define VL53L1_REG_IDENTIFICATION_MODEL_ID 0x010F /* Classes -------------------------------------------------------------------*/ /** Class representing a VL53L1 sensor component */ class VL53L1CB : public RangeSensor { - - - public: - #define VL53L1DevStructGetLLDriverHandle(Dev) (&Dev->Data.LLData) /** Constructor * @param[in] &i2c device I2C to be used for communication @@ -153,7 +89,8 @@ VL53L1CB(ToF_DevI2C *i2c, DigitalOut *pin, PinName pin_gpio1, uint8_t dev_addr = VL53L1_DEFAULT_DEVICE_ADDRESS) : RangeSensor(), dev_i2c(i2c), _gpio0(pin) { - MyDevice.i2c_slave_address=dev_addr; + MyDevice.i2c_slave_address = dev_addr; + MyDevice.dev_i2c = (void*) i2c; Device = &MyDevice; _expgpio0 = NULL; @@ -174,7 +111,8 @@ uint8_t dev_addr = VL53L1_DEFAULT_DEVICE_ADDRESS) : dev_i2c(i2c), _expgpio0(pin) { - MyDevice.i2c_slave_address=dev_addr; + MyDevice.i2c_slave_address = dev_addr; + MyDevice.dev_i2c = (void*) i2c; Device = &MyDevice; _gpio0 = NULL; @@ -219,7 +157,7 @@ *_expgpio0 = 1; } } -#if (MBED_VERSION > 60300) +#if (MBED_VERSION > 60300) thread_sleep_for(100); #else wait_ms(100); // NEEDS A DELAY BETWEEN SENSORS @@ -241,7 +179,7 @@ *_expgpio0 = 0; } } -#if (MBED_VERSION > 60300) +#if (MBED_VERSION > 60300) thread_sleep_for(100); #else wait_ms(100); // NEEDS A DELAY BETWEEN SENSORS @@ -267,23 +205,15 @@ VL53L1CB_ERROR InitSensor(uint8_t address){ VL53L1CB_ERROR status = 0; - uint8_t sensorState = 0; VL53L1CB_Off(); VL53L1CB_On(); - status = VL53L1CB_SetI2CAddress(address); + status = VL53L1CB_WaitDeviceBooted(); + if(!status){ + status = VL53L1CB_SetI2CAddress(address); + } if(!status){ status = VL53L1CB_SensorInit(); } - - while(!status && !sensorState) { - status = VL53L1CB_BootState(&sensorState); - -#if (MBED_VERSION > 60300) - thread_sleep_for(2); -#else - wait_ms(2); // NEEDS A DELAY BETWEEN SENSORS -#endif - } return status; } @@ -401,15 +331,13 @@ { int status; uint16_t distance; - status = VL53L1CB_GetDistance(&distance); + status = get_measurement(&distance); *piData = (uint32_t) distance; return status; } -/* VL53L1X_api.h functions */ - - +/* vl53l1_api.h functions */ /** * @brief This function returns the SW driver version @@ -429,58 +357,17 @@ VL53L1CB_ERROR VL53L1CB_SensorInit(); /** - * @brief This function clears the interrupt, to be called after a ranging data reading - * to arm the interrupt for the next data ready event. - */ - VL53L1CB_ERROR VL53L1CB_ClearInterrupt(); - - - /** - * @brief This function returns the current interrupt polarity\n - * 1=active high (default), 0=active low - */ - VL53L1CB_ERROR VL53L1CB_GetInterruptPolarity(uint8_t *pIntPol); - - /** - * @brief This function starts the ranging distance operation\n - * The ranging operation is continuous. The clear interrupt has to be done after each get data to allow the interrupt to raise when the next data is ready\n - * 1=active high (default), 0=active low, use SetInterruptPolarity() to change the interrupt polarity if required. - */ - VL53L1CB_ERROR VL53L1CB_StartRanging(); - - /** - * @brief This function stops the ranging. - */ - VL53L1CB_ERROR VL53L1CB_StopRanging(); - - - - /** * @brief This function returns the boot state of the device (1:booted, 0:not booted) */ VL53L1CB_ERROR VL53L1CB_BootState(uint8_t *state); - /** - * @brief This function returns the sensor id, sensor Id must be 0xEEAC - */ - // VL53L1CB_ERROR VL53L1X_GetSensorId(uint16_t *id); - - /** - * @brief This function returns the distance measured by the sensor in mm - */ - VL53L1CB_ERROR VL53L1CB_GetDistance(uint16_t *distance); - - - /**************************************************************************/ - VL53L1CB_ERROR VL53L1CB_WaitDeviceBooted(VL53L1_DEV Dev); - + + VL53L1CB_ERROR VL53L1CB_WaitDeviceBooted(); VL53L1CB_ERROR VL53L1CB_GetCalibrationData(VL53L1_CalibrationData_t *pCalibrationData); - - VL53L1_GPIO_Interrupt_Mode ConvertModeToLLD(VL53L1CB_ERROR *pStatus, VL53L1_ThresholdMode CrossMode); @@ -507,7 +394,7 @@ char *pPalStateString); - VL53L1CB_ERROR VL53L1CB_GetPalState(VL53L1_DEV Dev, VL53L1_State *pPalState); + VL53L1CB_ERROR VL53L1CB_GetPalState(VL53L1_State *pPalState); VL53L1CB_ERROR VL53L1CB_DataInit(); @@ -685,12 +572,6 @@ VL53L1CB_ERROR VL53L1CB_WaitValueMaskEx(VL53L1_Dev_t *pdev, uint32_t timeout_ms, uint16_t index, uint8_t value, uint8_t mask, uint32_t poll_delay_ms); VL53L1CB_ERROR VL53L1CB_SetDeviceAddress(VL53L1_DEV Dev, uint8_t DeviceAddress); - - // from vl53l1_api_debug.c - - VL53L1CB_ERROR VL53L1CB_get_additional_data( - VL53L1_DEV Dev, - VL53L1_additional_data_t *pdata); protected: @@ -712,4 +593,4 @@ }; -#endif /* _VL53L1X_CLASS_H_ */ \ No newline at end of file +#endif /* _VL53L1CB_CLASS_H_ */
--- a/inc/spi_interface.h Wed Jun 23 12:57:26 2021 +0000 +++ b/inc/spi_interface.h Wed Jul 21 17:06:38 2021 +0200 @@ -8,8 +8,8 @@ extern "C" { #endif - int v53l1x_i2c_write_if(uint8_t* pBuffer, uint8_t DeviceAddr, uint16_t RegisterAddr, uint16_t NumByteToWrite); - int v53l1x_i2c_read_if(uint8_t* pBuffer, uint8_t DeviceAddr, uint16_t RegisterAddr, uint16_t NumByteToWrite); + int v53l1cb_i2c_write_if(void *dev_I2C, uint8_t* pBuffer, uint8_t DeviceAddr, uint16_t RegisterAddr, uint16_t NumByteToWrite); + int v53l1cb_i2c_read_if(void *dev_I2C, uint8_t* pBuffer, uint8_t DeviceAddr, uint16_t RegisterAddr, uint16_t NumByteToWrite); int GetTickCount( uint32_t *ptick_count_ms); #ifdef __cplusplus @@ -17,4 +17,4 @@ #endif -#endif /* __DEV_53L1X_I2C_H */ \ No newline at end of file +#endif /*__SPI_INTERFACE_H */
--- a/inc/vl53l1_configuration.h Wed Jun 23 12:57:26 2021 +0000 +++ b/inc/vl53l1_configuration.h Wed Jul 21 17:06:38 2021 +0200 @@ -1,99 +0,0 @@ -#ifndef __VL53L1X_CONFIGURATION_H -#define __VL53L1X_CONFIGURATION_H - - -const uint8_t VL51L1X_DEFAULT_CONFIGURATION[] = { -0x00, /* 0x2d : set bit 2 and 5 to 1 for fast plus mode (1MHz I2C), else don't touch */ -0x00, /* 0x2e : bit 0 if I2C pulled up at 1.8V, else set bit 0 to 1 (pull up at AVDD) */ -0x00, /* 0x2f : bit 0 if GPIO pulled up at 1.8V, else set bit 0 to 1 (pull up at AVDD) */ -0x01, /* 0x30 : set bit 4 to 0 for active high interrupt and 1 for active low (bits 3:0 must be 0x1), use SetInterruptPolarity() */ -0x02, /* 0x31 : bit 1 = interrupt depending on the polarity, use CheckForDataReady() */ -0x00, /* 0x32 : not user-modifiable */ -0x02, /* 0x33 : not user-modifiable */ -0x08, /* 0x34 : not user-modifiable */ -0x00, /* 0x35 : not user-modifiable */ -0x08, /* 0x36 : not user-modifiable */ -0x10, /* 0x37 : not user-modifiable */ -0x01, /* 0x38 : not user-modifiable */ -0x01, /* 0x39 : not user-modifiable */ -0x00, /* 0x3a : not user-modifiable */ -0x00, /* 0x3b : not user-modifiable */ -0x00, /* 0x3c : not user-modifiable */ -0x00, /* 0x3d : not user-modifiable */ -0xff, /* 0x3e : not user-modifiable */ -0x00, /* 0x3f : not user-modifiable */ -0x0F, /* 0x40 : not user-modifiable */ -0x00, /* 0x41 : not user-modifiable */ -0x00, /* 0x42 : not user-modifiable */ -0x00, /* 0x43 : not user-modifiable */ -0x00, /* 0x44 : not user-modifiable */ -0x00, /* 0x45 : not user-modifiable */ -0x20, /* 0x46 : interrupt configuration 0->level low detection, 1-> level high, 2-> Out of window, 3->In window, 0x20-> New sample ready , TBC */ -0x0b, /* 0x47 : not user-modifiable */ -0x00, /* 0x48 : not user-modifiable */ -0x00, /* 0x49 : not user-modifiable */ -0x02, /* 0x4a : not user-modifiable */ -0x0a, /* 0x4b : not user-modifiable */ -0x21, /* 0x4c : not user-modifiable */ -0x00, /* 0x4d : not user-modifiable */ -0x00, /* 0x4e : not user-modifiable */ -0x05, /* 0x4f : not user-modifiable */ -0x00, /* 0x50 : not user-modifiable */ -0x00, /* 0x51 : not user-modifiable */ -0x00, /* 0x52 : not user-modifiable */ -0x00, /* 0x53 : not user-modifiable */ -0xc8, /* 0x54 : not user-modifiable */ -0x00, /* 0x55 : not user-modifiable */ -0x00, /* 0x56 : not user-modifiable */ -0x38, /* 0x57 : not user-modifiable */ -0xff, /* 0x58 : not user-modifiable */ -0x01, /* 0x59 : not user-modifiable */ -0x00, /* 0x5a : not user-modifiable */ -0x08, /* 0x5b : not user-modifiable */ -0x00, /* 0x5c : not user-modifiable */ -0x00, /* 0x5d : not user-modifiable */ -0x01, /* 0x5e : not user-modifiable */ -0xcc, /* 0x5f : not user-modifiable */ -0x0f, /* 0x60 : not user-modifiable */ -0x01, /* 0x61 : not user-modifiable */ -0xf1, /* 0x62 : not user-modifiable */ -0x0d, /* 0x63 : not user-modifiable */ -0x01, /* 0x64 : Sigma threshold MSB (mm in 14.2 format for MSB+LSB), use SetSigmaThreshold(), default value 90 mm */ -0x68, /* 0x65 : Sigma threshold LSB */ -0x00, /* 0x66 : Min count Rate MSB (MCPS in 9.7 format for MSB+LSB), use SetSignalThreshold() */ -0x80, /* 0x67 : Min count Rate LSB */ -0x08, /* 0x68 : not user-modifiable */ -0xb8, /* 0x69 : not user-modifiable */ -0x00, /* 0x6a : not user-modifiable */ -0x00, /* 0x6b : not user-modifiable */ -0x00, /* 0x6c : Intermeasurement period MSB, 32 bits register, use SetIntermeasurementInMs() */ -0x00, /* 0x6d : Intermeasurement period */ -0x0f, /* 0x6e : Intermeasurement period */ -0x89, /* 0x6f : Intermeasurement period LSB */ -0x00, /* 0x70 : not user-modifiable */ -0x00, /* 0x71 : not user-modifiable */ -0x00, /* 0x72 : distance threshold high MSB (in mm, MSB+LSB), use SetD:tanceThreshold() */ -0x00, /* 0x73 : distance threshold high LSB */ -0x00, /* 0x74 : distance threshold low MSB ( in mm, MSB+LSB), use SetD:tanceThreshold() */ -0x00, /* 0x75 : distance threshold low LSB */ -0x00, /* 0x76 : not user-modifiable */ -0x01, /* 0x77 : not user-modifiable */ -0x0f, /* 0x78 : not user-modifiable */ -0x0d, /* 0x79 : not user-modifiable */ -0x0e, /* 0x7a : not user-modifiable */ -0x0e, /* 0x7b : not user-modifiable */ -0x00, /* 0x7c : not user-modifiable */ -0x00, /* 0x7d : not user-modifiable */ -0x02, /* 0x7e : not user-modifiable */ -0xc7, /* 0x7f : ROI center, use SetROI() */ -0xff, /* 0x80 : XY ROI (X=Width, Y=Height), use SetROI() */ -0x9B, /* 0x81 : not user-modifiable */ -0x00, /* 0x82 : not user-modifiable */ -0x00, /* 0x83 : not user-modifiable */ -0x00, /* 0x84 : not user-modifiable */ -0x01, /* 0x85 : not user-modifiable */ -0x00, /* 0x86 : clear interrupt, use ClearInterrupt() */ -0x00 /* 0x87 : start ranging, use StartRanging() or StopRanging(), If you want an automatic start after VL53L1X_init() call, put 0x40 in location 0x87 */ -}; - -#endif //__VL53L1X_CONFIGURATION_H \ No newline at end of file
--- a/inc/vl53l1_def.h Wed Jun 23 12:57:26 2021 +0000 +++ b/inc/vl53l1_def.h Wed Jul 21 17:06:38 2021 +0200 @@ -37,9 +37,9 @@ /** VL53L1 IMPLEMENTATION minor version */ #define VL53L1_IMPLEMENTATION_VER_MINOR 6 /** VL53L1 IMPLEMENTATION sub version */ -#define VL53L1_IMPLEMENTATION_VER_SUB 5 +#define VL53L1_IMPLEMENTATION_VER_SUB 7 /** VL53L1 IMPLEMENTATION sub version */ -#define VL53L1_IMPLEMENTATION_VER_REVISION 2496 +#define VL53L1_IMPLEMENTATION_VER_REVISION 2536 /**************************************** * PRIVATE define do not edit @@ -342,13 +342,13 @@ typedef uint8_t VL53L1_SmudgeCorrectionModes; #define VL53L1_SMUDGE_CORRECTION_NONE ((VL53L1_SmudgeCorrectionModes) 0) - /*!< Smudge correction is applied continously accross the rangings */ + /*!< Smudge correction is disabled */ #define VL53L1_SMUDGE_CORRECTION_CONTINUOUS ((VL53L1_SmudgeCorrectionModes) 1) - /*!< Smudge correction is applied continously accross the rangings */ + /*!< Smudge correction is applied continuously across the rangings */ #define VL53L1_SMUDGE_CORRECTION_SINGLE ((VL53L1_SmudgeCorrectionModes) 2) - /*!< Smudge correction is applied only once accross the rangings */ + /*!< Smudge correction is applied only once across the rangings */ #define VL53L1_SMUDGE_CORRECTION_DEBUG ((VL53L1_SmudgeCorrectionModes) 3) - /*!< Smudge detection is applied continously but Xtalk values are not + /*!< Smudge detection is applied continuously but Xtalk values are not * updated automatically within the driver */ @@ -376,13 +376,13 @@ FixPoint1616_t SignalRateRtnMegaCps; /*!< Return signal rate (MCPS)\n these is a 16.16 fix point * value, which is effectively a measure of target - * reflectance. + * reflectance. */ FixPoint1616_t AmbientRateRtnMegaCps; /*!< Return ambient rate (MCPS)\n these is a 16.16 fix point - * value, which is effectively a measure of the ambien - * t light. + * value, which is effectively a measure of the ambient + * light. */ uint16_t EffectiveSpadRtnCount;
--- a/inc/vl53l1_error_codes.h Wed Jun 23 12:57:26 2021 +0000 +++ b/inc/vl53l1_error_codes.h Wed Jul 21 17:06:38 2021 +0200 @@ -92,7 +92,7 @@ /*!< Zone dynamic config GPH ID check failed - API out of sync */ #define VL53L1_ERROR_XTALK_EXTRACTION_NO_SAMPLE_FAIL ((VL53L1_Error) - 22) - /*!< Thrown when run_xtalk_extraction fn has 0 succesful samples + /*!< Thrown when run_xtalk_extraction fn has 0 successful samples * when using the full array to sample the xtalk. In this case there is * not enough information to generate new Xtalk parm info. The function * will exit and leave the current xtalk parameters unaltered @@ -187,7 +187,7 @@ * notification only, xtalk pulse and shape have still been generated */ #define VL53L1_WARNING_XTALK_NO_SAMPLES_FOR_GRADIENT ((VL53L1_Error) - 39) - /*!< Thrown to notify that some of teh xtalk samples used for gradient + /*!< Thrown to notify that some of the xtalk samples used for gradient * generation did not yield valid ranging pulse data while attempting to * measure the xtalk signal in vl53l1_run_xtalk_extract(). This can * signify that any one of the zones 0-3 yielded no successful samples.
--- a/inc/vl53l1_ll_def.h Wed Jun 23 12:57:26 2021 +0000 +++ b/inc/vl53l1_ll_def.h Wed Jul 21 17:06:38 2021 +0200 @@ -433,6 +433,7 @@ int16_t tp_uwr_lng_corr_z_4_rangeb; int16_t tp_uwr_lng_corr_z_5_rangea; int16_t tp_uwr_lng_corr_z_5_rangeb; + uint32_t tp_min_signal_secondary_targets; } VL53L1_tuning_parm_storage_t; @@ -809,6 +810,8 @@ VL53L1_smudge_corrector_data_t smudge_corrector_data; + uint16_t fmt_total_enabled_spads; + } VL53L1_range_results_t; @@ -1438,6 +1441,7 @@ uint8_t PreviousRangeStatus[VL53L1_MAX_RANGE_RESULTS]; uint8_t PreviousExtendedRange[VL53L1_MAX_RANGE_RESULTS]; uint8_t PreviousStreamCount; + uint16_t fmt_total_enabled_spads; } VL53L1_LLDriverData_t;
--- a/inc/vl53l1_ll_device.h Wed Jun 23 12:57:26 2021 +0000 +++ b/inc/vl53l1_ll_device.h Wed Jul 21 17:06:38 2021 +0200 @@ -663,7 +663,7 @@ #define VL53L1_TUNINGPARMS_LLD_PUBLIC_MIN_ADDRESS \ ((VL53L1_TuningParms) VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS) #define VL53L1_TUNINGPARMS_LLD_PUBLIC_MAX_ADDRESS \ - ((VL53L1_TuningParms) VL53L1_TUNINGPARM_UWR_LONG_CORRECTION_ZONE_5_RANGEB) + ((VL53L1_TuningParms) VL53L1_TUNINGPARM_MIN_SIGNAL_SECONDARY_TARGETS) #define VL53L1_TUNINGPARMS_LLD_PRIVATE_MIN_ADDRESS \ ((VL53L1_TuningParms) VL53L1_TUNINGPARM_PRIVATE_PAGE_BASE_ADDRESS) @@ -1050,6 +1050,8 @@ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 188)) #define VL53L1_TUNINGPARM_UWR_LONG_CORRECTION_ZONE_5_RANGEB \ ((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 189)) +#define VL53L1_TUNINGPARM_MIN_SIGNAL_SECONDARY_TARGETS \ +((VL53L1_TuningParms) (VL53L1_TUNINGPARM_PUBLIC_PAGE_BASE_ADDRESS + 190))
--- a/inc/vl53l1_platform.h Wed Jun 23 12:57:26 2021 +0000 +++ b/inc/vl53l1_platform.h Wed Jul 21 17:06:38 2021 +0200 @@ -1,30 +1,13 @@ -/******************************************************************************* - Copyright (C) 2016, STMicroelectronics International N.V. - All rights reserved. + +/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */ +/****************************************************************************** + * Copyright (c) 2020, STMicroelectronics - All Rights Reserved - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of STMicroelectronics nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND - NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED. - IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************/ + This file is part of VL53L1 and is dual licensed, + either GPL-2.0+ + or 'BSD 3-clause "New" or "Revised" License' , at your option. + ****************************************************************************** + */ #ifndef _VL53L1_PLATFORM_H_ @@ -389,6 +372,7 @@ /* * @brief Gets current system tick count in [ms] * + * @param[in] pdev : pointer to device structure (device handle) * @return time_ms : current time in [ms] * * @return VL53L1_ERROR_NONE Success @@ -396,6 +380,7 @@ */ VL53L1_Error VL53L1_GetTickCount( + VL53L1_Dev_t *pdev, uint32_t *ptime_ms); @@ -429,4 +414,3 @@ #endif -
--- a/inc/vl53l1_platform_init.h Wed Jun 23 12:57:26 2021 +0000 +++ b/inc/vl53l1_platform_init.h Wed Jul 21 17:06:38 2021 +0200 @@ -1,37 +1,15 @@ -/******************************************************************************* - This file is part of VL53L1 Platform - - Copyright (c) 2020, STMicroelectronics - All Rights Reserved - - License terms: BSD 3-clause "New" or "Revised" License. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. +/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */ +/****************************************************************************** + * Copyright (c) 2020, STMicroelectronics - All Rights Reserved - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - 3. Neither the name of the copyright holder nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. + This file is part of VL53L1 and is dual licensed, + either GPL-2.0+ + or 'BSD 3-clause "New" or "Revised" License' , at your option. + ****************************************************************************** + */ - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ @@ -70,4 +48,3 @@ #endif -
--- a/inc/vl53l1_platform_ipp.h Wed Jun 23 12:57:26 2021 +0000 +++ b/inc/vl53l1_platform_ipp.h Wed Jul 21 17:06:38 2021 +0200 @@ -1,37 +1,15 @@ -/******************************************************************************* - This file is part of VL53L1 Platform - - Copyright (c) 2020, STMicroelectronics - All Rights Reserved - - License terms: BSD 3-clause "New" or "Revised" License. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. +/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */ +/****************************************************************************** + * Copyright (c) 2020, STMicroelectronics - All Rights Reserved - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - 3. Neither the name of the copyright holder nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. + This file is part of VL53L1 and is dual licensed, + either GPL-2.0+ + or 'BSD 3-clause "New" or "Revised" License' , at your option. + ****************************************************************************** + */ - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ @@ -111,4 +89,3 @@ #endif -
--- a/inc/vl53l1_platform_ipp_imports.h Wed Jun 23 12:57:26 2021 +0000 +++ b/inc/vl53l1_platform_ipp_imports.h Wed Jul 21 17:06:38 2021 +0200 @@ -1,37 +1,13 @@ -/******************************************************************************* - This file is part of VL53L1 Platform - - Copyright (c) 2020, STMicroelectronics - All Rights Reserved - - License terms: BSD 3-clause "New" or "Revised" License. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. +/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */ +/****************************************************************************** + * Copyright (c) 2020, STMicroelectronics - All Rights Reserved - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - 3. Neither the name of the copyright holder nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ + This file is part of VL53L1 and is dual licensed, + either GPL-2.0+ + or 'BSD 3-clause "New" or "Revised" License' , at your option. + ****************************************************************************** + */ #ifdef VL53L1_NEEDS_IPP # undef VL53L1_IPP_API @@ -39,4 +15,3 @@ # pragma comment (lib, "EwokPlus25API_IPP") #endif -
--- a/inc/vl53l1_platform_log.h Wed Jun 23 12:57:26 2021 +0000 +++ b/inc/vl53l1_platform_log.h Wed Jul 21 17:06:38 2021 +0200 @@ -1,37 +1,15 @@ -/******************************************************************************* - This file is part of VL53L1 Platform - - Copyright (c) 2020, STMicroelectronics - All Rights Reserved - - License terms: BSD 3-clause "New" or "Revised" License. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. +/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */ +/****************************************************************************** + * Copyright (c) 2020, STMicroelectronics - All Rights Reserved - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - 3. Neither the name of the copyright holder nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. + This file is part of VL53L1 and is dual licensed, + either GPL-2.0+ + or 'BSD 3-clause "New" or "Revised" License' , at your option. + ****************************************************************************** + */ - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ @@ -170,4 +148,3 @@ #endif -
--- a/inc/vl53l1_platform_user_config.h Wed Jun 23 12:57:26 2021 +0000 +++ b/inc/vl53l1_platform_user_config.h Wed Jul 21 17:06:38 2021 +0200 @@ -1,37 +1,15 @@ -/******************************************************************************* - This file is part of VL53L1 Platform - - Copyright (c) 2020, STMicroelectronics - All Rights Reserved - - License terms: BSD 3-clause "New" or "Revised" License. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. +/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */ +/****************************************************************************** + * Copyright (c) 2020, STMicroelectronics - All Rights Reserved - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - 3. Neither the name of the copyright holder nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. + This file is part of VL53L1 and is dual licensed, + either GPL-2.0+ + or 'BSD 3-clause "New" or "Revised" License' , at your option. + ****************************************************************************** + */ - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ @@ -81,7 +59,7 @@ -#define VL53L1_MAX_USER_ZONES 16 +#define VL53L1_MAX_USER_ZONES 6 #define VL53L1_MAX_RANGE_RESULTS 4 @@ -93,4 +71,3 @@ #endif -
--- a/inc/vl53l1_platform_user_data.h Wed Jun 23 12:57:26 2021 +0000 +++ b/inc/vl53l1_platform_user_data.h Wed Jul 21 17:06:38 2021 +0200 @@ -1,37 +1,13 @@ -/******************************************************************************* - This file is part of VL53L1 Platform - - Copyright (c) 2020, STMicroelectronics - All Rights Reserved - - License terms: BSD 3-clause "New" or "Revised" License. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. +/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */ +/****************************************************************************** + * Copyright (c) 2020, STMicroelectronics - All Rights Reserved - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - 3. Neither the name of the copyright holder nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ + This file is part of VL53L1 and is dual licensed, + either GPL-2.0+ + or 'BSD 3-clause "New" or "Revised" License' , at your option. + ****************************************************************************** + */ @@ -55,17 +31,11 @@ typedef struct { - VL53L1_DevData_t Data; - - - uint8_t i2c_slave_address; + VL53L1_DevData_t Data; - uint8_t comms_type; + uint8_t i2c_slave_address; - uint16_t comms_speed_khz; - - - uint32_t new_data_ready_poll_duration_ms; + void *dev_i2c; } VL53L1_Dev_t; @@ -96,4 +66,3 @@ #endif -
--- a/inc/vl53l1_platform_user_defines.h Wed Jun 23 12:57:26 2021 +0000 +++ b/inc/vl53l1_platform_user_defines.h Wed Jul 21 17:06:38 2021 +0200 @@ -1,37 +1,13 @@ -/******************************************************************************* - This file is part of VL53L1 Platform - - Copyright (c) 2020, STMicroelectronics - All Rights Reserved - - License terms: BSD 3-clause "New" or "Revised" License. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. +/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */ +/****************************************************************************** + * Copyright (c) 2020, STMicroelectronics - All Rights Reserved - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - 3. Neither the name of the copyright holder nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ + This file is part of VL53L1 and is dual licensed, + either GPL-2.0+ + or 'BSD 3-clause "New" or "Revised" License' , at your option. + ****************************************************************************** + */ @@ -80,4 +56,3 @@ #endif -
--- a/inc/vl53l1_tuning_parm_defaults.h Wed Jun 23 12:57:26 2021 +0000 +++ b/inc/vl53l1_tuning_parm_defaults.h Wed Jul 21 17:06:38 2021 +0200 @@ -10,8 +10,19 @@ */ + + + +#ifndef _VL53L1_TUNING_PARM_DEFAULTS_H_ +#define _VL53L1_TUNING_PARM_DEFAULTS_H_ + + +#ifdef __cplusplus +extern "C" { +#endif + #define VL53L1_TUNINGPARM_VERSION_DEFAULT \ -((uint16_t) 31) +((uint16_t) 32) #define VL53L1_TUNINGPARM_KEY_TABLE_VERSION_DEFAULT \ ((uint16_t) 14) #define VL53L1_TUNINGPARM_LLD_VERSION_DEFAULT \ @@ -390,4 +401,15 @@ ((int16_t) 0) #define VL53L1_TUNINGPARM_UWR_LONG_CORRECTION_ZONE_5_RANGEB_DEFAULT \ ((int16_t) 0) +#define VL53L1_TUNINGPARM_MIN_SIGNAL_SECONDARY_TARGETS_DEFAULT \ +((uint32_t) 6536) + +#ifdef __cplusplus +} +#endif + +#endif + + +
--- a/inc/vl53l1_types.h Wed Jun 23 12:57:26 2021 +0000 +++ b/inc/vl53l1_types.h Wed Jul 21 17:06:38 2021 +0200 @@ -1,37 +1,13 @@ -/******************************************************************************* - This file is part of VL53L1 Platform - - Copyright (c) 2020, STMicroelectronics - All Rights Reserved - - License terms: BSD 3-clause "New" or "Revised" License. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. +/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */ +/****************************************************************************** + * Copyright (c) 2020, STMicroelectronics - All Rights Reserved - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - 3. Neither the name of the copyright holder nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ + This file is part of VL53L1 and is dual licensed, + either GPL-2.0+ + or 'BSD 3-clause "New" or "Revised" License' , at your option. + ****************************************************************************** + */ @@ -89,4 +65,3 @@ #endif -
--- a/src/VL53L1CB.cpp Wed Jun 23 12:57:26 2021 +0000 +++ b/src/VL53L1CB.cpp Wed Jul 21 17:06:38 2021 +0200 @@ -69,41 +69,21 @@ { VL53L1CB_ERROR Status = 0; - pVersion->major = VL53L1_IMPLEMENTATION_VER_MAJOR; - pVersion->minor = VL53L1_IMPLEMENTATION_VER_MINOR; - pVersion->build = VL53L1_IMPLEMENTATION_VER_SUB; - pVersion->revision = VL53L1_IMPLEMENTATION_VER_REVISION; + pVersion->major = VL53L1CB_IMPLEMENTATION_VER_MAJOR; + pVersion->minor = VL53L1CB_IMPLEMENTATION_VER_MINOR; + pVersion->build = VL53L1CB_IMPLEMENTATION_VER_SUB; + pVersion->revision = VL53L1CB_IMPLEMENTATION_VER_REVISION; return Status; } VL53L1CB_ERROR VL53L1CB::VL53L1CB_SetI2CAddress(uint8_t new_address) { VL53L1CB_ERROR status = 0; - // status = (VL53L1CB_ERROR)VL53L1_SetDeviceAddress(Device,new_address); - - - // Device->i2c_slave_address = new_address; //~~ was if ( Device->i2c_slave_address != new_address) { - status = VL53L1_WrByte(Device, VL53L1_I2C_SLAVE__DEVICE_ADDRESS, new_address >> 1); + status = (VL53L1CB_ERROR)VL53L1_SetDeviceAddress(Device,new_address); printf("VL53L1_SetI2CAddress %d to %d status = %d\n", Device->i2c_slave_address,new_address,status); - Device->i2c_slave_address = new_address; - - } - return status; -} - -int VL53L1CB::init_sensor(uint8_t new_addr) -{ - Device->i2c_slave_address = new_addr; - int status = 0; - VL53L1CB_Off(); - VL53L1CB_On(); - - status = is_present(); - if (!status) { - printf("Failed to init VL53L0X sensor!\n\r"); - return status; + Device->i2c_slave_address = new_address; } return status; } @@ -112,99 +92,17 @@ VL53L1CB_ERROR VL53L1CB::VL53L1CB_SensorInit() { VL53L1CB_ERROR status = 0; - uint8_t Addr = 0x00; - - for (Addr = 0x2D; Addr <= 0x87; Addr++){ - status = VL53L1_WrByte(Device, Addr, VL51L1X_DEFAULT_CONFIGURATION[Addr - 0x2D]); - if (status != 0) - { - printf("Writing config failed - %d\r\n", status); - } - } - - // uint16_t sensorID= 0; -// status = VL53L1X_GetSensorId(&sensorID); - // printf("Sensor id is - %d (%X)\r\n", sensorID, sensorID); - - status = VL53L1CB_StartRanging(); - if (status != 0) - { - printf("start ranging failed - %d\r\n", status); - } - - status = VL53L1CB_ClearInterrupt(); - status = VL53L1CB_StopRanging(); - status = VL53L1_WrByte(Device, VL53L1_VHV_CONFIG__TIMEOUT_MACROP_LOOP_BOUND, 0x09); // two bounds VHV - status = VL53L1_WrByte(Device, 0x0B, 0); // start VHV from the previous temperature - return status; -} - - -VL53L1CB_ERROR VL53L1CB::VL53L1CB_ClearInterrupt() -{ - VL53L1CB_ERROR status = 0; - - status = VL53L1_WrByte(Device, SYSTEM__INTERRUPT_CLEAR, 0x01); -// printf("VL53L1CB::VL53L1X_ClearInterrupt()\n"); - return status; -} - - - - - -VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetInterruptPolarity(uint8_t *pInterruptPolarity) -{ - uint8_t Temp; - VL53L1CB_ERROR status = 0; - status = VL53L1_RdByte(Device, GPIO_HV_MUX__CTRL, &Temp); - Temp = Temp & 0x10; - *pInterruptPolarity = !(Temp>>4); - return status; -} - - - -VL53L1CB_ERROR VL53L1CB::VL53L1CB_StartRanging() -{ - VL53L1CB_ERROR status = 0; - - status = VL53L1_WrByte(Device, SYSTEM__MODE_START, 0x40); - return status; -} - - -VL53L1CB_ERROR VL53L1CB::VL53L1CB_StopRanging() -{ - VL53L1CB_ERROR status = 0; + /* Device Initialization and setting */ + status = VL53L1CB_DataInit(); + if (status != 0) { + return status; + } + status = VL53L1CB_StaticInit(); + if (status != 0) { + return status; + } - status = VL53L1_WrByte(Device, SYSTEM__MODE_START, 0x00); - return status; -} - - - - -VL53L1CB_ERROR VL53L1CB::VL53L1CB_BootState(uint8_t *state) -{ - VL53L1CB_ERROR status = 0; - uint8_t tmp = 0; - - status = VL53L1_RdByte(Device,VL53L1_FIRMWARE__SYSTEM_STATUS, &tmp); - *state = tmp; - return status; -} - - -VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetDistance(uint16_t *distance) -{ - VL53L1CB_ERROR status = 0; - uint16_t tmp; - - status = (VL53L1_RdWord(Device, - VL53L1_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0, &tmp)); - *distance = tmp; return status; } @@ -212,225 +110,13 @@ /* Write and read functions from I2C */ -VL53L1CB_ERROR VL53L1CB::VL53L1CB_WriteMulti(VL53L1_DEV Dev, uint16_t index, uint8_t *pdata, uint32_t count) -{ - int status; -//printf(" class VL53L1_WriteMulti \n"); - status = VL53L1CB_I2CWrite(Dev->i2c_slave_address, index, pdata, (uint16_t)count); - return status; -} - -VL53L1CB_ERROR VL53L1CB::VL53L1CB_ReadMulti(VL53L1_DEV Dev, uint16_t index, uint8_t *pdata, uint32_t count) -{ - int status; - - status = VL53L1CB_I2CRead(Dev->i2c_slave_address, index, pdata, (uint16_t)count); - - return status; -} - - -VL53L1CB_ERROR VL53L1CB::VL53L1_WrByte(VL53L1_DEV Dev, uint16_t index, uint8_t data) -{ - int status; - - status=VL53L1CB_I2CWrite(Dev->i2c_slave_address, index, &data, 1); - return status; -} - - -VL53L1CB_ERROR VL53L1CB::VL53L1_WrWord(VL53L1_DEV Dev, uint16_t index, uint16_t data) -{ - int status; - uint8_t buffer[2]; - - buffer[0] = data >> 8; - buffer[1] = data & 0x00FF; - status=VL53L1CB_I2CWrite(Dev->i2c_slave_address, index, (uint8_t *)buffer, 2); - return status; -} - -VL53L1CB_ERROR VL53L1CB::VL53L1_WrDWord(VL53L1_DEV Dev, uint16_t index, uint32_t data) -{ - int status; - uint8_t buffer[4]; - - buffer[0] = (data >> 24) & 0xFF; - buffer[1] = (data >> 16) & 0xFF; - buffer[2] = (data >> 8) & 0xFF; - buffer[3] = (data >> 0) & 0xFF; - status=VL53L1CB_I2CWrite(Dev->i2c_slave_address, index, (uint8_t *)buffer, 4); - return status; -} - - -VL53L1CB_ERROR VL53L1CB::VL53L1_RdByte(VL53L1_DEV Dev, uint16_t index, uint8_t *data) -{ - int status; - - status = VL53L1CB_I2CRead(Dev->i2c_slave_address, index, data, 1); - - if(status) - return -1; - - return 0; -} - -VL53L1CB_ERROR VL53L1CB::VL53L1_RdWord(VL53L1_DEV Dev, uint16_t index, uint16_t *data) -{ - int status; - uint8_t buffer[2] = {0,0}; - - status = VL53L1CB_I2CRead(Dev->i2c_slave_address, index, buffer, 2); - if (!status) - { - *data = (buffer[0] << 8) + buffer[1]; - } - // printf("VL53L1_RdWord %d %d %d \n",Dev->i2c_slave_address,index,status); - return status; - -} - -VL53L1CB_ERROR VL53L1CB::VL53L1_RdDWord(VL53L1_DEV Dev, uint16_t index, uint32_t *data) -{ - int status; - uint8_t buffer[4] = {0,0,0,0}; - - status = VL53L1CB_I2CRead(Dev->i2c_slave_address, index, buffer, 4); - if(!status) - { - *data = (buffer[0] << 24) + (buffer[1] << 16) + (buffer[2] << 8) + buffer[3]; - } - return status; - -} - -VL53L1CB_ERROR VL53L1CB::VL53L1_UpdateByte(VL53L1_DEV Dev, uint16_t index, uint8_t AndData, uint8_t OrData) -{ - int status; - uint8_t buffer = 0; - - /* read data direct onto buffer */ - status = VL53L1CB_I2CRead(Dev->i2c_slave_address, index, &buffer,1); - if (!status) - { - buffer = (buffer & AndData) | OrData; - status = VL53L1CB_I2CWrite(Dev->i2c_slave_address, index, &buffer, (uint16_t)1); - } - return status; -} - -VL53L1CB_ERROR VL53L1CB::VL53L1CB_I2CWrite(uint8_t DeviceAddr, uint16_t RegisterAddr, uint8_t* pBuffer, uint16_t NumByteToWrite) -{ - int ret; - ret = dev_i2c->ToF_i2c_write(pBuffer, DeviceAddr, RegisterAddr, NumByteToWrite); - if (ret) { - return -1; - } - return 0; - -} - -VL53L1CB_ERROR VL53L1CB::VL53L1CB_I2CRead(uint8_t DeviceAddr, uint16_t RegisterAddr, uint8_t* pBuffer, uint16_t NumByteToRead) -{ - int ret; - - ret = dev_i2c->ToF_i2c_read(pBuffer, DeviceAddr, RegisterAddr, NumByteToRead); - //ret = dev_i2c->i2c_read(pBuffer, DeviceAddr, RegisterAddr, NumByteToRead); - if (ret) { - return -1; - } - return 0; -} - - -VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetTickCount( - uint32_t *ptick_count_ms) +VL53L1CB_ERROR VL53L1CB::VL53L1CB_WaitDeviceBooted() { - /* Returns current tick count in [ms] */ - - VL53L1CB_ERROR status = VL53L1_ERROR_NONE; - - //*ptick_count_ms = timeGetTime(); - *ptick_count_ms = us_ticker_read() / 1000; - - return status; -} - - - -VL53L1CB_ERROR VL53L1CB::VL53L1CB_WaitUs(VL53L1_Dev_t *pdev, int32_t wait_time) -{ - //(void)pdev; - wait_us(wait_time); - return VL53L1_ERROR_NONE; -} - - -VL53L1CB_ERROR VL53L1CB::VL53L1CB_WaitMs(VL53L1_Dev_t *pdev, int32_t wait_time) -{ - //(void)pdev; - -#if (MBED_VERSION > 60300) - thread_sleep_for(wait_time); -#else - wait_ms(wait_time); // NEEDS A DELAY BETWEEN SENSORS -#endif - return VL53L1_ERROR_NONE; + return VL53L1_WaitDeviceBooted(Device); } -VL53L1CB_ERROR VL53L1CB::VL53L1CB_WaitValueMaskEx( - VL53L1_Dev_t *pdev, - uint32_t timeout_ms, - uint16_t index, - uint8_t value, - uint8_t mask, - uint32_t poll_delay_ms) -{ - - /* - * Platform implementation of WaitValueMaskEx V2WReg script command - * - * WaitValueMaskEx( - * duration_ms, - * index, - * value, - * mask, - * poll_delay_ms); - */ - - - return VL53L1_WaitValueMaskEx( pdev, timeout_ms,index, value, mask, poll_delay_ms); -} - - -/***************************************************************************/ -//VL53L1CB_ERROR VL53L1CB::VL53L1_WaitValueMaskEx( - -VL53L1CB_ERROR VL53L1CB::VL53L1CB_WaitDeviceBooted(VL53L1_DEV Dev) -{ - - return VL53L1_WaitDeviceBooted(Dev); -} - - -static int32_t BDTable[VL53L1_TUNING_MAX_TUNABLE_KEY] = { - TUNING_VERSION, - TUNING_PROXY_MIN, - TUNING_SINGLE_TARGET_XTALK_TARGET_DISTANCE_MM, - TUNING_SINGLE_TARGET_XTALK_SAMPLE_NUMBER, - TUNING_MIN_AMBIENT_DMAX_VALID, - TUNING_MAX_SIMPLE_OFFSET_CALIBRATION_SAMPLE_NUMBER, - TUNING_XTALK_FULL_ROI_TARGET_DISTANCE_MM, - TUNING_SIMPLE_OFFSET_CALIBRATION_REPEAT, - TUNING_XTALK_FULL_ROI_BIN_SUM_MARGIN, - TUNING_XTALK_FULL_ROI_DEFAULT_OFFSET, - TUNING_ZERO_DISTANCE_OFFSET_NON_LINEAR_FACTOR_DEFAULT, -}; - - VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetVersion(VL53L1_Version_t *pVersion) { @@ -446,7 +132,6 @@ //****************************************************************** - VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetDeviceInfo( VL53L1_DeviceInfo_t *pVL53L1_DeviceInfo) { @@ -477,28 +162,14 @@ return VL53L1_GetPalStateString(PalStateCode, pPalStateString); } -VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetPalState(VL53L1_DEV Dev, VL53L1_State *pPalState) +VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetPalState(VL53L1_State *pPalState) { - return VL53L1_GetPalState(Dev,pPalState); + return VL53L1_GetPalState(Device, pPalState); } -VL53L1CB_ERROR VL53L1CB::VL53L1CB_SetDeviceAddress(VL53L1_DEV Dev, uint8_t DeviceAddress) -{ - VL53L1CB_ERROR Status = VL53L1_ERROR_NONE; - - // LOG_FUNCTION_START(""); - - Status = VL53L1_WrByte(Dev, VL53L1_I2C_SLAVE__DEVICE_ADDRESS, - DeviceAddress / 2); - -// LOG_FUNCTION_END(Status); - return Status; -} - VL53L1CB_ERROR VL53L1CB::VL53L1CB_DataInit() { - printf("vl53L1_DataInit %d \n",Device->i2c_slave_address); return VL53L1_DataInit( Device); } @@ -598,17 +269,9 @@ } - VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetNumberOfLimitCheck(uint16_t *pNumberOfLimitCheck) { - VL53L1CB_ERROR Status = VL53L1_ERROR_NONE; - - // LOG_FUNCTION_START(""); - - *pNumberOfLimitCheck = VL53L1_CHECKENABLE_NUMBER_OF_CHECKS; - - // LOG_FUNCTION_END(Status); - return Status; + return VL53L1_GetNumberOfLimitCheck(pNumberOfLimitCheck); } VL53L1CB_ERROR VL53L1CB::VL53L1CB_GetLimitCheckInfo(uint16_t LimitCheckId, @@ -859,6 +522,11 @@ return VL53L1_PerformOffsetZeroDistanceCalibration(Device); } +VL53L1CB_ERROR VL53L1CB::VL53L1CB_PerformOffsetPerVcselCalibration(int32_t CalDistanceMilliMeter) +{ + return VL53L1_PerformOffsetPerVcselCalibration(Device,CalDistanceMilliMeter); +} + VL53L1CB_ERROR VL53L1CB::VL53L1CB_SetCalibrationData( VL53L1_CalibrationData_t *pCalibrationData) { @@ -892,11 +560,6 @@ return VL53L1_GetOpticalCenter(Device,pOpticalCenterX,pOpticalCenterY); } - - - - - VL53L1CB_ERROR VL53L1CB::VL53L1CB_SetThresholdConfig(VL53L1_DetectionConfig_t *pConfig) { return VL53L1_SetThresholdConfig(Device,pConfig); @@ -910,26 +573,6 @@ - -VL53L1CB_ERROR VL53L1CB::VL53L1CB_PerformOffsetPerVcselCalibration(int32_t CalDistanceMilliMeter) -{ - return VL53L1_PerformOffsetPerVcselCalibration(Device,CalDistanceMilliMeter); -} - - - -// from vl53l1_api_debug.c - - -VL53L1CB_ERROR VL53L1CB::VL53L1CB_get_additional_data( - VL53L1_DEV Dev, - VL53L1_additional_data_t *pdata) -{ - return VL53L1_get_additional_data(Dev,pdata); -} - - - int VL53L1CB::handle_irq(uint16_t *distance) { int status; @@ -941,9 +584,11 @@ int VL53L1CB::get_measurement(uint16_t *distance) { int status = 0; + VL53L1_RangingMeasurementData_t RangingMeasurementData; - status = VL53L1CB_GetDistance(distance); - status = VL53L1CB_ClearInterrupt(); + status = VL53L1CB_GetRangingMeasurementData(&RangingMeasurementData); + *distance = RangingMeasurementData.RangeMilliMeter; + status = VL53L1CB_ClearInterruptAndStartMeasurement(); return status; } @@ -957,16 +602,12 @@ return 1; } - status = VL53L1CB_StopRanging(); // it is safer to do this while sensor is stopped + VL53L1CB_StopMeasurement(); // it is safer to do this while sensor is stopped - if (status == 0) { - attach_interrupt_measure_detection_irq(fptr); - enable_interrupt_measure_detection_irq(); - } + attach_interrupt_measure_detection_irq(fptr); + enable_interrupt_measure_detection_irq(); - if (status == 0) { - status = VL53L1CB_StartRanging(); - } + status = VL53L1CB_StartMeasurement(); return status; } @@ -976,14 +617,8 @@ int status = 0; if (status == 0) { - printf("Call of VL53L1_StopMeasurement\n"); - status = VL53L1CB_StopRanging(); + status = VL53L1CB_StopMeasurement(); } - if (status == 0) - status = VL53L1CB_ClearInterrupt(); - return status; } - -
--- a/src/spi_interface.cpp Wed Jun 23 12:57:26 2021 +0000 +++ b/src/spi_interface.cpp Wed Jul 21 17:06:38 2021 +0200 @@ -1,60 +1,38 @@ #include "ToF_I2C.h" #include "spi_interface.h" -/* This file is an interface between the c files and the mbed cpp files. */ - int v53l1x_i2c_write_if(uint8_t* pBuffer, uint8_t DeviceAddr, uint16_t RegisterAddr, +/* This file is an interface between the c platform file and the mbed cpp files. */ + + int v53l1cb_i2c_write_if(void *dev_I2C, uint8_t* pBuffer, uint8_t DeviceAddr, uint16_t RegisterAddr, uint16_t NumByteToWrite) { - - static ToF_DevI2C *dev_I2C = new ToF_DevI2C(D14, D15); - - dev_I2C->frequency(400000); - - // printf("v53l1x_i2c_write_if %d\n",NumByteToWrite); - int status = dev_I2C->ToF_i2c_write(pBuffer, DeviceAddr, RegisterAddr, NumByteToWrite); - - if(status) - { - delete dev_I2C; - return -1; - } - - return status; + int status = 0; + ToF_DevI2C *I2C= (ToF_DevI2C*)dev_I2C; + //I2C->frequency(400000); + status = I2C->ToF_i2c_write(pBuffer, DeviceAddr, RegisterAddr, NumByteToWrite); + return status; } - int v53l1x_i2c_read_if(uint8_t* pBuffer, uint8_t DeviceAddr, uint16_t RegisterAddr, + int v53l1cb_i2c_read_if(void *dev_I2C, uint8_t* pBuffer, uint8_t DeviceAddr, uint16_t RegisterAddr, uint16_t NumByteToRead) { - - - static ToF_DevI2C *dev_I2C = new ToF_DevI2C(D14, D15); - if (dev_I2C == NULL) - { - printf("v53l1x_i2c_read_if no pointer%d\n",NumByteToRead); - } - dev_I2C->frequency(400000); - // printf("v53l1x_i2c_read_if %d\n",NumByteToRead); - int status = dev_I2C->ToF_i2c_read(pBuffer, DeviceAddr, RegisterAddr, NumByteToRead); - // printf("v53l1x_i2c_read_if %d %d %d %d %d\n",status, DeviceAddr, RegisterAddr,NumByteToRead ,pBuffer[0]); - // delete dev_I2C; - - return status; + int status = 0; + ToF_DevI2C *I2C= (ToF_DevI2C*)dev_I2C; + // I2C->frequency(400000); + status = I2C->ToF_i2c_read(pBuffer, DeviceAddr, RegisterAddr, NumByteToRead); + return status; } int GetTickCount( uint32_t *ptick_count_ms) { - /* Returns current tick count in [ms] */ - int status = 0; - //*ptick_count_ms = timeGetTime(); *ptick_count_ms = us_ticker_read() / 1000; - return status; }
--- a/src/vl53l1_api.c Wed Jun 23 12:57:26 2021 +0000 +++ b/src/vl53l1_api.c Wed Jul 21 17:06:38 2021 +0200 @@ -638,10 +638,10 @@ VL53L1_Error Status = VL53L1_ERROR_NONE; VL53L1_DevicePresetModes device_preset_mode; uint8_t measurement_mode; - uint16_t dss_config__target_total_rate_mcps; - uint32_t phasecal_config_timeout_us; - uint32_t mm_config_timeout_us; - uint32_t lld_range_config_timeout_us; + uint16_t dss_config__target_total_rate_mcps = 0; + uint32_t phasecal_config_timeout_us = 0; + uint32_t mm_config_timeout_us = 0; + uint32_t lld_range_config_timeout_us = 0; LOG_FUNCTION_START("%d", (int)PresetMode); @@ -746,9 +746,9 @@ VL53L1_Error Status = VL53L1_ERROR_NONE; VL53L1_PresetModes PresetMode; uint32_t inter_measurement_period_ms; - uint32_t TimingBudget; - uint32_t MmTimeoutUs; - uint32_t PhaseCalTimeoutUs; + uint32_t TimingBudget = 0; + uint32_t MmTimeoutUs = 0; + uint32_t PhaseCalTimeoutUs = 0; VL53L1_zone_config_t zone_config; LOG_FUNCTION_START("%d", (int)DistanceMode); @@ -851,14 +851,14 @@ uint32_t MeasurementTimingBudgetMicroSeconds) { VL53L1_Error Status = VL53L1_ERROR_NONE; - uint8_t Mm1Enabled; - uint8_t Mm2Enabled; + uint8_t Mm1Enabled = 0; + uint8_t Mm2Enabled = 0; uint32_t TimingGuard; uint32_t divisor; - uint32_t TimingBudget; - uint32_t MmTimeoutUs; + uint32_t TimingBudget = 0; + uint32_t MmTimeoutUs = 0; VL53L1_PresetModes PresetMode; - uint32_t PhaseCalTimeoutUs; + uint32_t PhaseCalTimeoutUs = 0; uint32_t vhv; int32_t vhv_loops; uint32_t FDAMaxTimingBudgetUs = FDA_MAX_TIMING_BUDGET_US; @@ -1171,6 +1171,7 @@ dmax_mode = VL53L1_DEVICEDMAXMODE__PER_ZONE_CAL_DATA; break; default: + dmax_mode = VL53L1_DEVICEDMAXMODE__CUST_CAL_DATA; Status = VL53L1_ERROR_INVALID_PARAMS; break; } @@ -1388,7 +1389,7 @@ { VL53L1_Error Status = VL53L1_ERROR_NONE; uint16_t MinCountRate; - FixPoint1616_t TempFix1616; + FixPoint1616_t TempFix1616 = 0; uint16_t SigmaThresh; LOG_FUNCTION_START(""); @@ -2171,6 +2172,8 @@ int32_t ExtendedRangeEnabled = 0; uint8_t uwr_status; int16_t AddOffset; + int32_t TuningMinValidSignal; + FixPoint1616_t MinValidSignal; FilteredRangeStatus = presults_data->range_status & 0x1F; @@ -2297,6 +2300,18 @@ } + VL53L1_get_tuning_parm(Dev, + VL53L1_TUNINGPARM_MIN_SIGNAL_SECONDARY_TARGETS, + &TuningMinValidSignal); + MinValidSignal = (FixPoint1616_t)TuningMinValidSignal; + if ((iteration > 0) && + (pRangeData->RangeStatus == VL53L1_RANGESTATUS_RANGE_VALID) && + (pRangeData->SignalRateRtnMegaCps < MinValidSignal)) + pRangeData->RangeStatus = + VL53L1_RANGESTATUS_TARGET_PRESENT_LACK_OF_SIGNAL; + + + VL53L1_get_tuning_parm(Dev, VL53L1_TUNINGPARM_UWR_ENABLE, &ExtendedRangeEnabled); @@ -2413,17 +2428,6 @@ tp->tp_uwr_med_corr_z_6_rangea; } else - - - - - - - - - - - uwr_status = 0; break; @@ -2812,10 +2816,7 @@ pc->ref_spad_man__ref_location = numloc[1]; } - if (Status == VL53L1_ERROR_NONE) - commbuf = &dcrbuffer[16]; - - + commbuf = &dcrbuffer[16]; if (Status == VL53L1_ERROR_NONE) Status = VL53L1_WriteMulti(Dev, @@ -3019,6 +3020,9 @@ LOG_FUNCTION_START(""); + offset_cal_mode = + VL53L1_OFFSETCALIBRATIONMODE__MM1_MM2__STANDARD; + if (OffsetCalibrationMode == VL53L1_OFFSETCALIBRATIONMODE_STANDARD) { offset_cal_mode = VL53L1_OFFSETCALIBRATIONMODE__MM1_MM2__STANDARD; @@ -3050,6 +3054,8 @@ LOG_FUNCTION_START(""); + offset_cor_mode = + VL53L1_OFFSETCORRECTIONMODE__MM1_MM2_OFFSETS; if (OffsetCorrectionMode == VL53L1_OFFSETCORRECTIONMODE_STANDARD) { offset_cor_mode = VL53L1_OFFSETCORRECTIONMODE__MM1_MM2_OFFSETS; @@ -3091,9 +3097,8 @@ CalReflectancePercent_int = VL53L1_FIXPOINT1616TOFIXPOINT72(CalReflectancePercent); - if (Status == VL53L1_ERROR_NONE) - Status = VL53L1_get_offset_calibration_mode(Dev, - &offset_cal_mode); + Status = VL53L1_get_offset_calibration_mode(Dev, + &offset_cal_mode); if (Status != VL53L1_ERROR_NONE) { LOG_FUNCTION_END(Status);
--- a/src/vl53l1_api_calibration.c Wed Jun 23 12:57:26 2021 +0000 +++ b/src/vl53l1_api_calibration.c Wed Jul 21 17:06:38 2021 +0200 @@ -1300,7 +1300,14 @@ VL53L1_p_017 -= (2048 * (uint32_t)pdev->hist_data.cal_config__vcsel_start); - VL53L1_p_017 = VL53L1_p_017 % period; + if (period != 0) { + VL53L1_p_017 = VL53L1_p_017 % period; + } + else { + status = + VL53L1_ERROR_DIVISION_BY_ZERO; + VL53L1_p_017 = 0; + } phasecal_result__reference_phase += (uint32_t)( pdev->hist_data.phasecal_result__reference_phase); @@ -2082,23 +2089,22 @@ status = VL53L1_clear_interrupt_and_enable_next_range( Dev, measurement_mode); - - - if (status == VL53L1_ERROR_NONE) - status = - VL53L1_hist_xtalk_extract_fini( - &(pdev->hist_data), - &(pdev->xtalk_extract), - &(pdev->xtalk_cal), - &(pdev->xtalk_shapes.xtalk_shape)); - if (status != VL53L1_ERROR_NONE) - goto LOOPOUT; + } + + + if (status == VL53L1_ERROR_NONE) + status = + VL53L1_hist_xtalk_extract_fini( + &(pdev->hist_data), + &(pdev->xtalk_extract), + &(pdev->xtalk_cal), + &(pdev->xtalk_shapes.xtalk_shape)); + if (status == VL53L1_ERROR_NONE) { pXC->algo__xtalk_cpo_HistoMerge_kcps[k * MaxId] = pXC->algo__crosstalk_compensation_plane_offset_kcps; } } -LOOPOUT: VL53L1_stop_range(Dev);
--- a/src/vl53l1_api_core.c Wed Jun 23 12:57:26 2021 +0000 +++ b/src/vl53l1_api_core.c Wed Jul 21 17:06:38 2021 +0200 @@ -71,6 +71,8 @@ tB = pdev->per_vcsel_cal_data.long_b_offset_mm; break; default: + tA = pdev->per_vcsel_cal_data.long_a_offset_mm; + tB = pdev->per_vcsel_cal_data.long_b_offset_mm; status = VL53L1_ERROR_INVALID_PARAMS; *poffset = 0; break; @@ -610,9 +612,12 @@ VL53L1_additional_offset_cal_data_t *pCD = &(pdev->add_off_cal_data); VL53L1_decoded_nvm_fmt_range_data_t fmt_rrd; + uint8_t i, VL53L1_p_001, count; LOG_FUNCTION_START(""); + pdev->fmt_total_enabled_spads = 256; + if (status == VL53L1_ERROR_NONE) status = VL53L1_get_static_nvm_managed( Dev, @@ -630,10 +635,21 @@ &(pdev->nvm_copy_data)); - if (status == VL53L1_ERROR_NONE) + if (status == VL53L1_ERROR_NONE) { VL53L1_copy_rtn_good_spads_to_buffer( &(pdev->nvm_copy_data), &(pdev->rtn_good_spads[0])); + pdev->fmt_total_enabled_spads = 0; + for (i = 0; i < 32; i++) { + VL53L1_p_001 = pdev->rtn_good_spads[i]; + count = 0; + while(VL53L1_p_001) { + count += VL53L1_p_001&1; + VL53L1_p_001 = VL53L1_p_001>>1; + } + pdev->fmt_total_enabled_spads += count; + } + } } @@ -3676,7 +3692,7 @@ (VL53L1DevDataGet(Dev, CurrentParameters.PresetMode) == VL53L1_PRESETMODE_RANGING); - + presults->fmt_total_enabled_spads = pdev->fmt_total_enabled_spads; if ((pdev->sys_ctrl.system__mode_start & VL53L1_DEVICESCHEDULERMODE_HISTOGRAM) == VL53L1_DEVICESCHEDULERMODE_HISTOGRAM) { @@ -6258,6 +6274,10 @@ *ptuning_parm_value = pdev->tuning_parms.tp_uwr_lng_corr_z_5_rangeb; break; + case VL53L1_TUNINGPARM_MIN_SIGNAL_SECONDARY_TARGETS: + *ptuning_parm_value = + pdev->tuning_parms.tp_min_signal_secondary_targets; + break; default: *ptuning_parm_value = 0x7FFFFFFF; @@ -7058,7 +7078,10 @@ pdev->tuning_parms.tp_uwr_lng_corr_z_5_rangeb = (int16_t)tuning_parm_value; break; - + case VL53L1_TUNINGPARM_MIN_SIGNAL_SECONDARY_TARGETS: + pdev->tuning_parms.tp_min_signal_secondary_targets = + (uint32_t)tuning_parm_value; + break; default: status = VL53L1_ERROR_INVALID_PARAMS;
--- a/src/vl53l1_api_preset_modes.c Wed Jun 23 12:57:26 2021 +0000 +++ b/src/vl53l1_api_preset_modes.c Wed Jul 21 17:06:38 2021 +0200 @@ -679,7 +679,8 @@ VL53L1_TUNINGPARM_UWR_LONG_CORRECTION_ZONE_5_RANGEA_DEFAULT; pdata->tp_uwr_lng_corr_z_5_rangeb = VL53L1_TUNINGPARM_UWR_LONG_CORRECTION_ZONE_5_RANGEB_DEFAULT; - + pdata->tp_min_signal_secondary_targets = + VL53L1_TUNINGPARM_MIN_SIGNAL_SECONDARY_TARGETS_DEFAULT; LOG_FUNCTION_END(status); return status;
--- a/src/vl53l1_core.c Wed Jun 23 12:57:26 2021 +0000 +++ b/src/vl53l1_core.c Wed Jul 21 17:06:38 2021 +0200 @@ -1222,7 +1222,10 @@ LOG_FUNCTION_START(""); - timeout_mclks = + if (macro_period_us == 0) + timeout_mclks = 0; + else + timeout_mclks = ((timeout_us << 12) + (macro_period_us>>1)) / macro_period_us; @@ -2395,27 +2398,36 @@ - if (pxtalk_data->signal_events_sum > 0) { + + + tmp64_1 = + (uint64_t)pxtalk_data->effective_spad_count_sum * + (uint64_t)pxtalk_data->peak_duration_us_sum; + + if (pxtalk_data->signal_events_sum < 0) { + pxtalk_data->signal_events_sum = 0; + tmp64_0 = - ((uint64_t)pxtalk_data->signal_events_sum * - (uint64_t)pxtalk_data->sample_count * - (uint64_t)pxtalk_data->event_scaler_avg * 256U) << 9U; - tmp64_1 = - (uint64_t)pxtalk_data->effective_spad_count_sum * - (uint64_t)pxtalk_data->peak_duration_us_sum; - - - - if (tmp64_1 > 0U) { - - tmp64_0 = tmp64_0 + (tmp64_1 >> 1U); - xtalk_per_spad = do_division_u(tmp64_0, tmp64_1); - } else { - xtalk_per_spad = (uint64_t)tmp64_0; + ((uint64_t)pxtalk_data->sample_count * + (uint64_t)pxtalk_data->event_scaler_avg * 256U) << 9U; + if (tmp64_0 > 0) { + pxtalk_data->signal_events_sum = (int32_t) + do_division_u((50U * tmp64_1), tmp64_0); } - + } + tmp64_0 = + ((uint64_t)pxtalk_data->signal_events_sum * + (uint64_t)pxtalk_data->sample_count * + (uint64_t)pxtalk_data->event_scaler_avg * 256U) << 9U; + + + + if (tmp64_1 > 0U) { + + tmp64_0 = tmp64_0 + (tmp64_1 >> 1U); + xtalk_per_spad = do_division_u(tmp64_0, tmp64_1); } else { - status = VL53L1_ERROR_XTALK_EXTRACTION_SIGMA_LIMIT_FAIL; + xtalk_per_spad = (uint64_t)tmp64_0; } pxtalk_data->xtalk_rate_kcps_per_spad = (uint32_t)xtalk_per_spad; @@ -3622,6 +3634,8 @@ VL53L1_calc_macro_period_us( fast_osc_frequency, vcsel_period_a); + if (macro_period_us == 0) + macro_period_us = 1;
--- a/src/vl53l1_core_support.c Wed Jun 23 12:57:26 2021 +0000 +++ b/src/vl53l1_core_support.c Wed Jul 21 17:06:38 2021 +0200 @@ -180,7 +180,10 @@ VL53L1_p_017 += (2048 * (uint32_t)pdata->phasecal_result__vcsel_start); VL53L1_p_017 -= (2048 * (uint32_t)pdata->cal_config__vcsel_start); - VL53L1_p_017 = VL53L1_p_017 % period; + if (period != 0) + VL53L1_p_017 = VL53L1_p_017 % period; + else + VL53L1_p_017 = 0; pdata->zero_distance_phase = (uint16_t)VL53L1_p_017;
--- a/src/vl53l1_hist_algos_gen3.c Wed Jun 23 12:57:26 2021 +0000 +++ b/src/vl53l1_hist_algos_gen3.c Wed Jul 21 17:06:38 2021 +0200 @@ -601,6 +601,9 @@ *pphase = VL53L1_MAX_ALLOWED_PHASE; + if (VL53L1_p_031 == 0) + return VL53L1_ERROR_DIVISION_BY_ZERO; + else for (lb = VL53L1_p_022; lb <= VL53L1_p_026; lb++) { if (lb < 0) @@ -715,7 +718,10 @@ int32_t cx = 0; - + if (VL53L1_p_031 == 0) { + *psigma_est = 0xFFFF; + return VL53L1_ERROR_DIVISION_BY_ZERO; + } i = bin % VL53L1_p_031;
--- a/src/vl53l1_hist_algos_gen4.c Wed Jun 23 12:57:26 2021 +0000 +++ b/src/vl53l1_hist_algos_gen4.c Wed Jul 21 17:06:38 2021 +0200 @@ -96,6 +96,8 @@ uint8_t p = 0; VL53L1_histogram_bin_data_t *pB = &(palgo3->VL53L1_p_010); + uint16_t enabled_spads_ninety_percent; + int32_t amb_threshold_sigma; LOG_FUNCTION_START(""); @@ -151,9 +153,16 @@ &(palgo3->VL53L1_p_038)); + amb_threshold_sigma = ppost_cfg->ambient_thresh_sigma1; + enabled_spads_ninety_percent = + presults->fmt_total_enabled_spads * 230; + if ((pbins_input->result__dss_actual_effective_spads < + enabled_spads_ninety_percent) && + (presults->VL53L1_p_002[0].ambient_count_rate_mcps < (5 * 128))){ + amb_threshold_sigma *= histo_merge_nb; + } - pdmax_cfg->ambient_thresh_sigma = - ppost_cfg->ambient_thresh_sigma1; + pdmax_cfg->ambient_thresh_sigma = amb_threshold_sigma; for (p = 0; p < VL53L1_MAX_AMBIENT_DMAX_VALUES; p++) { if (status == VL53L1_ERROR_NONE) { @@ -176,7 +185,7 @@ status = VL53L1_f_018( ppost_cfg->ambient_thresh_events_scaler, - (int32_t)ppost_cfg->ambient_thresh_sigma1, + (int32_t)amb_threshold_sigma, (int32_t)ppost_cfg->min_ambient_thresh_events, ppost_cfg->algo__crosstalk_compensation_enable, &(palgo3->VL53L1_p_010),
--- a/src/vl53l1_hist_core.c Wed Jun 23 12:57:26 2021 +0000 +++ b/src/vl53l1_hist_core.c Wed Jul 21 17:06:38 2021 +0200 @@ -381,7 +381,9 @@ period = 2048 * (uint32_t)VL53L1_decode_vcsel_period(pdata1->VL53L1_p_009); - remapped_phase = (uint32_t)pdata2->zero_distance_phase % period; + if (period != 0) + remapped_phase = + (uint32_t)pdata2->zero_distance_phase % period; phase_delta = (int32_t)pdata1->zero_distance_phase
--- a/src/vl53l1_platform.c Wed Jun 23 12:57:26 2021 +0000 +++ b/src/vl53l1_platform.c Wed Jul 21 17:06:38 2021 +0200 @@ -1,37 +1,13 @@ -/* -* This file is part of VL53L1 Platform -* -* Copyright (c) 2016, STMicroelectronics - All Rights Reserved -* -* License terms: BSD 3-clause "New" or "Revised" License. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* 1. Redistributions of source code must retain the above copyright notice, this -* list of conditions and the following disclaimer. -* -* 2. Redistributions in binary form must reproduce the above copyright notice, -* this list of conditions and the following disclaimer in the documentation -* and/or other materials provided with the distribution. -* -* 3. Neither the name of the copyright holder nor the names of its contributors -* may be used to endorse or promote products derived from this software -* without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ +// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause +/****************************************************************************** + * Copyright (c) 2020, STMicroelectronics - All Rights Reserved + + This file is part of VL53L1 and is dual licensed, + either GPL-2.0+ + or 'BSD 3-clause "New" or "Revised" License' , at your option. + ****************************************************************************** + */ unsigned int i2creadCount = 0; unsigned int i2cwriteCount = 0; @@ -40,8 +16,6 @@ #include <mbed_wait_api.h> #include "vl53l1_platform.h" -#ifndef SMALL_FOOTPRINT -#endif #include "vl53l1_platform_log.h" #include "vl53l1_api.h" #include "spi_interface.h" @@ -79,7 +53,7 @@ { int status; // printf("VL53L1_WriteMulti %d %d %d \n",Dev->I2cDevAddr,index,count); - status = v53l1x_i2c_write_if(pdata,Dev->i2c_slave_address, index,count); + status = v53l1cb_i2c_write_if(Dev->dev_i2c, pdata,Dev->i2c_slave_address, index,count); return status; } @@ -88,7 +62,7 @@ { int status; - status = v53l1x_i2c_read_if(pdata,Dev->i2c_slave_address, index,count); + status = v53l1cb_i2c_read_if(Dev->dev_i2c, pdata,Dev->i2c_slave_address, index,count); return status; } @@ -98,7 +72,7 @@ { int status; - status = v53l1x_i2c_write_if(&data,Dev->i2c_slave_address, index,1); + status = v53l1cb_i2c_write_if(Dev->dev_i2c, &data,Dev->i2c_slave_address, index,1); return status; } @@ -110,7 +84,7 @@ buffer[0] = data >> 8; buffer[1] = data & 0x00FF; - status = v53l1x_i2c_write_if((uint8_t *)buffer,Dev->i2c_slave_address, index,2); + status = v53l1cb_i2c_write_if(Dev->dev_i2c, (uint8_t *)buffer,Dev->i2c_slave_address, index,2); return status; } @@ -124,7 +98,7 @@ buffer[1] = (data >> 16) & 0xFF; buffer[2] = (data >> 8) & 0xFF; buffer[3] = (data >> 0) & 0xFF; - status = v53l1x_i2c_write_if((uint8_t *)buffer,Dev->i2c_slave_address, index,4); + status = v53l1cb_i2c_write_if(Dev->dev_i2c, (uint8_t *)buffer,Dev->i2c_slave_address, index,4); return status; } @@ -134,11 +108,11 @@ uint8_t buffer = 0; /* read data direct onto buffer */ - status = v53l1x_i2c_read_if(&buffer,Dev->i2c_slave_address, index,1); + status = v53l1cb_i2c_read_if(Dev->dev_i2c, &buffer,Dev->i2c_slave_address, index,1); if (!status) { buffer = (buffer & AndData) | OrData; - status = v53l1x_i2c_write_if(&buffer,Dev->i2c_slave_address, index,1); + status = v53l1cb_i2c_write_if(Dev->dev_i2c, &buffer,Dev->i2c_slave_address, index,1); } return status; } @@ -147,7 +121,7 @@ { int status; - status = v53l1x_i2c_read_if(data,Dev->i2c_slave_address, index,1); //is this correct + status = v53l1cb_i2c_read_if(Dev->dev_i2c, data,Dev->i2c_slave_address, index,1); //is this correct // printf("VL53L1_RdByte %d %d %d\n",Dev->i2c_slave_address, status,*data); if(status) return -1; @@ -161,7 +135,7 @@ int status; uint8_t buffer[2] = {0,0}; - status = v53l1x_i2c_read_if(buffer,Dev->i2c_slave_address, index,2); //is this correct + status = v53l1cb_i2c_read_if(Dev->dev_i2c, buffer,Dev->i2c_slave_address, index,2); //is this correct if (!status) { *data = (buffer[0] << 8) + buffer[1]; @@ -177,7 +151,7 @@ int status; uint8_t buffer[4] = {0,0,0,0}; - status = v53l1x_i2c_read_if(buffer,Dev->i2c_slave_address, index,4); + status = v53l1cb_i2c_read_if(Dev->dev_i2c, buffer,Dev->i2c_slave_address, index,4); if(!status) { *data = (buffer[0] << 24) + (buffer[1] << 16) + (buffer[2] << 8) + buffer[3]; @@ -188,12 +162,14 @@ VL53L1_Error VL53L1_GetTickCount( + VL53L1_DEV Dev, uint32_t *ptick_count_ms) { /* Returns current tick count in [ms] */ VL53L1_Error status = VL53L1_ERROR_NONE; + (void) Dev; GetTickCount( ptick_count_ms); @@ -228,7 +204,7 @@ VL53L1_Error VL53L1_WaitMs(VL53L1_Dev_t *pdev, int32_t wait_time){ (void)pdev; - wait_ms(wait_time); + wait_us(wait_time * 1000); return VL53L1_ERROR_NONE; } @@ -289,10 +265,10 @@ /* calculate time limit in absolute time */ - VL53L1_GetTickCount(&start_time_ms); + VL53L1_GetTickCount(pdev, &start_time_ms); - wait_ms(10); + VL53L1_WaitMs(pdev, 10); /* remember current trace functions and temporarily disable * function logging @@ -316,10 +292,6 @@ if ((byte_value & mask) == value) found = 1; - if (status) - { - printf("VL53L1_WaitValueMaskEx 1 %d %d\n",pdev->i2c_slave_address,status); - } if (status == VL53L1_ERROR_NONE && found == 0 && @@ -329,11 +301,7 @@ poll_delay_ms); /* Update polling time (Compare difference rather than absolute to negate 32bit wrap around issue) */ - if (status) - { - printf("VL53L1_WaitValueMaskEx 2 %d\n",status); - } - VL53L1_GetTickCount(¤t_time_ms); + VL53L1_GetTickCount(pdev, ¤t_time_ms); polling_time_ms = current_time_ms - start_time_ms; }
--- a/src/vl53l1_platform_ipp.c Wed Jun 23 12:57:26 2021 +0000 +++ b/src/vl53l1_platform_ipp.c Wed Jul 21 17:06:38 2021 +0200 @@ -1,37 +1,13 @@ -/******************************************************************************* - This file is part of VL53L1 Platform - - Copyright (c) 2020, STMicroelectronics - All Rights Reserved - - License terms: BSD 3-clause "New" or "Revised" License. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. +// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause +/****************************************************************************** + * Copyright (c) 2020, STMicroelectronics - All Rights Reserved - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - 3. Neither the name of the copyright holder nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ + This file is part of VL53L1 and is dual licensed, + either GPL-2.0+ + or 'BSD 3-clause "New" or "Revised" License' , at your option. + ****************************************************************************** + */ @@ -187,4 +163,3 @@ } -
--- a/src/vl53l1_platform_log.c Wed Jun 23 12:57:26 2021 +0000 +++ b/src/vl53l1_platform_log.c Wed Jul 21 17:06:38 2021 +0200 @@ -1,37 +1,13 @@ -/******************************************************************************* - This file is part of VL53L1 Platform - - Copyright (c) 2020, STMicroelectronics - All Rights Reserved - - License terms: BSD 3-clause "New" or "Revised" License. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. +// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause +/****************************************************************************** + * Copyright (c) 2020, STMicroelectronics - All Rights Reserved - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - 3. Neither the name of the copyright holder nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ + This file is part of VL53L1 and is dual licensed, + either GPL-2.0+ + or 'BSD 3-clause "New" or "Revised" License' , at your option. + ****************************************************************************** + */ @@ -39,7 +15,6 @@ #include <stdio.h> #include <string.h> #include <stdarg.h> -//#include <malloc.h> #include "vl53l1_platform_log.h" #include "vl53l1_platform_user_config.h" @@ -149,4 +124,3 @@ } #endif -
--- a/src/vl53l1_wait.c Wed Jun 23 12:57:26 2021 +0000 +++ b/src/vl53l1_wait.c Wed Jul 21 17:06:38 2021 +0200 @@ -390,7 +390,7 @@ - VL53L1_GetTickCount(&start_time_ms); + VL53L1_GetTickCount(Dev, &start_time_ms); pdev->fw_ready_poll_duration_ms = 0; @@ -412,7 +412,7 @@ } - VL53L1_GetTickCount(¤t_time_ms); + VL53L1_GetTickCount(Dev, ¤t_time_ms); pdev->fw_ready_poll_duration_ms = current_time_ms - start_time_ms; }