[bsp][wch]增加适配CH32V208 CAN驱动
拉取/合并请求描述:(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):
- [ ] 本拉取/合并请求是一个草稿版本 This PR is for a code-review and is intended to get feedback
- [x] 本拉取/合并请求是一个成熟版本 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:
- [x] 已经仔细查看过代码改动的对比 Already check the difference between PR and old code
- [x] 代码风格正确,包括缩进空格,命名及其他风格 Style guide is adhered to, including spacing, naming and other styles
- [x] 没有垃圾代码,代码尽量精简,不包含
#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up - [x] 所有变更均有原因及合理的,并且不会影响到其他软件组件代码或BSP All modifications are justified and not affect other components or BSP
- [x] 对难懂代码均提供对应的注释 I've commented appropriately where code is tricky
- [x] 代码是高质量的 Code in this PR is of high quality
- [x] 已经使用formatting等源码格式化工具确保格式符合RT-Thread代码规范 This PR complies with RT-Thread code specification
是这样的,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: @.***>
是这样的,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 不开启这个宏不就好了吗。不开启的话,下面的代码不参与编译,也不会报错吧。
如果不加上,就报错,你可以试一下,难不成,我是为了凑字数吗?这都是一步一步调试出来的!
华仔 @.***
------------------ 原始邮件 ------------------ 发件人: "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: @.***>