fix(CAN): Avoid double counting RX overflow drops

This commit is contained in:
wdfk-prog
2026-02-07 15:28:02 +08:00
committed by Rbb666
parent c2103a5cc9
commit 27b2ba5556

View File

@@ -968,15 +968,19 @@ rt_err_t rt_hw_can_register(struct rt_can_device *can,
*/
void rt_hw_can_isr(struct rt_can_device *can, int event)
{
rt_bool_t is_rxof_event = RT_FALSE;
switch (event & 0xff)
{
case RT_CAN_EVENT_RXOF_IND:
{
rt_base_t level;
is_rxof_event = RT_TRUE;
level = rt_hw_local_irq_disable();
can->status.dropedrcvpkg++;
rt_hw_local_irq_enable(level);
}
/* FALLTHROUGH: RX overflow still tries to fetch one pending frame into software FIFO. */
case RT_CAN_EVENT_RX_IND:
{
struct rt_can_msg tmpmsg;
@@ -1020,7 +1024,10 @@ void rt_hw_can_isr(struct rt_can_device *can, int event)
else if (!rt_list_isempty(&rx_fifo->uselist))
{
listmsg = rt_list_entry(rx_fifo->uselist.next, struct rt_can_msg_list, list);
can->status.dropedrcvpkg++;
if (!is_rxof_event)
{
can->status.dropedrcvpkg++;
}
rt_list_remove(&listmsg->list);
#ifdef RT_CAN_USING_HDR
rt_list_remove(&listmsg->hdrlist);