Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions MAINTAINERS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5732,6 +5732,15 @@ West:
files:
- modules/Kconfig.wurthelektronik

"West project: hal_xhsc":
status: maintained
maintainers:
- XH-YongbingLiu
files:
- modules/Kconfig.xhsc
labels:
- "platform: XHSC"

"West project: hal_xtensa":
status: maintained
maintainers:
Expand Down
5 changes: 5 additions & 0 deletions boards/xhsc/hc32f4a0_evb/Kconfig.hc32f4a0_evb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright (C) 2024-2025, Xiaohua Semiconductor Co., Ltd.
# SPDX-License-Identifier: Apache-2.0

config BOARD_HC32F4A0_EVB
select SOC_HC32F4A0
8 changes: 8 additions & 0 deletions boards/xhsc/hc32f4a0_evb/board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright (C) 2024-2025, Xiaohua Semiconductor Co., Ltd.
# SPDX-License-Identifier: Apache-2.0

board_runner_args(pyocd "--target=HC32F4A0" "--frequency=10000000")
board_runner_args(jlink "--device=HC32F4A0" "--speed=4000")

include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake)
include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake)
5 changes: 5 additions & 0 deletions boards/xhsc/hc32f4a0_evb/board.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
board:
name: hc32f4a0_evb
vendor: xhsc
socs:
- name: hc32f4a0
Binary file added boards/xhsc/hc32f4a0_evb/doc/board.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
127 changes: 127 additions & 0 deletions boards/xhsc/hc32f4a0_evb/doc/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
.. zephyr:board:: hc32f4a0_evb

Overview
********

HC32F4A0_EVB, also named as EV_F4A0_LQ176, is the official development board of
XHSC, equipped with HC32F4A0SITB chip, based on ARM Cortex-M4 core, with a
maximum frequency of 240 MHz, and rich on-board resources, which can give full
play to the performance of HC32F4A0SITB chip.

Hardware
********

- MCU: HC32F4A0SITB, 240MHz, 2048KB FLASH, 512KB RAM
- External RAM:
* SRAM: 1MB , IS62WV51216
* SDRAM: 8MB, IS42S16400J
- External FLASH:
* Nand: 256MB, MT29F2G08AB,
* SPI NOR: 64MB , W25Q64
- Common Peripherals
- LEDs: 3, user LEDs (LED0, LED1, LED2).
- Buttons: 11, Matrix Keyboard (K1~K9), WAKEUP (K10), RESET (K11)
- Common Interfaces
* USB to serial port
* SD card interface
* Ethernet interface
* LCD interface
* USB HS, USB FS, USB 3300
* DVP interface
* 3.5mm headphone jack,
* Line in connector
* speaker connector
- Debugging Interface
* On-board DAP debugger
* standard JTAG/SWD

More information about the board and MCU can be found
at [XHSC](https://www.xhsc.com.cn/).

Supported Features
==================

.. zephyr:board-supported-hw::

Pin Mapping
===========

The peripherals of the HC32F4A0 SoC can be routed to various pins on the board.
The configuration of these routes can be modified through DTS. Please refer to
the datasheet to see the possible routings for each peripheral.

Default Zephyr Peripheral Mapping
----------------------------------

- USART_1 TX/RX : PH15/PH13 (Virtual Port Com)
- LED11 : PC9
- K10/WKUP : PA0

System Clock
------------

HC32F4A0_EVB System Clock could be driven by an internal or external oscillator,
as well as the PLL clock. By default, the System clock is driven by the PLL
clock at 240MHz, driven by an 8MHz high-speed external clock.

Serial Port
-----------

HC32F4A0_EVB board has 10 USARTs. The Zephyr console output is
assigned to UART1. Default settings are 115200 8N1.

Programming and Debugging
*************************

HC32F4A0_EVB board includes an XH-Link embedded debug tool interface.

Using XH-Link
=============

The HC32F4A0_EVB includes an onboard programmer/debugger (XH-Link) which
allow flash programming and debug over USB.

#. Build the Zephyr kernel and the :zephyr:code-sample:`hello_world` sample
application:

.. zephyr-app-commands::
:zephyr-app: samples/hello_world
:board: hc32f4a0_evb
:goals: build
:compact:

#. Run your favorite terminal program to listen for output. Under Linux the
terminal should be :code:`/dev/ttyUSB0`. For example:

.. code-block:: console

$ minicom -D /dev/ttyUSB0 -o

The -o option tells minicom not to send the modem initialization
string. Connection should be configured as follows:

- Speed: 115200
- Data: 8 bits
- Parity: None
- Stop bits: 1

#. To flash an image:

.. zephyr-app-commands::
:zephyr-app: samples/hello_world
:board: hc32f4a0_evb
:goals: flash
:compact:

You should see "Hello World! hc32f4a0_evb/hc32f4a0" in your terminal.

#. To debug an image:

.. zephyr-app-commands::
:zephyr-app: samples/hello_world
:board: hc32f4a0_evb
:goals: debug
:compact:

.. _HC32F4A0 Datasheet, Reference Manual, HC32F4A0_EVB Schematics:
https://www.xhsc.com.cn/product/112.html
37 changes: 37 additions & 0 deletions boards/xhsc/hc32f4a0_evb/hc32f4a0_evb-pinctrl.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (C) 2024-2025, Xiaohua Semiconductor Co., Ltd.
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <dt-bindings/pinctrl/hc32-pinctrl.h>

&pinctrl {
usart1_default: usart1_default {
group0 {
pinmux = <HC32_PINMUX('H', 15, FUNC, 32, 0)>,
<HC32_PINMUX('H', 13, FUNC, 33, 0)>;
};
};

usart2_default: usart2_default {
group1 {
pinmux = <HC32_PINMUX('D', 5, FUNC, 20, 0)>,
<HC32_PINMUX('D', 6, FUNC, 20, 0)>;
};
};

usart3_default: usart3_default {
group1 {
pinmux = <HC32_PINMUX('I', 1, FUNC, 36, 0)>,
<HC32_PINMUX('I', 2, FUNC, 37, 0)>;
};
};

usart4_default: usart4_default {
group1 {
pinmux = <HC32_PINMUX('I', 6, FUNC, 38, 0)>,
<HC32_PINMUX('I', 7, FUNC, 39, 0)>;
};
};
};
121 changes: 121 additions & 0 deletions boards/xhsc/hc32f4a0_evb/hc32f4a0_evb.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/*
* Copyright (C) 2024-2025, Xiaohua Semiconductor Co., Ltd.
*
* SPDX-License-Identifier: Apache-2.0
*/

/dts-v1/;
#include <xhsc/f4/hc32f4a0.dtsi>
#include "hc32f4a0_evb-pinctrl.dtsi"
#include <zephyr/dt-bindings/input/input-event-codes.h>

/ {
model = "xhsc, EV_F4A0_LQ176_Rev1.0 board";
compatible = "xhsc,hc32f4a0_evb";

chosen {
zephyr,sram = &sram0;
zephyr,flash = &flash0;
zephyr,console = &usart1;
zephyr,shell-uart = &usart1;
};

leds {
compatible = "gpio-leds";

green_led: led_0 {
gpios = <&gpioc 9 GPIO_ACTIVE_HIGH>;
label = "User LED";
};
};

gpio_keys {
compatible = "gpio-keys";

user_button: button {
label = "Wkup_key";
gpios = <&gpioa 0 GPIO_ACTIVE_LOW>;
zephyr,code = <INPUT_KEY_0>;
};
};

aliases {
led0 = &green_led;
sw0 = &user_button;
};
};

&gpioa {
status = "okay";
};

&gpiob {
status = "okay";
};

&gpioc {
status = "okay";
};

&gpiod {
status = "okay";
};

&gpioe {
status = "okay";
};

&gpiof {
status = "okay";
};

&gpiog {
status = "okay";
};

&gpioh {
status = "okay";
};

&gpioi {
status = "okay";
};

&clk_xtal {
status = "okay";
};

&clk_xtal32 {
status = "okay";
};

&clk_hrc {
status = "okay";
};

&clk_mrc {
status = "okay";
};

&clk_lrc {
status = "okay";
};

&clk_pll {
status = "okay";
};

&usart1 {
status = "okay";
current-speed = <115200>;
pinctrl-0 = <&usart1_default>;
pinctrl-names = "default";
interrupt-parent = <&intc>;
interrupts = <HC32_UART1_RXERR_IRQ_NUM HC32_UART1_RXERR_IRQ_PRIO \
INT_SRC_USART1_EI>,
<HC32_UART1_RX_IRQ_NUM HC32_UART1_RX_IRQ_PRIO \
INT_SRC_USART1_RI>,
<HC32_UART1_TX_CPLT_IRQ_NUM HC32_UART1_TX_CPLT_IRQ_PRIO \
INT_SRC_USART1_TCI>;
interrupt-names = "ore", "rxne", "tc";
};
16 changes: 16 additions & 0 deletions boards/xhsc/hc32f4a0_evb/hc32f4a0_evb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
identifier: hc32f4a0_evb
name: XHSC hc32f4a0_evb
type: mcu
arch: arm
ram: 512
flash: 2048
toolchain:
- zephyr
- gnuarmemb
- xtools
supported:
- gpio
- clock control
- interrupt control
- serial
vendor: xhsc
17 changes: 17 additions & 0 deletions boards/xhsc/hc32f4a0_evb/hc32f4a0_evb_defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright (C) 2024-2025, Xiaohua Semiconductor Co., Ltd.
# SPDX-License-Identifier: Apache-2.0

# Enable MPU
CONFIG_ARM_MPU=y

# Enable FPU
CONFIG_FPU=y

# GPIO Controller
CONFIG_GPIO=y

CONFIG_CLOCK_CONTROL=y

CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
CONFIG_SERIAL=y
10 changes: 10 additions & 0 deletions boards/xhsc/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.. _boards-xhsc:

XHSC
##############

.. toctree::
:maxdepth: 1
:glob:

**/*
1 change: 1 addition & 0 deletions drivers/clock_control/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_ARM_SCMI clock_cont
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_ESP32 clock_control_esp32.c)
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_FIXED_RATE_CLOCK clock_control_fixed_rate.c)
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_GD32 clock_control_gd32.c)
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_HC32 clock_control_hc32.c)
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_LITEX clock_control_litex.c)
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_LPC11U6X clock_control_lpc11u6x.c)
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_MCHP_SAM_D5X_E5X clock_control_mchp_sam_d5x_e5x.c)
Expand Down
2 changes: 2 additions & 0 deletions drivers/clock_control/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,6 @@ source "drivers/clock_control/Kconfig.sf32lb_hxt48"

source "drivers/clock_control/Kconfig.sf32lb_rcc"

source "drivers/clock_control/Kconfig.hc32"

endif # CLOCK_CONTROL
7 changes: 7 additions & 0 deletions drivers/clock_control/Kconfig.hc32
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright (C) 2024-2025, Xiaohua Semiconductor Co., Ltd.
# SPDX-License-Identifier: Apache-2.0

config CLOCK_CONTROL_HC32
bool "HC32 Clock Control"
default y
depends on DT_HAS_XHSC_HC32_CLOCK_CONTROL_ENABLED
Loading
Loading