This repository was archived by the owner on Jun 8, 2023. It is now read-only.
Add automatic bus recovery for SAM E5x #2
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When the CAN peripheral of the SAM E5x enters "bus off" state, an explicit recovery step is required. Before sending or attempting to receive a packet, check if the bus has entered BUS_OFF state and if so reinitialize the peripheral.
This PR seems to have additional things in it because I placed the change on the branch we're requesting to merge into sandeepmistry/arduino-CAN, and cherry-picked things from our main branch into this branch so that our pull request there is complete.
Testing performed: I didn't have two working retail version Feather M4 CAN boards so I can't test traffic between them. However, with debug statements enabled I see that it is entering and completing the "bus off recovery" steps, which are copied from our CircuitPython implementation where we are confident it is working; and I can see that the board is continually driving the CAN H/L lines rather than stopping when it enters BUS_OFF the first time.
This partially addresses #1. The other problems with undefined pin names would be better reported against the BSP, https://github.com/adafruit/ArduinoCore-samd -- though I didn't reproduce the problem, after I updated the BSP using Library Manager the named pins were available. I tried to make sure I'm not using a git version of ArduinoCore-samd but it's possible I made an error.
@ashishsk can you let us know if this helps with the bus recovery problem and open a fresh issue in https://github.com/adafruit/ArduinoCore-samd if you're still having trouble with the pin definitions?