-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[bsp][wch]增加适配CH32V208 CAN驱动 #7366
base: master
Are you sure you want to change the base?
Conversation
@@ -91,14 +91,15 @@ static struct ch32v307x_can_obj drv_can1 = | |||
}; | |||
#endif | |||
|
|||
#ifdef BSP_USING_CAN2 | |||
#if (defined BSP_USING_CAN2) && (defined CH32V30x_D8C) |
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.
这么改的原因是什么?CH32V30x_D8C 这个不支持 CAN2?
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.
如果CH32V30x_D8C这个不支持CAN2,BSP里不开启不就好了?
是这样的,CH32V208,他只有1个can1。既使不开启,他也会报错,用这个条件后,他就不去编译CAN2了,你可以测试一下。其实可以象国民技术的N32L403那样,重写一bCAN但是那样,代码太多了。综合来讲,这样时间成本最低,也可以反馈给沁恒,让他们自己修改。
华仔
***@***.***
…------------------ 原始邮件 ------------------
发件人: ***@***.***>;
发送时间: 2023年4月27日(星期四) 中午11:24
收件人: ***@***.***>;
抄送: ***@***.***>; ***@***.***>;
主题: Re: [RT-Thread/rt-thread] 增加适配CH32V208 CAN驱动 (PR #7366)
@Guozhanxin commented on this pull request.
In bsp/wch/risc-v/Libraries/ch32_drivers/drv_can.c:
> @@ -91,14 +91,15 @@ static struct ch32v307x_can_obj drv_can1 = }; #endif -#ifdef BSP_USING_CAN2 +#if (defined BSP_USING_CAN2) && (defined CH32V30x_D8C)
如果CH32V30x_D8C这个不支持CAN2,BSP里不开启不就好了?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
是只有CH32V30才有CAN2 CH32V208只有一个CAN1,所以要用条件来过滤掉CH32V208
华仔
***@***.***
…------------------ 原始邮件 ------------------
发件人: "RT-Thread/rt-thread" ***@***.***>;
发送时间: 2023年4月27日(星期四) 中午11:23
***@***.***>;
***@***.******@***.***>;
主题: Re: [RT-Thread/rt-thread] 增加适配CH32V208 CAN驱动 (PR #7366)
@Guozhanxin commented on this pull request.
In bsp/wch/risc-v/Libraries/ch32_drivers/drv_can.c:
> @@ -91,14 +91,15 @@ static struct ch32v307x_can_obj drv_can1 = }; #endif -#ifdef BSP_USING_CAN2 +#if (defined BSP_USING_CAN2) && (defined CH32V30x_D8C)
这么改的原因是什么?CH32V30x_D8C 这个不支持 CAN2?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
这里不是本身就有一个宏控制吗? BSP_USING_CAN2 不开启这个宏不就好了吗。不开启的话,下面的代码不参与编译,也不会报错吧。 |
如果不加上,就报错,你可以试一下,难不成,我是为了凑字数吗?这都是一步一步调试出来的!
华仔
***@***.***
…------------------ 原始邮件 ------------------
发件人: "RT-Thread/rt-thread" ***@***.***>;
发送时间: 2023年4月27日(星期四) 下午5:07
***@***.***>;
***@***.******@***.***>;
主题: Re: [RT-Thread/rt-thread] 增加适配CH32V208 CAN驱动 (PR #7366)
是这样的,CH32V208,他只有1个can1。既使不开启,他也会报错,用这个条件后,他就不去编译CAN2了,你可以测试一下。其实可以象国民技术的N32L403那样,重写一bCAN但是那样,代码太多了。综合来讲,这样时间成本最低,也可以反馈给沁恒,让他们自己修改。 华仔 @.***
…
------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2023年4月27日(星期四) 中午11:24 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [RT-Thread/rt-thread] 增加适配CH32V208 CAN驱动 (PR #7366) @Guozhanxin commented on this pull request. In bsp/wch/risc-v/Libraries/ch32_drivers/drv_can.c: > @@ -91,14 +91,15 @@ static struct ch32v307x_can_obj drv_can1 = }; #endif -#ifdef BSP_USING_CAN2 +#if (defined BSP_USING_CAN2) && (defined CH32V30x_D8C) 如果CH32V30x_D8C这个不支持CAN2,BSP里不开启不就好了? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
这里不是本身就有一个宏控制吗? BSP_USING_CAN2 不开启这个宏不就好了吗。不开启的话,下面的代码不参与编译,也不会报错吧。
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
发个PR,这样太难了,要是这样,我就不发了,浪费时间精力!
华仔
***@***.***
…------------------ 原始邮件 ------------------
发件人: ***@***.***>;
发送时间: 2023年4月27日(星期四) 下午5:07
收件人: ***@***.***>;
抄送: ***@***.***>; ***@***.***>;
主题: Re: [RT-Thread/rt-thread] 增加适配CH32V208 CAN驱动 (PR #7366)
是这样的,CH32V208,他只有1个can1。既使不开启,他也会报错,用这个条件后,他就不去编译CAN2了,你可以测试一下。其实可以象国民技术的N32L403那样,重写一bCAN但是那样,代码太多了。综合来讲,这样时间成本最低,也可以反馈给沁恒,让他们自己修改。 华仔 @.***
…
------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2023年4月27日(星期四) 中午11:24 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [RT-Thread/rt-thread] 增加适配CH32V208 CAN驱动 (PR #7366) @Guozhanxin commented on this pull request. In bsp/wch/risc-v/Libraries/ch32_drivers/drv_can.c: > @@ -91,14 +91,15 @@ static struct ch32v307x_can_obj drv_can1 = }; #endif -#ifdef BSP_USING_CAN2 +#if (defined BSP_USING_CAN2) && (defined CH32V30x_D8C) 如果CH32V30x_D8C这个不支持CAN2,BSP里不开启不就好了? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
这里不是本身就有一个宏控制吗? BSP_USING_CAN2 不开启这个宏不就好了吗。不开启的话,下面的代码不参与编译,也不会报错吧。
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
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.
无需更改,只是作为后续重新梳理的参考
@@ -91,14 +91,15 @@ static struct ch32v307x_can_obj drv_can1 = | |||
}; | |||
#endif | |||
|
|||
#ifdef BSP_USING_CAN2 | |||
#ifdef CAN2 |
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.
#ifdef CAN2 | |
#if defined(BSP_USING_CAN2) && defined(CAN2) |
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.
我建议这里就用 #ifdef BSP_USING_CAN2, 然后在前面加上一个总的
#if (defined BSP_USING_CAN2) && !(defined CAN2)
#error "CAN2 is not available for this board. Please change kconfig."
#endif
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.
如果只使用 #if defined(BSP_USING_CAN2) && defined(CAN2) 的话 则有可能用户选择了BSP_USING_CAN2但是其实没有CAN2 编译虽然不会报错但是会给用户造成困惑
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.
实际上应该由BSP的开发者保证kconfig里面没有BSP_USING_CAN2,但是开发者可能犯错误,使用#error提供一种纠错机制
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.
另外群里有关于到底应该用#ifdef BSP_USING_CAN2还是#ifdef CAN2的讨论,原则上在ops里应该是不关心BSP的事的所以应该用#ifdef CAN2,但是如果用#ifdef CAN2 则可能出现用户没有选择BSP_USING_CAN2的时候CAN2相关的资源仍然被占用了,其原因在于CAN2的初始化代码跟CAN1写在一起了。这其实不符合rtt的规范,如果后面有人跟进的话,可以考虑一个独立于CAN1和CAN2(复用)的ops,这样在ops里面就不存在该用BSP_USING_CAN2还是CAN2的问题了,只在外面定义对向的时候用#ifdef BSP_USING_CAN2来判断是否生成针对CAN2的对象。
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.
以上评论主要是为了后续讨论,不需要执行。
@@ -132,7 +133,7 @@ rt_weak void ch32v307x_can_gpio_init(CAN_TypeDef *can_base) | |||
*/ | |||
} | |||
#endif | |||
#ifdef BSP_USING_CAN2 | |||
#ifdef CAN2 |
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.
#ifdef CAN2 | |
#if defined(BSP_USING_CAN2) && defined(CAN2) |
@@ -955,7 +974,7 @@ void CAN1_SCE_IRQHandler(void) | |||
} | |||
#endif /* BSP_USING_CAN1 */ | |||
|
|||
#ifdef BSP_USING_CAN2 | |||
#ifdef CAN2 |
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.
#ifdef CAN2 | |
#if defined(BSP_USING_CAN2) && defined(CAN2) |
@@ -1132,7 +1151,7 @@ int rt_hw_can_init(void) | |||
rt_hw_can_register(&drv_can1.device, drv_can1.name, &_can_ops, &drv_can1); | |||
#endif /* BSP_USING_CAN1 */ | |||
|
|||
#ifdef BSP_USING_CAN2 | |||
#ifdef CAN2 |
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.
#ifdef CAN2 | |
#if defined(BSP_USING_CAN2) && defined(CAN2) |
修改serial.h的引用错误
拉取/合并请求描述:(PR description)
[
为什么提交这份PR (why to submit this PR)
我在调试CH32V208时,发现原先的CH32_drivers没有配置对ch32v208的匹配。经我修改drv_can.c,完成了对can的驱动匹配。
你的解决方案是什么 (what is your solution)
增加宏编译条件,增加匹配CH32V208的can_baud_rate_tab定义,同时因为ch32v208有CAN1 在CAN的相关操作上增加了CH32V307的编译条件,有效的过滤掉CH32V208的CAN2的相关定义,避免编译时报错。
在什么测试环境下测试通过 (what is the test environment)
在scons下对CH32V208、CH32V307均编译通过,在相关开发板上也测试通过。
]
当前拉取/合并请求的状态 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