-
Notifications
You must be signed in to change notification settings - Fork 25
Add support for ESP32 boards using the native TWAI (CAN) driver. #20
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
base: master
Are you sure you want to change the base?
Conversation
Changes: - Add ODriveESP32TWAI.hpp interface that calls twai_transmit/twai_receive directly - Add IS_ESP32_TWAI option to SineWaveCAN example - Add esp32 PlatformIO target
samuelsadok
left a comment
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.
Pending desk test.
examples/SineWaveCAN/SineWaveCAN.ino
Outdated
| return false; | ||
| } | ||
|
|
||
| can_intf.initialized = true; |
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.
arguably it is the user's responsibility to call setupCan() before using the interface. Our other CAN drivers don't do this check.
src/ODriveESP32TWAI.hpp
Outdated
| twai_message_t tx_msg = {}; | ||
| tx_msg.identifier = id; | ||
| tx_msg.data_length_code = length; | ||
| tx_msg.extd = (id > 0x7FF) ? 1 : 0; |
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 existing drivers use id & 0x80000000 as the extended-id flag, so we should do the same here.
src/ODriveESP32TWAI.hpp
Outdated
| } | ||
| } | ||
|
|
||
| return twai_transmit(&tx_msg, pdMS_TO_TICKS(100)) == ESP_OK; |
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 timeout makes this look like it blocks until the message is sent. But I think all other drivers are non-blocking. Is there any non-blocking version of this call? Or is this non-blocking and the timeout is more like a time-to-live for the message?
| https://github.com/pazi88/STM32_CAN.git#1.2.0 | ||
| https://github.com/pazi88/STM32_CAN.git#1.2.0 | ||
|
|
||
| [env:esp32] |
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.
picked up by CI and compiles, great!
…, make twai_transmit non-blocking
Changes:
This PR supersedes #11 .
Not tested yet - will desk test ASAP.