esphome / feature-requests

ESPHome Feature Request Tracker
https://esphome.io/
409 stars 26 forks source link

Add support for second CAN-Bus on ESP32-C6 #2801

Open Adminius opened 1 month ago

Adminius commented 1 month ago

Describe the problem you have/What new integration you would like ESP32-C6 has hardware for two CAN-busses. ESPHome is not cabable to use it

Please describe your use case for this integration and alternatives you've tried: Any dual CAN-bus application. SPI-based CAN transceiver could be an alternative but requeires more wirerig and special hardware.

Additional context for second CAN-Bus API v2 has to be used: https://docs.espressif.com/projects/esp-idf/en/v5.2.2/esp32c6/api-reference/peripherals/twai.html#install-multiple-twai-instances

Adminius commented 1 month ago

Some examples for the new API: https://github.com/MagnusThome/RejsaCAN-ESP32/blob/main/Code%20Examples/RejsaCAN%20v6.x%20-%20ESP32-C6%20-%20dual%20CAN%20-%20Self%20tester/main/main.c

As a quick and dirty solution we can copy esp32_can to esp32_can2 for the second bus, add some v2, like

    twai_handle_t twai_bus_0;
    twai_handle_t twai_bus_1;

and it ready and also beckwards compatible