# stmicroelectronics/stm32-vl53l5cx architecture

> Architecture diagram of the GitHub repository stmicroelectronics/stm32-vl53l5cx, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/stmicroelectronics/stm32-vl53l5cx
- Repository: https://github.com/stmicroelectronics/stm32-vl53l5cx

## Overview

This is ST’s STM32Cube BSP component for the VL53L5CX time-of-flight ranging sensor. An application uses the component driver to initialize the sensor, configure ranging, poll for data, and receive per-zone results; the driver relies on the lower-level sensor API and platform I/O callbacks. Separate plugins provide cross-talk calibration, detection thresholds, and motion-indicator configuration. The source index identifies a large embedded buffer module, but its contents were not sampled; plugin-to-driver orchestration is likewise not shown, so those links are omitted.

Main entry points: [`modules/vl53l5cx_api.c`](https://github.com/stmicroelectronics/stm32-vl53l5cx/blob/main/modules/vl53l5cx_api.c) (Ranging API), [`vl53l5cx.c`](https://github.com/stmicroelectronics/stm32-vl53l5cx/blob/main/vl53l5cx.c) (Component driver), [`porting/platform.c`](https://github.com/stmicroelectronics/stm32-vl53l5cx/blob/main/porting/platform.c) (Platform transport), [`modules/vl53l5cx_plugin_xtalk.c`](https://github.com/stmicroelectronics/stm32-vl53l5cx/blob/main/modules/vl53l5cx_plugin_xtalk.c) (Cross-talk calibration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_bsp["BSP driver"]
  node_component_driver["Component driver<br/>[vl53l5cx.c]"]
  node_driver_interface["Driver interface<br/>[vl53l5cx.h]"]
end

subgraph group_sensor_api["Sensor API"]
  node_sensor_api_impl["Ranging API<br/>[vl53l5cx_api.c]"]
  node_api_interface["API definitions<br/>[vl53l5cx_api.h]"]
  node_firmware_buffers["Firmware buffers<br/>[vl53l5cx_buffers.h]"]
end

subgraph group_plugins["Feature plugins"]
  node_xtalk["Cross-talk calibration"]
  node_thresholds["Detection thresholds"]
  node_motion["Motion indicator"]
end

subgraph group_platform["Platform I/O"]
  node_platform_io["Platform transport<br/>[platform.c]"]
  node_platform_contract["Platform contract<br/>[platform.h]"]
end

node_application(("STM32 application"))
node_host_callbacks["Host I/O callbacks"]
node_vl53l5cx_sensor{{"VL53L5CX sensor"}}

node_application -.->|"uses"| node_component_driver
node_component_driver -->|"configures and reads"| node_sensor_api_impl
node_component_driver -->|"returns results"| node_application
node_sensor_api_impl -->|"performs register I/O"| node_platform_io
node_sensor_api_impl -->|"uses buffers"| node_firmware_buffers
node_platform_io -->|"calls read/write"| node_host_callbacks
node_platform_contract -->|"defines callbacks"| node_host_callbacks
node_platform_io -.->|"transfers over I²C"| node_vl53l5cx_sensor
node_xtalk -->|"uses DCI API"| node_sensor_api_impl
node_thresholds -->|"uses DCI API"| node_sensor_api_impl
node_motion -->|"uses DCI API"| node_sensor_api_impl

click node_component_driver "https://github.com/stmicroelectronics/stm32-vl53l5cx/blob/main/vl53l5cx.c"
click node_driver_interface "https://github.com/stmicroelectronics/stm32-vl53l5cx/blob/main/vl53l5cx.h"
click node_sensor_api_impl "https://github.com/stmicroelectronics/stm32-vl53l5cx/blob/main/modules/vl53l5cx_api.c"
click node_api_interface "https://github.com/stmicroelectronics/stm32-vl53l5cx/blob/main/modules/vl53l5cx_api.h"
click node_firmware_buffers "https://github.com/stmicroelectronics/stm32-vl53l5cx/blob/main/modules/vl53l5cx_buffers.h"
click node_xtalk "https://github.com/stmicroelectronics/stm32-vl53l5cx/blob/main/modules/vl53l5cx_plugin_xtalk.c"
click node_thresholds "https://github.com/stmicroelectronics/stm32-vl53l5cx/blob/main/modules/vl53l5cx_plugin_detection_thresholds.c"
click node_motion "https://github.com/stmicroelectronics/stm32-vl53l5cx/blob/main/modules/vl53l5cx_plugin_motion_indicator.c"
click node_platform_io "https://github.com/stmicroelectronics/stm32-vl53l5cx/blob/main/porting/platform.c"
click node_platform_contract "https://github.com/stmicroelectronics/stm32-vl53l5cx/blob/main/porting/platform.h"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_component_driver,node_driver_interface toneBlue
class node_sensor_api_impl,node_api_interface,node_firmware_buffers toneAmber
class node_xtalk,node_thresholds,node_motion toneMint
class node_platform_io,node_platform_contract toneRose
class node_application,node_host_callbacks,node_vl53l5cx_sensor toneIndigo
```

## Components

### BSP driver

- [Component driver](https://github.com/stmicroelectronics/stm32-vl53l5cx/blob/main/vl53l5cx.c): `vl53l5cx.c`
- [Driver interface](https://github.com/stmicroelectronics/stm32-vl53l5cx/blob/main/vl53l5cx.h): `vl53l5cx.h`

### Sensor API

- [Ranging API](https://github.com/stmicroelectronics/stm32-vl53l5cx/blob/main/modules/vl53l5cx_api.c): `modules/vl53l5cx_api.c`
- [API definitions](https://github.com/stmicroelectronics/stm32-vl53l5cx/blob/main/modules/vl53l5cx_api.h): `modules/vl53l5cx_api.h`
- [Firmware buffers](https://github.com/stmicroelectronics/stm32-vl53l5cx/blob/main/modules/vl53l5cx_buffers.h): `modules/vl53l5cx_buffers.h`

### Feature plugins

- [Cross-talk calibration](https://github.com/stmicroelectronics/stm32-vl53l5cx/blob/main/modules/vl53l5cx_plugin_xtalk.c): `modules/vl53l5cx_plugin_xtalk.c`
- [Detection thresholds](https://github.com/stmicroelectronics/stm32-vl53l5cx/blob/main/modules/vl53l5cx_plugin_detection_thresholds.c): `modules/vl53l5cx_plugin_detection_thresholds.c`
- [Motion indicator](https://github.com/stmicroelectronics/stm32-vl53l5cx/blob/main/modules/vl53l5cx_plugin_motion_indicator.c): `modules/vl53l5cx_plugin_motion_indicator.c`

### Platform I/O

- [Platform transport](https://github.com/stmicroelectronics/stm32-vl53l5cx/blob/main/porting/platform.c): `porting/platform.c`
- [Platform contract](https://github.com/stmicroelectronics/stm32-vl53l5cx/blob/main/porting/platform.h): `porting/platform.h`

### Other components

- **STM32 application**
- **Host I/O callbacks**
- **VL53L5CX sensor**

## Connections

- STM32 application → Component driver: uses
- Component driver → Ranging API: configures and reads (evidence: `vl53l5cx.c`)
- Component driver → STM32 application: returns results (evidence: `vl53l5cx.c`)
- Ranging API → Platform transport: performs register I/O (evidence: `modules/vl53l5cx_api.c`)
- Ranging API → Firmware buffers: uses buffers (evidence: `modules/vl53l5cx_api.c`)
- Platform transport → Host I/O callbacks: calls read/write (evidence: `porting/platform.c`)
- Platform contract → Host I/O callbacks: defines callbacks (evidence: `porting/platform.h`)
- Platform transport → VL53L5CX sensor: transfers over I²C
- Cross-talk calibration → Ranging API: uses DCI API (evidence: `modules/vl53l5cx_plugin_xtalk.c`)
- Detection thresholds → Ranging API: uses DCI API (evidence: `modules/vl53l5cx_plugin_detection_thresholds.c`)
- Motion indicator → Ranging API: uses DCI API (evidence: `modules/vl53l5cx_plugin_motion_indicator.c`)
