# sleepypandas/icm42670_driver_stm32_esp32 architecture

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

- Interactive diagram: https://gitdiagram.com/sleepypandas/icm42670_driver_stm32_esp32
- Repository: https://github.com/sleepypandas/icm42670_driver_stm32_esp32

## Overview

This repository is a portable C driver for the ICM-42670-P IMU. An application configures a transport (direct callbacks or a platform adapter), initializes the driver, then reads scaled or raw measurements and may opt into APEX, FIFO, or FSYNC features. The core separates sensor behavior from platform bus access through callbacks. The README documents the workflow and feature scope; source-index references support several internal module relationships, but many implementation details were not sampled.

Main entry points: [`ICM42670_Driver/ICM42670_internal.c`](https://github.com/sleepypandas/icm42670_driver_stm32_esp32/blob/main/ICM42670_Driver/ICM42670_internal.c) (Register helpers), [`ICM42670_Driver/ICM42670_driver.c`](https://github.com/sleepypandas/icm42670_driver_stm32_esp32/blob/main/ICM42670_Driver/ICM42670_driver.c) (Init and control), [`ICM42670_Driver/ICM42670_apex.c`](https://github.com/sleepypandas/icm42670_driver_stm32_esp32/blob/main/ICM42670_Driver/ICM42670_apex.c) (APEX motion), [`ICM42670_Driver/ICM42670_fifo.c`](https://github.com/sleepypandas/icm42670_driver_stm32_esp32/blob/main/ICM42670_Driver/ICM42670_fifo.c) (FIFO capture)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_usage["Application workflow"]
  node_application(("Embedded application"))
end

subgraph group_core["Portable driver core"]
  node_init["Init and control<br/>[ICM42670_driver.c]"]
  node_sensor_reads["Sensor reads<br/>[ICM42670_driver.c]"]
  node_calibration["Gyro calibration<br/>[ICM42670_driver.c]"]
  node_internal_helpers["Register helpers"]
  node_register_api["Driver API<br/>[ICM42670_driver.h]"]
end

subgraph group_transport["Platform transports"]
  node_esp_adapter["ESP-IDF adapter<br/>[ICM42670_esp_idf.c]"]
  node_stm_adapter["STM32 HAL adapter"]
end

subgraph group_features["Optional sensor features"]
  node_apex["APEX motion<br/>[ICM42670_apex.c]"]
  node_fifo["FIFO capture<br/>[ICM42670_fifo.c]"]
  node_fsync["FSYNC capture<br/>[ICM42670_fsync.c]"]
end

subgraph group_protocol["Register protocol"]
  node_register_map["Register definitions"]
end

node_imu["ICM-42670-P IMU"]

node_application -->|"configures bus"| node_esp_adapter
node_application -->|"configures bus"| node_stm_adapter
node_application -->|"initializes"| node_init
node_application -->|"requests measurements"| node_sensor_reads
node_application -->|"calibrates gyro"| node_calibration
node_esp_adapter -->|"sets callbacks"| node_init
node_stm_adapter -->|"sets callbacks"| node_init
node_init -->|"uses helpers"| node_internal_helpers
node_sensor_reads -->|"uses helpers"| node_internal_helpers
node_calibration -->|"uses helpers"| node_internal_helpers
node_init -->|"configures registers"| node_imu
node_sensor_reads -->|"reads measurements"| node_imu
node_apex -->|"uses helpers"| node_internal_helpers
node_fifo -->|"uses helpers"| node_internal_helpers
node_fsync -->|"uses helpers"| node_internal_helpers
node_apex -->|"configures and reads"| node_imu
node_fifo -->|"configures and reads"| node_imu
node_fsync -->|"configures and reads"| node_imu
node_register_api -->|"uses definitions"| node_register_map

click node_init "https://github.com/sleepypandas/icm42670_driver_stm32_esp32/blob/main/ICM42670_Driver/ICM42670_driver.c"
click node_sensor_reads "https://github.com/sleepypandas/icm42670_driver_stm32_esp32/blob/main/ICM42670_Driver/ICM42670_driver.c"
click node_calibration "https://github.com/sleepypandas/icm42670_driver_stm32_esp32/blob/main/ICM42670_Driver/ICM42670_driver.c"
click node_internal_helpers "https://github.com/sleepypandas/icm42670_driver_stm32_esp32/blob/main/ICM42670_Driver/ICM42670_internal.c"
click node_register_api "https://github.com/sleepypandas/icm42670_driver_stm32_esp32/blob/main/ICM42670_Driver/ICM42670_driver.h"
click node_esp_adapter "https://github.com/sleepypandas/icm42670_driver_stm32_esp32/blob/main/ICM42670_Driver/ports/esp_idf/ICM42670_esp_idf.c"
click node_stm_adapter "https://github.com/sleepypandas/icm42670_driver_stm32_esp32/blob/main/ICM42670_Driver/ports/stm32_hal/ICM42670_stm32_hal.c"
click node_apex "https://github.com/sleepypandas/icm42670_driver_stm32_esp32/blob/main/ICM42670_Driver/ICM42670_apex.c"
click node_fifo "https://github.com/sleepypandas/icm42670_driver_stm32_esp32/blob/main/ICM42670_Driver/ICM42670_fifo.c"
click node_fsync "https://github.com/sleepypandas/icm42670_driver_stm32_esp32/blob/main/ICM42670_Driver/ICM42670_fsync.c"
click node_register_map "https://github.com/sleepypandas/icm42670_driver_stm32_esp32/blob/main/ICM42670_Driver/ICM42670_registermap.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_application toneBlue
class node_init,node_sensor_reads,node_calibration,node_internal_helpers,node_register_api toneAmber
class node_esp_adapter,node_stm_adapter toneMint
class node_apex,node_fifo,node_fsync toneRose
class node_register_map,node_imu toneIndigo
```

## Components

### Application workflow

- **Embedded application**

### Portable driver core

- [Init and control](https://github.com/sleepypandas/icm42670_driver_stm32_esp32/blob/main/ICM42670_Driver/ICM42670_driver.c): `ICM42670_Driver/ICM42670_driver.c`
- [Sensor reads](https://github.com/sleepypandas/icm42670_driver_stm32_esp32/blob/main/ICM42670_Driver/ICM42670_driver.c): `ICM42670_Driver/ICM42670_driver.c`
- [Gyro calibration](https://github.com/sleepypandas/icm42670_driver_stm32_esp32/blob/main/ICM42670_Driver/ICM42670_driver.c): `ICM42670_Driver/ICM42670_driver.c`
- [Register helpers](https://github.com/sleepypandas/icm42670_driver_stm32_esp32/blob/main/ICM42670_Driver/ICM42670_internal.c): `ICM42670_Driver/ICM42670_internal.c`
- [Driver API](https://github.com/sleepypandas/icm42670_driver_stm32_esp32/blob/main/ICM42670_Driver/ICM42670_driver.h): `ICM42670_Driver/ICM42670_driver.h`

### Platform transports

- [ESP-IDF adapter](https://github.com/sleepypandas/icm42670_driver_stm32_esp32/blob/main/ICM42670_Driver/ports/esp_idf/ICM42670_esp_idf.c): `ICM42670_Driver/ports/esp_idf/ICM42670_esp_idf.c`
- [STM32 HAL adapter](https://github.com/sleepypandas/icm42670_driver_stm32_esp32/blob/main/ICM42670_Driver/ports/stm32_hal/ICM42670_stm32_hal.c): `ICM42670_Driver/ports/stm32_hal/ICM42670_stm32_hal.c`

### Optional sensor features

- [APEX motion](https://github.com/sleepypandas/icm42670_driver_stm32_esp32/blob/main/ICM42670_Driver/ICM42670_apex.c): `ICM42670_Driver/ICM42670_apex.c`
- [FIFO capture](https://github.com/sleepypandas/icm42670_driver_stm32_esp32/blob/main/ICM42670_Driver/ICM42670_fifo.c): `ICM42670_Driver/ICM42670_fifo.c`
- [FSYNC capture](https://github.com/sleepypandas/icm42670_driver_stm32_esp32/blob/main/ICM42670_Driver/ICM42670_fsync.c): `ICM42670_Driver/ICM42670_fsync.c`

### Register protocol

- [Register definitions](https://github.com/sleepypandas/icm42670_driver_stm32_esp32/blob/main/ICM42670_Driver/ICM42670_registermap.h): `ICM42670_Driver/ICM42670_registermap.h`

### Other components

- **ICM-42670-P IMU**

## Connections

- Embedded application → ESP-IDF adapter: configures bus (evidence: `README.md`)
- Embedded application → STM32 HAL adapter: configures bus (evidence: `README.md`)
- Embedded application → Init and control: initializes (evidence: `README.md`)
- Embedded application → Sensor reads: requests measurements (evidence: `README.md`)
- Embedded application → Gyro calibration: calibrates gyro (evidence: `README.md`)
- ESP-IDF adapter → Init and control: sets callbacks (evidence: `README.md`)
- STM32 HAL adapter → Init and control: sets callbacks (evidence: `README.md`)
- Init and control → Register helpers: uses helpers (evidence: `ICM42670_Driver/ICM42670_driver.c`)
- Sensor reads → Register helpers: uses helpers (evidence: `ICM42670_Driver/ICM42670_driver.c`)
- Gyro calibration → Register helpers: uses helpers (evidence: `README.md`)
- Init and control → ICM-42670-P IMU: configures registers (evidence: `README.md`)
- Sensor reads → ICM-42670-P IMU: reads measurements (evidence: `README.md`)
- APEX motion → Register helpers: uses helpers (evidence: `ICM42670_Driver/ICM42670_apex.c`)
- FIFO capture → Register helpers: uses helpers (evidence: `ICM42670_Driver/ICM42670_fifo.c`)
- FSYNC capture → Register helpers: uses helpers (evidence: `ICM42670_Driver/ICM42670_fsync.c`)
- APEX motion → ICM-42670-P IMU: configures and reads (evidence: `README.md`)
- FIFO capture → ICM-42670-P IMU: configures and reads (evidence: `README.md`)
- FSYNC capture → ICM-42670-P IMU: configures and reads (evidence: `README.md`)
- Driver API → Register definitions: uses definitions (evidence: `ICM42670_Driver/ICM42670_driver.h`)
