Add CAN support for MPPT 2420 RC board

The CAN-FD driver is not yet in Zephyr master, so it is required to get
Zephyr PR 22832 to actually use CAN with this MCU.
This commit is contained in:
Martin Jäger
2020-07-23 12:41:24 +02:00
parent d283436747
commit a7f4ccaa91
4 changed files with 36 additions and 6 deletions
+22
View File
@@ -44,6 +44,15 @@
};
};
outputs {
compatible = "outputs";
can_en {
label = "CAN disable / standby";
gpios = <&gpiob 14 GPIO_ACTIVE_LOW>;
};
};
adc-inputs {
compatible = "adc-inputs";
@@ -191,3 +200,16 @@
timeout = <7>;
};
};
/*
// This requires https://github.com/zephyrproject-rtos/zephyr/pull/22832
&can1 {
bus-speed = <250000>;
bus-speed-data = <250000>;
sjw = <1>;
sjw-data = <1>;
sample-point = <875>;
sample-point-data = <875>;
status = "okay";
};
*/
@@ -60,3 +60,7 @@ CONFIG_I2C=y
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_EXT_THINGSET_CAN=y
+7
View File
@@ -30,6 +30,13 @@ static const struct pin_config pinconf[] = {
{STM32_PIN_PA11, STM32G4X_PINMUX_FUNC_PA11_USB_DM},
{STM32_PIN_PA12, STM32G4X_PINMUX_FUNC_PA12_USB_DP},
#endif /* CONFIG_USB_DC_STM32 */
#if DT_NODE_HAS_STATUS(DT_NODELABEL(can1), okay)
{STM32_PIN_PA11, STM32G4X_PINMUX_FUNC_PA11_FDCAN1_RX},
{STM32_PIN_PA12, STM32G4X_PINMUX_FUNC_PA12_FDCAN1_TX},
#endif
#if defined(CONFIG_USB_DC_STM32) && DT_NODE_HAS_STATUS(DT_NODELABEL(can1), okay)
#error "PINMUX does not allow concurrent USB and CAN."
#endif
};
static int pinmux_stm32_init(struct device *port)
+3 -6
View File
@@ -14,7 +14,6 @@
#include <device.h>
#include <drivers/gpio.h>
#include <drivers/can.h>
#include <stm32f0xx_ll_system.h> // needed for debug printing of register contents
#include "board.h"
#include "thingset.h"
@@ -114,11 +113,9 @@ int ThingSetCAN::pub()
int start_pos = 0;
while ((data_len = ts.bin_pub_can(start_pos, PUB_CAN, node_id, can_id, can_data)) != -1) {
struct zcan_frame frame = {
.id_type = CAN_EXTENDED_IDENTIFIER,
.rtr = CAN_DATAFRAME
};
struct zcan_frame frame = {0};
frame.id_type = CAN_STANDARD_IDENTIFIER;
frame.rtr = CAN_DATAFRAME;
frame.ext_id = can_id;
memcpy(frame.data, can_data, 8);