-
Notifications
You must be signed in to change notification settings - Fork 21
Add STM32 support #12
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
Conversation
097a73f
to
6ddc5df
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.
This looks generally good, see one comment.
I also added a basic CI compile test, so when you push again it will pick up the new test and might require additional changes.
I'm a bit surprised that the STM32 Arduino core doesn't already come with a standard HardwareCAN implementation. Is pazi88/STM32_CAN.git the go-to CAN library that people use on STM32 Arduinos?
src/ODriveSTM32CAN.hpp
Outdated
|
||
static bool sendMsg(STM32_CAN& can_intf, uint32_t id, uint8_t length, const uint8_t* data) { | ||
CanMsg msg; | ||
msg.id = id; |
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.
The top three bits of id
are reserved, with the MSB meaning "extended". Additionally, if data is null, it should send a remote request frame if the CAN lib supports it.
msg.id = id; | |
msg.id = id & 0x1ffffff; | |
msg.flags.extended = id & 0x80000000; | |
msg.flags.remote = data; |
(not tested)
There is no CAN support in STM32duino, see this issue: stm32duino/Arduino_Core_STM32#259. From the thread it seems like pazi88/STM32_CAN is a decent implementation that works on most STM32 devies. |
`msg.flags.remote = data;` caused the example to stop working. ChatGPT suggested `msg.flags.remote = (data == nullptr);` which seems to work.
Ah yes I got the polarity flipped in my suggestion. |
Thanks for adding this! |
Hi! Thanks for the project!
I added support for STM32 boards with built-in CAN controller using https://github.com/pazi88/STM32_CAN.
As far as I can see, the example seems to work with my ODrive S1 and Adafruit STM32F405 Feather Express.
Please note that I am not comfortable with C++ programming, please let me know of any improvements I can make.
Thanks!