can2040-rust

A pure Rust CAN 2.0 implementation for the RP2040 — no C dependencies, no_std compatible, built for embedded systems.

Motivation

Most CAN libraries for microcontrollers rely on C implementations or vendor HALs. can2040-rust takes a different approach: a from-scratch Rust implementation that targets the RP2040's PIO peripheral for bit-level CAN frame handling.

The result is a self-contained CAN stack with no external C dependencies — just Rust and the RP2040 hardware. This makes it easy to audit, modify, and integrate into larger embedded Rust projects.

Architecture

The library is split into three layers:

  • PIO driver — Handles CAN bit timing and frame assembly via the RP2040's programmable I/O
  • Frame layer — CAN 2.0 frame encoding, decoding, and CRC validation
  • Public API — A clean, idiomatic Rust interface for sending and receiving CAN frames

Usage

As of July 2026, the crate has over 8,500 downloads on crates.io and is used in production by multiple embedded Rust projects — including the Pizzaro firmware and the canopen-rust stack. It has become the go-to CAN library for the RP2040 in the Rust ecosystem.

Status

The library supports standard (11-bit) and extended (29-bit) CAN identifiers, with configurable bit rates up to 1 Mbps. Both standard and extended frame formats are fully supported.

Tech Stack

Language: Rust

Target: RP2040

Protocol: CAN 2.0 A/B

Std: no_std + alloc

License: MIT / Apache 2.0