[bsp/stm32h7]: Add STM32H7 fdcan driver.#10767
Conversation
|
👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread! 为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。 🛠 操作步骤 | Steps
完成后,提交将自动更新至 如有问题欢迎联系我们,再次感谢您的贡献!💐 |
📌 Code Review Assignment🏷️ Tag: bsp_stm32Reviewers: Liang1795 hamburger-os wdfk-prog Changed Files (Click to expand)
📊 Current Review Status (Last Updated: 2025-10-28 20:25 CST)
📝 Review Instructions
|
|
补充一下,添加了对data域的频率配置 |
/**
* @brief Error callback.
* @param hfdcan pointer to an FDCAN_HandleTypeDef structure that contains
* the configuration information for the specified FDCAN.
* @retval None
*/
__weak void HAL_FDCAN_ErrorCallback(FDCAN_HandleTypeDef *hfdcan)
{
/* Prevent unused argument(s) compilation warning */
UNUSED(hfdcan);
/* NOTE: This function Should not be modified, when the callback is needed,
the HAL_FDCAN_ErrorCallback could be implemented in the user file
*/
}
/**
* @brief Error status callback.
* @param hfdcan pointer to an FDCAN_HandleTypeDef structure that contains
* the configuration information for the specified FDCAN.
* @param ErrorStatusITs indicates which Error Status interrupts are signaled.
* This parameter can be any combination of @arg FDCAN_Error_Status_Interrupts.
* @retval None
*/
__weak void HAL_FDCAN_ErrorStatusCallback(FDCAN_HandleTypeDef *hfdcan, uint32_t ErrorStatusITs)
{
/* Prevent unused argument(s) compilation warning */
UNUSED(hfdcan);
UNUSED(ErrorStatusITs);
/* NOTE: This function Should not be modified, when the callback is needed,
the HAL_FDCAN_ErrorStatusCallback could be implemented in the user file
*/
} |
|
没办法适配之前的drv_can的sce_isr逻辑。sce主要涉及的是传输的错误处理,h7的error的两个回调都是处理硬件错误相关逻辑。我看了下,这部分代码只是为了去给dev_can进行错误计数的,对实际功能没有太多影响。进入error_callback函数的时候,清除掉标志位即可,不会导致发送失败阻塞。 |
|
|
已添加,网上有这个问题的复现,我按思路添加了对应的处理。先这样防止阻塞,后续我再思考下,因为这个errorcallback并不是给tx fail使用的,还有一些硬件error,如果要完整的实现,可能得在rtthread的can框架里面加一些其他额外的事件 |
There was a problem hiding this comment.
Pull Request Overview
This PR adds STM32H7 FDCAN driver support to the RT-Thread operating system. The implementation provides a dedicated FDCAN (Flexible Data-rate CAN) driver specifically for STM32H7 series microcontrollers, enabling both classic CAN and CAN-FD functionality.
Key Changes:
- Adds comprehensive FDCAN driver implementation for STM32H7 series
- Provides support for both classic CAN and CAN-FD protocols with configurable data rates
- Integrates FDCAN driver into the build system through SConscript modifications
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| drv_fdcan.h | Header file defining FDCAN driver structures and timing configurations |
| drv_fdcan.c | Complete FDCAN driver implementation with interrupt handlers and CAN operations |
| SConscript | Build system integration to use FDCAN driver for STM32H7 series |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
请修改PR标题,建议标题 [bsp/stm32h7]: fdcan ... |
拉取/合并请求描述:(PR description)
添加STM32H7 fdcan驱动
[
为什么提交这份PR (why to submit this PR)
添加STM32H7的FDCAN驱动
你的解决方案是什么 (what is your solution)
在原有的arp-pi驱动上进行修改,并参考https://github.com/CN-CaoJun进行修改。
修复新版fdcan的hal驱动对pmsg->len无需进行移位操作的bug
请提供验证的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