-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
canio: implement for stm32f405 #3505
Conversation
I implemented a send-and-receive program that operates on both built in canio and adafruit_mcp2515: https://gist.github.com/ffc169a73954e02ab9f18f9c53fa4618 It's a bit fiddly to get it started because if you don't start them close to the same time each one concludes the CAN bus is not functioning properly. |
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 few questions but nothing major. Please fix up lib/tinyusb
as well.
This PR has been rebased. I believe there's no longer an unintended change to tinyusb. I've attempted to address all review comments. Testing performed (today): sending to a Feather M4 CAN prototype board |
I still see a TinyUSB change in the first commit: c46cf85 Everything else looks good. |
The has successfully run my loopback self-test program for CAN, which tests transmission, reception, and filtering. The 1M baud rate setting was also verified on saleae to be accurate.
.. also add the 8ms wait for transmission that the atmel sam port has
.. it's necessary to wait for a cancellation request to actually free the respective Tx mailbox
these relate to properties that were removed as well
Thanks for the patience, I've tried again to correct it. |
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! Thank you!
Shoot, didn't get a chance to test. My CAN stuff is coming in late. I'll open an issue if I have any issues once I get them. |
|
||
|
||
void common_hal_canio_listener_construct(canio_listener_obj_t *self, canio_can_obj_t *can, size_t nmatch, canio_match_obj_t **matches, float timeout) { | ||
if (!can->fifo0_in_use) { |
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.
Is the expectation that a canio stm32f405 user will always need to create 2 listeners?
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.
I'm not sure if this is what you're asking, but I believe the bus needs two devices to function in active mode adafruit/Adafruit_CircuitPython_MCP2515#21 (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.
In this repo, if I understand this correctly, a separate listener object is required to use FIFO1. I was comparing this implementation with another library (Rust), and noticed that in their receive handler, they check both FIFOs in one check.
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.
It is not clear to me which listener will get which messages when there is no matching/filtering setup. I suppose the likely recommendation is to use message id filtering.
Aka, incorrect usage (that will lead to weird behavior):
listenerFIFO0 = can.listen(timeout=.1)
listenerFIFO1 = can.listen(timeout=.1)
Correct usage:
listenerFIFO0 = can.listen(matches=[<list of message ids>], timeout=.1)
listenerFIFO1 = can.listen(matches=[<list of message ids different than FIFO0>], timeout=.1)
I have not tested this though.
The has successfully run my loopback self-test program for CAN, which tests transmission, reception, and filtering. The 1M baud rate setting was also verified on a saleae to be accurate.
I also verified that I could exchange packets with Adafruit_CircuitPython_MCP2515 at baudrate=250_000.