# seeed-studio/seeed_arduino_can architecture

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

- Interactive diagram: https://gitdiagram.com/seeed-studio/seeed_arduino_can
- Repository: https://github.com/seeed-studio/seeed_arduino_can

## Overview

Seeed Arduino CAN is a hardware-facing library for sending and receiving CAN and CAN-FD frames through MCP2515 or MCP2518FD controllers. An Arduino sketch configures a controller through the shared CAN API, then uses it to transmit or receive frames on the bus; sketches can also use the LAWICEL-style serial command interface. The source excerpts show controller setup, frame handling, and SPI access, while the README documents both shield families. Wiring among unsampled features is kept conservative.

Main entry points: [`src/mcp_can.h`](https://github.com/seeed-studio/seeed_arduino_can/blob/master/src/mcp_can.h) (Shared CAN API), [`src/mcp2515_can.cpp`](https://github.com/seeed-studio/seeed_arduino_can/blob/master/src/mcp2515_can.cpp) (MCP2515 driver), [`src/mcp2518fd_can.cpp`](https://github.com/seeed-studio/seeed_arduino_can/blob/master/src/mcp2518fd_can.cpp) (MCP2518FD driver), [`src/can-serial.cpp`](https://github.com/seeed-studio/seeed_arduino_can/blob/master/src/can-serial.cpp) (LAWICEL serial)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["CAN API"]
  node_api["Shared CAN API<br/>[mcp_can.h]"]
  node_base["API base setup<br/>[mcp_can.cpp]"]
end

subgraph group_drivers["Controller Drivers"]
  node_mcp5["MCP2515 driver<br/>[mcp2515_can.cpp]"]
  node_mcpfd["MCP2518FD driver<br/>[mcp2518fd_can.cpp]"]
  node_regs5["MCP2515 definitions<br/>[mcp2515_can_dfs.h]"]
  node_regsfd["FD register definitions"]
end

subgraph group_interfaces["Device Interfaces"]
  node_serial["LAWICEL serial<br/>[can-serial.cpp]"]
  node_serialapi["Serial protocol API<br/>[can-serial.h]"]
end

node_sketch(("Arduino sketch"))
node_spi["SPI interface"]
node_chip5{{"MCP2515 controller"}}
node_chipfd{{"MCP2518FD controller"}}
node_bus(("CAN network"))
node_examples["Usage examples"]

node_sketch -->|"calls"| node_api
node_api -->|"initializes"| node_base
node_api -->|"implemented by"| node_mcp5
node_api -->|"implemented by"| node_mcpfd
node_mcp5 -->|"uses definitions"| node_regs5
node_mcpfd -->|"uses definitions"| node_regsfd
node_mcp5 -->|"transfers over"| node_spi
node_mcpfd -->|"transfers over"| node_spi
node_spi -->|"accesses"| node_chip5
node_spi -->|"accesses"| node_chipfd
node_chip5 -->|"exchanges frames"| node_bus
node_chipfd -->|"exchanges frames"| node_bus
node_sketch -.->|"uses optionally"| node_serialapi
node_serialapi -->|"declares protocol"| node_serial
node_serial -->|"sends and reads"| node_api
node_examples -->|"demonstrates"| node_api

click node_api "https://github.com/seeed-studio/seeed_arduino_can/blob/master/src/mcp_can.h"
click node_base "https://github.com/seeed-studio/seeed_arduino_can/blob/master/src/mcp_can.cpp"
click node_mcp5 "https://github.com/seeed-studio/seeed_arduino_can/blob/master/src/mcp2515_can.cpp"
click node_mcpfd "https://github.com/seeed-studio/seeed_arduino_can/blob/master/src/mcp2518fd_can.cpp"
click node_regs5 "https://github.com/seeed-studio/seeed_arduino_can/blob/master/src/mcp2515_can_dfs.h"
click node_regsfd "https://github.com/seeed-studio/seeed_arduino_can/blob/master/src/mcp2518fd_can_dfs.h"
click node_serial "https://github.com/seeed-studio/seeed_arduino_can/blob/master/src/can-serial.cpp"
click node_serialapi "https://github.com/seeed-studio/seeed_arduino_can/blob/master/src/can-serial.h"
click node_examples "https://github.com/seeed-studio/seeed_arduino_can/tree/master/examples"

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_base toneBlue
class node_mcp5,node_mcpfd,node_regs5,node_regsfd toneAmber
class node_serial,node_serialapi toneMint
class node_sketch,node_spi,node_chip5,node_chipfd,node_bus toneIndigo
class node_examples toneTeal
```

## Components

### CAN API

- [Shared CAN API](https://github.com/seeed-studio/seeed_arduino_can/blob/master/src/mcp_can.h): `src/mcp_can.h`
- [API base setup](https://github.com/seeed-studio/seeed_arduino_can/blob/master/src/mcp_can.cpp): `src/mcp_can.cpp`

### Controller Drivers

- [MCP2515 driver](https://github.com/seeed-studio/seeed_arduino_can/blob/master/src/mcp2515_can.cpp): `src/mcp2515_can.cpp`
- [MCP2518FD driver](https://github.com/seeed-studio/seeed_arduino_can/blob/master/src/mcp2518fd_can.cpp): `src/mcp2518fd_can.cpp`
- [MCP2515 definitions](https://github.com/seeed-studio/seeed_arduino_can/blob/master/src/mcp2515_can_dfs.h): `src/mcp2515_can_dfs.h`
- [FD register definitions](https://github.com/seeed-studio/seeed_arduino_can/blob/master/src/mcp2518fd_can_dfs.h): `src/mcp2518fd_can_dfs.h`

### Device Interfaces

- [LAWICEL serial](https://github.com/seeed-studio/seeed_arduino_can/blob/master/src/can-serial.cpp): `src/can-serial.cpp`
- [Serial protocol API](https://github.com/seeed-studio/seeed_arduino_can/blob/master/src/can-serial.h): `src/can-serial.h`

### Other components

- **Arduino sketch**
- **SPI interface**
- **MCP2515 controller**
- **MCP2518FD controller**
- **CAN network**
- [Usage examples](https://github.com/seeed-studio/seeed_arduino_can/tree/master/examples): `examples`

## Connections

- Arduino sketch → Shared CAN API: calls
- Shared CAN API → API base setup: initializes
- Shared CAN API → MCP2515 driver: implemented by
- Shared CAN API → MCP2518FD driver: implemented by
- MCP2515 driver → MCP2515 definitions: uses definitions
- MCP2518FD driver → FD register definitions: uses definitions
- MCP2515 driver → SPI interface: transfers over
- MCP2518FD driver → SPI interface: transfers over
- SPI interface → MCP2515 controller: accesses
- SPI interface → MCP2518FD controller: accesses
- MCP2515 controller → CAN network: exchanges frames
- MCP2518FD controller → CAN network: exchanges frames
- Arduino sketch → Serial protocol API: uses optionally
- Serial protocol API → LAWICEL serial: declares protocol
- LAWICEL serial → Shared CAN API: sends and reads
- Usage examples → Shared CAN API: demonstrates
