-
Notifications
You must be signed in to change notification settings - Fork 143
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
STM32G4 FDCAN driver #607
STM32G4 FDCAN driver #607
Conversation
813317c
to
0d0098b
Compare
I can test the example on the Nucleo-G474RE board. |
0d0098b
to
38355d9
Compare
Done, works 👍🏽
|
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.
Nice work, thank you a lot! 👍🏽
I really like the MessageRam
abstraction!
Aside from the minor suggested changes, I would like to merge this PR soon and add the other features in future PRs, or is there something against that? |
I guess ST and Atmel/Microchip bought the Fdcan IP from the same IP-vendor? |
I will squash the commits after review. |
bb9056e
to
810e21e
Compare
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.
A very thorough driver!
ad15b7c
to
5ac3ee9
Compare
Rebase? |
Finish FDCAN driver to at least work with standard CAN. Message RAM handling is factored out to a separate source file. FDCAN features and a new concept for buffering can be implemented later.
5ac3ee9
to
2d2199b
Compare
done |
This is a follow-up to #325 and adds an FDCAN driver working for standard CAN with an interface similar to the bxCAN driver. Do not consider this driver done, support for FDCAN features is totally missing. The intention was to provide a working implementation of standard CAN first before we start experimenting with redesigning APIs for FDCAN support. So it still has the integrated buffers like the bxCAN driver, not the concept of #294 to implement buffering outside of the driver.
This is tested in hardware on a custom board with a G473RB.
The Nucleo example compiles but is untested.An on-target unit test for a Nucleo board using the FDCAN internal loopback mode will follow.One thing that is still not solved is proper handling of the global clock prescaler which affects all instances. Configuring it is really ugly because the FDCAN1 instance needs to be put into initialization mode to reconfigure it. Right now it simply does that on initialize.Solved by moving common clock settings to Rcc.A simple but suboptimal solution could be letting the user configure it inside SystemClock and the FDCAN driver does not need to touch it at all. If your data rates are not less than 50 kbit/s standard rate (and 300 kbit/s fast data bitrate for canfd with bit rate switching) a prescaler of 1 will do anyway, even with a 170MHz peripheral clock.
An option is yet missing to bypass the fast bitrate assert if CANFD is not used at all.Implemented now.Another aspect to consider is trying to create a common interface for CAN filters for different drivers. This is not straightforward since the semantics and feature sets differ between drivers. FDCAN has 8 filters that apply to extended id messages and 28 for standard 2.0A messages. bxCAN does not have this strict distinction and treats the frame format as a bit of the id and mask. This is not supported for FDCAN. Furthermore, FDCAN filters do not consider the RTR flag. Because I didn't find an obvious solution for an easy to use API, I skipped that effort for now, ignored @rleh'sRefactoring of CAN filters is out of scope for this PR.modm::can::Filter
type and went for a less ambitious hardware specific API.If you look at the SAM E5x manual, you will find that the message RAM data structures are identical to the STM32 FDCAN implementation. I guess both vendors did some copy-paste from an automotive standard. Does anyone know more details?
cc @rleh @salkinium