Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: VL6180_Board
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:
-
dev The 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:
-
dev The device state New 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:
-
dev The 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:
-
dev The device state New 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:
-
dev The 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:
-
dev The device low scaled low Threshold ptr can be NULL if not needed high scaled 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:
-
dev The Device ValidHeight_mm Valid height in mm (unscaled ie not raw value before scaling) IgnoreThreshold Ignore 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:
-
dev The Device EnableState Feature 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:
-
dev The device FactorM ECE factor M in M/D FactorD ECE 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:
-
dev The device enable State 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:
-
dev The device InterMeasTime_msec Requires 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:
-
dev The device low raw low threshold set to raw register high raw 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:
-
dev The device mode A 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:
-
dev The device low Low threshold in mm high High threshold in mm SafeHold Use 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:
-
dev The device MaxLoop Max 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:
-
dev The 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:
- Set Group hold : VL6180_SetGroupParamHold()
- Get Threshold VL6180_RangeGetThresholds()
- Change scaling : VL6180_UpscaleSetScaling()
- Set Threshold : VL6180_RangeSetThresholds()
- Unset Group Hold : VL6180_SetGroupParamHold()
- Set Group hold : VL6180_SetGroupParamHold()
- Parameters:
-
dev The device scaling Scaling 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.
Generated on Tue Nov 29 2022 20:47:36 by
1.7.2