Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
vl53l1x_nonblocking.c File Reference

Non-blocking runtime functions for the VL53L1X. More...

#include "vl53l1x_nonblocking.h"
#include <assert.h>
+ Include dependency graph for vl53l1x_nonblocking.c:

Go to the source code of this file.

Functions

static bool VL53L1_NonBlocking_WriteMulti (VL53L1_DEV dev, uint16_t index, uint8_t *pdata, uint32_t count)
 
static bool VL53L1_NonBlocking_ReadMulti (VL53L1_DEV dev, uint16_t index, uint8_t *pdata, uint32_t count)
 
bool VL53L1X_NonBlocking_CheckForDataReady (VL53L1_DEV dev, uint8_t *isDataReady)
 This function checks if the new ranging data is available by polling the dedicated register. More...
 
bool VL53L1X_NonBlocking_GetRangeStatus (VL53L1_DEV dev, uint8_t *rangeStatus)
 This function returns the range status to discard wrong measurments. More...
 
bool VL53L1X_NonBlocking_GetDistance (VL53L1_DEV dev, uint16_t *distance)
 This function returns the distance measured by the sensor in mm. More...
 
bool VL53L1X_NonBlocking_ClearInterrupt (VL53L1_DEV dev)
 This function clears the interrupt, to be called after a ranging data reading to arm the interrupt for the next data ready event. More...
 
bool VL53L1X_NonBlocking_ReadDataEvent (VL53L1_DEV dev, uint16_t *distance_mm, bool *new_data)
 Implement non-blocking read sequence The data reading actually starts when the read_state is set to VL53L1_READ_DATA_READY using VL53L1X_NonBlocking_RequestData() More...
 
bool VL53L1X_NonBlocking_IsIdle (VL53L1_DEV dev)
 Test is read status is on idle. More...
 
bool VL53L1X_NonBlocking_RequestData (VL53L1_DEV dev)
 Request a new reading. More...
 

Variables

static const uint8_t status_rtn [24]
 

Detailed Description

Non-blocking runtime functions for the VL53L1X.

These functions are adapted from vl53l1x_api.c to use the non-blocking version of I2C functions.

Definition in file vl53l1x_nonblocking.c.

Function Documentation

◆ VL53L1_NonBlocking_ReadMulti()

static bool VL53L1_NonBlocking_ReadMulti ( VL53L1_DEV  dev,
uint16_t  index,
uint8_t pdata,
uint32_t  count 
)
static

Definition at line 64 of file vl53l1x_nonblocking.c.

References dev, I2C_BUF_LEN, i2c_transceive(), I2CTransFailed, and I2CTransSuccess.

Referenced by VL53L1X_NonBlocking_CheckForDataReady(), VL53L1X_NonBlocking_GetDistance(), and VL53L1X_NonBlocking_GetRangeStatus().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ VL53L1_NonBlocking_WriteMulti()

static bool VL53L1_NonBlocking_WriteMulti ( VL53L1_DEV  dev,
uint16_t  index,
uint8_t pdata,
uint32_t  count 
)
static

Definition at line 39 of file vl53l1x_nonblocking.c.

References dev, I2C_BUF_LEN, i2c_transmit(), I2CTransFailed, and I2CTransSuccess.

Referenced by VL53L1X_NonBlocking_ClearInterrupt().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ VL53L1X_NonBlocking_CheckForDataReady()

bool VL53L1X_NonBlocking_CheckForDataReady ( VL53L1_DEV  dev,
uint8_t isDataReady 
)

This function checks if the new ranging data is available by polling the dedicated register.

Parameters
isDataReady==0 -> not ready; isDataReady==1 -> ready
Returns
: TRUE upon completion

Definition at line 89 of file vl53l1x_nonblocking.c.

References dev, GPIO__TIO_HV_STATUS, GPIO_HV_MUX__CTRL, and VL53L1_NonBlocking_ReadMulti().

Referenced by VL53L1X_NonBlocking_ReadDataEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ VL53L1X_NonBlocking_ClearInterrupt()

bool VL53L1X_NonBlocking_ClearInterrupt ( VL53L1_DEV  dev)

This function clears the interrupt, to be called after a ranging data reading to arm the interrupt for the next data ready event.

Returns
: TRUE upon completion

Definition at line 138 of file vl53l1x_nonblocking.c.

References dev, SYSTEM__INTERRUPT_CLEAR, and VL53L1_NonBlocking_WriteMulti().

Referenced by VL53L1X_NonBlocking_ReadDataEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ VL53L1X_NonBlocking_GetDistance()

bool VL53L1X_NonBlocking_GetDistance ( VL53L1_DEV  dev,
uint16_t distance 
)

This function returns the distance measured by the sensor in mm.

Returns
: TRUE upon completion

Definition at line 128 of file vl53l1x_nonblocking.c.

References dev, VL53L1_NonBlocking_ReadMulti(), and VL53L1_RESULT__FINAL_CROSSTALK_CORRECTED_RANGE_MM_SD0.

Referenced by VL53L1X_NonBlocking_ReadDataEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ VL53L1X_NonBlocking_GetRangeStatus()

bool VL53L1X_NonBlocking_GetRangeStatus ( VL53L1_DEV  dev,
uint8_t rangeStatus 
)

This function returns the range status to discard wrong measurments.

Parameters
rangeStatus (0:no error, 1:sigma failed, 2:signal failed, ..., 7:wrap-around)
Returns
: TRUE upon completion

Definition at line 115 of file vl53l1x_nonblocking.c.

References dev, status_rtn, VL53L1_NonBlocking_ReadMulti(), and VL53L1_RESULT__RANGE_STATUS.

Referenced by VL53L1X_NonBlocking_ReadDataEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ VL53L1X_NonBlocking_IsIdle()

bool VL53L1X_NonBlocking_IsIdle ( VL53L1_DEV  dev)

Test is read status is on idle.

Returns
: TRUE if idle

Definition at line 190 of file vl53l1x_nonblocking.c.

References dev, and VL53L1_READ_IDLE.

Referenced by multi_ranger_periodic(), and sonar_vl53l1x_read().

+ Here is the caller graph for this function:

◆ VL53L1X_NonBlocking_ReadDataEvent()

bool VL53L1X_NonBlocking_ReadDataEvent ( VL53L1_DEV  dev,
uint16_t distance_mm,
bool *  new_data 
)

Implement non-blocking read sequence The data reading actually starts when the read_state is set to VL53L1_READ_DATA_READY using VL53L1X_NonBlocking_RequestData()

Parameters
distance measurement in millimeter
flag when a new data is available
Returns
: TRUE when a complete read sequence is finished

Definition at line 144 of file vl53l1x_nonblocking.c.

References dev, VL53L1_CLEAR_INT, VL53L1_READ_DATA_READY, VL53L1_READ_DISTANCE, VL53L1_READ_IDLE, VL53L1_READ_STATUS, VL53L1X_NonBlocking_CheckForDataReady(), VL53L1X_NonBlocking_ClearInterrupt(), VL53L1X_NonBlocking_GetDistance(), and VL53L1X_NonBlocking_GetRangeStatus().

Referenced by multi_ranger_read(), and sonar_vl53l1x_event().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ VL53L1X_NonBlocking_RequestData()

bool VL53L1X_NonBlocking_RequestData ( VL53L1_DEV  dev)

Request a new reading.

Returns
: TRUE if request successful

Definition at line 195 of file vl53l1x_nonblocking.c.

References dev, and VL53L1_READ_DATA_READY.

Referenced by multi_ranger_periodic(), and sonar_vl53l1x_read().

+ Here is the caller graph for this function:

Variable Documentation

◆ status_rtn

const uint8_t status_rtn[24]
static
Initial value:
= { 255, 255, 255, 5, 2, 4, 1, 7, 3, 0,
255, 255, 9, 13, 255, 255, 255, 255, 10, 6,
255, 255, 11, 12
}

Definition at line 34 of file vl53l1x_nonblocking.c.

Referenced by VL53L1X_NonBlocking_GetRangeStatus().