# thomasbarth/esp32-can-driver architecture

> Architecture diagram of the GitHub repository thomasbarth/esp32-can-driver, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/thomasbarth/esp32-can-driver
- Repository: https://github.com/thomasbarth/esp32-can-driver

## Overview

This repository is a small ESP32 CAN driver. Its principal workflow is that application code configures the driver and submits CAN frames; the driver programs the ESP32 CAN controller to transmit them, and its interrupt handler reads received frames into a configured FreeRTOS queue. The README also documents menuconfig options for baud rate, pins, node ID, and test-frame settings, though those configuration mechanisms are not shown in the sampled runtime code. The map is limited to the driver’s actual runtime modules and documented capabilities.

Main entry points: [`components/can/CAN.c`](https://github.com/thomasbarth/esp32-can-driver/blob/master/components/can/CAN.c) (CAN runtime), [`components/can/include/CAN.h`](https://github.com/thomasbarth/esp32-can-driver/blob/master/components/can/include/CAN.h) (Frame API), [`components/can/include/CAN_config.h`](https://github.com/thomasbarth/esp32-can-driver/blob/master/components/can/include/CAN_config.h) (Driver configuration), [`components/can/include/can_regdef.h`](https://github.com/thomasbarth/esp32-can-driver/blob/master/components/can/include/can_regdef.h) (Controller registers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_driver["CAN driver"]
  node_api["Frame API<br/>[CAN.h]"]
  node_runtime["CAN runtime<br/>[CAN.c]"]
  node_configuration["Driver configuration<br/>[CAN_config.h]"]
  node_registers["Controller registers<br/>[can_regdef.h]"]
end

node_application(("Application"))
node_rxqueue["RX queue"]
node_controller[("ESP32 CAN controller")]
node_bus(("CAN bus"))

node_application -.->|"uses API"| node_api
node_api -->|"includes"| node_configuration
node_runtime -->|"reads settings"| node_configuration
node_runtime -->|"uses definitions"| node_registers
node_runtime -->|"configures and accesses"| node_controller
node_controller -->|"interrupts"| node_runtime
node_runtime -->|"enqueues frames"| node_rxqueue
node_bus -.->|"provides CAN frames"| node_controller
node_controller -.->|"transmits frames"| node_bus

click node_api "https://github.com/thomasbarth/esp32-can-driver/blob/master/components/can/include/CAN.h"
click node_runtime "https://github.com/thomasbarth/esp32-can-driver/blob/master/components/can/CAN.c"
click node_configuration "https://github.com/thomasbarth/esp32-can-driver/blob/master/components/can/include/CAN_config.h"
click node_registers "https://github.com/thomasbarth/esp32-can-driver/blob/master/components/can/include/can_regdef.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_api,node_runtime,node_configuration,node_registers toneBlue
class node_application,node_bus toneIndigo
class node_rxqueue toneRose
class node_controller toneAmber
```

## Components

### CAN driver

- [Frame API](https://github.com/thomasbarth/esp32-can-driver/blob/master/components/can/include/CAN.h): `components/can/include/CAN.h`
- [CAN runtime](https://github.com/thomasbarth/esp32-can-driver/blob/master/components/can/CAN.c): `components/can/CAN.c`
- [Driver configuration](https://github.com/thomasbarth/esp32-can-driver/blob/master/components/can/include/CAN_config.h): `components/can/include/CAN_config.h`
- [Controller registers](https://github.com/thomasbarth/esp32-can-driver/blob/master/components/can/include/can_regdef.h): `components/can/include/can_regdef.h`

### Other components

- **Application**
- **RX queue**
- **ESP32 CAN controller**
- **CAN bus**

## Connections

- Application → Frame API: uses API
- Frame API → Driver configuration: includes (evidence: `components/can/include/CAN.h`)
- CAN runtime → Driver configuration: reads settings (evidence: `components/can/CAN.c`)
- CAN runtime → Controller registers: uses definitions (evidence: `components/can/CAN.c`)
- CAN runtime → ESP32 CAN controller: configures and accesses (evidence: `components/can/CAN.c`)
- ESP32 CAN controller → CAN runtime: interrupts (evidence: `components/can/CAN.c`)
- CAN runtime → RX queue: enqueues frames (evidence: `components/can/CAN.c`)
- CAN bus → ESP32 CAN controller: provides CAN frames
- ESP32 CAN controller → CAN bus: transmits frames
