drivers: can: convert enum can_mode to a bit field

Convert the can_mode enum to a bit field to prepare for future extensions
(CAN-FD mode, transmitter delay compensation, one-shot mode, 3-samples
mode, ...).

Rename the existing modes:
- CAN_NORMAL_MODE   -> CAN_MODE_NORMAL
- CAN_SILENT_MODE   -> CAN_MODE_LISTENONLY
- CAN_LOOPBACK_MODE -> CAN_MODE_LOOPBACK

These mode names align with the Linux naming for CAN control modes.

The old CAN_SILENT_LOOPBACK_MODE can be set with the bitmask
(CAN_MODE_LISTENONLY | CAN_MODE_LOOPBACK).

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
This commit is contained in:
Henrik Brix Andersen 2022-05-05 11:28:30 +02:00 committed by Carles Cufí
commit 3f97d11afd
25 changed files with 155 additions and 110 deletions

View file

@ -229,7 +229,7 @@ CO_ReturnError_t CO_CANmodule_init(CO_CANmodule_t *CANmodule,
return CO_ERROR_ILLEGAL_ARGUMENT;
}
err = can_set_mode(CANmodule->dev, CAN_NORMAL_MODE);
err = can_set_mode(CANmodule->dev, CAN_MODE_NORMAL);
if (err) {
LOG_ERR("failed to configure CAN interface (err %d)", err);
return CO_ERROR_ILLEGAL_ARGUMENT;
@ -250,7 +250,7 @@ void CO_CANmodule_disable(CO_CANmodule_t *CANmodule)
canopen_detach_all_rx_filters(CANmodule);
err = can_set_mode(CANmodule->dev, CAN_SILENT_MODE);
err = can_set_mode(CANmodule->dev, CAN_MODE_LISTENONLY);
if (err) {
LOG_ERR("failed to disable CAN interface (err %d)", err);
}