drivers: can: add start and stop CAN controller API functions
Up until now, the Zephyr CAN controller drivers set a default bitrate (or timing) specified via devicetree and start the CAN controller in their respective driver initialization functions. This is fine for CAN nodes using only one fixed bitrate, but if the bitrate is set by the user (e.g. via a DIP-switch or other HMI which is very common), the CAN driver will still initialise with the default bitrate/timing at boot and use this until the application has determined the requested bitrate/timing and set it using can_set_bitrate()/can_set_timing(). During this period, the CAN node will potentially destroy valid CAN frames on the CAN bus (which is using the soon-to-be-set-by-the-application bitrate) by sending error frames. This causes interruptions to the ongoing CAN bus traffic when a Zephyr-based CAN node connected to the bus is (re-)booted. Instead, require all configuration (setting bitrate, timing, or mode) to take place when the CAN controller is stopped. This maps nicely to entering "reset mode" (called "configuration mode" or "freeze mode" for some CAN controller implementations) when stopping and exiting this mode when starting the CAN controller. Fixes: #45304 Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
This commit is contained in:
parent
6d094d0ad5
commit
180cdc105e
30 changed files with 930 additions and 319 deletions
|
@ -77,6 +77,8 @@ static int mcux_mcan_init(const struct device *dev)
|
|||
|
||||
static const struct can_driver_api mcux_mcan_driver_api = {
|
||||
.get_capabilities = can_mcan_get_capabilities,
|
||||
.start = can_mcan_start,
|
||||
.stop = can_mcan_stop,
|
||||
.set_mode = can_mcan_set_mode,
|
||||
.set_timing = can_mcan_set_timing,
|
||||
.send = can_mcan_send,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue