Skip to content

Conversation

@gta5zsk
Copy link

@gta5zsk gta5zsk commented Feb 11, 2026

拉取/合并请求描述:(PR description)

[

为什么提交这份PR (why to submit this PR)

  • Add GD32VW553H SPI drive support

你的解决方案是什么 (what is your solution)

  • 去除GD32VW553 不存在的其他SPI口的配置,仅保留SPI0;
  • 解决GD32VW553 原厂SPI外设调用函数的适配问题;

请提供验证的bsp和config (provide the config and bsp)

  • BSP: bsp/gd32/risc-v/gd32vw553h-eval

]

当前拉取/合并请求的状态 Intent for your PR

必须选择一项 Choose one (Mandatory):

  • 本拉取/合并请求是一个草稿版本 This PR is for a code-review and is intended to get feedback
  • 本拉取/合并请求是一个成熟版本 This PR is mature, and ready to be integrated into the repo

代码质量 Code Quality:

我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:

  • 已经仔细查看过代码改动的对比 Already check the difference between PR and old code
  • 代码风格正确,包括缩进空格,命名及其他风格 Style guide is adhered to, including spacing, naming and other styles
  • 没有垃圾代码,代码尽量精简,不包含#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up
  • 所有变更均有原因及合理的,并且不会影响到其他软件组件代码或BSP All modifications are justified and not affect other components or BSP
  • 对难懂代码均提供对应的注释 I've commented appropriately where code is tricky
  • 代码是高质量的 Code in this PR is of high quality
  • 已经使用formatting 等源码格式化工具确保格式符合RT-Thread代码规范 This PR complies with RT-Thread code specification
  • 如果是新增bsp, 已经添加ci检查到.github/ALL_BSP_COMPILE.json 详细请参考链接BSP自查

@CLAassistant
Copy link

CLAassistant commented Feb 11, 2026

CLA assistant check
All committers have signed the CLA.

@github-actions
Copy link

👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread!

为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。
To ensure your code complies with RT-Thread's coding style, please run the code formatting workflow by following the steps below (If the formatting of CI fails to run).


🛠 操作步骤 | Steps

  1. 前往 Actions 页面 | Go to the Actions page
    点击进入工作流 → | Click to open workflow →

  2. 点击 Run workflow | Click Run workflow

  • 设置需排除的文件/目录(目录请以"/"结尾)
    Set files/directories to exclude (directories should end with "/")
  • 将目标分支设置为 \ Set the target branch to:master
  • 设置PR number为 \ Set the PR number to:11192
  1. 等待工作流完成 | Wait for the workflow to complete
    格式化后的代码将自动推送至你的分支。
    The formatted code will be automatically pushed to your branch.

完成后,提交将自动更新至 master 分支,关联的 Pull Request 也会同步更新。
Once completed, commits will be pushed to the master branch automatically, and the related Pull Request will be updated.

如有问题欢迎联系我们,再次感谢您的贡献!💐
If you have any questions, feel free to reach out. Thanks again for your contribution!

@github-actions github-actions bot added BSP BSP: GD32 BSP related with GD32 labels Feb 11, 2026
@Rbb666 Rbb666 requested a review from Copilot February 11, 2026 04:29
@Rbb666
Copy link
Member

Rbb666 commented Feb 11, 2026

请为驱动添加ci-attach

参考:https://club.rt-thread.org/ask/article/5edd0f0940a57129.html

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds SPI driver support for the GD32VW553H RISC-V microcontroller. The implementation adapts the existing GD32 RISC-V SPI driver to accommodate the GD32VW55x series, which uses a different peripheral library API compared to the GD32VF103 series. The PR includes conditional compilation blocks to handle the different GPIO initialization sequences, SPI clock configurations, and function call patterns between the two chip families.

Changes:

  • Added GD32VW55x-specific SPI peripheral configuration with different naming conventions (SPI vs SPI0, RCU_SPI vs RCU_SPI0)
  • Implemented GD32VW55x GPIO initialization using alternate function configuration instead of direct GPIO mode
  • Added SPI configuration support for GD32VW55x with different API calls (spi_* functions without peripheral parameter vs spi_i2s_* functions with parameter)
  • Added SPI bus configuration to Kconfig for GD32VW553H BSP
  • Modified source path and removed PWM configurations in Kconfig (unrelated to SPI support)
  • Added UART3 and UART4 support to align with other GD32 BSPs

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.

File Description
bsp/gd32/risc-v/libraries/gd32_drivers/drv_spi.c Added conditional compilation for GD32VW55x SPI support with different peripheral library API, GPIO configuration, and SPI function calls
bsp/gd32/risc-v/gd32vw553h-eval/board/Kconfig Added SPI0 configuration options, UART3/4 support, removed PWM configurations, and modified source path

}

#if defined (SOC_SERIES_GD32VW55x)
// Todo: replace register read/write by gd32f4 lib
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment references 'gd32f4 lib' but this code is for GD32VW55x. The comment should be updated to reference the correct library: 'gd32vw55x lib'.

注释引用了 'gd32f4 lib',但此代码适用于 GD32VW55x。注释应更新为引用正确的库:'gd32vw55x lib'。

Copilot uses AI. Check for mistakes.
// Get the received data
data = spi_data_receive();
#else
// Todo: replace register read/write by gd32f4 lib
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment references 'gd32f4 lib' but the code is for GD32VF103 series. This is a pre-existing issue that should be addressed for consistency. The comment should reference the correct library or be more generic.

注释引用了 'gd32f4 lib',但代码适用于 GD32VF103 系列。这是一个应该解决以保持一致性的现有问题。注释应引用正确的库或更通用。

Copilot uses AI. Check for mistakes.
}
#endif


Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are extra blank lines (lines 176-177) after the #endif directive. According to RT-Thread coding standards, there should be only one blank line. Please remove the extra blank line.

在 #endif 指令后有多余的空行(第 176-177 行)。根据 RT-Thread 编码标准,应该只有一个空行。请删除多余的空行。

Suggested change

Copilot uses AI. Check for mistakes.
Comment on lines +33 to +44
#if defined (SOC_SERIES_GD32VW55x)
{
SPI,
"spi0",
RCU_SPI,
RCU_GPIOA,
&spi_bus0,
GPIOA,
GPIO_PIN_9,
GPIO_PIN_10,
GPIO_PIN_11,
}
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critical verification needed for GD32VW55x peripheral naming. The configuration uses 'SPI' (line 35) and 'RCU_SPI' (line 37) instead of the typical 'SPI0' and 'RCU_SPI0' pattern used in other GD32 series. Additionally, the code extracts spi_periph from the structure (line 130) but the GD32VW55x code path never uses this parameter when calling SPI functions (lines 246-250, 301-308, 347-354).

This indicates one of two scenarios:

  1. GD32VW55x library uses a singleton pattern where only one SPI peripheral exists and functions don't need the peripheral parameter
  2. The peripheral identifier is incorrect and will cause compilation or runtime errors

Please verify:

  • That 'SPI' and 'RCU_SPI' are the correct identifiers defined in the GD32VW55x library headers
  • That the GD32VW55x SPI functions (spi_init, spi_enable, spi_crc_off, spi_data_transmit, etc.) are correctly defined without the spi_periph parameter
  • That this code has been tested on actual GD32VW553H hardware

GD32VW55x 外设命名需要关键验证。配置使用 'SPI'(第 35 行)和 'RCU_SPI'(第 37 行),而不是其他 GD32 系列中使用的典型 'SPI0' 和 'RCU_SPI0' 模式。此外,代码从结构中提取 spi_periph(第 130 行),但 GD32VW55x 代码路径在调用 SPI 函数时从未使用此参数(第 246-250、301-308、347-354 行)。

这表明以下两种情况之一:

  1. GD32VW55x 库使用单例模式,其中只存在一个 SPI 外设,函数不需要外设参数
  2. 外设标识符不正确,将导致编译或运行时错误

请验证:

  • 'SPI' 和 'RCU_SPI' 是否是 GD32VW55x 库头文件中定义的正确标识符
  • GD32VW55x SPI 函数(spi_init、spi_enable、spi_crc_off、spi_data_transmit 等)是否正确定义为不带 spi_periph 参数
  • 此代码是否已在实际 GD32VW553H 硬件上测试

Copilot uses AI. Check for mistakes.
Comment on lines 25 to 102
@@ -56,33 +77,29 @@ menu "On-chip Peripheral Drivers"
depends on BSP_USING_UART2
select RT_SERIAL_USING_DMA
default n
endif

menuconfig BSP_USING_PWM
bool "Enable PWM"
default n
select RT_USING_PWM
if BSP_USING_PWM
config BSP_USING_PWM0
bool "Enable PWM0"
default y
config BSP_USING_PWM1
bool "Enable PWM1"
config BSP_USING_UART3
bool "Enable UART3"
default n
config BSP_USING_PWM2
bool "Enable PWM2"

config BSP_UART3_RX_USING_DMA
bool "Enable UART3 RX DMA"
depends on BSP_USING_UART3
select RT_SERIAL_USING_DMA
default n
config BSP_USING_PWM15
bool "Enable PWM15"

config BSP_USING_UART4
bool "Enable UART4"
default n
config BSP_USING_PWM16
bool "Enable PWM16"

config BSP_UART4_RX_USING_DMA
bool "Enable UART4 RX DMA"
depends on BSP_USING_UART4
select RT_SERIAL_USING_DMA
default n
endif



source "$(BSP_DIR)/../libraries/gd32_drivers/Kconfig"
source "$(BSP_DIR)/libraries/gd32_drivers/Kconfig"
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR contains unrelated changes that should be split into separate PRs:

  1. Removal of all PWM configurations (BSP_USING_PWM and related options) - not mentioned in PR description
  2. Incorrect change to the source path on line 102 from '$(BSP_DIR)/../libraries/gd32_drivers/Kconfig' to '$(BSP_DIR)/libraries/gd32_drivers/Kconfig'

According to RT-Thread PR guidelines (CodingGuidelineID: 1000000), each PR should focus on a single feature. The PWM removal is unrelated to SPI support. The UART3/4 additions appear to align the configuration with other GD32 BSPs, so they may be acceptable if they're part of completing the board support.

此 PR 包含应拆分为多个 PR 的不相关更改:

  1. 删除所有 PWM 配置(BSP_USING_PWM 及相关选项)- PR 描述中未提及
  2. 第 102 行源路径从 '$(BSP_DIR)/../libraries/gd32_drivers/Kconfig' 错误更改为 '$(BSP_DIR)/libraries/gd32_drivers/Kconfig'

根据 RT-Thread PR 指南(CodingGuidelineID: 1000000),每个 PR 应专注于单个功能。PWM 删除与 SPI 支持无关。UART3/4 添加似乎与其他 GD32 BSP 的配置对齐,因此如果它们是完成板级支持的一部分,可能是可以接受的。

Copilot generated this review using guidance from repository custom instructions.


source "$(BSP_DIR)/../libraries/gd32_drivers/Kconfig"
source "$(BSP_DIR)/libraries/gd32_drivers/Kconfig"
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The source path has been changed from '$(BSP_DIR)/../libraries/gd32_drivers/Kconfig' to '$(BSP_DIR)/libraries/gd32_drivers/Kconfig'. However, the directory '$(BSP_DIR)/libraries' does not exist in the gd32vw553h-eval BSP. The correct path should be '$(BSP_DIR)/../libraries/gd32_drivers/Kconfig' as the gd32_drivers directory is located at 'bsp/gd32/risc-v/libraries/gd32_drivers/', not 'bsp/gd32/risc-v/gd32vw553h-eval/libraries/gd32_drivers/'. This change will break the Kconfig build.

源路径已从 '$(BSP_DIR)/../libraries/gd32_drivers/Kconfig' 更改为 '$(BSP_DIR)/libraries/gd32_drivers/Kconfig'。但是,目录 '$(BSP_DIR)/libraries' 在 gd32vw553h-eval BSP 中不存在。正确的路径应该是 '$(BSP_DIR)/../libraries/gd32_drivers/Kconfig',因为 gd32_drivers 目录位于 'bsp/gd32/risc-v/libraries/gd32_drivers/',而不是 'bsp/gd32/risc-v/gd32vw553h-eval/libraries/gd32_drivers/'。此更改将破坏 Kconfig 构建。

Suggested change
source "$(BSP_DIR)/libraries/gd32_drivers/Kconfig"
source "$(BSP_DIR)/../libraries/gd32_drivers/Kconfig"

Copilot uses AI. Check for mistakes.
}

#if defined (SOC_SERIES_GD32VW55x)
// Todo: replace register read/write by gd32f4 lib
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment references 'gd32f4 lib' but this code is for GD32VW55x. The comment should be updated to reference the correct library: 'gd32vw55x lib'. This same incorrect comment appears in multiple locations (lines 299, 345).

注释引用了 'gd32f4 lib',但此代码适用于 GD32VW55x。注释应更新为引用正确的库:'gd32vw55x lib'。此相同的不正确注释出现在多个位置(第 299、345 行)。

Copilot uses AI. Check for mistakes.
Comment on lines +299 to +308
// Todo: replace register read/write by gd32f4 lib
//Wait until the transmit buffer is empty
while(RESET == spi_flag_get(SPI_FLAG_TBE));
// Send the byte
spi_data_transmit(data);

//Wait until a data is received
while(RESET == spi_flag_get(SPI_FLAG_RBNE));
// Get the received data
data = spi_data_receive();
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments should use C-style (/* ... */) rather than C++-style (// ...) according to RT-Thread coding standards. This applies to comments on lines 299-308, 310-319, 345-354, and 356-365. Please convert these to C-style comments.

根据 RT-Thread 编码标准,注释应使用 C 风格(/* ... */)而不是 C++ 风格(// ...)。这适用于第 299-308、310-319、345-354 和 356-365 行的注释。请将这些转换为 C 风格注释。

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BSP: GD32 BSP related with GD32 BSP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants