diff --git a/boards/fysetc/index.rst b/boards/fysetc/index.rst new file mode 100644 index 00000000000..546023ba7b0 --- /dev/null +++ b/boards/fysetc/index.rst @@ -0,0 +1,10 @@ +.. _boards-fysetc: + +FYSETC +###### + +.. toctree:: + :maxdepth: 1 + :glob: + + **/* diff --git a/boards/fysetc/ucan/Kconfig.ucan b/boards/fysetc/ucan/Kconfig.ucan new file mode 100644 index 00000000000..c88f895ea01 --- /dev/null +++ b/boards/fysetc/ucan/Kconfig.ucan @@ -0,0 +1,5 @@ +# Copyright (c) 2024 Henrik Brix Andersen +# SPDX-License-Identifier: Apache-2.0 + +config BOARD_UCAN + select SOC_STM32F072XB diff --git a/boards/fysetc/ucan/board.cmake b/boards/fysetc/ucan/board.cmake new file mode 100644 index 00000000000..c383530f74c --- /dev/null +++ b/boards/fysetc/ucan/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/fysetc/ucan/board.yml b/boards/fysetc/ucan/board.yml new file mode 100644 index 00000000000..3e9b1d3b092 --- /dev/null +++ b/boards/fysetc/ucan/board.yml @@ -0,0 +1,6 @@ +board: + name: ucan + full_name: UCAN + vendor: fysetc + socs: + - name: stm32f072xb diff --git a/boards/fysetc/ucan/doc/index.rst b/boards/fysetc/ucan/doc/index.rst new file mode 100644 index 00000000000..f9b4b53809f --- /dev/null +++ b/boards/fysetc/ucan/doc/index.rst @@ -0,0 +1,71 @@ +.. zephyr:board:: ucan + +Overview +******** + +The FYSETC UCAN is an open-source USB to CAN 2.0B adapter board. More information can be found on +the `UCAN website`_ and in the `UCAN wiki`_. + +Hardware +******** + +The UCAN board is equipped with a STM32F072CB microcontroller and features an USB-C connector, a +terminal block for connecting to the CAN bus, and two user LEDs. Schematics and component placement +drawings are available in the `UCAN GitHub repository`_. + +Supported Features +================== + +The ``ucan`` board configuration supports the following hardware features: + ++-----------+------------+-------------------------------------+ +| Interface | Controller | Driver/Component | ++===========+============+=====================================+ +| NVIC | on-chip | nested vector interrupt controller | ++-----------+------------+-------------------------------------+ +| PINMUX | on-chip | pinmux | ++-----------+------------+-------------------------------------+ +| FLASH | on-chip | flash memory | ++-----------+------------+-------------------------------------+ +| GPIO | on-chip | gpio | ++-----------+------------+-------------------------------------+ +| USB | on-chip | USB | ++-----------+------------+-------------------------------------+ +| CAN1 | on-chip | CAN controller | ++-----------+------------+-------------------------------------+ + +The default configuration can be found in the defconfig file: +:zephyr_file:`boards/fysetc/ucan/ucan_defconfig`. + +Other hardware features are not currently supported by the port. + +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 +************************* + +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 ``B0`` and ``3V3`` when applying power to the UCAN 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: ucan + :goals: flash + +.. _UCAN website: + https://www.fysetc.com/products/fysetc-ucan-board + +.. _UCAN wiki: + https://wiki.fysetc.com/UCAN/ + +.. _UCAN GitHub repository: + https://github.com/FYSETC/UCAN/ diff --git a/boards/fysetc/ucan/doc/ucan.webp b/boards/fysetc/ucan/doc/ucan.webp new file mode 100644 index 00000000000..427747f4296 Binary files /dev/null and b/boards/fysetc/ucan/doc/ucan.webp differ diff --git a/boards/fysetc/ucan/ucan.dts b/boards/fysetc/ucan/ucan.dts new file mode 100644 index 00000000000..a0f47da9256 --- /dev/null +++ b/boards/fysetc/ucan/ucan.dts @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2024 Henrik Brix Andersen + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; + +#include +#include + +/ { + model = "FYSETC UCAN board"; + compatible = "fysetc,ucan"; + + 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 = <&gpioa 0 GPIO_ACTIVE_HIGH>; + label = "LED RX"; + }; + led_tx: led_tx { + gpios = <&gpioa 1 GPIO_ACTIVE_HIGH>; + label = "LED TX"; + }; + }; + + transceiver0: can-phy0 { + compatible = "can-transceiver-gpio"; + enable-gpios = <&gpioc 13 GPIO_ACTIVE_LOW>; + max-bitrate = <1000000>; + #phy-cells = <0>; + }; +}; + +&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"; + phys = <&transceiver0>; + 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/fysetc/ucan/ucan.yaml b/boards/fysetc/ucan/ucan.yaml new file mode 100644 index 00000000000..cd65a21e1fd --- /dev/null +++ b/boards/fysetc/ucan/ucan.yaml @@ -0,0 +1,15 @@ +identifier: ucan +name: FYSETC UCAN +type: mcu +arch: arm +toolchain: + - zephyr + - gnuarmemb +ram: 16 +flash: 128 +supported: + - can + - gpio + - usb_device + - usbd +vendor: fysetc diff --git a/boards/fysetc/ucan/ucan_defconfig b/boards/fysetc/ucan/ucan_defconfig new file mode 100644 index 00000000000..91c3c15b37d --- /dev/null +++ b/boards/fysetc/ucan/ucan_defconfig @@ -0,0 +1 @@ +CONFIG_GPIO=y