From fec60aacbb6aeb6ddb336600d7b6bf8cb5b050eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20J=C3=A4ger?= Date: Tue, 22 Dec 2020 21:50:11 +0100 Subject: [PATCH] Enable CAN for MCUs with CAN-FD controller --- boards/arm/mppt_2420_hc/mppt_2420_hc.dts | 3 --- boards/arm/mppt_2420_hc/mppt_2420_hc_defconfig | 5 ++--- boards/arm/mppt_2420_rc/mppt_2420_rc.dts | 3 --- boards/arm/mppt_2420_rc/mppt_2420_rc_defconfig | 5 ++--- src/ext/can.cpp | 6 +++--- 5 files changed, 7 insertions(+), 15 deletions(-) diff --git a/boards/arm/mppt_2420_hc/mppt_2420_hc.dts b/boards/arm/mppt_2420_hc/mppt_2420_hc.dts index 572e4ad..e18450e 100644 --- a/boards/arm/mppt_2420_hc/mppt_2420_hc.dts +++ b/boards/arm/mppt_2420_hc/mppt_2420_hc.dts @@ -216,8 +216,6 @@ }; }; -/* -// This requires https://github.com/zephyrproject-rtos/zephyr/pull/22832 &can1 { pinctrl-0 = <&fdcan1_rx_pa11 &fdcan1_tx_pa12>; bus-speed = <250000>; @@ -228,4 +226,3 @@ sample-point-data = <875>; status = "okay"; }; -*/ \ No newline at end of file diff --git a/boards/arm/mppt_2420_hc/mppt_2420_hc_defconfig b/boards/arm/mppt_2420_hc/mppt_2420_hc_defconfig index 774b159..d1f3e86 100644 --- a/boards/arm/mppt_2420_hc/mppt_2420_hc_defconfig +++ b/boards/arm/mppt_2420_hc/mppt_2420_hc_defconfig @@ -62,9 +62,8 @@ CONFIG_I2C=y CONFIG_EEPROM=y CONFIG_EEPROM_AT24=y -# don't enable CAN by default until PR #22832 is merged to upstream Zephyr -#CONFIG_CAN=y -#CONFIG_THINGSET_CAN=y +CONFIG_CAN=y +CONFIG_THINGSET_CAN=y CONFIG_ISOTP=y CONFIG_ISOTP_RX_BUF_COUNT=1 diff --git a/boards/arm/mppt_2420_rc/mppt_2420_rc.dts b/boards/arm/mppt_2420_rc/mppt_2420_rc.dts index 1412d6c..5284639 100644 --- a/boards/arm/mppt_2420_rc/mppt_2420_rc.dts +++ b/boards/arm/mppt_2420_rc/mppt_2420_rc.dts @@ -188,8 +188,6 @@ }; }; -/* -// This requires https://github.com/zephyrproject-rtos/zephyr/pull/22832 &can1 { pinctrl-0 = <&fdcan1_rx_pa11 &fdcan1_tx_pa12>; bus-speed = <250000>; @@ -200,4 +198,3 @@ sample-point-data = <875>; status = "okay"; }; -*/ diff --git a/boards/arm/mppt_2420_rc/mppt_2420_rc_defconfig b/boards/arm/mppt_2420_rc/mppt_2420_rc_defconfig index 1a24f32..c4169cf 100644 --- a/boards/arm/mppt_2420_rc/mppt_2420_rc_defconfig +++ b/boards/arm/mppt_2420_rc/mppt_2420_rc_defconfig @@ -61,9 +61,8 @@ CONFIG_I2C_1=y CONFIG_EEPROM=y CONFIG_EEPROM_AT24=y -# don't enable CAN by default until PR #22832 is merged to upstream Zephyr -#CONFIG_CAN=y -#CONFIG_THINGSET_CAN=y +CONFIG_CAN=y +CONFIG_THINGSET_CAN=y CONFIG_ISOTP=y CONFIG_ISOTP_RX_BUF_COUNT=1 diff --git a/src/ext/can.cpp b/src/ext/can.cpp index d6289ca..28981ed 100644 --- a/src/ext/can.cpp +++ b/src/ext/can.cpp @@ -55,7 +55,7 @@ struct isotp_recv_ctx recv_ctx; void send_complette_cb(int error_nr, void *arg) { ARG_UNUSED(arg); - LOG_DBG("TX complete cb [%d]", error_nr); + LOG_DBG("TX complete callback, err: %d", error_nr); } void can_rx_thread() @@ -63,8 +63,8 @@ void can_rx_thread() int ret, rem_len; unsigned int received_len; struct net_buf *buf; - static u8_t rx_buffer[100]; - static u8_t tx_buffer[500]; + static uint8_t rx_buffer[100]; + static uint8_t tx_buffer[500]; // CAN node ID retrieved from EEPROM --> reset necessary after change via ThingSet serial rx_addr.ext_id = ts_can_node_id << 8;