diff --git a/arch/arm/src/stm32f7/stm32_can.c b/arch/arm/src/stm32f7/stm32_can.c index d68c4ab934..6c76472af5 100644 --- a/arch/arm/src/stm32f7/stm32_can.c +++ b/arch/arm/src/stm32f7/stm32_can.c @@ -1134,6 +1134,50 @@ static int stm32can_ioctl(FAR struct can_dev_s *dev, int cmd, } 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 */ default: diff --git a/include/nuttx/can/can.h b/include/nuttx/can/can.h index f462832af5..d1cd37dffe 100644 --- a/include/nuttx/can/can.h +++ b/include/nuttx/can/can.h @@ -197,6 +197,24 @@ * is returned with the errno variable set to indicate the * nature of the error. * Dependencies: None + * + * CANIOC_SET_NART: + * Description: Enable/Disable NART (No Automatic Retry) + * Argument: Set to 1 to enable NART, 0 to disable. Default is + * disabled. + * Returned Value: Zero (OK) is returned on success. Otherwise -1 (ERROR) + * is returned with the errno variable set to indicate the + * nature of the error. + * Dependencies: None + * + * CANIOC_SET_ABOM: + * Description: Enable/Disable ABOM (Automatic Bus-off Management) + * Argument: Set to 1 to enable ABOM, 0 to disable. Default is + * disabled. + * Returned Value: Zero (OK) is returned on success. Otherwise -1 (ERROR) + * is returned with the errno variable set to indicate the + * nature of the error. + * Dependencies: None */ #define CANIOC_RTR _CANIOC(1) @@ -209,9 +227,11 @@ #define CANIOC_GET_CONNMODES _CANIOC(8) #define CANIOC_SET_CONNMODES _CANIOC(9) #define CANIOC_BUSOFF_RECOVERY _CANIOC(10) +#define CANIOC_SET_NART _CANIOC(11) +#define CANIOC_SET_ABOM _CANIOC(12) #define CAN_FIRST 0x0001 /* First common command */ -#define CAN_NCMDS 10 /* Ten common commands */ +#define CAN_NCMDS 12 /* Ten common commands */ /* User defined ioctl commands are also supported. These will be forwarded * by the upper-half CAN driver to the lower-half CAN driver via the co_ioctl()