-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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: stm32: support for dual CAN instances #46646
drivers: can: stm32: support for dual CAN instances #46646
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this enhancement! I have not tested it on hardware, but I'd like to highlight two points.
- one-shot mode:
The config initialization got lost during the multi instance refactoring. - locking of filter registers:
Locking is done per instance, but both instances access the filter registers of CAN1 (master_can).
I believe we should make sure that the filter configuration happens mutually exclusive.
I have tested this on hardware, and can confirm it works :) Caveats: I am not using one-shot mode or any special filter config, but I am using heavy traffic (ISO-TP bootloader on CAN2) while simultaneously sending messages from CAN1. |
This commit unifies the driver initialization for can1 and can2 instances so that a single macro can be used. Enabling the master clock for can2 as introduced in 8ab81b0 had to be moved to devicetree in order to have the same CAN_STM32_CONFIG_INST macro for all instances. Signed-off-by: Martin Jäger <[email protected]>
Remove two functions which were only called from one place and did not improve readibility of the code. Signed-off-by: Martin Jäger <[email protected]>
CAN1 and CAN2 share the memory for the filter banks. This commit adds an offset for filters installed for CAN2, allowing to use both CAN instances simultaneously. The hardware allows to freely split the avalable 28 filters between CAN1 and CAN2. In order to simplify the driver implementation, it only supports an equal split of 14 filters per instance. This is the same amount of filters as available in MCUs with only a single CAN. Signed-off-by: Martin Jäger <[email protected]>
Choose can2 as the zephyr,canbus instance and add necessary settings for testing of the STM32 dual CAN driver implementation. Signed-off-by: Martin Jäger <[email protected]>
ebbcb6c
to
2f13b82
Compare
Good spot! I must have accidentally dropped that line. It's now added back.
That's also a good point. Added a static |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, one suggestion:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good improvement, thanks!
This PR implements support for the STM32 dual CAN, where CAN1 and CAN2 share the memory for the filter banks.
Compared to the previous proposal #40531, this implementation only supports an equal split of the available 28 filter banks, which leads to the same amount of 14 filter banks per instance independent of the number of instances available in the MCU. This simplifies the driver implementation significantly and should cover most use cases.
The implementation was tested on a Nucleo F446RE and passes all tests with the following command (the board definition was updated to use
can2
instance instead ofcan1
for testing):In theory, also CAN3 available on some STM32F7 series MCUs should work if the missing devicetree nodes are added, but I don't have any hardware to test.