mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-05-24 22:58:30 +02:00
Extend ESP32 CAN bit rates /bus speed support (#5280)
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Co-authored-by: mkaiser <mkaiser@techfak.uni-bielefeld.de>
This commit is contained in:
@@ -16,6 +16,30 @@ static const char *const TAG = "esp32_can";
|
||||
|
||||
static bool get_bitrate(canbus::CanSpeed bitrate, twai_timing_config_t *t_config) {
|
||||
switch (bitrate) {
|
||||
#if defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3) || defined(USE_ESP32_VARIANT_ESP32C3) || \
|
||||
defined(USE_ESP32_VARIANT_ESP32C6) || defined(USE_ESP32_VARIANT_ESP32H6)
|
||||
case canbus::CAN_1KBPS:
|
||||
*t_config = (twai_timing_config_t) TWAI_TIMING_CONFIG_1KBITS();
|
||||
return true;
|
||||
case canbus::CAN_5KBPS:
|
||||
*t_config = (twai_timing_config_t) TWAI_TIMING_CONFIG_5KBITS();
|
||||
return true;
|
||||
case canbus::CAN_10KBPS:
|
||||
*t_config = (twai_timing_config_t) TWAI_TIMING_CONFIG_10KBITS();
|
||||
return true;
|
||||
case canbus::CAN_12K5BPS:
|
||||
*t_config = (twai_timing_config_t) TWAI_TIMING_CONFIG_12_5KBITS();
|
||||
return true;
|
||||
case canbus::CAN_16KBPS:
|
||||
*t_config = (twai_timing_config_t) TWAI_TIMING_CONFIG_16KBITS();
|
||||
return true;
|
||||
case canbus::CAN_20KBPS:
|
||||
*t_config = (twai_timing_config_t) TWAI_TIMING_CONFIG_20KBITS();
|
||||
return true;
|
||||
#endif
|
||||
case canbus::CAN_25KBPS:
|
||||
*t_config = (twai_timing_config_t) TWAI_TIMING_CONFIG_25KBITS();
|
||||
return true;
|
||||
case canbus::CAN_50KBPS:
|
||||
*t_config = (twai_timing_config_t) TWAI_TIMING_CONFIG_50KBITS();
|
||||
return true;
|
||||
@@ -31,6 +55,9 @@ static bool get_bitrate(canbus::CanSpeed bitrate, twai_timing_config_t *t_config
|
||||
case canbus::CAN_500KBPS:
|
||||
*t_config = (twai_timing_config_t) TWAI_TIMING_CONFIG_500KBITS();
|
||||
return true;
|
||||
case canbus::CAN_800KBPS:
|
||||
*t_config = (twai_timing_config_t) TWAI_TIMING_CONFIG_800KBITS();
|
||||
return true;
|
||||
case canbus::CAN_1000KBPS:
|
||||
*t_config = (twai_timing_config_t) TWAI_TIMING_CONFIG_1MBITS();
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user