Macros | Functions | Variables
vl53l1_api.c File Reference
#include "vl53l1_api.h"
#include "vl53l1_api_strings.h"
#include "vl53l1_register_settings.h"
#include "vl53l1_register_funcs.h"
#include "vl53l1_core.h"
#include "vl53l1_api_calibration.h"
#include "vl53l1_wait.h"
#include "vl53l1_preset_setup.h"
#include "vl53l1_api_debug.h"
#include "vl53l1_api_core.h"
Include dependency graph for vl53l1_api.c:

Go to the source code of this file.

Macros

#define BADTHRESBOUNDS(T)
 
#define DMAX_REFLECTANCE_IDX   2
 
#define FDA_MAX_TIMING_BUDGET_US   550000
 
#define LOG_FUNCTION_END(status, ...)   _LOG_FUNCTION_END(VL53L1_TRACE_MODULE_API, status, ##__VA_ARGS__)
 
#define LOG_FUNCTION_END_FMT(status, fmt, ...)
 
#define LOG_FUNCTION_START(fmt, ...)   _LOG_FUNCTION_START(VL53L1_TRACE_MODULE_API, fmt, ##__VA_ARGS__)
 
#define LOWPOWER_AUTO_OVERHEAD_BEFORE_A_RANGING   1448
 
#define LOWPOWER_AUTO_OVERHEAD_BETWEEN_A_B_RANGING   2100
 
#define LOWPOWER_AUTO_VHV_LOOP_DURATION_US   245
 
#define MAX(v1, v2)   ((v1) < (v2) ? (v2) : (v1))
 
#define MIN(v1, v2)   ((v1) < (v2) ? (v1) : (v2))
 
#define OFFSET_CALIB
 
#define TIMED_MODE_TIMING_GUARD_MILLISECONDS   4
 
#define VL53L1_NVM_POWER_UP_DELAY_US   50
 
#define VL53L1_NVM_READ_TRIGGER_DELAY_US   5
 
#define ZONE_CHECK   5
 

Functions

static VL53L1_Error ChangePresetMode (VL53L1_DEV Dev)
 
static VL53L1_Error CheckValidRectRoi (VL53L1_UserRoi_t ROI)
 
static VL53L1_Error ComputeDevicePresetMode (VL53L1_PresetModes PresetMode, VL53L1_DistanceModes DistanceMode, VL53L1_DevicePresetModes *pDevicePresetMode)
 
static uint8_t ComputeRQL (uint8_t active_results, uint8_t FilteredRangeStatus, VL53L1_range_data_t *presults_data)
 
static VL53L1_ThresholdMode ConvertModeFromLLD (VL53L1_Error *pStatus, VL53L1_GPIO_Interrupt_Mode CrossMode)
 
static VL53L1_GPIO_Interrupt_Mode ConvertModeToLLD (VL53L1_Error *pStatus, VL53L1_ThresholdMode CrossMode)
 
static uint8_t ConvertStatusLite (uint8_t FilteredRangeStatus)
 
static VL53L1_Error SetLimitValue (VL53L1_DEV Dev, uint16_t LimitCheckId, FixPoint1616_t value)
 
static VL53L1_Error SetPresetMode (VL53L1_DEV Dev, VL53L1_PresetModes PresetMode, VL53L1_DistanceModes DistanceMode, uint32_t inter_measurement_period_ms)
 
static VL53L1_Error SetSimpleData (VL53L1_DEV Dev, uint8_t active_results, uint8_t device_status, VL53L1_range_data_t *presults_data, VL53L1_RangingMeasurementData_t *pRangeData)
 
static VL53L1_Error SingleTargetXTalkCalibration (VL53L1_DEV Dev)
 
VL53L1_Error VL53L1_ClearInterruptAndStartMeasurement (VL53L1_DEV Dev)
 Clear the Interrupt flag and start new measurement *. More...
 
VL53L1_Error VL53L1_DataInit (VL53L1_DEV Dev)
 One time device initialization. More...
 
VL53L1_Error VL53L1_GetCalibrationData (VL53L1_DEV Dev, VL53L1_CalibrationData_t *pCalibrationData)
 Gets the Calibration Data. More...
 
VL53L1_Error VL53L1_GetDeviceInfo (VL53L1_DEV Dev, VL53L1_DeviceInfo_t *pVL53L1_DeviceInfo)
 Reads the Device information for given Device. More...
 
VL53L1_Error VL53L1_GetDistanceMode (VL53L1_DEV Dev, VL53L1_DistanceModes *pDistanceMode)
 Get the distance mode. More...
 
VL53L1_Error VL53L1_GetInterMeasurementPeriodMilliSeconds (VL53L1_DEV Dev, uint32_t *pInterMeasurementPeriodMilliSeconds)
 
VL53L1_Error VL53L1_GetLimitCheckCurrent (VL53L1_DEV Dev, uint16_t LimitCheckId, FixPoint1616_t *pLimitCheckCurrent)
 Get the current value of the signal used for the limit check. More...
 
VL53L1_Error VL53L1_GetLimitCheckEnable (VL53L1_DEV Dev, uint16_t LimitCheckId, uint8_t *pLimitCheckEnable)
 Get specific limit check enable state. More...
 
VL53L1_Error VL53L1_GetLimitCheckInfo (uint16_t LimitCheckId, char *pLimitCheckString)
 Return a description string for a given limit check number. More...
 
VL53L1_Error VL53L1_GetLimitCheckStatus (VL53L1_DEV Dev, uint16_t LimitCheckId, uint8_t *pLimitCheckStatus)
 Return a the Status of the specified check limit. More...
 
VL53L1_Error VL53L1_GetLimitCheckValue (VL53L1_DEV Dev, uint16_t LimitCheckId, FixPoint1616_t *pLimitCheckValue)
 Get a specific limit check value. More...
 
VL53L1_Error VL53L1_GetMeasurementDataReady (VL53L1_DEV Dev, uint8_t *pMeasurementDataReady)
 Return Measurement Data Ready. More...
 
VL53L1_Error VL53L1_GetMeasurementTimingBudgetMicroSeconds (VL53L1_DEV Dev, uint32_t *pMeasurementTimingBudgetMicroSeconds)
 Get Ranging Timing Budget in microseconds. More...
 
VL53L1_Error VL53L1_GetNumberOfLimitCheck (uint16_t *pNumberOfLimitCheck)
 Get the number of the check limit managed by a given Device. More...
 
VL53L1_Error VL53L1_GetNumberOfSequenceSteps (VL53L1_DEV Dev, uint8_t *pNumberOfSequenceSteps)
 Gets number of sequence steps managed by the API. More...
 
VL53L1_Error VL53L1_GetOpticalCenter (VL53L1_DEV Dev, FixPoint1616_t *pOpticalCenterX, FixPoint1616_t *pOpticalCenterY)
 Gets the optical center. More...
 
VL53L1_Error VL53L1_GetPalErrorString (VL53L1_Error PalErrorCode, char *pPalErrorString)
 Human readable error string for driver error status. More...
 
VL53L1_Error VL53L1_GetPalState (VL53L1_DEV Dev, VL53L1_State *pPalState)
 Reads the internal state of the driver for a given Device. More...
 
VL53L1_Error VL53L1_GetPalStateString (VL53L1_State PalStateCode, char *pPalStateString)
 Human readable driver State string. More...
 
VL53L1_Error VL53L1_GetPresetMode (VL53L1_DEV Dev, VL53L1_PresetModes *pPresetMode)
 Get current Preset Mode. More...
 
VL53L1_Error VL53L1_GetProductRevision (VL53L1_DEV Dev, uint8_t *pProductRevisionMajor, uint8_t *pProductRevisionMinor)
 Reads the Product Revision for a for given Device This function can be used to distinguish cut1.0 from cut1.1. More...
 
VL53L1_Error VL53L1_GetRangeStatusString (uint8_t RangeStatus, char *pRangeStatusString)
 Human readable Range Status string for a given RangeStatus. More...
 
VL53L1_Error VL53L1_GetRangingMeasurementData (VL53L1_DEV Dev, VL53L1_RangingMeasurementData_t *pRangingMeasurementData)
 Retrieve the measurements from device for a given setup. More...
 
VL53L1_Error VL53L1_GetSequenceStepEnable (VL53L1_DEV Dev, VL53L1_SequenceStepId SequenceStepId, uint8_t *pSequenceStepEnabled)
 Gets the (on/off) state of a requested sequence step. More...
 
VL53L1_Error VL53L1_GetSequenceStepsInfo (VL53L1_SequenceStepId SequenceStepId, char *pSequenceStepsString)
 Gets the name of a given sequence step. More...
 
VL53L1_Error VL53L1_GetThresholdConfig (VL53L1_DEV Dev, VL53L1_DetectionConfig_t *pConfig)
 Retrieves the interrupt config structure currently programmed into the API. More...
 
VL53L1_Error VL53L1_GetTuningParameter (VL53L1_DEV Dev, uint16_t TuningParameterId, int32_t *pTuningParameterValue)
 Get Tuning Parameter value for a given parameter ID. More...
 
VL53L1_Error VL53L1_GetUserROI (VL53L1_DEV Dev, VL53L1_UserRoi_t *pRoi)
 Get the ROI managed by the Device. More...
 
VL53L1_Error VL53L1_GetVersion (VL53L1_Version_t *pVersion)
 Return the VL53L1 driver Version. More...
 
VL53L1_Error VL53L1_GetXTalkCompensationEnable (VL53L1_DEV Dev, uint8_t *pXTalkCompensationEnable)
 Get Cross talk compensation rate enable. More...
 
static VL53L1_Error VL53L1_nvm_disable (VL53L1_DEV Dev)
 
static VL53L1_Error VL53L1_nvm_enable (VL53L1_DEV Dev, uint16_t nvm_ctrl_pulse_width, int32_t nvm_power_up_delay_us)
 
static VL53L1_Error VL53L1_nvm_read (VL53L1_DEV Dev, uint8_t start_address, uint8_t count, uint8_t *pdata)
 
VL53L1_Error VL53L1_PerformOffsetCalibration (VL53L1_DEV Dev, int32_t CalDistanceMilliMeter)
 Perform Offset Calibration. More...
 
VL53L1_Error VL53L1_PerformOffsetSimpleCalibration (VL53L1_DEV Dev, int32_t CalDistanceMilliMeter)
 Perform Offset simple Calibration. More...
 
VL53L1_Error VL53L1_PerformRefSpadManagement (VL53L1_DEV Dev)
 Performs Reference Spad Management. More...
 
VL53L1_Error VL53L1_PerformSingleTargetXTalkCalibration (VL53L1_DEV Dev, int32_t CalDistanceMilliMeter)
 Perform XTalk Calibration. More...
 
static VL53L1_Error VL53L1_read_nvm_raw_data (VL53L1_DEV Dev, uint8_t start_address, uint8_t count, uint8_t *pnvm_raw_data)
 
VL53L1_Error VL53L1_SetCalibrationData (VL53L1_DEV Dev, VL53L1_CalibrationData_t *pCalibrationData)
 Sets the Calibration Data. More...
 
VL53L1_Error VL53L1_SetDeviceAddress (VL53L1_DEV Dev, uint8_t DeviceAddress)
 Set new device address. More...
 
VL53L1_Error VL53L1_SetDistanceMode (VL53L1_DEV Dev, VL53L1_DistanceModes DistanceMode)
 Set the distance mode. More...
 
VL53L1_Error VL53L1_SetInterMeasurementPeriodMilliSeconds (VL53L1_DEV Dev, uint32_t InterMeasurementPeriodMilliSeconds)
 
VL53L1_Error VL53L1_SetLimitCheckEnable (VL53L1_DEV Dev, uint16_t LimitCheckId, uint8_t LimitCheckEnable)
 Enable/Disable a specific limit check. More...
 
VL53L1_Error VL53L1_SetLimitCheckValue (VL53L1_DEV Dev, uint16_t LimitCheckId, FixPoint1616_t LimitCheckValue)
 Set a specific limit check value. More...
 
VL53L1_Error VL53L1_SetMeasurementTimingBudgetMicroSeconds (VL53L1_DEV Dev, uint32_t MeasurementTimingBudgetMicroSeconds)
 Set Ranging Timing Budget in microseconds. More...
 
VL53L1_Error VL53L1_SetOffsetCalibrationMode (VL53L1_DEV Dev, VL53L1_OffsetCalibrationModes OffsetCalibrationMode)
 Define the mode to be used for the offset calibration. More...
 
VL53L1_Error VL53L1_SetPresetMode (VL53L1_DEV Dev, VL53L1_PresetModes PresetMode)
 Set a new Preset Mode. More...
 
VL53L1_Error VL53L1_SetSequenceStepEnable (VL53L1_DEV Dev, VL53L1_SequenceStepId SequenceStepId, uint8_t SequenceStepEnabled)
 Sets the (on/off) state of a requested sequence step. More...
 
VL53L1_Error VL53L1_SetThresholdConfig (VL53L1_DEV Dev, VL53L1_DetectionConfig_t *pConfig)
 Configure the interrupt config, from the given structure. More...
 
VL53L1_Error VL53L1_SetTuningParameter (VL53L1_DEV Dev, uint16_t TuningParameterId, int32_t TuningParameterValue)
 Set Tuning Parameter value for a given parameter ID. More...
 
VL53L1_Error VL53L1_SetUserROI (VL53L1_DEV Dev, VL53L1_UserRoi_t *pRoi)
 Set the ROI to be used for ranging. More...
 
VL53L1_Error VL53L1_SetXTalkCompensationEnable (VL53L1_DEV Dev, uint8_t XTalkCompensationEnable)
 Enable/Disable Cross talk compensation feature. More...
 
VL53L1_Error VL53L1_StartMeasurement (VL53L1_DEV Dev)
 Start device measurement. More...
 
VL53L1_Error VL53L1_StaticInit (VL53L1_DEV Dev)
 Do basic device init (and eventually patch loading) This function will change the VL53L1_State from VL53L1_STATE_WAIT_STATICINIT to VL53L1_STATE_IDLE. In this stage all default setting will be applied. More...
 
VL53L1_Error VL53L1_StopMeasurement (VL53L1_DEV Dev)
 Stop device measurement. More...
 
VL53L1_Error VL53L1_WaitDeviceBooted (VL53L1_DEV Dev)
 Wait for device booted after chip enable (hardware standby) This function can be run only when VL53L1_State is VL53L1_STATE_POWERDOWN. More...
 
VL53L1_Error VL53L1_WaitMeasurementDataReady (VL53L1_DEV Dev)
 Wait for measurement data ready. Blocking function. Note that the timeout is given by: VL53L1_RANGE_COMPLETION_POLLING_TIMEOUT_MS defined in def.h. More...
 

Variables

static int32_t BDTable [VL53L1_TUNING_MAX_TUNABLE_KEY]
 

Macro Definition Documentation

◆ BADTHRESBOUNDS

#define BADTHRESBOUNDS (   T)
Value:
(((T.CrossMode == VL53L1_THRESHOLD_OUT_OF_WINDOW) || \
(T.CrossMode == VL53L1_THRESHOLD_IN_WINDOW)) && (T.Low > T.High))

◆ DMAX_REFLECTANCE_IDX

#define DMAX_REFLECTANCE_IDX   2

Definition at line 112 of file vl53l1_api.c.

◆ FDA_MAX_TIMING_BUDGET_US

#define FDA_MAX_TIMING_BUDGET_US   550000

Definition at line 122 of file vl53l1_api.c.

◆ LOG_FUNCTION_END

#define LOG_FUNCTION_END (   status,
  ... 
)    _LOG_FUNCTION_END(VL53L1_TRACE_MODULE_API, status, ##__VA_ARGS__)

Definition at line 93 of file vl53l1_api.c.

◆ LOG_FUNCTION_END_FMT

#define LOG_FUNCTION_END_FMT (   status,
  fmt,
  ... 
)
Value:
_LOG_FUNCTION_END_FMT(VL53L1_TRACE_MODULE_API, status, \
fmt, ##__VA_ARGS__)

Definition at line 95 of file vl53l1_api.c.

◆ LOG_FUNCTION_START

#define LOG_FUNCTION_START (   fmt,
  ... 
)    _LOG_FUNCTION_START(VL53L1_TRACE_MODULE_API, fmt, ##__VA_ARGS__)

Definition at line 91 of file vl53l1_api.c.

◆ LOWPOWER_AUTO_OVERHEAD_BEFORE_A_RANGING

#define LOWPOWER_AUTO_OVERHEAD_BEFORE_A_RANGING   1448

Definition at line 119 of file vl53l1_api.c.

◆ LOWPOWER_AUTO_OVERHEAD_BETWEEN_A_B_RANGING

#define LOWPOWER_AUTO_OVERHEAD_BETWEEN_A_B_RANGING   2100

Definition at line 120 of file vl53l1_api.c.

◆ LOWPOWER_AUTO_VHV_LOOP_DURATION_US

#define LOWPOWER_AUTO_VHV_LOOP_DURATION_US   245

Definition at line 118 of file vl53l1_api.c.

◆ MAX

#define MAX (   v1,
  v2 
)    ((v1) < (v2) ? (v2) : (v1))

Definition at line 109 of file vl53l1_api.c.

◆ MIN

#define MIN (   v1,
  v2 
)    ((v1) < (v2) ? (v1) : (v2))

Definition at line 106 of file vl53l1_api.c.

◆ OFFSET_CALIB

#define OFFSET_CALIB

Definition at line 88 of file vl53l1_api.c.

◆ TIMED_MODE_TIMING_GUARD_MILLISECONDS

#define TIMED_MODE_TIMING_GUARD_MILLISECONDS   4

◆ VL53L1_NVM_POWER_UP_DELAY_US

#define VL53L1_NVM_POWER_UP_DELAY_US   50

Definition at line 141 of file vl53l1_api.c.

◆ VL53L1_NVM_READ_TRIGGER_DELAY_US

#define VL53L1_NVM_READ_TRIGGER_DELAY_US   5

Definition at line 142 of file vl53l1_api.c.

◆ ZONE_CHECK

#define ZONE_CHECK   5

Definition at line 76 of file vl53l1_api.c.

Function Documentation

◆ ChangePresetMode()

static VL53L1_Error ChangePresetMode ( VL53L1_DEV  Dev)
static

Definition at line 1810 of file vl53l1_api.c.

◆ CheckValidRectRoi()

static VL53L1_Error CheckValidRectRoi ( VL53L1_UserRoi_t  ROI)
static

Definition at line 541 of file vl53l1_api.c.

◆ ComputeDevicePresetMode()

static VL53L1_Error ComputeDevicePresetMode ( VL53L1_PresetModes  PresetMode,
VL53L1_DistanceModes  DistanceMode,
VL53L1_DevicePresetModes pDevicePresetMode 
)
static

Definition at line 856 of file vl53l1_api.c.

◆ ComputeRQL()

static uint8_t ComputeRQL ( uint8_t  active_results,
uint8_t  FilteredRangeStatus,
VL53L1_range_data_t presults_data 
)
static

Definition at line 1942 of file vl53l1_api.c.

◆ ConvertModeFromLLD()

static VL53L1_ThresholdMode ConvertModeFromLLD ( VL53L1_Error pStatus,
VL53L1_GPIO_Interrupt_Mode  CrossMode 
)
static

Definition at line 585 of file vl53l1_api.c.

◆ ConvertModeToLLD()

static VL53L1_GPIO_Interrupt_Mode ConvertModeToLLD ( VL53L1_Error pStatus,
VL53L1_ThresholdMode  CrossMode 
)
static

Definition at line 559 of file vl53l1_api.c.

◆ ConvertStatusLite()

static uint8_t ConvertStatusLite ( uint8_t  FilteredRangeStatus)
static

Definition at line 1988 of file vl53l1_api.c.

◆ SetLimitValue()

static VL53L1_Error SetLimitValue ( VL53L1_DEV  Dev,
uint16_t  LimitCheckId,
FixPoint1616_t  value 
)
static

Definition at line 1404 of file vl53l1_api.c.

◆ SetPresetMode()

static VL53L1_Error SetPresetMode ( VL53L1_DEV  Dev,
VL53L1_PresetModes  PresetMode,
VL53L1_DistanceModes  DistanceMode,
uint32_t  inter_measurement_period_ms 
)
static

Definition at line 915 of file vl53l1_api.c.

◆ SetSimpleData()

static VL53L1_Error SetSimpleData ( VL53L1_DEV  Dev,
uint8_t  active_results,
uint8_t  device_status,
VL53L1_range_data_t presults_data,
VL53L1_RangingMeasurementData_t pRangeData 
)
static

Definition at line 2029 of file vl53l1_api.c.

◆ SingleTargetXTalkCalibration()

static VL53L1_Error SingleTargetXTalkCalibration ( VL53L1_DEV  Dev)
static

Definition at line 390 of file vl53l1_api.c.

◆ VL53L1_nvm_disable()

static VL53L1_Error VL53L1_nvm_disable ( VL53L1_DEV  Dev)
static

Definition at line 299 of file vl53l1_api.c.

◆ VL53L1_nvm_enable()

static VL53L1_Error VL53L1_nvm_enable ( VL53L1_DEV  Dev,
uint16_t  nvm_ctrl_pulse_width,
int32_t  nvm_power_up_delay_us 
)
static

Definition at line 144 of file vl53l1_api.c.

◆ VL53L1_nvm_read()

static VL53L1_Error VL53L1_nvm_read ( VL53L1_DEV  Dev,
uint8_t  start_address,
uint8_t  count,
uint8_t pdata 
)
static

Definition at line 228 of file vl53l1_api.c.

◆ VL53L1_read_nvm_raw_data()

static VL53L1_Error VL53L1_read_nvm_raw_data ( VL53L1_DEV  Dev,
uint8_t  start_address,
uint8_t  count,
uint8_t pnvm_raw_data 
)
static

Definition at line 340 of file vl53l1_api.c.

Variable Documentation

◆ BDTable

TUNING_PROXY_MIN
#define TUNING_PROXY_MIN
Definition: vl53l1_preset_setup.h:89
TUNING_XTALK_FULL_ROI_TARGET_DISTANCE_MM
#define TUNING_XTALK_FULL_ROI_TARGET_DISTANCE_MM
Definition: vl53l1_preset_setup.h:98
VL53L1_THRESHOLD_IN_WINDOW
#define VL53L1_THRESHOLD_IN_WINDOW
Definition: vl53l1_def.h:224
VL53L1_THRESHOLD_OUT_OF_WINDOW
#define VL53L1_THRESHOLD_OUT_OF_WINDOW
Definition: vl53l1_def.h:221
TUNING_SIMPLE_OFFSET_CALIBRATION_REPEAT
#define TUNING_SIMPLE_OFFSET_CALIBRATION_REPEAT
Definition: vl53l1_preset_setup.h:100
TUNING_MAX_SIMPLE_OFFSET_CALIBRATION_SAMPLE_NUMBER
#define TUNING_MAX_SIMPLE_OFFSET_CALIBRATION_SAMPLE_NUMBER
Definition: vl53l1_preset_setup.h:96
TUNING_SINGLE_TARGET_XTALK_SAMPLE_NUMBER
#define TUNING_SINGLE_TARGET_XTALK_SAMPLE_NUMBER
Definition: vl53l1_preset_setup.h:92
TUNING_VERSION
#define TUNING_VERSION
Definition: vl53l1_preset_setup.h:87
_LOG_FUNCTION_END_FMT
#define _LOG_FUNCTION_END_FMT(module, status, fmt,...)
Definition: vl53l1_platform_log.h:250
TUNING_MIN_AMBIENT_DMAX_VALID
#define TUNING_MIN_AMBIENT_DMAX_VALID
Definition: vl53l1_preset_setup.h:94
TUNING_SINGLE_TARGET_XTALK_TARGET_DISTANCE_MM
#define TUNING_SINGLE_TARGET_XTALK_TARGET_DISTANCE_MM
Definition: vl53l1_preset_setup.h:90


vl53l1x
Author(s):
autogenerated on Fri Aug 2 2024 08:35:54