fixes: busio, SPI OS error 5 for mimxrt10xx #4048
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.
I ran into an issue trying to connect an MCP2515 CAN bus controller via SPI to a Teensy 4.0 (using adafruit_mcp2515) and might have a simple solution to this and possibly related issues #3763 and #3055.
After a few CAN messages transferred, there is an exception with the following information.
It seems that SPI might occasionally be busy. The SPI drivers (e.g.
MIMXRT10xx_SDK/.../MIMXRT1062/drivers/fsl_lpspi.c
) then returnkStatus_LPSPI_Busy
, which in busiomimxrt10xx/common-hal/busio/SPI.c
translates intofalse
result, thus resulting in OS Error 5.Attempting a simple busy waiting loop in case of
kStatus_LPSPI_Busy
instead seems to do the trick. The problem seems to be resolved and I so far did not see more than a single additional iteration of the idle loop.However, since I do not know the details of how SPI works here, I have no idea whether this simple solution is too simple. So if someone can asses this, please comment.