HF Interface Wrapper 0.1.0-dev
Embedded C++ hardware abstraction layer
Loading...
Searching...
No Matches
EspCan.h File Reference

ESP32 CAN (TWAI) implementation for the HardFOC system - ESP-IDF v5.5 Compatible. More...

#include "McuSelect.h"
#include "esp_twai.h"
#include "esp_twai_onchip.h"
#include "BaseCan.h"
#include "PlatformMutex.h"
#include "utils/EspTypes_CAN.h"
#include <atomic>
#include <memory>
Include dependency graph for EspCan.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  hf_esp_can_config_t
 ESP32 TWAI node configuration structure for ESP-IDF v5.5. More...
 
struct  hf_esp_can_timing_config_t
 Advanced bit timing configuration for fine-tuning. More...
 
struct  hf_esp_can_filter_config_t
 CAN message filter configuration for hardware filtering. More...
 
struct  hf_esp_can_error_info_t
 Comprehensive error information structure for error callbacks. More...
 
struct  hf_esp_can_state_info_t
 Bus state information for state change callbacks. More...
 
struct  hf_esp_can_tx_info_t
 Transmission completion information. More...
 
class  EspCan
 ESP32 CAN (TWAI) implementation using ESP-IDF v5.5+ node-based API. More...
 

Typedefs

using hf_esp_can_receive_callback_t
 User callback function types with user data support.
 
using hf_esp_can_error_callback_t
 
using hf_esp_can_state_callback_t
 
using hf_esp_can_tx_callback_t
 

Detailed Description

ESP32 CAN (TWAI) implementation for the HardFOC system - ESP-IDF v5.5 Compatible.

This file contains the ESP32 CAN (TWAI) implementation that extends the BaseCan abstract class. It provides a clean, minimal, and robust CAN interface using the modern ESP-IDF v5.5+ handle-based TWAI node API with comprehensive testing support for ESP32-C6 with external SN65 transceiver.

Key Features:

  • ESP-IDF v5.5+ handle-based TWAI node API
  • ESP32-C6 compatible TWAI controller support
  • Event-driven callback-based message reception
  • Advanced acceptance filtering (single/dual mask modes)
  • Comprehensive error detection and bus recovery
  • Advanced bit timing configuration for various baud rates
  • Thread-safe operations with proper resource management
  • Support for external SN65 CAN transceivers
  • Comprehensive diagnostics and performance monitoring
Author
Nebiyu Tadesse
Date
2025
Note
This implementation requires ESP-IDF v5.5 or later
Each EspCan instance represents a single TWAI node
Higher-level applications should instantiate multiple EspCan objects for multi-controller boards

Typedef Documentation

◆ hf_esp_can_error_callback_t

Initial value:
void (*)(const hf_esp_can_error_info_t& error_info, void* user_data)
Comprehensive error information structure for error callbacks.
Definition EspCan.h:142

◆ hf_esp_can_receive_callback_t

Initial value:
void (*)(const hf_can_message_t& message, void* user_data)
Platform-agnostic CAN message structure.
Definition BaseCan.h:165

User callback function types with user data support.

◆ hf_esp_can_state_callback_t

Initial value:
void (*)(const hf_esp_can_state_info_t& state_info, void* user_data)
Bus state information for state change callbacks.
Definition EspCan.h:155

◆ hf_esp_can_tx_callback_t

Initial value:
void (*)(const hf_esp_can_tx_info_t& tx_info, void* user_data)
Transmission completion information.
Definition EspCan.h:164