Skip to content

Commit 56143c4

Browse files
Update drv_fdcan.c
修复注释
1 parent 4bd2fd9 commit 56143c4

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

bsp/stm32/libraries/HAL_Drivers/drivers/drv_fdcan.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Date Author Notes
88
* 2020-02-24 heyuan the first version
99
* 2020-08-17 malongwei Fix something
10+
* 2025-10-27 pandafeng Fix some bugs
1011
*/
1112

1213
#include "drv_fdcan.h"
@@ -101,7 +102,11 @@ static uint32_t _inline_get_ArbBaudIndex(uint32_t baud_rate)
101102
}
102103

103104
/**
104-
* @brief 获取 FDCAN 数据段波特率配置索引
105+
* @brief Get the index of the FDCAN data segment bitrate configuration.
106+
*
107+
* @param baud_rate The desired data phase baud rate (in bps).
108+
* @retval uint32_t Index of the matching data segment configuration.
109+
* Returns -1 if no matching configuration is found.
105110
*/
106111
static uint32_t _inline_get_DataBaudIndex(uint32_t baud_rate)
107112
{
@@ -156,7 +161,7 @@ static rt_err_t _inline_can_config(struct rt_can_device *can, struct can_configu
156161
LOG_E("not support %d baudrate", cfg->baud_rate);
157162
return -RT_ERROR;
158163
}
159-
/* 仲裁段 */
164+
/* FDCAN arbitration segment */
160165
pdrv_can->fdcanHandle.Init.NominalPrescaler = st_FDCAN_ArbTiming[arb_idx].cam_bit_timing.prescaler;
161166
pdrv_can->fdcanHandle.Init.NominalSyncJumpWidth = st_FDCAN_ArbTiming[arb_idx].cam_bit_timing.num_sjw;
162167
pdrv_can->fdcanHandle.Init.NominalTimeSeg1 = st_FDCAN_ArbTiming[arb_idx].cam_bit_timing.num_seg1;
@@ -345,10 +350,9 @@ static rt_err_t _inline_can_control(struct rt_can_device *can, int cmd, void *ar
345350
break;
346351
case RT_CAN_CMD_SET_BAUD:
347352
argval = (rt_uint32_t) arg;
348-
/* 查找仲裁相位波特率是否存在 */
349353
uint32_t arb_idx = _inline_get_ArbBaudIndex(argval);
350354
if (arb_idx == (uint32_t) -1) {
351-
return -RT_ERROR; // 未找到匹配波特率
355+
return -RT_ERROR;
352356
}
353357
if (argval != pdrv_can->device.config.baud_rate) {
354358
pdrv_can->device.config.baud_rate = argval;
@@ -383,10 +387,9 @@ static rt_err_t _inline_can_control(struct rt_can_device *can, int cmd, void *ar
383387
break;
384388
case RT_CAN_CMD_SET_BAUD_FD: {
385389
argval = (rt_uint32_t) arg;
386-
/* 查找仲裁相位波特率是否存在 */
387390
uint32_t data_idx = _inline_get_DataBaudIndex(argval);
388391
if (data_idx == (uint32_t) -1) {
389-
return -RT_ERROR; // 未找到匹配波特率
392+
return -RT_ERROR;
390393
}
391394
if (argval != pdrv_can->device.config.baud_rate_fd) {
392395
pdrv_can->device.config.baud_rate_fd = argval;

0 commit comments

Comments
 (0)