Skip to content

Latest commit

 

History

History
27 lines (20 loc) · 1.68 KB

README.md

File metadata and controls

27 lines (20 loc) · 1.68 KB

Lightweight ESP32 CAN Library

Library to support ESP32 built-in CAN controller.

This project is at experimental stage!

Introduction

When I developed the code for the heating boiler monitoring module (PelletMon) I used several different CAN libraries.

Most of them are linked below, but each of them has disadvantages.

  • The most extensive is esp32_can, but it has a few redundant tasks running in the background. Nevertheless, I took a lot of inspiration from it - for example, the idea for an automatic watchdog.
  • As for ESP32-Arduino-CAN, this library is very simple. It inspired me in the context of the code architecture itself.
  • The last linked library is the basis of most implementations available on the web. In short, it contains all the commands we need to give the SJA1000 module.
  • ... of course, I also used the original TWAI driver from ESP-IDF, but here the most disturbing was its instability - for example, a fatal error in twai_initiate_recovery().

All these issues led me to create my own solution - lw_can - which is lightweight CAN bus library for ESP32.

Features

  • TWAI-like interface known from ESP-IDF (methods like lw_can_install, lw_can_transmit etc)
  • Error counters (arbitration lost, bus error, overrun, passive etc)
  • Watchdog (will reset peripheral in case of error - this is "smart reset" avoiding reset loop - however this is not CAN standard compliant).
  • Various bus speed support (BRP settings available)

Based on