ST Expansion SW Team / Vl6180

Dependencies:   VL6180_Board

Dependents:   X_NUCLEO_6180

Embed: (wiki syntax)

« Back to documentation index

Ranging functions

Ranging functions
[API Low Level Functions]

Ranging Low Level functions. More...

Functions

VL6180_API int VL6180_RangeWaitDeviceReady (VL6180Dev_t dev, int MaxLoop)
 Wait for device to be ready (before a new ranging command can be issued by application)
VL6180_API int VL6180_RangeSetInterMeasPeriod (VL6180Dev_t dev, uint32_t InterMeasTime_msec)
 Program Inter measurement period (used only in continuous mode)
VL6180_API int VL6180_UpscaleSetScaling (VL6180Dev_t dev, uint8_t scaling)
 Set device ranging scaling factor.
VL6180_API int VL6180_UpscaleGetScaling (VL6180Dev_t dev)
 Get current ranging scaling factor.
uint16_t VL6180_GetUpperLimit (VL6180Dev_t dev)
 Get the maximal distance for actual scaling.
VL6180_API int VL6180_RangeSetThresholds (VL6180Dev_t dev, uint16_t low, uint16_t high, int SafeHold)
 Apply low and high ranging thresholds that are considered only in continuous mode.
VL6180_API int VL6180_RangeGetThresholds (VL6180Dev_t dev, uint16_t *low, uint16_t *high)
 Get scaled high and low threshold from device.
VL6180_API int VL6180_RangeSetRawThresholds (VL6180Dev_t dev, uint8_t low, uint8_t high)
 Set ranging raw thresholds (scaling not considered so not recommended to use it)
VL6180_API int VL6180_RangeSetEceFactor (VL6180Dev_t dev, uint16_t FactorM, uint16_t FactorD)
 Set Early Convergence Estimate ratio.
VL6180_API int VL6180_RangeSetEceState (VL6180Dev_t dev, int enable)
 Set Early Convergence Estimate state (See SYSRANGE_RANGE_CHECK_ENABLES register)
VL6180_API int VL6180_FilterSetState (VL6180Dev_t dev, int state)
 Set activation state of the wrap around filter.
VL6180_API int VL6180_FilterGetState (VL6180Dev_t dev)
 Get activation state of the wrap around filter.
VL6180_API int VL6180_DMaxSetState (VL6180Dev_t dev, int state)
 Set activation state of DMax computation.
VL6180_API int VL6180_DMaxGetState (VL6180Dev_t dev)
 Get activation state of DMax computation.
VL6180_API int VL6180_RangeSetSystemMode (VL6180Dev_t dev, uint8_t mode)
 Set ranging mode and start/stop measure (use high level functions instead : VL6180_RangeStartSingleShot() or VL6180_RangeStartContinuousMode())
VL6180_API int VL6180_RangeIgnoreSetEnable (VL6180Dev_t dev, int EnableState)
 Enable/disable range ignore feature.
VL6180_API int VL6180_RangeIgnoreConfigure (VL6180Dev_t dev, uint16_t ValidHeight_mm, uint16_t IgnoreThreshold)
 Configure Range ignore feature.

Detailed Description

Ranging Low Level functions.


Function Documentation

VL6180_API int VL6180_DMaxGetState ( VL6180Dev_t  dev )

Get activation state of DMax computation.

Parameters:
devThe device
Returns:
Filter enabled or not, when filter is not supported it always returns 0S

Definition at line 2219 of file vl6180_api.c.

VL6180_API int VL6180_DMaxSetState ( VL6180Dev_t  dev,
int  state 
)

Set activation state of DMax computation.

Parameters:
devThe device
stateNew activation state (0=off, otherwise on)
Returns:
0 on success

Definition at line 2201 of file vl6180_api.c.

VL6180_API int VL6180_FilterGetState ( VL6180Dev_t  dev )

Get activation state of the wrap around filter.

Parameters:
devThe device
Returns:
Filter enabled or not, when filter is not supported it always returns 0S

Definition at line 664 of file vl6180_api.c.

VL6180_API int VL6180_FilterSetState ( VL6180Dev_t  dev,
int  state 
)

Set activation state of the wrap around filter.

Parameters:
devThe device
stateNew activation state (0=off, otherwise on)
Returns:
0 on success

Definition at line 650 of file vl6180_api.c.

uint16_t VL6180_GetUpperLimit ( VL6180Dev_t  dev )

Get the maximal distance for actual scaling.

Function Description
Do not use prior to VL6180_Prepare() or at least VL6180_InitData()

Any range value more than the value returned by this function is to be considered as "no target detected" or "no target in detectable range"

Warning:
The maximal distance depends on the scaling
Parameters:
devThe device
Returns:
The maximal range limit for actual mode and scaling

Definition at line 311 of file vl6180_api.c.

VL6180_API int VL6180_RangeGetThresholds ( VL6180Dev_t  dev,
uint16_t *  low,
uint16_t *  high 
)

Get scaled high and low threshold from device.

Function Description
Due to scaling factor, the returned value may be different from what has been programmed first (precision lost). For instance VL6180_RangeSetThresholds(dev,11,22) with scale 3 will read back 9 ((11/3)x3) and 21 ((22/3)x3).
Parameters:
devThe device
lowscaled low Threshold ptr can be NULL if not needed
highscaled High Threshold ptr can be NULL if not needed
Returns:
0 on success, return value is undefined if both low and high are NULL
Warning:
return value is undefined if both low and high are NULL

Definition at line 742 of file vl6180_api.c.

VL6180_API int VL6180_RangeIgnoreConfigure ( VL6180Dev_t  dev,
uint16_t  ValidHeight_mm,
uint16_t  IgnoreThreshold 
)

Configure Range ignore feature.

Function Description
When return signal rate is below the IgnoreThreshold and return distance is below the ValidHeight, the distance will be ignored
Warning:
It is recommended to enable range ignore feature and configure it only when device is in stop or idle state
Once this function is called, next call to VL6180_InitData() function without reseting the device will result in wrong ranging operation
Parameters:
devThe Device
ValidHeight_mmValid height in mm (unscaled ie not raw value before scaling)
IgnoreThresholdIgnore threshold in fixpoint 9.7 MegaCount/sec
Returns:

Definition at line 1446 of file vl6180_api.c.

VL6180_API int VL6180_RangeIgnoreSetEnable ( VL6180Dev_t  dev,
int  EnableState 
)

Enable/disable range ignore feature.

Function Description
Enable range ignore feature to ensure that the device does not range on the cover glass because of cross-talk. VL6180_RangeIgnoreConfigure() should be run first to configure feature prior to enable it.
Parameters:
devThe Device
EnableStateFeature state to set 0= off else =on
Returns:
0 on success

Definition at line 1429 of file vl6180_api.c.

VL6180_API int VL6180_RangeSetEceFactor ( VL6180Dev_t  dev,
uint16_t  FactorM,
uint16_t  FactorD 
)

Set Early Convergence Estimate ratio.

Function Description
For more information on ECE check datasheet
Warning:
May return a calibration warning in some use cases
Parameters:
devThe device
FactorMECE factor M in M/D
FactorDECE factor D in M/D
Returns:
0 on success. <0 on error. >0 on warning

Definition at line 1171 of file vl6180_api.c.

VL6180_API int VL6180_RangeSetEceState ( VL6180Dev_t  dev,
int  enable 
)

Set Early Convergence Estimate state (See SYSRANGE_RANGE_CHECK_ENABLES register)

Parameters:
devThe device
enableState to be set 0=disabled, otherwise enabled
Returns:
0 on success

Definition at line 1202 of file vl6180_api.c.

VL6180_API int VL6180_RangeSetInterMeasPeriod ( VL6180Dev_t  dev,
uint32_t  InterMeasTime_msec 
)

Program Inter measurement period (used only in continuous mode)

Function Description
When trying to set too long time, it returns INVALID_PARAMS
Parameters:
devThe device
InterMeasTime_msecRequires inter-measurement time in msec
Returns:
0 on success

Definition at line 1238 of file vl6180_api.c.

VL6180_API int VL6180_RangeSetRawThresholds ( VL6180Dev_t  dev,
uint8_t  low,
uint8_t  high 
)

Set ranging raw thresholds (scaling not considered so not recommended to use it)

Parameters:
devThe device
lowraw low threshold set to raw register
highraw high threshold set to raw register
Returns:
0 on success

Definition at line 694 of file vl6180_api.c.

VL6180_API int VL6180_RangeSetSystemMode ( VL6180Dev_t  dev,
uint8_t  mode 
)

Set ranging mode and start/stop measure (use high level functions instead : VL6180_RangeStartSingleShot() or VL6180_RangeStartContinuousMode())

Function Description
When used outside scope of known polling single shot stopped state,
user must ensure the device state is "idle" before to issue a new command.
Parameters:
devThe device
modeA combination of working mode (MODE_SINGLESHOT or MODE_CONTINUOUS) and start/stop condition (MODE_START_STOP)
Returns:
0 on success

Definition at line 1306 of file vl6180_api.c.

VL6180_API int VL6180_RangeSetThresholds ( VL6180Dev_t  dev,
uint16_t  low,
uint16_t  high,
int  SafeHold 
)

Apply low and high ranging thresholds that are considered only in continuous mode.

Function Description
This function programs low and high ranging thresholds that are considered in continuous mode : interrupt will be raised only when an object is detected at a distance inside this [low:high] range. The function takes care of applying current scaling factor if any.
To be safe, in continuous operation, thresholds must be changed under "group parameter hold" cover. Group hold can be activated/deactivated directly in the function or externally (then set 0) using /a VL6180_SetGroupParamHold() function.
Parameters:
devThe device
lowLow threshold in mm
highHigh threshold in mm
SafeHoldUse of group parameters hold to surround threshold programming.
Returns:
0 On success

Definition at line 708 of file vl6180_api.c.

VL6180_API int VL6180_RangeWaitDeviceReady ( VL6180Dev_t  dev,
int  MaxLoop 
)

Wait for device to be ready (before a new ranging command can be issued by application)

Parameters:
devThe device
MaxLoopMax Number of i2c polling loop see msec_2_i2cloop
Returns:
0 on success. <0 when fail
VL6180_ErrCode_t::TIME_OUT for time out
VL6180_ErrCode_t::INVALID_PARAMS if MaxLop<1

Definition at line 1280 of file vl6180_api.c.

VL6180_API int VL6180_UpscaleGetScaling ( VL6180Dev_t  dev )

Get current ranging scaling factor.

Parameters:
devThe device
Returns:
The current scaling factor

Definition at line 1000 of file vl6180_api.c.

VL6180_API int VL6180_UpscaleSetScaling ( VL6180Dev_t  dev,
uint8_t  scaling 
)

Set device ranging scaling factor.

Function Description
The ranging scaling factor is applied on the raw distance measured by the device to increase operating ranging at the price of the precision. Changing the scaling factor when device is not in f/w standby state (free running) is not safe. It can be source of spurious interrupt, wrongly scaled range etc ...
Warning:
__This function doesns't update high/low threshold and other programmed settings linked to scaling factor__. To ensure proper operation, threshold and scaling changes should be done following this procedure:
Parameters:
devThe device
scalingScaling factor to apply (1,2 or 3)
Returns:
0 on success when up-scale support is not configured it fail for any scaling than the one statically configured.

Definition at line 936 of file vl6180_api.c.