ACwing FC firmware
STM32WB55: attitude IEKF, altitude Kalman filter, flight core, protocol v2
Loading...
Searching...
No Matches
vl53l1x.h File Reference

Minimal VL53L1X time-of-flight driver (ACwing Flow rev A, Qwiic 0x29). More...

#include <stdint.h>
Include dependency graph for vl53l1x.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  vl53_bus_t
 
struct  vl53_t
 
struct  vl53_sample_t
 Range status after the ULD mapping: 0 valid, 1 sigma fail, 2 signal fail, 4 out of bounds, 7 wrap-around, others < 255 unusual, 255 unknown. More...
 

Macros

#define VL53L1X_ADDR_7BIT   0x29u
 
#define VL53L1X_MODEL_ID   0xEACCu
 

Functions

int32_t vl53_init (vl53_t *d, const vl53_bus_t *bus, uint16_t budget_ms)
 0 = sensor found and ranging; < 0 = absent or error (the board works without it)
 
int32_t vl53_poll (vl53_t *d, vl53_sample_t *s)
 1 = new sample in *s, 0 = none yet, < 0 = bus error
 

Detailed Description

Minimal VL53L1X time-of-flight driver (ACwing Flow rev A, Qwiic 0x29).

Register sequences and the default configuration block are those of ST's VL53L1X Ultra Lite Driver (ULD, STSW-IMG009, BSD-3-Clause, see vl53l1x.c). Only what the flight controller needs: init, long distance mode, 33 ms timing budget (~30 Hz continuous ranging), non-blocking poll.

No HAL, no RTOS: the bus is given as function pointers (16-bit registers, big-endian data as on the device). Host-testable with a simulated bus.

Definition in file vl53l1x.h.

Macro Definition Documentation

◆ VL53L1X_ADDR_7BIT

#define VL53L1X_ADDR_7BIT   0x29u

Definition at line 18 of file vl53l1x.h.

◆ VL53L1X_MODEL_ID

#define VL53L1X_MODEL_ID   0xEACCu

Definition at line 19 of file vl53l1x.h.

Function Documentation

◆ vl53_init()

int32_t vl53_init ( vl53_t *  d,
const vl53_bus_t *  bus,
uint16_t  budget_ms 
)

0 = sensor found and ranging; < 0 = absent or error (the board works without it)

Definition at line 86 of file vl53l1x.c.

References b, vl53_t::bus, data_ready(), dly(), vl53_bus_t::handle, vl53_t::int_pol, k_default, vl53_t::ok, rd16(), rd8(), REG_FIRMWARE_SYSTEM_STATUS, REG_GPIO_HV_MUX_CTRL, REG_INTERMEASUREMENT, REG_INTERRUPT_CLEAR, REG_MODE_START, REG_MODEL_ID, REG_OSC_CALIBRATE_VAL, REG_PHASECAL_TIMEOUT, REG_RANGE_TIMEOUT_A_HI, REG_RANGE_TIMEOUT_B_HI, REG_RANGE_VALID_PHASE_HIGH, REG_RANGE_VCSEL_PERIOD_A, REG_RANGE_VCSEL_PERIOD_B, REG_SD_INITIAL_PHASE_SD0, REG_SD_WOI_SD0, REG_VHV_START, REG_VHV_TIMEOUT_LOOP_BOUND, st(), VL53L1X_MODEL_ID, wr16(), wr32(), wr8(), and vl53_bus_t::write.

Referenced by ext_step().

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

◆ vl53_poll()

int32_t vl53_poll ( vl53_t *  d,
vl53_sample_t *  s 
)

1 = new sample in *s, 0 = none yet, < 0 = bus error

Definition at line 137 of file vl53l1x.c.

References vl53_t::bus, data_ready(), vl53_bus_t::handle, map_status(), vl53_t::ok, vl53_bus_t::read, REG_INTERRUPT_CLEAR, REG_RESULT_RANGE_STATUS, s, and wr8().

Referenced by ext_step().

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