Skip to content

[bsp][n32] add H47X/H49X/H7XX driver support - #11711

Open
OnlyoutzZ wants to merge 3 commits into
RT-Thread:masterfrom
OnlyoutzZ:pr/n32-h47x-h49x-h7xx-driver-support
Open

[bsp][n32] add H47X/H49X/H7XX driver support#11711
OnlyoutzZ wants to merge 3 commits into
RT-Thread:masterfrom
OnlyoutzZ:pr/n32-h47x-h49x-h7xx-driver-support

Conversation

@OnlyoutzZ

@OnlyoutzZ OnlyoutzZ commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

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

[

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

1、优化[bsp][n32]的drv_fdcan驱动
2、添加[bsp][n32]的drv_sdmmc驱动对N32H7XX系列支持
3、添加[bsp][n32]的on-chipflash驱动对N32H47X_48X和N32H49X系列支持
4、添加[bsp][n32]的drv_fdcan和dev_rtc驱动对N32H47X_48X和N32H49X系列支持

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

add H47X/H49X/H7XX driver support

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

  • BSP:
    bsp\n32\n32hxxx\n32h487zgl7-evb
    bsp\n32\n32hxxx\n32h497zgl7-evb
    bsp\n32\n32hxxx\n32h760zil7-stb
  • .config:
  • CONFIG_RT_USING_DFS / CONFIG_DFS_USING_POSIX / CONFIG_RT_USING_DFS_DEVFS (n32h760zil7-stb): 启用 DFS/devfs
  • CONFIG_BSP_USING_ON_CHIP_FLASH / CONFIG_BSP_USING_ONCHIP_RTC / CONFIG_BSP_USING_FDCAN (n32h487zgl7-evb, n32h497zgl7-evb)
  • 验证: 在 BSP 目录执行 scons --menuconfig 确认配置后 scons -j 编译即可
  • action:

]

当前拉取/合并请求的状态 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
  • 已经使用clang-format 源码格式化工具确保格式符合RT-Thread代码规范 This PR has been formatted with clang-format and complies with RT-Thread code specification
  • 如果是新增bsp, 已经添加ci检查到.github/ALL_BSP_COMPILE.json 详细请参考链接BSP自查

@github-actions

Copy link
Copy Markdown

👋 感谢您对 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

  • Use workflow from 保持默认分支(通常为 master
    Keep the default branch (usually master) in Use workflow from
  • branch 输入框填写 PR 分支 pr/n32-h47x-h49x-h7xx-driver-support
    Enter PR branch pr/n32-h47x-h49x-h7xx-driver-support in the branch field
  • 设置需排除的文件/目录(目录请以"/"结尾)
    Set files/directories to exclude (directories should end with "/")
  1. 等待工作流完成 | Wait for the workflow to complete
    格式化后的代码将作为独立提交推送至你的分支。
    The formatting changes will be pushed to your branch as a separate commit.

完成后,提交将自动更新至 pr/n32-h47x-h49x-h7xx-driver-support 分支,关联的 Pull Request 也会同步更新。
Once completed, commits will be pushed to the pr/n32-h47x-h49x-h7xx-driver-support 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 the BSP label Aug 14, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Purpose / 目的:
This PR extends the N32 BSP (bsp/n32/n32hxxx) to support additional N32H47x/48x, N32H49x, and N32H7xx on-chip drivers (notably FDCAN/RTC/on-chip flash/SDMMC-related pieces) and updates related BSP project/configuration files.
本次 PR 扩展 N32 BSP(bsp/n32/n32hxxx),为 N32H47x/48x、N32H49x、N32H7xx 增加/完善片上驱动支持(重点包含 FDCAN/RTC/片上 Flash/SDMMC 相关内容),并同步更新 BSP 工程与配置文件。

Changes / 变更点:

  • Add/extend on-chip flash drivers for N32H47x/48x and N32H49x (and related build integration).
    新增/扩展 N32H47x/48x 与 N32H49x 的片上 Flash 驱动,并接入构建流程。
  • Extend RTC/FDCAN configuration to support N32H47x/48x and N32H49x families.
    扩展 RTC/FDCAN 配置以支持 N32H47x/48x 与 N32H49x 系列。
  • Update BSP configs/projects and documentation tables to reflect newly supported features/boards.
    更新 BSP 配置/工程文件与文档表格以反映新增支持。

Reviewed changes

Copilot reviewed 34 out of 61 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
bsp/README.md Update N32 board capability matrix entries
bsp/n32/n32hxxx/n32h760zil7-stb/rtconfig.h Add DFS-related macros (should be generated, not hand-edited)
bsp/n32/n32hxxx/n32h760zil7-stb/project.uvprojx Adjust Keil defines/include paths; remove elmfat sources; misc cleanup
bsp/n32/n32hxxx/n32h760zil7-stb/board/ports/sd_host.h Add SD host/card data structures (new header)
bsp/n32/n32hxxx/n32h760zil7-stb/board/Cube_Config/USER/src/n32h7xx_cfg.c Cube-generated board init formatting/logic tweaks
bsp/n32/n32hxxx/n32h760zil7-stb/board/Cube_Config/USER/inc/n32h7xx_cfg.h Adjust prototype formatting
bsp/n32/n32hxxx/n32h760zil7-stb/board/board.h Formatting cleanup for memory/heap macros
bsp/n32/n32hxxx/n32h760zil7-stb/board/board.c MPU config formatting cleanup
bsp/n32/n32hxxx/n32h760zil7-stb/.config Enable DFS options and add additional BSP config symbols
bsp/n32/n32hxxx/n32h497zgl7-evb/project.uvprojx Adjust Keil defines/include paths
bsp/n32/n32hxxx/n32h497zgl7-evb/project.uvoptx Keil UI state change (tvExp)
bsp/n32/n32hxxx/n32h497zgl7-evb/board/Kconfig Add on-chip flash/RTC/FDCAN Kconfig options
bsp/n32/n32hxxx/n32h497zgl7-evb/board/Cube_Config/USER/src/n32h49x_cfg.c Cube-generated board init formatting/logic tweaks
bsp/n32/n32hxxx/n32h497zgl7-evb/board/Cube_Config/USER/inc/n32h49x_cfg.h Adjust prototype formatting
bsp/n32/n32hxxx/n32h497zgl7-evb/.config Add new BSP config symbols (flash/RTC/FDCAN)
bsp/n32/n32hxxx/n32h487zgl7-evb/project.uvprojx Adjust Keil defines/include paths
bsp/n32/n32hxxx/n32h487zgl7-evb/board/Kconfig Add on-chip flash/RTC/FDCAN Kconfig options
bsp/n32/n32hxxx/n32h487zgl7-evb/board/Cube_Config/USER/src/n32h47x_48x_cfg.c Cube-generated board init formatting/logic tweaks + SHRTPLL helper
bsp/n32/n32hxxx/n32h487zgl7-evb/board/Cube_Config/USER/inc/n32h47x_48x_cfg.h Adjust prototype formatting
bsp/n32/n32hxxx/n32h487zgl7-evb/.config Add new BSP config symbols (flash/RTC/FDCAN)
bsp/n32/n32hxxx/libraries/N32_Drivers/nano/drv_gpio.h Formatting cleanup for pin macros
bsp/n32/n32hxxx/libraries/N32_Drivers/nano/drv_console.c Formatting cleanup in console init
bsp/n32/n32hxxx/libraries/N32_Drivers/drv_common.h Fix include indentation under RT_USING_DEVICE
bsp/n32/n32hxxx/libraries/N32_Drivers/drv_common.c Fix include indentation; add braces for clarity
bsp/n32/n32hxxx/libraries/N32_Drivers/drivers/drv_spi.h Formatting cleanup for DMA flags
bsp/n32/n32hxxx/libraries/N32_Drivers/drivers/drv_sdmmc.h Add SDMMC driver public header (new)
bsp/n32/n32hxxx/libraries/N32_Drivers/drivers/drv_rtc.c Extend RTC init/alarm handling across N32H7xx/H47x_48x/H49x
bsp/n32/n32hxxx/libraries/N32_Drivers/drivers/drv_lptim.h Formatting cleanup for enum constants
bsp/n32/n32hxxx/libraries/N32_Drivers/drivers/drv_hard_i2c.h Formatting cleanup; struct field alignment
bsp/n32/n32hxxx/libraries/N32_Drivers/drivers/drv_gpio.h Formatting cleanup for GET_PIN macro
bsp/n32/n32hxxx/libraries/N32_Drivers/drivers/drv_flash/drv_flash_h49x.h Add H49x on-chip flash driver API header (new)
bsp/n32/n32hxxx/libraries/N32_Drivers/drivers/drv_flash/drv_flash_h49x.c Add H49x on-chip flash driver implementation (new)
bsp/n32/n32hxxx/libraries/N32_Drivers/drivers/drv_flash/drv_flash_h47x_48x.h Add H47x/48x on-chip flash driver API header (new)
bsp/n32/n32hxxx/libraries/N32_Drivers/drivers/drv_flash/drv_flash_h47x_48x.c Add H47x/48x on-chip flash driver implementation (new)
bsp/n32/n32hxxx/libraries/N32_Drivers/drivers/drv_fdcan.h Extend FDCAN struct/config integration (add per-instance config pointer)
bsp/n32/n32hxxx/libraries/N32_Drivers/drivers/drv_dma.h Formatting cleanup for DMA config struct
bsp/n32/n32hxxx/libraries/N32_Drivers/drivers/drv_config.h Include per-series CAN config headers for H49x/H47x_48x
bsp/n32/n32hxxx/libraries/N32_Drivers/drivers/drv_adc.c Formatting cleanup; initialize locals; minor brace additions
bsp/n32/n32hxxx/libraries/N32_Drivers/drivers/config/h7xx/tim_config.h Formatting cleanup in timer config macros
bsp/n32/n32hxxx/libraries/N32_Drivers/drivers/config/h7xx/spi_config.h Formatting cleanup in SPI config macros
bsp/n32/n32hxxx/libraries/N32_Drivers/drivers/config/h7xx/pwm_config.h Formatting cleanup in PWM config macros
bsp/n32/n32hxxx/libraries/N32_Drivers/drivers/config/h7xx/pulse_encoder_config.h Formatting cleanup in pulse encoder macros
bsp/n32/n32hxxx/libraries/N32_Drivers/drivers/config/h7xx/lptim_config.h Formatting cleanup in LPTIM config macros
bsp/n32/n32hxxx/libraries/N32_Drivers/drivers/config/h7xx/dac_config.h Formatting cleanup in DAC config macros
bsp/n32/n32hxxx/libraries/N32_Drivers/drivers/config/h7xx/can_config.h Expand FDCAN instance resource configuration fields/macros
bsp/n32/n32hxxx/libraries/N32_Drivers/drivers/config/h7xx/adc_config.h Formatting cleanup in ADC config macros
bsp/n32/n32hxxx/libraries/N32_Drivers/drivers/config/h49x/uart_config.h Formatting cleanup in UART config macros
bsp/n32/n32hxxx/libraries/N32_Drivers/drivers/config/h49x/can_config.h Add H49x FDCAN config header (new)
bsp/n32/n32hxxx/libraries/N32_Drivers/drivers/config/h47x_48x/uart_config.h Formatting cleanup in UART config macros
bsp/n32/n32hxxx/libraries/N32_Drivers/drivers/config/h47x_48x/can_config.h Add H47x/48x FDCAN config header (new)
Suppressed comments (1)

bsp/n32/n32hxxx/n32h760zil7-stb/board/ports/sd_host.h:130

  • [naming/命名]: Typo/unclear member name TMODE_truct / 成员命名疑似拼写错误且不清晰 TMODE_truct

English: TMODE_truct reads like a typo (missing 's' in 'struct') and is hard to read. Consider renaming to a clear, conventional member name.
中文:TMODE_truct 读起来像拼写错误(struct 少了 s),也不利于阅读。建议改成更清晰、符合习惯的成员名。


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +85 to +90
typedef enum
{
SDMMC_BusWdith1Bit = 0U, /* card bus 1 width */
SDMMC_BusWdith4Bit = 1U, /* card bus 4 width */
SDMMC_BusWdith8Bit = 2U, /* card bus 8 width */
} sd_buswidth_t;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review. Fixed in bc3c928: renamed SDMMC_BusWdith* -> SDMMC_BusWidth*, sd_buswidth_t -> sd_bus_width_t, and TMODE_truct -> tMode in sd_host.h. The SDK driver library itself is left untouched, as it is vendor-provided code.

Comment on lines +143 to +150
#define RT_USING_DFS
#define DFS_USING_POSIX
#define DFS_USING_WORKDIR
#define DFS_FD_MAX 16
#define RT_USING_DFS_V1
#define DFS_FILESYSTEMS_MAX 4
#define DFS_FILESYSTEM_TYPES_MAX 4
#define RT_USING_DFS_DEVFS

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed. The hand-edited DFS macros in rtconfig.h were removed in bc3c928. DFS is now managed solely by the .config file (CONFIG_RT_USING_DFS=y etc.) and will be regenerated into rtconfig.h by scons, per RT-Thread convention.

Comment on lines +227 to +237
CONFIG_RT_USING_DFS=y
CONFIG_DFS_USING_POSIX=y
CONFIG_DFS_USING_WORKDIR=y
# CONFIG_RT_USING_DFS_MNTTABLE is not set
CONFIG_DFS_FD_MAX=16
CONFIG_RT_USING_DFS_V1=y
# CONFIG_RT_USING_DFS_V2 is not set
CONFIG_DFS_FILESYSTEMS_MAX=4
CONFIG_DFS_FILESYSTEM_TYPES_MAX=4
# CONFIG_RT_USING_DFS_ELMFAT is not set
CONFIG_RT_USING_DFS_DEVFS=y

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed. The PR description has been updated to list the changed .config options (DFS/devfs for n32h760zil7-stb, on-chip flash/RTC/FDCAN for n32h487zgl7-evb and n32h497zgl7-evb) together with the verification steps (scons --menuconfig + scons -j).

- sd_host.h: fix BusWdith typo -> BusWidth, rename sd_buswidth_t,
  rename TMODE_truct -> tMode (avoid conflicting with SDK naming)
- rtconfig.h (n32h760): remove hand-edited DFS macros, managed by .config
- project.uvprojx (n32h487/n497/n760): drop local applications\test_file
  include-path reference (test dir is not part of the repository)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants