stm32: extend CAN ioctrl with NART/ABOM. Add RTR to CAN header

Signed-off-by: Claudio Micheli <claudio@auterion.com>
This commit is contained in:
Claudio Micheli 2020-05-25 14:01:13 +02:00 committed by Alan Carvalho de Assis
parent 7a346bee26
commit 94e87bb6e8
1 changed files with 49 additions and 2 deletions

View File

@ -1102,6 +1102,50 @@ static int stm32can_ioctl(FAR struct can_dev_s *dev, int cmd,
} }
break; break;
case CANIOC_SET_NART:
{
uint32_t regval;
ret = stm32can_enterinitmode(priv);
if (ret != 0)
{
return ret;
}
regval = stm32can_getreg(priv, STM32_CAN_MCR_OFFSET);
if (arg == 1)
{
regval |= CAN_MCR_NART;
}
else
{
regval &= ~CAN_MCR_NART;
}
stm32can_putreg(priv, STM32_CAN_MCR_OFFSET, regval);
return stm32can_exitinitmode(priv);
}
break;
case CANIOC_SET_ABOM:
{
uint32_t regval;
ret = stm32can_enterinitmode(priv);
if (ret != 0)
{
return ret;
}
regval = stm32can_getreg(priv, STM32_CAN_MCR_OFFSET);
if (arg == 1)
{
regval |= CAN_MCR_ABOM;
}
else
{
regval &= ~CAN_MCR_ABOM;
}
stm32can_putreg(priv, STM32_CAN_MCR_OFFSET, regval);
return stm32can_exitinitmode(priv);
}
break;
/* Unsupported/unrecognized command */ /* Unsupported/unrecognized command */
default: default:
@ -1211,8 +1255,11 @@ static int stm32can_send(FAR struct can_dev_s *dev,
regval |= msg->cm_hdr.ch_id << CAN_TIR_STID_SHIFT; regval |= msg->cm_hdr.ch_id << CAN_TIR_STID_SHIFT;
} }
#else #else
regval &= ~CAN_TIR_STID_MASK; regval |= ( ( (uint32_t) msg->cm_hdr.ch_id << CAN_TIR_STID_SHIFT) & CAN_TIR_STID_MASK );
regval |= (uint32_t)msg->cm_hdr.ch_id << CAN_TIR_STID_SHIFT;
#ifdef CONFIG_CAN_USE_RTR
regval |= (msg->cm_hdr.ch_rtr ? CAN_TIR_RTR : 0);
#endif
#endif #endif
stm32can_putreg(priv, STM32_CAN_TIR_OFFSET(txmb), regval); stm32can_putreg(priv, STM32_CAN_TIR_OFFSET(txmb), regval);