ST Expansion SW Team / Vl6180

Dependencies:   VL6180_Board

Dependents:   X_NUCLEO_6180

Embed: (wiki syntax)

« Back to documentation index

Ranging functions

Ranging functions
[API High Level Functions]

Ranging functions. More...

Functions

VL6180_API int VL6180_RangeStartContinuousMode (VL6180Dev_t dev)
 Start continuous ranging mode.
VL6180_API int VL6180_RangeStartSingleShot (VL6180Dev_t dev)
 Start single shot ranging measure.
VL6180_API int VL6180_RangeSetMaxConvergenceTime (VL6180Dev_t dev, uint8_t MaxConTime_msec)
 Set maximum convergence time.
VL6180_API int VL6180_RangePollMeasurement (VL6180Dev_t dev, VL6180_RangeData_t *pRangeData)
 Single shot Range measurement in polling mode.
VL6180_API int VL6180_RangeGetMeasurementIfReady (VL6180Dev_t dev, VL6180_RangeData_t *pRangeData)
 Check for measure readiness and get it if ready.
VL6180_API int VL6180_RangeGetMeasurement (VL6180Dev_t dev, VL6180_RangeData_t *pRangeData)
 Retrieve range measurements set from device.
VL6180_API int VL6180_RangeGetResult (VL6180Dev_t dev, int32_t *pRange_mm)
 Get ranging result and only that.
VL6180_API int VL6180_RangeConfigInterrupt (VL6180Dev_t dev, uint8_t ConfigGpioInt)
 Configure ranging interrupt reported to application.
VL6180_API int VL6180_RangeGetInterruptStatus (VL6180Dev_t dev, uint8_t *pIntStatus)
 Return ranging error interrupt status.
const char * VL6180_RangeGetStatusErrString (uint8_t RangeErrCode)
 Human readable error string for range error status.

Detailed Description

Ranging functions.


Function Documentation

VL6180_API int VL6180_RangeConfigInterrupt ( VL6180Dev_t  dev,
uint8_t  ConfigGpioInt 
)

Configure ranging interrupt reported to application.

Parameters:
devThe device
ConfigGpioIntSelect ranging report
select one (and only one) of:
CONFIG_GPIO_INTERRUPT_DISABLED
CONFIG_GPIO_INTERRUPT_LEVEL_LOW
CONFIG_GPIO_INTERRUPT_LEVEL_HIGH
CONFIG_GPIO_INTERRUPT_OUT_OF_WINDOW
CONFIG_GPIO_INTERRUPT_NEW_SAMPLE_READY
Returns:
0 on success

Definition at line 1154 of file vl6180_api.c.

VL6180_API int VL6180_RangeGetInterruptStatus ( VL6180Dev_t  dev,
uint8_t *  pIntStatus 
)

Return ranging error interrupt status.

Function Description
Appropriate Interrupt report must have been selected first by VL6180_RangeConfigInterrupt() or VL6180_Prepare()

Can be used in polling loop to wait for a given ranging event or in interrupt to read the trigger
Events triggers are :
RES_INT_STAT_GPIO_LOW_LEVEL_THRESHOLD
RES_INT_STAT_GPIO_HIGH_LEVEL_THRESHOLD
RES_INT_STAT_GPIO_OUT_OF_WINDOW
(RES_INT_STAT_GPIO_LOW_LEVEL_THRESHOLD|RES_INT_STAT_GPIO_HIGH_LEVEL_THRESHOLD) RES_INT_STAT_GPIO_NEW_SAMPLE_READY

See also:
IntrStatus_t
Parameters:
devThe device
pIntStatusPointer to status variable to update
Returns:
0 on success

Definition at line 774 of file vl6180_api.c.

VL6180_API int VL6180_RangeGetMeasurement ( VL6180Dev_t  dev,
VL6180_RangeData_t pRangeData 
)

Retrieve range measurements set from device.

Function Description
The measurement is made of range_mm status and error code VL6180_RangeData_t
Based on configuration selected extra measures are included.
Warning:
should not be used in continuous if wrap around filter is active
Does not perform any wait nor check for result availability or validity.
See also:
VL6180_RangeGetResult for "range only" measurement
Parameters:
devThe device
pRangeDataPointer to the data structure to fill up
Returns:
0 on success

Definition at line 561 of file vl6180_api.c.

VL6180_API int VL6180_RangeGetMeasurementIfReady ( VL6180Dev_t  dev,
VL6180_RangeData_t pRangeData 
)

Check for measure readiness and get it if ready.

Function Description
Using this function is an alternative to VL6180_RangePollMeasurement() to avoid polling operation. This is suitable for applications where host CPU is triggered on a interrupt (not from VL6180) to perform ranging operation. In this scenario, we assume that the very first ranging operation is triggered by a call to VL6180_RangeStartSingleShot(). Then, host CPU regularly calls VL6180_RangeGetMeasurementIfReady() to get a distance measure if ready. In case the distance is not ready, host may get it at the next call.
Warning:
This function does not re-start a new measurement : this is up to the host CPU to do it.
This function clears Range Interrupt for measure ready , but not error interrupts. For that, uses VL6180_ClearErrorInterrupt()
Parameters:
devThe device
pRangeDataWill be populated with the result ranging data if available
Returns:
0 on success and <0 in case of error. Please check pRangeData.errorStatus to check is new measurement is ready or not.

Definition at line 622 of file vl6180_api.c.

VL6180_API int VL6180_RangeGetResult ( VL6180Dev_t  dev,
int32_t *  pRange_mm 
)

Get ranging result and only that.

Function Description
Unlike VL6180_RangeGetMeasurement() this function only retrieves the range in millimeter
It does any required up-scale translation
It can be called after success status polling or in interrupt mode
Warning:
these function is not doing wrap around filtering
This function doesn't perform any data ready check!
Parameters:
devThe device
pRange_mmPointer to range distance
Returns:
0 on success

Definition at line 677 of file vl6180_api.c.

const char* VL6180_RangeGetStatusErrString ( uint8_t  RangeErrCode )

Human readable error string for range error status.

Parameters:
RangeErrCodeThe error code as stored on VL6180_RangeData_t::errorStatus
Returns:
error string , NULL for invalid RangeErrCode
See also:
RangeError_u

Definition at line 100 of file vl6180_api.c.

VL6180_API int VL6180_RangePollMeasurement ( VL6180Dev_t  dev,
VL6180_RangeData_t pRangeData 
)

Single shot Range measurement in polling mode.

Function Description
Kick off a new single shot range then wait for ready to retrieve it by polling interrupt status
Ranging must be prepared by a first call to VL6180_Prepare() and it is safer to clear very first poll call
This function reference VL6180_PollDelay(dev) porting macro/call on each polling loop, but PollDelay(dev) may never be called if measure in ready on first poll loop
Should not be use in continuous mode operation as it will stop it and cause stop/start misbehaviour

This function clears Range Interrupt status , but not error one. For that uses VL6180_ClearErrorInterrupt()
This range error is not related VL6180_RangeData_t::errorStatus that refer measure status
Parameters:
devThe device
pRangeDataWill be populated with the result ranging data VL6180_RangeData_t
Returns:
0 on success , RANGE_ERROR if device reports an error case in it status (not cleared) use
See also:
VL6180_RangeData_t

Definition at line 414 of file vl6180_api.c.

VL6180_API int VL6180_RangeSetMaxConvergenceTime ( VL6180Dev_t  dev,
uint8_t  MaxConTime_msec 
)

Set maximum convergence time.

Function Description
Setting a low convergence time can impact maximal detectable distance. Refer to VL6180 Datasheet Table 7 : Typical range convergence time. A typical value for up to x3 scaling is 50 ms
Parameters:
dev
MaxConTime_msec
Returns:
0 on success. <0 on error. >0 for calibration warning status

Definition at line 1219 of file vl6180_api.c.

VL6180_API int VL6180_RangeStartContinuousMode ( VL6180Dev_t  dev )

Start continuous ranging mode.

End user should ensure device is in idle state and not already running

Definition at line 1328 of file vl6180_api.c.

VL6180_API int VL6180_RangeStartSingleShot ( VL6180Dev_t  dev )

Start single shot ranging measure.

End user should ensure device is in idle state and not already running

Definition at line 1337 of file vl6180_api.c.