Skip to content
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

Draft
wants to merge 21 commits into
base: master
Choose a base branch
from
Draft
Prev Previous commit
Next Next commit
Update drv_can.c
  • Loading branch information
zylugl committed Apr 21, 2023
commit b028ccc49750fb5cf6005b09184a90471dd30a67
20 changes: 10 additions & 10 deletions bsp/wch/risc-v/Libraries/ch32_drivers/drv_can.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ static rt_err_t _can_filter_config(struct ch32v307x_can_obj *drv_can_obj)
{
CAN_FilterInit( &(drv_can_obj->can_filter_init) );
}
#if (defined BSP_USING_CAN2) && (defined CH32V30x_D8C)
#if (defined BSP_USING_CAN2) && (defined CH32V30x_D8C)
else if (drv_can_obj->can_base == CAN2)
{
CAN_FilterInit( &(drv_can_obj->can_filter_init) );
Expand Down Expand Up @@ -237,7 +237,7 @@ static rt_err_t _can_config(struct rt_can_device *can, struct can_configure *cfg
{
ch32v307x_can_gpio_init(CAN1);
}
#if (defined BSP_USING_CAN2) && (defined CH32V30x_D8C)
#if (defined BSP_USING_CAN2) && (defined CH32V30x_D8C)
else if (drv_can_obj->can_base == CAN2)
{
ch32v307x_can_gpio_init(CAN2);
Expand Down Expand Up @@ -305,7 +305,7 @@ static rt_err_t _can_control(struct rt_can_device *can, int cmd, void *arg)
NVIC_DisableIRQ(USB_LP_CAN1_RX0_IRQn);
NVIC_DisableIRQ(CAN1_RX1_IRQn);
}
#if (defined BSP_USING_CAN2) && (defined CH32V30x_D8C)
#if (defined BSP_USING_CAN2) && (defined CH32V30x_D8C)
if (CAN2 == drv_can_obj->can_base)
{
NVIC_DisableIRQ(CAN2_RX0_IRQn);
Expand All @@ -332,7 +332,7 @@ static rt_err_t _can_control(struct rt_can_device *can, int cmd, void *arg)
{
NVIC_DisableIRQ(USB_HP_CAN1_TX_IRQn);
}
#if (defined BSP_USING_CAN2) && (defined CH32V30x_D8C)
#if (defined BSP_USING_CAN2) && (defined CH32V30x_D8C)
if (CAN2 == drv_can_obj->can_base)
{
NVIC_DisableIRQ(CAN2_TX_IRQn);
Expand All @@ -346,7 +346,7 @@ static rt_err_t _can_control(struct rt_can_device *can, int cmd, void *arg)
{
NVIC_DisableIRQ(CAN1_SCE_IRQn);
}
#if (defined BSP_USING_CAN2) && (defined CH32V30x_D8C)
#if (defined BSP_USING_CAN2) && (defined CH32V30x_D8C)
if (CAN2 == drv_can_obj->can_base)
{
NVIC_DisableIRQ(CAN2_SCE_IRQn);
Expand Down Expand Up @@ -390,15 +390,15 @@ static rt_err_t _can_control(struct rt_can_device *can, int cmd, void *arg)
NVIC_SetPriority(CAN1_RX1_IRQn, 1);
NVIC_EnableIRQ(CAN1_RX1_IRQn);
}
#if (defined BSP_USING_CAN2) && (defined CH32V30x_D8C)
#if (defined BSP_USING_CAN2) && (defined CH32V30x_D8C)
if (CAN2 == drv_can_obj->can_base)
{
NVIC_SetPriority(CAN2_RX0_IRQn, 1);
NVIC_EnableIRQ(CAN2_RX0_IRQn);
NVIC_SetPriority(CAN2_RX1_IRQn, 1);
NVIC_EnableIRQ(CAN2_RX1_IRQn);
}
#endif
#endif
}
else if (argval == RT_DEVICE_FLAG_INT_TX)
{
Expand All @@ -410,7 +410,7 @@ static rt_err_t _can_control(struct rt_can_device *can, int cmd, void *arg)
NVIC_SetPriority(USB_HP_CAN1_TX_IRQn, 1);
NVIC_EnableIRQ(USB_HP_CAN1_TX_IRQn);
}
#if (defined BSP_USING_CAN2) && (defined CH32V30x_D8C)
#if (defined BSP_USING_CAN2) && (defined CH32V30x_D8C)
if (CAN2 == drv_can_obj->can_base)
{
NVIC_SetPriority(CAN2_TX_IRQn, 1);
Expand All @@ -431,7 +431,7 @@ static rt_err_t _can_control(struct rt_can_device *can, int cmd, void *arg)
NVIC_SetPriority(CAN1_SCE_IRQn, 1);
NVIC_EnableIRQ(CAN1_SCE_IRQn);
}
#if (defined BSP_USING_CAN2) && (defined CH32V30x_D8C)
#if (defined BSP_USING_CAN2) && (defined CH32V30x_D8C)
if (CAN2 == drv_can_obj->can_base)
{
NVIC_SetPriority(CAN2_SCE_IRQn, 1);
Expand Down Expand Up @@ -747,7 +747,7 @@ static int _can_recv_rtmsg(CAN_TypeDef *can_base, struct rt_can_msg *pmsg, rt_ui
{
pmsg->hdr_index = (RxMessage->FMI + 1) >> 1;
}
#if (defined BSP_USING_CAN2) && (defined CH32V30x_D8C)
#if (defined BSP_USING_CAN2) && (defined CH32V30x_D8C)
else if (can_base == CAN2)
{
pmsg->hdr_index = (RxMessage->FMI >> 1) + 14;
Expand Down