drivers: can: mcux: flexcan: add triple sampling mode support

Add support for triple sampling mode to the NXP FlexCAN driver.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
This commit is contained in:
Henrik Brix Andersen 2022-07-13 15:26:00 +02:00 committed by Carles Cufí
commit 5c16ba05c2

View file

@ -183,7 +183,7 @@ static int mcux_flexcan_get_capabilities(const struct device *dev, can_mode_t *c
{
ARG_UNUSED(dev);
*cap = CAN_MODE_NORMAL | CAN_MODE_LOOPBACK | CAN_MODE_LISTENONLY;
*cap = CAN_MODE_NORMAL | CAN_MODE_LOOPBACK | CAN_MODE_LISTENONLY | CAN_MODE_3_SAMPLES;
return 0;
}
@ -195,7 +195,7 @@ static int mcux_flexcan_set_mode(const struct device *dev, can_mode_t mode)
uint32_t mcr;
int err;
if ((mode & ~(CAN_MODE_LOOPBACK | CAN_MODE_LISTENONLY)) != 0) {
if ((mode & ~(CAN_MODE_LOOPBACK | CAN_MODE_LISTENONLY | CAN_MODE_3_SAMPLES)) != 0) {
LOG_ERR("unsupported mode: 0x%08x", mode);
return -ENOTSUP;
}
@ -231,6 +231,14 @@ static int mcux_flexcan_set_mode(const struct device *dev, can_mode_t mode)
ctrl1 &= ~(CAN_CTRL1_LOM_MASK);
}
if ((mode & CAN_MODE_3_SAMPLES) != 0) {
/* Enable triple sampling mode */
ctrl1 |= CAN_CTRL1_SMP_MASK;
} else {
/* Disable triple sampling mode */
ctrl1 &= ~(CAN_CTRL1_SMP_MASK);
}
config->base->CTRL1 = ctrl1;
config->base->MCR = mcr;