All CAN drivers: Set the new error indication to zero in the CAN message report
This commit is contained in:
parent
c01d3298e5
commit
b7d6720a23
@ -750,7 +750,8 @@ static int can_send(FAR struct can_dev_s *dev, FAR struct can_msg_s *msg)
|
||||
irqstate_t flags;
|
||||
int ret = OK;
|
||||
|
||||
canvdbg("CAN%d ID: %d DLC: %d\n", priv->port, msg->cm_hdr.ch_id, msg->cm_hdr.ch_dlc);
|
||||
canvdbg("CAN%d ID: %d DLC: %d\n",
|
||||
priv->port, msg->cm_hdr.ch_id, msg->cm_hdr.ch_dlc);
|
||||
|
||||
if (msg->cm_hdr.ch_rtr)
|
||||
{
|
||||
@ -971,12 +972,15 @@ static void can_interrupt(FAR struct can_dev_s *dev)
|
||||
|
||||
/* Construct the CAN header */
|
||||
|
||||
hdr.ch_id = rid;
|
||||
hdr.ch_rtr = ((rfs & CAN_RFS_RTR) != 0);
|
||||
hdr.ch_dlc = (rfs & CAN_RFS_DLC_MASK) >> CAN_RFS_DLC_SHIFT;
|
||||
hdr.ch_id = rid;
|
||||
hdr.ch_rtr = ((rfs & CAN_RFS_RTR) != 0);
|
||||
hdr.ch_dlc = (rfs & CAN_RFS_DLC_MASK) >> CAN_RFS_DLC_SHIFT;
|
||||
hdr.ch_error = 0;
|
||||
#ifdef CONFIG_CAN_EXTID
|
||||
hdr.ch_extid = ((rfs & CAN_RFS_FF) != 0);
|
||||
hdr.ch_extid = ((rfs & CAN_RFS_FF) != 0);
|
||||
#else
|
||||
hdr.ch_unused = 0;
|
||||
|
||||
if ((rfs & CAN_RFS_FF) != 0)
|
||||
{
|
||||
canlldbg("ERROR: Received message with extended identifier. Dropped\n");
|
||||
|
@ -733,7 +733,10 @@ static int can_recvsetup(FAR struct sam_can_s *priv)
|
||||
canvdbg("CAN%d Mailbox %d: Index=%d rxmbset=%02x\n",
|
||||
config->port, mbno, mbndx, priv->rxmbset);
|
||||
|
||||
/* Set up the message ID and filter mask */
|
||||
/* Set up the message ID and filter mask
|
||||
* REVISIT: This logic should be capable of setting up standard
|
||||
* filters when CONFIG_CAN_EXTID is selected.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_CAN_EXTID
|
||||
can_putreg(priv, SAM_CAN_MnID_OFFSET(mbndx),
|
||||
@ -1125,14 +1128,16 @@ static int can_send(FAR struct can_dev_s *dev, FAR struct can_msg_s *msg)
|
||||
|
||||
canvdbg("Mailbox Index=%d txmbset=%02x\n", mbndx, priv->txmbset);
|
||||
|
||||
/* Set up the ID and mask, standard 11-bit or extended 29-bit. */
|
||||
/* Set up the ID and mask, standard 11-bit or extended 29-bit.
|
||||
* REVISIT: This logic should be capable of sending standard messages
|
||||
* when CONFIG_CAN_EXTID is selected.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_CAN_EXTID
|
||||
DEBUGASSERT(msg->cm_hdr.ch_extid);
|
||||
DEBUGASSERT(msg->cm_hdr.ch_id < (1 << 29));
|
||||
can_putreg(priv, SAM_CAN_MnID_OFFSET(mbndx), CAN_MID_EXTID(msg->cm_hdr.ch_id));
|
||||
#else
|
||||
DEBUGASSERT(!msg->cm_hdr.ch_extid);
|
||||
DEBUGASSERT(msg->cm_hdr.ch_id < (1 << 11));
|
||||
can_putreg(priv, SAM_CAN_MnID_OFFSET(mbndx), CAN_MID_STDID(msg->cm_hdr.ch_id));
|
||||
#endif
|
||||
@ -1309,24 +1314,27 @@ static inline void can_rxinterrupt(FAR struct can_dev_s *dev, int mbndx,
|
||||
|
||||
mid = can_getreg(priv, SAM_CAN_MnID_OFFSET(mbndx));
|
||||
|
||||
/* Format the CAN header */
|
||||
/* Format the CAN header.
|
||||
* REVISIT: This logic should be capable of receiving standard messages
|
||||
* when CONFIG_CAN_EXTID is selected.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_CAN_EXTID
|
||||
/* Save the extended ID of the newly received message */
|
||||
|
||||
hdr.ch_id = (mid & CAN_MAM_EXTID_MASK) >> CAN_MAM_EXTID_SHIFT;
|
||||
hdr.ch_dlc = (msr & CAN_MSR_MDLC_MASK) >> CAN_MSR_MDLC_SHIFT;
|
||||
hdr.ch_rtr = 0;
|
||||
hdr.ch_extid = true;
|
||||
hdr.ch_unused = 0;
|
||||
#else
|
||||
/* Save the standard ID of the newly received message */
|
||||
|
||||
hdr.ch_dlc = (msr & CAN_MSR_MDLC_MASK) >> CAN_MSR_MDLC_SHIFT;
|
||||
hdr.ch_rtr = 0;
|
||||
hdr.ch_id = (mid & CAN_MAM_STDID_MASK) >> CAN_MAM_STDID_SHIFT;
|
||||
#endif
|
||||
|
||||
hdr.ch_dlc = (msr & CAN_MSR_MDLC_MASK) >> CAN_MSR_MDLC_SHIFT;
|
||||
hdr.ch_rtr = 0;
|
||||
hdr.ch_error = 0;
|
||||
hdr.ch_unused = 0;
|
||||
|
||||
/* And provide the CAN message to the upper half logic */
|
||||
|
||||
ret = can_receive(dev, &hdr, (FAR uint8_t *)md);
|
||||
|
@ -1512,6 +1512,7 @@ config SAMV7_MCAN0_NEXTFILTERS
|
||||
int "MCAN0 number of extended filters"
|
||||
default 8
|
||||
range 0 64
|
||||
depends on CAN_EXTID
|
||||
---help---
|
||||
Number of extended message ID filters.
|
||||
|
||||
@ -1827,6 +1828,7 @@ config SAMV7_MCAN1_NEXTFILTERS
|
||||
int "MCAN1 number of extended filters"
|
||||
default 8
|
||||
range 0 64
|
||||
depends on CAN_EXTID
|
||||
---help---
|
||||
Number of extended message ID filters.
|
||||
|
||||
|
@ -2796,9 +2796,10 @@ static void mcan_receive(FAR struct can_dev_s *dev, FAR uint32_t *rxbuffer,
|
||||
canregdbg("R0: %08x\n", regval);
|
||||
|
||||
hdr.ch_rtr = 0;
|
||||
#ifdef CONFIG_CAN_EXTID
|
||||
hdr.ch_error = 0;
|
||||
hdr.ch_unused = 0;
|
||||
|
||||
#ifdef CONFIG_CAN_EXTID
|
||||
if ((regval & BUFFER_R0_XTD) != 0)
|
||||
{
|
||||
/* Save the extended ID of the newly received message */
|
||||
|
@ -1070,6 +1070,7 @@ static int can_rx0interrupt(int irq, void *context)
|
||||
/* Get the CAN identifier. */
|
||||
|
||||
regval = can_getreg(priv, STM32_CAN_RI0R_OFFSET);
|
||||
|
||||
#ifdef CONFIG_CAN_EXTID
|
||||
if ((regval & CAN_RIR_IDE) != 0)
|
||||
{
|
||||
@ -1089,17 +1090,22 @@ static int can_rx0interrupt(int irq, void *context)
|
||||
goto errout;
|
||||
}
|
||||
|
||||
hdr.ch_id = (regval & CAN_RIR_STID_MASK) >> CAN_RIR_STID_SHIFT;
|
||||
hdr.ch_id = (regval & CAN_RIR_STID_MASK) >> CAN_RIR_STID_SHIFT;
|
||||
#endif
|
||||
|
||||
/* Clear the error indication and unused bits */
|
||||
|
||||
hdr.ch_error = 0;
|
||||
hdr.ch_unused = 0;
|
||||
|
||||
/* Extract the RTR bit */
|
||||
|
||||
hdr.ch_rtr = (regval & CAN_RIR_RTR) != 0 ? true : false;
|
||||
hdr.ch_rtr = (regval & CAN_RIR_RTR) != 0 ? true : false;
|
||||
|
||||
/* Get the DLC */
|
||||
|
||||
regval = can_getreg(priv, STM32_CAN_RDT0R_OFFSET);
|
||||
hdr.ch_dlc = (regval & CAN_RDTR_DLC_MASK) >> CAN_RDTR_DLC_SHIFT;
|
||||
regval = can_getreg(priv, STM32_CAN_RDT0R_OFFSET);
|
||||
hdr.ch_dlc = (regval & CAN_RDTR_DLC_MASK) >> CAN_RDTR_DLC_SHIFT;
|
||||
|
||||
/* Save the message data */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user