# libdriver/max30102 architecture

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

- Interactive diagram: https://gitdiagram.com/libdriver/max30102
- Repository: https://github.com/libdriver/max30102

## Overview

LibDriver MAX30102 is a C driver library with Raspberry Pi and STM32F407 sample applications. A typical use configures the sensor through the driver, handles FIFO-ready interrupts, reads red/IR samples, and reports them. The central driver uses platform-provided I2C, delay, and debug hooks; the projects supply board-specific adapters and peripherals. The README documents the FIFO workflow, while sampled code confirms interrupt callbacks and the driver’s I2C hook. Some adapter internals and application dispatch paths were not sampled, so those links are omitted or marked unverified.

Main entry points: [`src/driver_max30102.c`](https://github.com/libdriver/max30102/blob/main/src/driver_max30102.c) (MAX30102 driver), [`interface/driver_max30102_interface.h`](https://github.com/libdriver/max30102/blob/main/interface/driver_max30102_interface.h) (Platform contract), [`project/raspberrypi4b/src/main.c`](https://github.com/libdriver/max30102/blob/main/project/raspberrypi4b/src/main.c) (Board demo), [`project/raspberrypi4b/driver/src/raspberrypi4b_driver_max30102_interface.c`](https://github.com/libdriver/max30102/blob/main/project/raspberrypi4b/driver/src/raspberrypi4b_driver_max30102_interface.c) (Raspberry adapter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_lib["Driver Library"]
  node_driver["MAX30102 driver<br/>[driver_max30102.c]"]
  node_api["Driver API<br/>[driver_max30102.h]"]
  node_contract["Platform contract"]
end

subgraph group_apps["Board Applications"]
  node_app["Board demo<br/>[main.c]"]
  node_stmapp["STM32 demo<br/>[main.c]"]
end

subgraph group_platform["Platform I/O"]
  node_rp_adapter["Raspberry adapter"]
  node_stm_adapter["STM32 adapter"]
  node_rp_i2c["Raspberry I2C<br/>[iic.c]"]
  node_stm_i2c["STM32 I2C<br/>[iic.c]"]
end

node_user(("Application user"))
node_sensor{{"MAX30102 sensor"}}
node_fifo["FIFO samples"]

node_user -->|"runs demo"| node_app
node_user -->|"runs demo"| node_stmapp
node_app -->|"reads FIFO"| node_driver
node_driver -->|"implements API"| node_api
node_driver -->|"uses hooks"| node_contract
node_contract -.->|"implemented by"| node_rp_adapter
node_contract -->|"implemented by"| node_stm_adapter
node_rp_adapter -.->|"uses bus"| node_rp_i2c
node_stm_adapter -->|"uses bus"| node_stm_i2c
node_rp_i2c -.->|"transfers data"| node_sensor
node_stm_i2c -.->|"transfers data"| node_sensor
node_driver -->|"returns samples"| node_fifo

click node_app "https://github.com/libdriver/max30102/blob/main/project/raspberrypi4b/src/main.c"
click node_stmapp "https://github.com/libdriver/max30102/blob/main/project/stm32f407/usr/src/main.c"
click node_driver "https://github.com/libdriver/max30102/blob/main/src/driver_max30102.c"
click node_api "https://github.com/libdriver/max30102/blob/main/src/driver_max30102.h"
click node_contract "https://github.com/libdriver/max30102/blob/main/interface/driver_max30102_interface.h"
click node_rp_adapter "https://github.com/libdriver/max30102/blob/main/project/raspberrypi4b/driver/src/raspberrypi4b_driver_max30102_interface.c"
click node_stm_adapter "https://github.com/libdriver/max30102/blob/main/project/stm32f407/driver/src/stm32f407_driver_max30102_interface.c"
click node_rp_i2c "https://github.com/libdriver/max30102/blob/main/project/raspberrypi4b/interface/src/iic.c"
click node_stm_i2c "https://github.com/libdriver/max30102/blob/main/project/stm32f407/interface/src/iic.c"

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_driver,node_api,node_contract,node_user toneBlue
class node_app,node_stmapp toneAmber
class node_rp_adapter,node_stm_adapter,node_rp_i2c,node_stm_i2c toneMint
class node_sensor,node_fifo toneIndigo
```

## Components

### Driver Library

- [MAX30102 driver](https://github.com/libdriver/max30102/blob/main/src/driver_max30102.c): `src/driver_max30102.c`
- [Driver API](https://github.com/libdriver/max30102/blob/main/src/driver_max30102.h): `src/driver_max30102.h`
- [Platform contract](https://github.com/libdriver/max30102/blob/main/interface/driver_max30102_interface.h): `interface/driver_max30102_interface.h`

### Board Applications

- [Board demo](https://github.com/libdriver/max30102/blob/main/project/raspberrypi4b/src/main.c): `project/raspberrypi4b/src/main.c`
- [STM32 demo](https://github.com/libdriver/max30102/blob/main/project/stm32f407/usr/src/main.c): `project/stm32f407/usr/src/main.c`

### Platform I/O

- [Raspberry adapter](https://github.com/libdriver/max30102/blob/main/project/raspberrypi4b/driver/src/raspberrypi4b_driver_max30102_interface.c): `project/raspberrypi4b/driver/src/raspberrypi4b_driver_max30102_interface.c`
- [STM32 adapter](https://github.com/libdriver/max30102/blob/main/project/stm32f407/driver/src/stm32f407_driver_max30102_interface.c): `project/stm32f407/driver/src/stm32f407_driver_max30102_interface.c`
- [Raspberry I2C](https://github.com/libdriver/max30102/blob/main/project/raspberrypi4b/interface/src/iic.c): `project/raspberrypi4b/interface/src/iic.c`
- [STM32 I2C](https://github.com/libdriver/max30102/blob/main/project/stm32f407/interface/src/iic.c): `project/stm32f407/interface/src/iic.c`

### Other components

- **Application user**
- **MAX30102 sensor**
- **FIFO samples**

## Connections

- Application user → Board demo: runs demo (evidence: `README.md`)
- Application user → STM32 demo: runs demo (evidence: `README.md`)
- Board demo → MAX30102 driver: reads FIFO (evidence: `README.md`)
- MAX30102 driver → Driver API: implements API (evidence: `src/driver_max30102.c`)
- MAX30102 driver → Platform contract: uses hooks (evidence: `src/driver_max30102.c`)
- Platform contract → Raspberry adapter: implemented by (evidence: `project/raspberrypi4b/driver/src/raspberrypi4b_driver_max30102_interface.c`)
- Platform contract → STM32 adapter: implemented by (evidence: `project/stm32f407/driver/src/stm32f407_driver_max30102_interface.c`)
- Raspberry adapter → Raspberry I2C: uses bus
- STM32 adapter → STM32 I2C: uses bus (evidence: `project/stm32f407/driver/src/stm32f407_driver_max30102_interface.c`)
- Raspberry I2C → MAX30102 sensor: transfers data
- STM32 I2C → MAX30102 sensor: transfers data
- MAX30102 driver → FIFO samples: returns samples (evidence: `README.md`)
