Skip to content

Commit 5c16ba0

Browse files
henrikbrixandersencarlescufi
authored andcommitted
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 <[email protected]>
1 parent 97d9ab8 commit 5c16ba0

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

drivers/can/can_mcux_flexcan.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ static int mcux_flexcan_get_capabilities(const struct device *dev, can_mode_t *c
183183
{
184184
ARG_UNUSED(dev);
185185

186-
*cap = CAN_MODE_NORMAL | CAN_MODE_LOOPBACK | CAN_MODE_LISTENONLY;
186+
*cap = CAN_MODE_NORMAL | CAN_MODE_LOOPBACK | CAN_MODE_LISTENONLY | CAN_MODE_3_SAMPLES;
187187

188188
return 0;
189189
}
@@ -195,7 +195,7 @@ static int mcux_flexcan_set_mode(const struct device *dev, can_mode_t mode)
195195
uint32_t mcr;
196196
int err;
197197

198-
if ((mode & ~(CAN_MODE_LOOPBACK | CAN_MODE_LISTENONLY)) != 0) {
198+
if ((mode & ~(CAN_MODE_LOOPBACK | CAN_MODE_LISTENONLY | CAN_MODE_3_SAMPLES)) != 0) {
199199
LOG_ERR("unsupported mode: 0x%08x", mode);
200200
return -ENOTSUP;
201201
}
@@ -231,6 +231,14 @@ static int mcux_flexcan_set_mode(const struct device *dev, can_mode_t mode)
231231
ctrl1 &= ~(CAN_CTRL1_LOM_MASK);
232232
}
233233

234+
if ((mode & CAN_MODE_3_SAMPLES) != 0) {
235+
/* Enable triple sampling mode */
236+
ctrl1 |= CAN_CTRL1_SMP_MASK;
237+
} else {
238+
/* Disable triple sampling mode */
239+
ctrl1 &= ~(CAN_CTRL1_SMP_MASK);
240+
}
241+
234242
config->base->CTRL1 = ctrl1;
235243
config->base->MCR = mcr;
236244

0 commit comments

Comments
 (0)