Commit b1833e85 authored by Andrei-Edward Popa's avatar Andrei-Edward Popa Committed by Benjamin Cabé
Browse files

boards: wch: add support for ch32v003f4p6 development board

Added support for the CH32V003F4P6 Development Board, which
features QingKe RISC-V2A MCU.

Signed-off-by: default avatarAndrei-Edward Popa <andrei.popa105@yahoo.com>
parent 0a7fde2a
Loading
Loading
Loading
Loading
+5 −0
Changes for boards/wch/ch32v003f4p6_dev_board/CMakeLists.txt: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
# Copyright (c) 2025 Andrei-Edward Popa <andrei.popa105@yahoo.com>.
# SPDX-License-Identifier: Apache-2.0

zephyr_library()
zephyr_library_sources(board.c)
+5 −0
Changes for boards/wch/ch32v003f4p6_dev_board/Kconfig: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
# Copyright (c) 2025 Andrei-Edward Popa
# SPDX-License-Identifier: Apache-2.0

config BOARD_CH32V003F4P6_DEV_BOARD
	select BOARD_LATE_INIT_HOOK
+5 −0
Changes for boards/wch/ch32v003f4p6_dev_board/Kconfig.ch32v003f4p6_dev_board: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
# Copyright (c) 2025 Andrei-Edward Popa
# SPDX-License-Identifier: Apache-2.0

config BOARD_CH32V003F4P6_DEV_BOARD
	select SOC_CH32V003
+35 −0
Changes for boards/wch/ch32v003f4p6_dev_board/board.c: 35 added lines, 0 removed lines.
Original line number Diff line number Diff line
/*
 * Copyright (c) 2025 Andrei-Edward Popa <andrei.popa105@yahoo.com>
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#include <zephyr/init.h>
#include <zephyr/drivers/gpio.h>

#include <ch32fun.h>

#define AFIO_SWCFG_MASK    0x07000000
#define AFIO_SWCFG_SWD_OFF 0x04000000

void board_late_init_hook(void)
{
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(gpiod))
	const struct device *gpiod = DEVICE_DT_GET(DT_NODELABEL(gpiod));
	uint32_t pcfr1;

	/*
	 * PD1 is wired to led and to SWDIO pin.
	 * If PD1 is not put to ground, change the function to GPIO to use
	 * the led as a user led.
	 * If PD1 is put to ground, let the pin as SWDIO pin (default) to be
	 * able to program the board.
	 */
	if (gpio_pin_get(gpiod, 1) == 1) {
		RCC->APB2PCENR |= RCC_AFIOEN;
		pcfr1 = AFIO->PCFR1;
		pcfr1 = (pcfr1 & ~AFIO_SWCFG_MASK) | (AFIO_SWCFG_SWD_OFF & AFIO_SWCFG_MASK);
		AFIO->PCFR1 = pcfr1;
	}
#endif
}
+8 −0
Changes for boards/wch/ch32v003f4p6_dev_board/board.cmake: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
# Copyright (c) 2025 Andrei-Edward Popa
# SPDX-License-Identifier: Apache-2.0

board_runner_args(minichlink)
include(${ZEPHYR_BASE}/boards/common/minichlink.board.cmake)

board_runner_args(openocd "--use-elf" "--cmd-reset-halt" "halt")
include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake)
Loading