格式化代码

This commit is contained in:
chenbin 2022-01-13 00:03:13 +08:00
parent b4b9394051
commit 66628f1061
2 changed files with 449 additions and 461 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
* Copyright (c) 2006-2022, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
@ -26,7 +26,8 @@ struct n32g45x_baud_rate_tab
};
#define N32_CAN_BAUD_DEF(rate, rsjw, tbs1, tbs2, prescale) \
{.baud_rate = rate, \
{ \
.baud_rate = rate, \
.RSJW = rsjw, \
.TBS1 = tbs1, \
.TBS2 = tbs2, \
@ -123,8 +124,7 @@ static rt_err_t _can_filter_config(struct n32g45x_can *drv_can)
CAN1_InitFilter(&(drv_can->can_filter_init));
}
#ifdef CAN2
else
if(drv_can->CANx == CAN2)
else if (drv_can->CANx == CAN2)
{
CAN2_InitFilter(&(drv_can->can_filter_init));
}
@ -147,9 +147,6 @@ static rt_err_t _can_config(struct rt_can_device *can, struct can_configure *cfg
drv_can = (struct n32g45x_can *)can->parent.user_data;
RT_ASSERT(drv_can);
/* CAN1 and CAN2 register init */
//CAN_DeInit(drv_can->CANx);
/* Configure CAN1 and CAN2 */
if (drv_can->CANx == CAN1)
{
@ -157,8 +154,7 @@ static rt_err_t _can_config(struct rt_can_device *can, struct can_configure *cfg
n32_msp_can_init(CAN1);
}
#ifdef CAN2
else
if(drv_can->CANx == CAN2)
else if (drv_can->CANx == CAN2)
{
RCC_EnableAPB1PeriphClk(RCC_APB1_PERIPH_CAN2, ENABLE);
n32_msp_can_init(CAN2);
@ -385,7 +381,8 @@ static rt_err_t _can_control(struct rt_can_device *can, int cmd, void *arg)
id_h = ((filter_cfg->items[i].id << 18) >> 13) & 0xFFFF;
id_l = ((filter_cfg->items[i].id << 18) |
(filter_cfg->items[i].ide << 2) |
(filter_cfg->items[i].rtr << 1)) & 0xFFFF;
(filter_cfg->items[i].rtr << 1)) &
0xFFFF;
mask_h = ((filter_cfg->items[i].mask << 21) >> 16) & 0xFFFF;
mask_l = ((filter_cfg->items[i].mask << 21) | mask_l_tail) & 0xFFFF;
}
@ -394,11 +391,11 @@ static rt_err_t _can_control(struct rt_can_device *can, int cmd, void *arg)
id_h = (filter_cfg->items[i].id >> 13) & 0xFFFF;
id_l = ((filter_cfg->items[i].id << 3) |
(filter_cfg->items[i].ide << 2) |
(filter_cfg->items[i].rtr << 1)) & 0xFFFF;
(filter_cfg->items[i].rtr << 1)) &
0xFFFF;
mask_h = ((filter_cfg->items[i].mask << 3) >> 16) & 0xFFFF;
mask_l = ((filter_cfg->items[i].mask << 3) | mask_l_tail) & 0xFFFF;
}
drv_can->can_filter_init.Filter_Scale = CAN_Filter_32bitScale;
drv_can->can_filter_init.Filter_HighId = id_h;
drv_can->can_filter_init.Filter_LowId = id_l;
@ -463,11 +460,6 @@ static rt_err_t _can_control(struct rt_can_device *can, int cmd, void *arg)
break;
case RT_CAN_CMD_GET_STATUS:
{
// drv_can->device.status.rcverrcnt = CAN_GetReceiveErrCounter(drv_can->CANx);
// drv_can->device.status.snderrcnt = CAN_GetLSBTransmitErrCounter(drv_can->CANx);
// drv_can->device.status.lasterrtype = CAN_GetLastErrCode(drv_can->CANx);
// drv_can->device.status.errcode = CAN_GetLastErrCode(drv_can->CANx);
rt_uint32_t errtype;
errtype = drv_can->CANx->ESTS;
drv_can->device.status.rcverrcnt = errtype >> 24;
@ -554,7 +546,6 @@ static int _can_sendmsg_rtmsg(CAN_Module* CANx, struct rt_can_msg *pmsg, uint32_
return -RT_ERROR;
}
static int _can_sendmsg(struct rt_can_device *can, const void *buf, rt_uint32_t box_num)
{
struct n32g45x_can *drv_can;
@ -596,8 +587,6 @@ static int _can_sendmsg(struct rt_can_device *can, const void *buf, rt_uint32_t
return _can_sendmsg_rtmsg(drv_can->CANx, ((struct rt_can_msg *)buf), box_num);
}
static int _can_recvmsg_rtmsg(CAN_Module *CANx, struct rt_can_msg *pmsg, uint32_t FIFONum)
{
CanRxMessage CAN_RxMessage = {0};
@ -699,7 +688,6 @@ static int _can_recvmsg_rtmsg(CAN_Module* CANx, struct rt_can_msg *pmsg, uint32_
return RT_EOK;
}
static int _can_recvmsg(struct rt_can_device *can, void *buf, rt_uint32_t fifo)
{
struct n32g45x_can *drv_can;
@ -960,7 +948,6 @@ void CAN2_SCE_IRQHandler(void)
}
#endif /* BSP_USING_CAN2 */
int rt_hw_can_init(void)
{
struct can_configure config = CANDEFAULTCONFIG;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
* Copyright (c) 2006-2022, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
@ -12,7 +12,8 @@
#define __DRV_CAN_H__
#ifdef __cplusplus
extern "C" {
extern "C"
{
#endif
#include <board.h>