Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers: can_mcan: One shot mode support #79995

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions drivers/can/can_mcan.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ int can_mcan_get_capabilities(const struct device *dev, can_mode_t *cap)
{
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_ONE_SHOT;

if (IS_ENABLED(CONFIG_CAN_MANUAL_RECOVERY_MODE)) {
*cap |= CAN_MODE_MANUAL_RECOVERY;
Expand Down Expand Up @@ -373,7 +373,7 @@ int can_mcan_stop(const struct device *dev)

int can_mcan_set_mode(const struct device *dev, can_mode_t mode)
{
can_mode_t supported = CAN_MODE_LOOPBACK | CAN_MODE_LISTENONLY;
can_mode_t supported = CAN_MODE_LOOPBACK | CAN_MODE_LISTENONLY | CAN_MODE_ONE_SHOT;
struct can_mcan_data *data = dev->data;
uint32_t cccr;
uint32_t test;
Expand Down Expand Up @@ -423,6 +423,13 @@ int can_mcan_set_mode(const struct device *dev, can_mode_t mode)
cccr &= ~CAN_MCAN_CCCR_MON;
}

if ((mode & CAN_MODE_ONE_SHOT) != 0) {
/* No automatic retransmission */
cccr |= CAN_MCAN_CCCR_DAR;
} else {
cccr &= ~CAN_MCAN_CCCR_DAR;
}

#ifdef CONFIG_CAN_FD_MODE
if ((mode & CAN_MODE_FD) != 0) {
cccr |= CAN_MCAN_CCCR_FDOE | CAN_MCAN_CCCR_BRSE;
Expand Down
Loading