70 #ifndef VL53L1X_I2C_LEVEL
71 #define VL53L1X_I2C_LEVEL I2C_2V8
76 uint8_t VL51L1X_NVM_CONFIGURATION[] = {
208 static const uint8_t status_rtn[24] = { 255, 255, 255, 5, 2, 4, 1, 7, 3, 0,
209 255, 255, 9, 13, 255, 255, 255, 255, 10, 6,
213 #if VL53L1X_AUTO_INCR_ADDR
234 if (!
status) {
dev->i2c_trans.slave_addr = new_address; }
243 for (Addr = 0x2D; Addr <= 0x87; Addr++) {
255 #if VL53L1X_AUTO_INCR_ADDR
304 *pInterruptPolarity = !(Temp >> 4);
334 if ((Temp & 1) == IntPol) {
351 }
else if (DM == 1) {
352 switch (TimingBudgetInMs) {
400 switch (TimingBudgetInMs) {
469 *pTimingBudget = 100;
473 *pTimingBudget = 200;
477 *pTimingBudget = 500;
528 if (TempDM == 0x14) {
531 if (TempDM == 0x0A) {
543 ClockPLL = ClockPLL & 0x3FF;
545 (
uint32_t)(ClockPLL * InterMeasMs * 1.075));
559 ClockPLL = ClockPLL & 0x3FF;
560 *pIM = (
uint16_t)(*pIM / (ClockPLL * 1.065));
604 *signalRate = (
uint16_t)(2000.0 * signal / SpNb);
615 *ambPerSp = (
uint16_t)(2000.0 * AmbientRate / SpNb);
672 RgSt = Temp[0] & 0x1F;
677 pResult->
Ambient = (Temp[7] << 8 | Temp[8]) * 8;
679 pResult->
SigPerSPAD = (Temp[15] << 8 | Temp[16]) * 8;
680 pResult->
Distance = Temp[13] << 8 | Temp[14];
690 Temp = (OffsetValue * 4);
721 (XtalkValue << 9) / 1000);
731 *xtalk = (
uint16_t)(tmp * 1000) >> 9;
744 if (IntOnNoTarget == 0) {
746 (Temp | (Window & 0x07)));
749 ((Temp | (Window & 0x07)) | 0x40));
813 if (
X > 10 ||
Y > 10) {
818 (
Y - 1) << 4 | (
X - 1));
828 *ROI_X = ((
uint16_t)tmp & 0x0F) + 1;
829 *ROI_Y = (((
uint16_t)tmp & 0xF0) >> 4) + 1;
856 if (Sigma > (0xFFFF >> 2)) {
static const float offset[]
static const struct usb_device_descriptor dev
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
short int16_t
Typedef defining 16 bit short type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
VL53L1X_ERROR VL53L1X_GetROI_XY(VL53L1_DEV dev, uint16_t *ROI_X, uint16_t *ROI_Y)
This function returns width X and height Y.
#define VL53L1X_I2C_LEVEL
VL53L1X_ERROR VL53L1X_SensorInit(VL53L1_DEV dev)
This function loads the 135 bytes default values to initialize the sensor.
VL53L1X_ERROR VL53L1X_GetAmbientRate(VL53L1_DEV dev, uint16_t *ambRate)
This function returns the ambient rate in kcps.
VL53L1X_ERROR VL53L1X_SetSigmaThreshold(VL53L1_DEV dev, uint16_t Sigma)
This function programs a new sigma threshold in mm (default=15 mm)
VL53L1X_ERROR VL53L1X_GetTimingBudgetInMs(VL53L1_DEV dev, uint16_t *pTimingBudget)
This function returns the current timing budget in ms.
VL53L1X_ERROR VL53L1X_SetOffset(VL53L1_DEV dev, int16_t OffsetValue)
This function programs the offset correction in mm.
VL53L1X_ERROR VL53L1X_GetSignalRate(VL53L1_DEV dev, uint16_t *signal)
This function returns the returned signal in kcps.
VL53L1X_ERROR VL53L1X_SetInterMeasurementInMs(VL53L1_DEV dev, uint32_t InterMeasMs)
This function programs the Intermeasurement period in ms Intermeasurement period must be >/= timing b...
VL53L1X_ERROR VL53L1X_BootState(VL53L1_DEV dev, uint8_t *state)
This function returns the boot state of the device (1:booted, 0:not booted)
VL53L1X_ERROR VL53L1X_GetDistanceThresholdWindow(VL53L1_DEV dev, uint16_t *window)
This function returns the window detection mode (0=below; 1=above; 2=out; 3=in)
VL53L1X_ERROR VL53L1X_SetDistanceMode(VL53L1_DEV dev, uint16_t DM)
This function programs the distance mode (1=short, 2=long(default)).
VL53L1X_ERROR VL53L1X_SetInterruptPolarity(VL53L1_DEV dev, uint8_t NewPolarity)
This function programs the interrupt polarity 1=active high (default), 0=active low.
VL53L1X_ERROR VL53L1X_GetAmbientPerSpad(VL53L1_DEV dev, uint16_t *ambPerSp)
This function returns the ambient per SPAD in kcps/SPAD.
const uint8_t VL51L1X_DEFAULT_CONFIGURATION[]
VL53L1X_ERROR VL53L1X_CheckForDataReady(VL53L1_DEV dev, uint8_t *isDataReady)
This function checks if the new ranging data is available by polling the dedicated register.
VL53L1X_ERROR VL53L1X_SetXtalk(VL53L1_DEV dev, uint16_t XtalkValue)
This function programs the xtalk correction value in cps (Count Per Second).
VL53L1X_ERROR VL53L1X_SetROICenter(VL53L1_DEV dev, uint8_t ROICenter)
This function programs the new user ROI center, please to be aware that there is no check in this fun...
void VL53L1X_BootDevice(VL53L1_DEV dev, uint16_t TimingBudgetInMs, uint16_t DistanceMode, uint32_t InterMeasurementInMs)
Implement boot sequence of VL53L1 device as described in documentation See VL53L1X_SetTimingBudgetInM...
VL53L1X_ERROR VL53L1X_SetI2CAddress(VL53L1_DEV dev, uint8_t new_address)
This function sets the sensor I2C address used in case multiple devices application,...
VL53L1X_ERROR VL53L1X_GetInterruptPolarity(VL53L1_DEV dev, uint8_t *pInterruptPolarity)
This function returns the current interrupt polarity 1=active high (default), 0=active low.
VL53L1X_ERROR VL53L1X_GetRangeStatus(VL53L1_DEV dev, uint8_t *rangeStatus)
This function returns the ranging status error (0:no error, 1:sigma failed, 2:signal failed,...
VL53L1X_ERROR VL53L1X_StartRanging(VL53L1_DEV dev)
This function starts the ranging distance operation The ranging operation is continuous.
VL53L1X_ERROR VL53L1X_GetResult(VL53L1_DEV dev, VL53L1X_Result_t *pResult)
This function returns measurements and the range status in a single read access.
VL53L1X_ERROR VL53L1X_GetSensorId(VL53L1_DEV dev, uint16_t *sensorId)
This function returns the sensor id, sensor Id must be 0xEEAC.
VL53L1X_ERROR VL53L1X_GetDistanceThresholdLow(VL53L1_DEV dev, uint16_t *low)
This function returns the low threshold in mm.
VL53L1X_ERROR VL53L1X_GetSignalThreshold(VL53L1_DEV dev, uint16_t *signal)
This function returns the current signal threshold in kcps.
VL53L1X_ERROR VL53L1X_GetSignalPerSpad(VL53L1_DEV dev, uint16_t *signalRate)
This function returns the returned signal per SPAD in kcps/SPAD.
VL53L1X_ERROR VL53L1X_GetOffset(VL53L1_DEV dev, int16_t *offset)
This function returns the programmed offset correction value in mm.
VL53L1X_ERROR VL53L1X_GetSWVersion(VL53L1X_Version_t *pVersion)
This function returns the SW driver version.
VL53L1X_ERROR VL53L1X_SetTimingBudgetInMs(VL53L1_DEV dev, uint16_t TimingBudgetInMs)
This function programs the timing budget in ms.
static const uint8_t status_rtn[24]
VL53L1X_ERROR VL53L1X_SetDistanceThreshold(VL53L1_DEV dev, uint16_t ThreshLow, uint16_t ThreshHigh, uint8_t Window, uint8_t IntOnNoTarget)
This function programs the threshold detection mode Example: VL53L1X_SetDistanceThreshold(dev,...
VL53L1X_ERROR VL53L1X_GetInterMeasurementInMs(VL53L1_DEV dev, uint16_t *pIM)
This function returns the Intermeasurement period in ms.
VL53L1X_ERROR VL53L1X_StopRanging(VL53L1_DEV dev)
This function stops the ranging.
VL53L1X_ERROR VL53L1X_GetROICenter(VL53L1_DEV dev, uint8_t *ROICenter)
This function returns the current user ROI center.
VL53L1X_ERROR VL53L1X_GetSigmaThreshold(VL53L1_DEV dev, uint16_t *sigma)
This function returns the current sigma threshold in mm.
VL53L1X_ERROR VL53L1X_SetSignalThreshold(VL53L1_DEV dev, uint16_t Signal)
This function programs a new signal threshold in kcps (default=1024 kcps .
VL53L1X_ERROR VL53L1X_GetDistanceMode(VL53L1_DEV dev, uint16_t *DM)
This function returns the current distance mode (1=short, 2=long).
VL53L1X_ERROR VL53L1X_SetROI(VL53L1_DEV dev, uint16_t X, uint16_t Y)
This function programs the ROI (Region of Interest) The ROI position is centered, only the ROI size c...
VL53L1X_ERROR VL53L1X_GetSpadNb(VL53L1_DEV dev, uint16_t *spNb)
This function returns the current number of enabled SPADs.
VL53L1X_ERROR VL53L1X_ClearInterrupt(VL53L1_DEV dev)
This function clears the interrupt, to be called after a ranging data reading to arm the interrupt fo...
VL53L1X_ERROR VL53L1X_GetXtalk(VL53L1_DEV dev, uint16_t *xtalk)
This function returns the current programmed xtalk correction value in cps.
VL53L1X_ERROR VL53L1X_GetDistanceThresholdHigh(VL53L1_DEV dev, uint16_t *high)
This function returns the high threshold in mm.
VL53L1X_ERROR VL53L1X_GetDistance(VL53L1_DEV dev, uint16_t *distance)
This function returns the distance measured by the sensor in mm.
VL53L1X_ERROR VL53L1X_StartTemperatureUpdate(VL53L1_DEV dev)
This function performs the temperature calibration.
#define SYSTEM__INTERRUPT_CLEAR
#define RANGE_CONFIG__TIMEOUT_MACROP_A_HI
#define VL53L1_FIRMWARE__SYSTEM_STATUS
#define VL53L1_VHV_CONFIG__TIMEOUT_MACROP_LOOP_BOUND
#define RANGE_CONFIG__VCSEL_PERIOD_A
#define ALGO__CROSSTALK_COMPENSATION_Y_PLANE_GRADIENT_KCPS
#define ROI_CONFIG__USER_ROI_REQUESTED_GLOBAL_XY_SIZE
#define GPIO__TIO_HV_STATUS
#define ALGO__PART_TO_PART_RANGE_OFFSET_MM
#define MM_CONFIG__OUTER_OFFSET_MM
#define VL53L1X_IMPLEMENTATION_VER_MAJOR
#define ALGO__CROSSTALK_COMPENSATION_PLANE_OFFSET_KCPS
#define SD_CONFIG__WOI_SD0
#define VL53L1_IDENTIFICATION__MODEL_ID
#define ROI_CONFIG__USER_ROI_CENTRE_SPAD
#define VL53L1_RESULT__RANGE_STATUS
#define VL53L1_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0
#define VL53L1_RESULT__OSC_CALIBRATE_VAL
#define MM_CONFIG__INNER_OFFSET_MM
#define RESULT__AMBIENT_COUNT_RATE_MCPS_SD
#define SYSTEM__INTERRUPT_CONFIG_GPIO
#define SYSTEM__THRESH_LOW
#define SYSTEM__MODE_START
#define SYSTEM__THRESH_HIGH
#define VL53L1_RESULT__PEAK_SIGNAL_COUNT_RATE_CROSSTALK_CORRECTED_MCPS_SD0
#define RANGE_CONFIG__MIN_COUNT_RATE_RTN_LIMIT_MCPS
#define RANGE_CONFIG__VCSEL_PERIOD_B
#define PHASECAL_CONFIG__TIMEOUT_MACROP
#define RANGE_CONFIG__SIGMA_THRESH
#define VL53L1X_IMPLEMENTATION_VER_SUB
#define GPIO_HV_MUX__CTRL
#define RANGE_CONFIG__VALID_PHASE_HIGH
#define RANGE_CONFIG__TIMEOUT_MACROP_B_HI
#define SD_CONFIG__INITIAL_PHASE_SD0
#define VL53L1X_IMPLEMENTATION_VER_MINOR
#define VL53L1X_IMPLEMENTATION_VER_REVISION
#define VL53L1_I2C_SLAVE__DEVICE_ADDRESS
#define ALGO__CROSSTALK_COMPENSATION_X_PLANE_GRADIENT_KCPS
#define VL53L1_ROI_CONFIG__MODE_ROI_CENTRE_SPAD
#define VL53L1_RESULT__DSS_ACTUAL_EFFECTIVE_SPADS_SD0
#define VL53L1_SYSTEM__INTERMEASUREMENT_PERIOD
defines packed reading results type