# elektronikaembedded/vcnl4200 architecture

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

- Interactive diagram: https://gitdiagram.com/elektronikaembedded/vcnl4200
- Repository: https://github.com/elektronikaembedded/vcnl4200

## Overview

This is a lightweight, platform-independent VCNL4200 sensor driver. An application constructs the driver with an I2C bus, initializes it, then reads proximity, ambient-light, or white-channel data and configures sensor registers through the driver API. The implementation performs register transfers through the supplied bus; platform-specific bus behavior is intended to be adapted from the templates. The templates and platform wiring are documented but not sampled, so those links are shown as unverified.

Main entry points: [`include/vcnl4200_impl.hpp`](https://github.com/elektronikaembedded/vcnl4200/blob/main/include/vcnl4200_impl.hpp) (Sensor operations), [`include/vcnl4200.hpp`](https://github.com/elektronikaembedded/vcnl4200/blob/main/include/vcnl4200.hpp) (Driver API), [`include/i2c_interface.hpp`](https://github.com/elektronikaembedded/vcnl4200/blob/main/include/i2c_interface.hpp) (I2C error contract), [`template/i2c_interface.hpp.template`](https://github.com/elektronikaembedded/vcnl4200/blob/main/template/i2c_interface.hpp.template) (Platform I2C template)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_sensor["Sensor driver"]
  node_api["Driver API<br/>[vcnl4200.hpp]"]
  node_driver["Sensor operations<br/>[vcnl4200_impl.hpp]"]
  node_registers["Register definitions"]
end

subgraph group_bus["I2C port"]
  node_contract["I2C error contract<br/>[i2c_interface.hpp]"]
  node_adapter["Platform I2C template"]
end

node_app(("Application"))
node_platform["Platform I2C / MCU"]
node_sensor_hw["VCNL4200 sensor"]

node_app -->|"uses"| node_api
node_api -->|"implements"| node_driver
node_driver -->|"checks transfer status"| node_contract
node_driver -->|"accesses registers"| node_registers
node_driver -->|"reads and writes"| node_sensor_hw
node_contract -.->|"implemented by"| node_adapter
node_adapter -.->|"adapted for"| node_platform
node_platform -.->|"communicates over I2C"| node_sensor_hw

click node_api "https://github.com/elektronikaembedded/vcnl4200/blob/main/include/vcnl4200.hpp"
click node_driver "https://github.com/elektronikaembedded/vcnl4200/blob/main/include/vcnl4200_impl.hpp"
click node_registers "https://github.com/elektronikaembedded/vcnl4200/blob/main/include/vcnl4200_registers.hpp"
click node_contract "https://github.com/elektronikaembedded/vcnl4200/blob/main/include/i2c_interface.hpp"
click node_adapter "https://github.com/elektronikaembedded/vcnl4200/blob/main/template/i2c_interface.hpp.template"

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_api,node_driver,node_registers toneBlue
class node_contract,node_adapter toneAmber
class node_app,node_platform,node_sensor_hw toneIndigo
```

## Components

### Sensor driver

- [Driver API](https://github.com/elektronikaembedded/vcnl4200/blob/main/include/vcnl4200.hpp): `include/vcnl4200.hpp`
- [Sensor operations](https://github.com/elektronikaembedded/vcnl4200/blob/main/include/vcnl4200_impl.hpp): `include/vcnl4200_impl.hpp`
- [Register definitions](https://github.com/elektronikaembedded/vcnl4200/blob/main/include/vcnl4200_registers.hpp): `include/vcnl4200_registers.hpp`

### I2C port

- [I2C error contract](https://github.com/elektronikaembedded/vcnl4200/blob/main/include/i2c_interface.hpp): `include/i2c_interface.hpp`
- [Platform I2C template](https://github.com/elektronikaembedded/vcnl4200/blob/main/template/i2c_interface.hpp.template): `template/i2c_interface.hpp.template`

### Other components

- **Application**
- **Platform I2C / MCU**
- **VCNL4200 sensor**

## Connections

- Application → Driver API: uses (evidence: `README.md`)
- Driver API → Sensor operations: implements (evidence: `include/vcnl4200.hpp`)
- Sensor operations → I2C error contract: checks transfer status (evidence: `include/vcnl4200_impl.hpp`)
- Sensor operations → Register definitions: accesses registers (evidence: `include/vcnl4200_impl.hpp`)
- Sensor operations → VCNL4200 sensor: reads and writes (evidence: `README.md`)
- I2C error contract → Platform I2C template: implemented by (evidence: `README.md`)
- Platform I2C template → Platform I2C / MCU: adapted for (evidence: `README.md`)
- Platform I2C / MCU → VCNL4200 sensor: communicates over I2C (evidence: `README.md`)
