-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Add VW553H spi support #11192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add VW553H spi support #11192
Conversation
|
👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread! 为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。 🛠 操作步骤 | Steps
完成后,提交将自动更新至 如有问题欢迎联系我们,再次感谢您的贡献!💐 |
|
请为驱动添加ci-attach 参考:https://club.rt-thread.org/ask/article/5edd0f0940a57129.html |
There was a problem hiding this 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 |
Copilot
AI
Feb 11, 2026
There was a problem hiding this comment.
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'。
| // Get the received data | ||
| data = spi_data_receive(); | ||
| #else | ||
| // Todo: replace register read/write by gd32f4 lib |
Copilot
AI
Feb 11, 2026
There was a problem hiding this comment.
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 系列。这是一个应该解决以保持一致性的现有问题。注释应引用正确的库或更通用。
| } | ||
| #endif | ||
|
|
||
|
|
Copilot
AI
Feb 11, 2026
There was a problem hiding this comment.
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 编码标准,应该只有一个空行。请删除多余的空行。
| #if defined (SOC_SERIES_GD32VW55x) | ||
| { | ||
| SPI, | ||
| "spi0", | ||
| RCU_SPI, | ||
| RCU_GPIOA, | ||
| &spi_bus0, | ||
| GPIOA, | ||
| GPIO_PIN_9, | ||
| GPIO_PIN_10, | ||
| GPIO_PIN_11, | ||
| } |
Copilot
AI
Feb 11, 2026
There was a problem hiding this comment.
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:
- GD32VW55x library uses a singleton pattern where only one SPI peripheral exists and functions don't need the peripheral parameter
- 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 行)。
这表明以下两种情况之一:
- GD32VW55x 库使用单例模式,其中只存在一个 SPI 外设,函数不需要外设参数
- 外设标识符不正确,将导致编译或运行时错误
请验证:
- 'SPI' 和 'RCU_SPI' 是否是 GD32VW55x 库头文件中定义的正确标识符
- GD32VW55x SPI 函数(spi_init、spi_enable、spi_crc_off、spi_data_transmit 等)是否正确定义为不带 spi_periph 参数
- 此代码是否已在实际 GD32VW553H 硬件上测试
| @@ -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" | |||
Copilot
AI
Feb 11, 2026
There was a problem hiding this comment.
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:
- Removal of all PWM configurations (BSP_USING_PWM and related options) - not mentioned in PR description
- 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 的不相关更改:
- 删除所有 PWM 配置(BSP_USING_PWM 及相关选项)- PR 描述中未提及
- 第 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 的配置对齐,因此如果它们是完成板级支持的一部分,可能是可以接受的。
|
|
||
|
|
||
| source "$(BSP_DIR)/../libraries/gd32_drivers/Kconfig" | ||
| source "$(BSP_DIR)/libraries/gd32_drivers/Kconfig" |
Copilot
AI
Feb 11, 2026
There was a problem hiding this comment.
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 构建。
| source "$(BSP_DIR)/libraries/gd32_drivers/Kconfig" | |
| source "$(BSP_DIR)/../libraries/gd32_drivers/Kconfig" |
| } | ||
|
|
||
| #if defined (SOC_SERIES_GD32VW55x) | ||
| // Todo: replace register read/write by gd32f4 lib |
Copilot
AI
Feb 11, 2026
There was a problem hiding this comment.
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 行)。
| // 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(); |
Copilot
AI
Feb 11, 2026
There was a problem hiding this comment.
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 风格注释。
拉取/合并请求描述:(PR description)
[
为什么提交这份PR (why to submit this PR)
你的解决方案是什么 (what is your solution)
请提供验证的bsp和config (provide the config and bsp)
]
当前拉取/合并请求的状态 Intent for your PR
必须选择一项 Choose one (Mandatory):
代码质量 Code Quality:
我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:
#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up