Skip to content

[bsp/gd32] add gd32h759i-eval bsp add fix drv_usart.c #10623

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

Yaochenger
Copy link
Contributor

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

[
并确认并列出已经在什么情况或板卡上进行了测试。
And confirm in which case or board has been tested. -->

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

  • add gd32h759i-eval bsp
  • fix drv_usart.c

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

bsp/gd/arm/gd32h759i-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自查

@github-actions github-actions bot added BSP BSP: GD32 BSP related with GD32 labels Aug 20, 2025
Copilot

This comment was marked as outdated.

@supperthomas
Copy link
Member

如果是新增bsp, 已经添加ci检查到.github/ALL_BSP_COMPILE.json 详细请参考链接BSP自查

@supperthomas supperthomas added the BSP: new bsp board New added bsp, need sync action label Aug 21, 2025
@github-actions github-actions bot added the action github action yml imporve label Aug 21, 2025
Copy link

github-actions bot commented Aug 21, 2025

📌 Code Review Assignment

🏷️ Tag: workflow

Reviewers: Rbb666 kurisaW supperthomas

Changed Files (Click to expand)
  • .github/ALL_BSP_COMPILE.json

📊 Current Review Status (Last Updated: 2025-08-22 10:18 CST)

  • Rbb666 Pending Review
  • kurisaW Pending Review
  • supperthomas Pending Review

📝 Review Instructions

  1. 维护者可以通过单击此处来刷新审查状态: 🔄 刷新状态
    Maintainers can refresh the review status by clicking here: 🔄 Refresh Status

  2. 确认审核通过后评论 LGTM/lgtm
    Comment LGTM/lgtm after confirming approval

  3. PR合并前需至少一位维护者确认
    PR must be confirmed by at least one maintainer before merging

ℹ️ 刷新CI状态操作需要具备仓库写入权限。
ℹ️ Refresh CI status operation requires repository Write permission.

@Yaochenger Yaochenger closed this Aug 21, 2025
@Yaochenger Yaochenger reopened this Aug 21, 2025
@Rbb666 Rbb666 closed this Aug 21, 2025
@Rbb666 Rbb666 reopened this Aug 21, 2025
@BernardXiong BernardXiong requested a review from Copilot August 21, 2025 10:51
Copilot

This comment was marked as outdated.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@BernardXiong BernardXiong requested a review from Copilot August 21, 2025 12:28
Copy link
Contributor

@Copilot 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 support for the GD32H759I-EVAL board and introduces DMA functionality for UART in the GD32 BSP. The changes include adding a new board configuration, enabling DMA support for UART operations, and fixing issues in the UART driver implementation.

  • Adds new BSP for GD32H759I-EVAL board with complete project configuration
  • Implements comprehensive DMA support for UART transmission and reception
  • Fixes pin configurations and conditional compilation issues in the UART driver

Reviewed Changes

Copilot reviewed 33 out of 35 changed files in this pull request and generated 3 comments.

File Description
bsp/gd32/arm/libraries/gd32_drivers/drv_usart.h Adds DMA structure definitions and conditionally disables DMA for non-H7 series
bsp/gd32/arm/libraries/gd32_drivers/drv_usart.c Major refactor adding DMA support, interrupt handlers, and GPIO configuration fixes
bsp/gd32/arm/gd32h759i-start/rtconfig.h Disables DMA configuration for start board
bsp/gd32/arm/gd32h759i-eval/* Complete new BSP with project files and configuration
Comments suppressed due to low confidence (1)

bsp/gd32/arm/libraries/gd32_drivers/drv_usart.c:415

  • [bug] Inconsistent GPIO pin configuration for UART0 / UART0的GPIO引脚配置不一致。 English: The removed lines 411-415 showed conflicting pin configurations for UART0 on GD32H7xx. The code originally had separate configurations for H7xx (GPIOF pins 4,5) but now defaults to GPIOA pins 9,10. Verify this is correct for the H7xx series. / 中文:删除的第411-415行显示了GD32H7xx上UART0的引脚配置冲突。代码原本对H7xx有单独配置(GPIOF引脚4,5),但现在默认为GPIOA引脚9,10。请验证这对H7xx系列是否正确。
#if defined SOC_SERIES_GD32F4xx || defined SOC_SERIES_GD32F5xx || defined SOC_SERIES_GD32H7xx
        RCU_GPIOA, RCU_GPIOA,                  /* tx gpio clock, rx gpio clock */
        GPIOA, GPIO_AF_7, GPIO_PIN_9,          /* tx port, tx alternate, tx pin */
        GPIOA, GPIO_AF_7, GPIO_PIN_10,         /* rx port, rx alternate, rx pin */
#elif defined SOC_SERIES_GD32E50x
        RCU_GPIOA, RCU_GPIOA,                  /* tx gpio clock, rx gpio clock */
        GPIOA, 0, GPIO_PIN_9,                  /* tx port, tx alternate, tx pin */
        GPIOA, 0, GPIO_PIN_10,                 /* rx port, rx alternate, rx pin */

GPIOA, GPIO_PIN_3, /* rx port, rx pin */
RCU_GPIOA, RCU_GPIOA, // periph clock, tx gpio clock, rt gpio clock
GPIOA, GPIO_PIN_2, // tx port, tx pin
GPIOA, GPIO_PIN_3, // rx port, rx pin
Copy link
Preview

Copilot AI Aug 21, 2025

Choose a reason for hiding this comment

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

[nitpick] [best_practices] Inconsistent comment style / 注释风格不一致。 English: The code mixes C-style (/* /) and C++-style (//) comments. For consistency with RT-Thread coding standards, use C-style comments throughout. / 中文:代码混合使用C风格(/ */)和C++风格(//)注释。为了与RT-Thread编码标准保持一致,应全程使用C风格注释。

Suggested change
GPIOA, GPIO_PIN_3, // rx port, rx pin
RCU_GPIOA, RCU_GPIOA, /* periph clock, tx gpio clock, rt gpio clock */
GPIOA, GPIO_PIN_2, /* tx port, tx pin */
GPIOA, GPIO_PIN_3, /* rx port, rx pin */

Copilot uses AI. Check for mistakes.

dma_deinit(uart->uart_tx_dma->dma_periph, uart->uart_tx_dma->dma_ch);

dma_single_data_para_struct_init(&dma_init_struct);
dma_init_struct.request = uart->uart_tx_dma->dma_mux_req_rx;
Copy link
Preview

Copilot AI Aug 21, 2025

Choose a reason for hiding this comment

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

[bug] Incorrect DMA request assignment for TX / TX的DMA请求分配错误。 English: For TX DMA configuration, the code uses dma_mux_req_rx field, which appears to be for RX operations based on the field name. This should likely use a TX-specific request field. / 中文:在TX DMA配置中,代码使用了dma_mux_req_rx字段,从字段名来看这似乎是用于RX操作的。这应该使用TX特定的请求字段。

Suggested change
dma_init_struct.request = uart->uart_tx_dma->dma_mux_req_rx;
dma_init_struct.request = uart->uart_tx_dma->dma_mux_req_tx;

Copilot uses AI. Check for mistakes.

@@ -558,13 +1150,29 @@ static void GD32_UART_IRQHandler(struct rt_serial_device *serial)
RT_ASSERT(uart != RT_NULL);

/* UART in mode Receiver -------------------------------------------------*/
if ((usart_interrupt_flag_get(uart->uart_periph, USART_INT_FLAG_RBNE) != RESET) &&
(usart_flag_get(uart->uart_periph, USART_FLAG_RBNE) != RESET))
if ((usart_interrupt_flag_get(uart->uart_periph, USART_INT_FLAG_RBNE) != RESET))
Copy link
Preview

Copilot AI Aug 21, 2025

Choose a reason for hiding this comment

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

[bug] Removed USART_FLAG_RBNE check may cause issues / 移除USART_FLAG_RBNE检查可能导致问题。 English: The original code checked both USART_INT_FLAG_RBNE and USART_FLAG_RBNE, but the new code only checks the interrupt flag. This might cause the ISR to trigger even when no data is actually available, leading to potential race conditions. / 中文:原始代码同时检查USART_INT_FLAG_RBNE和USART_FLAG_RBNE,但新代码只检查中断标志。这可能导致即使没有数据可用时ISR也会触发,从而导致潜在的竞争条件。

Suggested change
if ((usart_interrupt_flag_get(uart->uart_periph, USART_INT_FLAG_RBNE) != RESET))
if ((usart_interrupt_flag_get(uart->uart_periph, USART_INT_FLAG_RBNE) != RESET) &&
(usart_flag_get(uart->uart_periph, USART_FLAG_RBNE) != RESET))

Copilot uses AI. Check for mistakes.

Yaochenger and others added 2 commits August 22, 2025 10:04
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action github action yml imporve BSP: GD32 BSP related with GD32 BSP: new bsp board New added bsp, need sync action BSP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants