From 1173711d0c83dd858e950b9bf5adc29db912e4d1 Mon Sep 17 00:00:00 2001 From: jonas Date: Wed, 24 Jul 2024 15:10:31 +0800 Subject: [PATCH] =?UTF-8?q?can=E9=A9=B1=E5=8A=A8=E4=BC=98=E5=8C=96?= =?UTF-8?q?=EF=BC=8C=E6=94=AF=E6=8C=81=E5=8F=91=E9=80=81=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E5=90=8E=E5=8F=96=E6=B6=88=E5=8F=91=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/drivers/can/can.c | 3 +++ components/drivers/include/drivers/can.h | 1 + 2 files changed, 4 insertions(+) diff --git a/components/drivers/can/can.c b/components/drivers/can/can.c index a3d81f6..6d09a17 100644 --- a/components/drivers/can/can.c +++ b/components/drivers/can/can.c @@ -154,6 +154,7 @@ rt_inline int _can_int_tx(struct rt_can_device *can, const struct rt_can_msg *da no = ((rt_uint32_t)tx_tosnd - (rt_uint32_t)tx_fifo->buffer) / sizeof(struct rt_can_sndbxinx_list); tx_tosnd->result = RT_CAN_SND_RESULT_WAIT; + rt_completion_init(&(tx_tosnd->completion)); if (can->ops->sendmsg(can, data, no) != RT_EOK) { /* send failed. */ @@ -192,6 +193,8 @@ rt_inline int _can_int_tx(struct rt_can_device *can, const struct rt_can_msg *da err_ret: level = rt_hw_interrupt_disable(); can->status.dropedsndpkg++; + //TODO:发送失败,取消发送状态 + can->ops->control(can, RT_CAN_CMD_CANCEL, (void *)no); rt_hw_interrupt_enable(level); break; } diff --git a/components/drivers/include/drivers/can.h b/components/drivers/include/drivers/can.h index 1834fbe..e607ba2 100644 --- a/components/drivers/include/drivers/can.h +++ b/components/drivers/include/drivers/can.h @@ -182,6 +182,7 @@ struct rt_can_ops; #define RT_CAN_CMD_SET_CANFD 0x1A #define RT_CAN_CMD_SET_BAUD_FD 0x1B #define RT_CAN_CMD_SET_BITTIMING 0x1C +#define RT_CAN_CMD_CANCEL 0x1D #define RT_DEVICE_CAN_INT_ERR 0x1000