diff --git a/boards/can-module_com/canBridge_Oleksii_g473/Kconfig.canBridge_Oleksii_g473 b/boards/can-module_com/canBridge_Oleksii_g473/Kconfig.canBridge_Oleksii_g473 new file mode 100644 index 0000000000000..f60eb29173646 --- /dev/null +++ b/boards/can-module_com/canBridge_Oleksii_g473/Kconfig.canBridge_Oleksii_g473 @@ -0,0 +1,3 @@ + +config BOARD_CANBRIDGE_OLEKSII_G473 + select SOC_STM32G473XX diff --git a/boards/can-module_com/canBridge_Oleksii_g473/board.cmake b/boards/can-module_com/canBridge_Oleksii_g473/board.cmake new file mode 100644 index 0000000000000..5b98199c697ca --- /dev/null +++ b/boards/can-module_com/canBridge_Oleksii_g473/board.cmake @@ -0,0 +1,6 @@ +# Copyright (c) 2024 Alexander Kozhinov +# SPDX-License-Identifier: Apache-2.0 + +board_runner_args(openocd "--config=${BOARD_DIR}/support/openocd.cfg") + +include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake) diff --git a/boards/can-module_com/canBridge_Oleksii_g473/board.yml b/boards/can-module_com/canBridge_Oleksii_g473/board.yml new file mode 100644 index 0000000000000..eb52152884bc1 --- /dev/null +++ b/boards/can-module_com/canBridge_Oleksii_g473/board.yml @@ -0,0 +1,6 @@ +board: + name: canBridge_Oleksii_g473 + full_name: USB CANFD TRIO + vendor: can-module.com + socs: + - name: stm32g473xx diff --git a/boards/can-module_com/canBridge_Oleksii_g473/canBridge_Oleksii_g473.dts b/boards/can-module_com/canBridge_Oleksii_g473/canBridge_Oleksii_g473.dts new file mode 100644 index 0000000000000..3387c3843be9d --- /dev/null +++ b/boards/can-module_com/canBridge_Oleksii_g473/canBridge_Oleksii_g473.dts @@ -0,0 +1,118 @@ + +/dts-v1/; +#include +#include + +/ { + model = "CAN BRIDGE"; + compatible = "canBridge_Oleksii,canBridge_Oleksii_g473"; + + chosen { + zephyr,sram = &sram0; + zephyr,flash = &flash0; + zephyr,canbus = &fdcan1; + }; + + aliases { + led0 = &led_can1; + led1 = &led_can2; + led2 = &led_can3; + led3 = &led_stat; + + }; + + leds: leds { + compatible = "gpio-leds"; + + led_can1: led_can1 { + gpios = <&gpioc 13 GPIO_ACTIVE_HIGH>; + label = "LED_CAN1"; + }; + + led_can2: led_can2 { + gpios = <&gpiob 7 GPIO_ACTIVE_HIGH>; + label = "LED_CAN2"; + }; + led_can3: led_can3 { + gpios = <&gpioa 15 GPIO_ACTIVE_HIGH>; + label = "LED_CAN3"; + }; + + led_stat: led_stat { + gpios = <&gpioa 5 GPIO_ACTIVE_HIGH>; + label = "LED_STAT"; + }; + }; +}; + +/* +&clk_hsi { // Internal 16 MHz clock used to drive PLL + status = "okay"; +}; +*/ + +&clk_hse { + clock-frequency = ; /* HSE 8 Mhz */ + status = "okay"; +}; + + +&clk_hsi48 { + /* Internal 48 MHz clock used to drive USB */ + status = "okay"; +}; + +/* Adjust the pll for a SYSTEM Clock of 160 MHz */ +&pll { + div-m = <2>; // 4 16Mhz + mul-n = <80>; + div-p = <2>; + div-q = <4>; + div-r = <2>; + clocks = <&clk_hse>;//<&clk_hsi> + status = "okay"; +}; + +&rcc { + clocks = <&pll>; + clock-frequency = ; + ahb-prescaler = <1>; + apb1-prescaler = <1>; + apb2-prescaler = <1>; +}; + +stm32_lp_tick_source: &lptim1 { + clocks = <&rcc STM32_CLOCK(APB1, 31)>, + <&rcc STM32_SRC_LSE LPTIM1_SEL(3)>; + status = "okay"; +}; + +zephyr_udc0: &usb { + pinctrl-0 = <&usb_dm_pa11 &usb_dp_pa12>; + pinctrl-names = "default"; + clocks = <&rcc STM32_CLOCK(APB1, 23)>, + <&rcc STM32_SRC_HSI48 CLK48_SEL(0)>; + status = "okay"; +}; + +&fdcan1 { + pinctrl-0 = <&fdcan1_rx_pb8 &fdcan1_tx_pb9>; + pinctrl-names = "default"; + clocks = <&rcc STM32_CLOCK(APB1, 25)>, + <&rcc STM32_SRC_PLL_Q FDCAN_SEL(1)>; + status = "okay"; +}; +&fdcan2 { + pinctrl-0 = <&fdcan2_rx_pb5 &fdcan2_tx_pb6>; + pinctrl-names = "default"; + clocks = <&rcc STM32_CLOCK(APB1, 25)>, + <&rcc STM32_SRC_PLL_Q FDCAN_SEL(1)>; + status = "okay"; +}; +&fdcan3 { + pinctrl-0 = <&fdcan3_rx_pb3 &fdcan3_tx_pb4>; + pinctrl-names = "default"; + clocks = <&rcc STM32_CLOCK(APB1, 25)>, + <&rcc STM32_SRC_PLL_Q FDCAN_SEL(1)>; + status = "okay"; +}; diff --git a/boards/can-module_com/canBridge_Oleksii_g473/canBridge_Oleksii_g473.yaml b/boards/can-module_com/canBridge_Oleksii_g473/canBridge_Oleksii_g473.yaml new file mode 100644 index 0000000000000..d21157645d2a6 --- /dev/null +++ b/boards/can-module_com/canBridge_Oleksii_g473/canBridge_Oleksii_g473.yaml @@ -0,0 +1,16 @@ +identifier: canBridge_Oleksii_g473 +name: USB CANFD TRIO +type: mcu +arch: arm +toolchain: + - zephyr + - gnuarmemb +ram: 128 +flash: 128 +supported: + - can + - counter + - gpio + - usb_device + - usbd +vendor: can-module.com diff --git a/boards/can-module_com/canBridge_Oleksii_g473/canBridge_Oleksii_g473_defconfig b/boards/can-module_com/canBridge_Oleksii_g473/canBridge_Oleksii_g473_defconfig new file mode 100644 index 0000000000000..63c273423036f --- /dev/null +++ b/boards/can-module_com/canBridge_Oleksii_g473/canBridge_Oleksii_g473_defconfig @@ -0,0 +1,3 @@ + +CONFIG_GPIO=y +CONFIG_ARM_MPU=y diff --git a/boards/can-module_com/canBridge_Oleksii_g473/doc/img/CanBridge.png b/boards/can-module_com/canBridge_Oleksii_g473/doc/img/CanBridge.png new file mode 100644 index 0000000000000..c3df2a2d64e28 Binary files /dev/null and b/boards/can-module_com/canBridge_Oleksii_g473/doc/img/CanBridge.png differ diff --git a/boards/can-module_com/canBridge_Oleksii_g473/doc/index.rst b/boards/can-module_com/canBridge_Oleksii_g473/doc/index.rst new file mode 100644 index 0000000000000..bc28986e50f0e --- /dev/null +++ b/boards/can-module_com/canBridge_Oleksii_g473/doc/index.rst @@ -0,0 +1,60 @@ +.. zephyr:board:: canBridge_Oleksii_g473 + + + +USB_CANFD_Bridge +###################### + +CAN_Bridge & USBCANFD 3ch. up to 5 Mbps ++ RS422 + +can-module.com + +.. figure:: img/CanBridge.png + :align: center + :alt: CanBridge_3ch + + CanBridge_3ch CANFD + + +https://github.com/AlekseyMamontov/CANnectivity-CANFD-adapters + + + +Default Zephyr Peripheral Mapping: +---------------------------------- + +.. rst-class:: rst-columns + +- CAN_RX1: PB8 +- CAN_TX2: PB9 +- CAN_RX2: PB5 +- CAN_TX2: PB6- + CAN_RX3: PB4 +- CAN_TX3: PB3 + +- ledCAN1 : PC13 +- LedCAN2 : PB7 +- ledCAN3 : PA15 +- LedSTAT : PA5 + +- USB_DN : PA11 +- USB_DP : PA12 + +- RS422 TX : PA2 +- RS422 RX : PA3 + +- SWDIO : PA13 +- SWCLK : PA14 +- NRST : PG10 + +System Clock +------------ +The FDCAN1,FDCAN2,FDCAN3 peripheral is driven by PLLQ, which has 80 MHz frequency. + + +.. _STM32G4 reference manual: + https://www.st.com/resource/en/reference_manual/rm0440-stm32g4-series-advanced-armbased-32bit-mcus-stmicroelectronics.pdf + +.. _STM32CubeProgrammer: + https://www.st.com/en/development-tools/stm32cubeprog.html diff --git a/boards/can-module_com/canBridge_Oleksii_g473/support/openocd.cfg b/boards/can-module_com/canBridge_Oleksii_g473/support/openocd.cfg new file mode 100644 index 0000000000000..b614de4fbf5cc --- /dev/null +++ b/boards/can-module_com/canBridge_Oleksii_g473/support/openocd.cfg @@ -0,0 +1,5 @@ +# Copyright (c) 2024 Alexander Kozhinov +# SPDX-License-Identifier: Apache-2.0 + +source [find interface/stlink.cfg] +source [find target/stm32g4x.cfg] diff --git a/boards/can-module_com/usbcan_iso/Kconfig.usbcan_iso b/boards/can-module_com/usbcan_iso/Kconfig.usbcan_iso new file mode 100644 index 0000000000000..9599beccae43a --- /dev/null +++ b/boards/can-module_com/usbcan_iso/Kconfig.usbcan_iso @@ -0,0 +1,5 @@ +# Copyright (c) 2024 Henrik Brix Andersen +# SPDX-License-Identifier: Apache-2.0 + +config BOARD_USBCAN_ISO + select SOC_STM32F072XB diff --git a/boards/can-module_com/usbcan_iso/board.cmake b/boards/can-module_com/usbcan_iso/board.cmake new file mode 100644 index 0000000000000..c383530f74c8a --- /dev/null +++ b/boards/can-module_com/usbcan_iso/board.cmake @@ -0,0 +1,8 @@ +# Copyright (c) 2024 Henrik Brix Andersen +# SPDX-License-Identifier: Apache-2.0 + +board_runner_args(dfu-util "--pid=0483:df11" "--alt=0" "--dfuse") +board_runner_args(jlink "--device=STM32F072CB") + +include(${ZEPHYR_BASE}/boards/common/dfu-util.board.cmake) +include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake) diff --git a/boards/can-module_com/usbcan_iso/board.yml b/boards/can-module_com/usbcan_iso/board.yml new file mode 100644 index 0000000000000..6ba15408d1f94 --- /dev/null +++ b/boards/can-module_com/usbcan_iso/board.yml @@ -0,0 +1,6 @@ +board: + name: usbcan_iso + full_name: USBAN_Iso + vendor: can-module.com + socs: + - name: stm32f072xb diff --git a/boards/can-module_com/usbcan_iso/doc/index.rst b/boards/can-module_com/usbcan_iso/doc/index.rst new file mode 100644 index 0000000000000..8c23d8ee2e44d --- /dev/null +++ b/boards/can-module_com/usbcan_iso/doc/index.rst @@ -0,0 +1,50 @@ +.. zephyr:board:: usbcan + +Overview +******** + +The USBCAN isolated is an open-source USB to CAN 2.0B adapter board. +******** + + + +.. figure:: standart072.png + :align: center + :alt: USBCAN 2.0 + + USBCAN 2.0 + + + +The USBCAN board is equipped with a STM32F072CB microcontroller + +Supported Features +================== + +.. zephyr:board-supported-hw:: + +System Clock +============ + +The STM32F072CB PLL is driven by an external crystal oscillator (HSE) running at 8 MHz and +configured to provide a system clock of 48 MHz. + +Programming and Debugging +************************* + +.. zephyr:board-supported-runners:: + +Build and flash applications as usual (see :ref:`build_an_application` and +:ref:`application_run` for more details). + +If flashing via USB DFU, short pins ``Boot0`` to the USBCAN board in +order to enter the built-in DFU mode. + +Here is an example for the :zephyr:code-sample:`blinky` application. + +.. zephyr-app-commands:: + :zephyr-app: samples/basic/blinky + :board: usbcan + :goals: flash + +.. _USBCAN iso website: can-module.com diff --git a/boards/can-module_com/usbcan_iso/doc/standart072.png b/boards/can-module_com/usbcan_iso/doc/standart072.png new file mode 100644 index 0000000000000..55ab882860cd6 Binary files /dev/null and b/boards/can-module_com/usbcan_iso/doc/standart072.png differ diff --git a/boards/can-module_com/usbcan_iso/usbcan_iso.dts b/boards/can-module_com/usbcan_iso/usbcan_iso.dts new file mode 100644 index 0000000000000..2fe182fbf3782 --- /dev/null +++ b/boards/can-module_com/usbcan_iso/usbcan_iso.dts @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2024 Henrik Brix Andersen + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; + +#include +#include + +/ { + model = "USBCAN board"; + compatible = "usbcan,usbcan_iso"; + + chosen { + zephyr,sram = &sram0; + zephyr,flash = &flash0; + zephyr,code-partition = &slot0_partition; + zephyr,canbus = &can1; + }; + + aliases { + led0 = &led_rx; + led1 = &led_tx; + }; + + leds { + compatible = "gpio-leds"; + + led_rx: led_rx { + gpios = <&gpiob 1 GPIO_ACTIVE_HIGH>; + label = "LED RX"; + }; + + led_tx: led_tx { + gpios = <&gpiob 0 GPIO_ACTIVE_HIGH>; + label = "LED TX"; + }; + }; +/**/ +}; + +&clk_hse { + status = "okay"; + clock-frequency = ; +}; + +&pll { + prediv = <1>; + mul = <6>; + clocks = <&clk_hse>; + status = "okay"; +}; + +&rcc { + clocks = <&pll>; + clock-frequency = ; + ahb-prescaler = <1>; + apb1-prescaler = <1>; +}; + +zephyr_udc0: &usb { + pinctrl-0 = <&usb_dm_pa11 &usb_dp_pa12>; + pinctrl-names = "default"; + status = "okay"; +}; + +&can1 { + pinctrl-0 = <&can_rx_pb8 &can_tx_pb9>; + pinctrl-names = "default"; + status = "okay"; +}; + +&flash0 { + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + boot_partition: partition@0 { + label = "mcuboot"; + reg = <0x00000000 DT_SIZE_K(48)>; + read-only; + }; + + slot0_partition: partition@c000 { + label = "image-0"; + reg = <0x0000c000 DT_SIZE_K(80)>; + }; + }; +}; diff --git a/boards/can-module_com/usbcan_iso/usbcan_iso.yaml b/boards/can-module_com/usbcan_iso/usbcan_iso.yaml new file mode 100644 index 0000000000000..d90e907b43ed0 --- /dev/null +++ b/boards/can-module_com/usbcan_iso/usbcan_iso.yaml @@ -0,0 +1,15 @@ +identifier: usbcan_iso +name: USBCAN +type: mcu +arch: arm +toolchain: + - zephyr + - gnuarmemb +ram: 16 +flash: 128 +supported: + - can + - gpio + - usb_device + - usbd +vendor: can-module.com diff --git a/boards/can-module_com/usbcan_iso/usbcan_iso_defconfig b/boards/can-module_com/usbcan_iso/usbcan_iso_defconfig new file mode 100644 index 0000000000000..91c3c15b37d1e --- /dev/null +++ b/boards/can-module_com/usbcan_iso/usbcan_iso_defconfig @@ -0,0 +1 @@ +CONFIG_GPIO=y diff --git a/boards/can-module_com/usbcanfd_Oleksii_g431/Kconfig.usbcanfd_Oleksii_g431 b/boards/can-module_com/usbcanfd_Oleksii_g431/Kconfig.usbcanfd_Oleksii_g431 new file mode 100644 index 0000000000000..e9f13128e16ba --- /dev/null +++ b/boards/can-module_com/usbcanfd_Oleksii_g431/Kconfig.usbcanfd_Oleksii_g431 @@ -0,0 +1,3 @@ + +config BOARD_USBCANFD_OLEKSII_G431 + select SOC_STM32G431XX diff --git a/boards/can-module_com/usbcanfd_Oleksii_g431/board.cmake b/boards/can-module_com/usbcanfd_Oleksii_g431/board.cmake new file mode 100644 index 0000000000000..5b98199c697ca --- /dev/null +++ b/boards/can-module_com/usbcanfd_Oleksii_g431/board.cmake @@ -0,0 +1,6 @@ +# Copyright (c) 2024 Alexander Kozhinov +# SPDX-License-Identifier: Apache-2.0 + +board_runner_args(openocd "--config=${BOARD_DIR}/support/openocd.cfg") + +include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake) diff --git a/boards/can-module_com/usbcanfd_Oleksii_g431/board.yml b/boards/can-module_com/usbcanfd_Oleksii_g431/board.yml new file mode 100644 index 0000000000000..88febb3036871 --- /dev/null +++ b/boards/can-module_com/usbcanfd_Oleksii_g431/board.yml @@ -0,0 +1,6 @@ +board: + name: usbcanfd_Oleksii_g431 + full_name: USB CANFD SOLO + vendor: can-module.com + socs: + - name: stm32g431xx diff --git a/boards/can-module_com/usbcanfd_Oleksii_g431/doc/img/G431.png b/boards/can-module_com/usbcanfd_Oleksii_g431/doc/img/G431.png new file mode 100644 index 0000000000000..eea87e5f5807b Binary files /dev/null and b/boards/can-module_com/usbcanfd_Oleksii_g431/doc/img/G431.png differ diff --git a/boards/can-module_com/usbcanfd_Oleksii_g431/doc/index.rst b/boards/can-module_com/usbcanfd_Oleksii_g431/doc/index.rst new file mode 100644 index 0000000000000..79f15dda2a01b --- /dev/null +++ b/boards/can-module_com/usbcanfd_Oleksii_g431/doc/index.rst @@ -0,0 +1,49 @@ +.. zephyr:board:: usbcanfd_Oleksii_g473 + +USBCANFD SOLO +###################### + +Adapter USBCANFD 1ch. up to 8 Mbps +can-module.com + +.. figure:: img/G431.png + :align: center + :alt: USBCANFD SOLO + + USBCANFD SOLO + + +https://github.com/AlekseyMamontov/CANnectivity-CANFD-adapters + + + + + +Default Zephyr Peripheral Mapping: +---------------------------------- + +.. rst-class:: rst-columns + +- CAN_RX/BOOT0 : PB8 +- CAN_TX : PB9 +- ledRX: PA6 +- LedTX : PA5 +- USB_DN : PA11 +- USB_DP : PA12 +- SWDIO : PA13 +- SWCLK : PA14 +- NRST : PG10 + +System Clock +------------ +The FDCAN1 peripheral is driven by PLLQ, which has 80 MHz frequency. + + +.. _STM32G431C8 on www.st.com: + https://www.st.com/en/microcontrollers-microprocessors/stm32g431c8.html + +.. _STM32G4 reference manual: + https://www.st.com/resource/en/reference_manual/rm0440-stm32g4-series-advanced-armbased-32bit-mcus-stmicroelectronics.pdf + +.. _STM32CubeProgrammer: + https://www.st.com/en/development-tools/stm32cubeprog.html diff --git a/boards/can-module_com/usbcanfd_Oleksii_g431/support/openocd.cfg b/boards/can-module_com/usbcanfd_Oleksii_g431/support/openocd.cfg new file mode 100644 index 0000000000000..b614de4fbf5cc --- /dev/null +++ b/boards/can-module_com/usbcanfd_Oleksii_g431/support/openocd.cfg @@ -0,0 +1,5 @@ +# Copyright (c) 2024 Alexander Kozhinov +# SPDX-License-Identifier: Apache-2.0 + +source [find interface/stlink.cfg] +source [find target/stm32g4x.cfg] diff --git a/boards/can-module_com/usbcanfd_Oleksii_g431/usbcanfd_Oleksii_g431.dts b/boards/can-module_com/usbcanfd_Oleksii_g431/usbcanfd_Oleksii_g431.dts new file mode 100644 index 0000000000000..6da95627f8e7f --- /dev/null +++ b/boards/can-module_com/usbcanfd_Oleksii_g431/usbcanfd_Oleksii_g431.dts @@ -0,0 +1,91 @@ + +/dts-v1/; +#include +#include + +/ { + model = "USB CANFD SOLO"; + compatible = "usbcanfd_Oleksii,usbcanfd_Oleksii_g431"; + + chosen { + zephyr,sram = &sram0; + zephyr,flash = &flash0; + zephyr,canbus = &fdcan1; + }; + + aliases { + led0 = &led_rx; + led1 = &led_tx; + }; + + leds: leds { + compatible = "gpio-leds"; + + led_rx: led_rx { + gpios = <&gpioa 6 GPIO_ACTIVE_HIGH>; + label = "RX"; + }; + + led_tx: led_tx { + gpios = <&gpioa 5 GPIO_ACTIVE_HIGH>; + label = "TX"; + }; + }; +}; +/* +&clk_hsi { // Internal 16 MHz clock used to drive PLL + status = "okay"; +}; +*/ + +&clk_hse { + clock-frequency = ; /* HSE 8 Mhz */ + status = "okay"; +}; + + +&clk_hsi48 { + /* Internal 48 MHz clock used to drive USB */ + status = "okay"; +}; + +/* Adjust the pll for a SYSTEM Clock of 160 MHz */ +&pll { + div-m = <2>; + mul-n = <80>; + div-p = <2>; + div-q = <4>; + div-r = <2>; + clocks = <&clk_hse>;//<&clk_hsi> + status = "okay"; +}; + +&rcc { + clocks = <&pll>; + clock-frequency = ; + ahb-prescaler = <1>; + apb1-prescaler = <1>; + apb2-prescaler = <1>; +}; + +stm32_lp_tick_source: &lptim1 { + clocks = <&rcc STM32_CLOCK(APB1, 31)>, + <&rcc STM32_SRC_LSE LPTIM1_SEL(3)>; + status = "okay"; +}; + +zephyr_udc0: &usb { + pinctrl-0 = <&usb_dm_pa11 &usb_dp_pa12>; + pinctrl-names = "default"; + clocks = <&rcc STM32_CLOCK(APB1, 23)>, + <&rcc STM32_SRC_HSI48 CLK48_SEL(0)>; + status = "okay"; +}; + +&fdcan1 { + pinctrl-0 = <&fdcan1_rx_pb8 &fdcan1_tx_pb9>; + pinctrl-names = "default"; + clocks = <&rcc STM32_CLOCK(APB1, 25)>, + <&rcc STM32_SRC_PLL_Q FDCAN_SEL(1)>; + status = "okay"; +}; diff --git a/boards/can-module_com/usbcanfd_Oleksii_g431/usbcanfd_Oleksii_g431.yaml b/boards/can-module_com/usbcanfd_Oleksii_g431/usbcanfd_Oleksii_g431.yaml new file mode 100644 index 0000000000000..bee9b3e49beec --- /dev/null +++ b/boards/can-module_com/usbcanfd_Oleksii_g431/usbcanfd_Oleksii_g431.yaml @@ -0,0 +1,16 @@ +identifier: usbcanfd_Oleksii_g431 +name: USB CANFD SOLO +type: mcu +arch: arm +toolchain: + - zephyr + - gnuarmemb +ram: 32 +flash: 64 +supported: + - can + - counter + - gpio + - usb_device + - usbd +vendor: can-module.com diff --git a/boards/can-module_com/usbcanfd_Oleksii_g431/usbcanfd_Oleksii_g431_defconfig b/boards/can-module_com/usbcanfd_Oleksii_g431/usbcanfd_Oleksii_g431_defconfig new file mode 100644 index 0000000000000..63c273423036f --- /dev/null +++ b/boards/can-module_com/usbcanfd_Oleksii_g431/usbcanfd_Oleksii_g431_defconfig @@ -0,0 +1,3 @@ + +CONFIG_GPIO=y +CONFIG_ARM_MPU=y diff --git a/boards/can-module_com/usbcanfd_Oleksii_g473/Kconfig.usbcanfd_Oleksii_g473 b/boards/can-module_com/usbcanfd_Oleksii_g473/Kconfig.usbcanfd_Oleksii_g473 new file mode 100644 index 0000000000000..a1429497cea8e --- /dev/null +++ b/boards/can-module_com/usbcanfd_Oleksii_g473/Kconfig.usbcanfd_Oleksii_g473 @@ -0,0 +1,3 @@ + +config BOARD_USBCANFD_OLEKSII_G473 + select SOC_STM32G473XX diff --git a/boards/can-module_com/usbcanfd_Oleksii_g473/board.cmake b/boards/can-module_com/usbcanfd_Oleksii_g473/board.cmake new file mode 100644 index 0000000000000..5b98199c697ca --- /dev/null +++ b/boards/can-module_com/usbcanfd_Oleksii_g473/board.cmake @@ -0,0 +1,6 @@ +# Copyright (c) 2024 Alexander Kozhinov +# SPDX-License-Identifier: Apache-2.0 + +board_runner_args(openocd "--config=${BOARD_DIR}/support/openocd.cfg") + +include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake) diff --git a/boards/can-module_com/usbcanfd_Oleksii_g473/board.yml b/boards/can-module_com/usbcanfd_Oleksii_g473/board.yml new file mode 100644 index 0000000000000..8ecae1fe228ca --- /dev/null +++ b/boards/can-module_com/usbcanfd_Oleksii_g473/board.yml @@ -0,0 +1,6 @@ +board: + name: usbcanfd_Oleksii_g473 + full_name: USB CANFD DUAL + vendor: can-module.com + socs: + - name: stm32g473xx diff --git a/boards/can-module_com/usbcanfd_Oleksii_g473/doc/img/G473.png b/boards/can-module_com/usbcanfd_Oleksii_g473/doc/img/G473.png new file mode 100644 index 0000000000000..92430c466505c Binary files /dev/null and b/boards/can-module_com/usbcanfd_Oleksii_g473/doc/img/G473.png differ diff --git a/boards/can-module_com/usbcanfd_Oleksii_g473/doc/index.rst b/boards/can-module_com/usbcanfd_Oleksii_g473/doc/index.rst new file mode 100644 index 0000000000000..b853df7e6e55f --- /dev/null +++ b/boards/can-module_com/usbcanfd_Oleksii_g473/doc/index.rst @@ -0,0 +1,52 @@ +.. zephyr:board:: usbcanfd_Oleksii_g473 + +USBCANFD DUAl +###################### + +Adapter USBCANFD 2ch. up to 8 Mbps +can-module.com + +.. figure:: img/G473.png + :align: center + :alt: USBCANFD DUAl + + USBCANFD DUAl (2ch.canfd) + + +https://github.com/AlekseyMamontov/CANnectivity-CANFD-adapters + + +Default Zephyr Peripheral Mapping: +---------------------------------- + +.. rst-class:: rst-columns + + + +- CAN_RX/BOOT0 : PB8 +- CAN_TX : PB9 +- CAN_RX2: PB5 +- CAN_TX2: PB6 + +- ledRX : PA6 +- LedTX : PA5 +- ledRX2 : PA4 +- LedTX2 : PA2 + +- USB_DN : PA11 +- USB_DP : PA12 + +- SWDIO : PA13 +- SWCLK : PA14 +- NRST : PG10 + +System Clock +------------ +The FDCAN1,FDCAN2 peripheral is driven by PLLQ, which has 80 MHz frequency. + + +.. _STM32G4 reference manual: + https://www.st.com/resource/en/reference_manual/rm0440-stm32g4-series-advanced-armbased-32bit-mcus-stmicroelectronics.pdf + +.. _STM32CubeProgrammer: + https://www.st.com/en/development-tools/stm32cubeprog.html diff --git a/boards/can-module_com/usbcanfd_Oleksii_g473/support/openocd.cfg b/boards/can-module_com/usbcanfd_Oleksii_g473/support/openocd.cfg new file mode 100644 index 0000000000000..b614de4fbf5cc --- /dev/null +++ b/boards/can-module_com/usbcanfd_Oleksii_g473/support/openocd.cfg @@ -0,0 +1,5 @@ +# Copyright (c) 2024 Alexander Kozhinov +# SPDX-License-Identifier: Apache-2.0 + +source [find interface/stlink.cfg] +source [find target/stm32g4x.cfg] diff --git a/boards/can-module_com/usbcanfd_Oleksii_g473/usbcanfd_Oleksii_g473.dts b/boards/can-module_com/usbcanfd_Oleksii_g473/usbcanfd_Oleksii_g473.dts new file mode 100644 index 0000000000000..75ec733667990 --- /dev/null +++ b/boards/can-module_com/usbcanfd_Oleksii_g473/usbcanfd_Oleksii_g473.dts @@ -0,0 +1,111 @@ + +/dts-v1/; +#include +#include + +/ { + model = "USB CANFD DUAL"; + compatible = "usbcanfd_Oleksii,usbcanfd_Oleksii_g473"; + + chosen { + zephyr,sram = &sram0; + zephyr,flash = &flash0; + zephyr,canbus = &fdcan1; + }; + + aliases { + led0 = &led_rx; + led1 = &led_tx; + led2 = &led_rx2; + led3 = &led_tx2; + + }; + + leds: leds { + compatible = "gpio-leds"; + + led_rx: led_rx { + gpios = <&gpioa 6 GPIO_ACTIVE_HIGH>; + label = "RX"; + }; + + led_tx: led_tx { + gpios = <&gpioa 5 GPIO_ACTIVE_HIGH>; + label = "TX"; + }; + led_rx2: led_rx2 { + gpios = <&gpioa 4 GPIO_ACTIVE_HIGH>; + label = "RX2"; + }; + + led_tx2: led_tx2 { + gpios = <&gpioa 3 GPIO_ACTIVE_HIGH>; + label = "TX2"; + }; + }; +}; + +/* +&clk_hsi { // Internal 16 MHz clock used to drive PLL + status = "okay"; +}; +*/ + +&clk_hse { + clock-frequency = ; /* HSE 8 Mhz */ + status = "okay"; +}; + + +&clk_hsi48 { + /* Internal 48 MHz clock used to drive USB */ + status = "okay"; +}; + +/* Adjust the pll for a SYSTEM Clock of 160 MHz */ +&pll { + div-m = <2>; // 4 16Mhz + mul-n = <80>; + div-p = <2>; + div-q = <4>; + div-r = <2>; + clocks = <&clk_hse>;//<&clk_hsi> + status = "okay"; +}; + +&rcc { + clocks = <&pll>; + clock-frequency = ; + ahb-prescaler = <1>; + apb1-prescaler = <1>; + apb2-prescaler = <1>; +}; + +stm32_lp_tick_source: &lptim1 { + clocks = <&rcc STM32_CLOCK(APB1, 31)>, + <&rcc STM32_SRC_LSE LPTIM1_SEL(3)>; + status = "okay"; +}; + +zephyr_udc0: &usb { + pinctrl-0 = <&usb_dm_pa11 &usb_dp_pa12>; + pinctrl-names = "default"; + clocks = <&rcc STM32_CLOCK(APB1, 23)>, + <&rcc STM32_SRC_HSI48 CLK48_SEL(0)>; + status = "okay"; +}; + +&fdcan1 { + pinctrl-0 = <&fdcan1_rx_pb8 &fdcan1_tx_pb9>; + pinctrl-names = "default"; + clocks = <&rcc STM32_CLOCK(APB1, 25)>, + <&rcc STM32_SRC_PLL_Q FDCAN_SEL(1)>; + status = "okay"; +}; +&fdcan2 { + pinctrl-0 = <&fdcan2_rx_pb5 &fdcan2_tx_pb6>; + pinctrl-names = "default"; + clocks = <&rcc STM32_CLOCK(APB1, 25)>, + <&rcc STM32_SRC_PLL_Q FDCAN_SEL(1)>; + status = "okay"; +}; diff --git a/boards/can-module_com/usbcanfd_Oleksii_g473/usbcanfd_Oleksii_g473.yaml b/boards/can-module_com/usbcanfd_Oleksii_g473/usbcanfd_Oleksii_g473.yaml new file mode 100644 index 0000000000000..b938a42f41be1 --- /dev/null +++ b/boards/can-module_com/usbcanfd_Oleksii_g473/usbcanfd_Oleksii_g473.yaml @@ -0,0 +1,16 @@ +identifier: usbcanfd_Oleksii_g473 +name: USB CANFD DUAL +type: mcu +arch: arm +toolchain: + - zephyr + - gnuarmemb +ram: 128 +flash: 128 +supported: + - can + - counter + - gpio + - usb_device + - usbd +vendor: can-module.com diff --git a/boards/can-module_com/usbcanfd_Oleksii_g473/usbcanfd_Oleksii_g473_defconfig b/boards/can-module_com/usbcanfd_Oleksii_g473/usbcanfd_Oleksii_g473_defconfig new file mode 100644 index 0000000000000..63c273423036f --- /dev/null +++ b/boards/can-module_com/usbcanfd_Oleksii_g473/usbcanfd_Oleksii_g473_defconfig @@ -0,0 +1,3 @@ + +CONFIG_GPIO=y +CONFIG_ARM_MPU=y