stm32: BusOFF, BusPassive, BusWarning removed from curr_error in FDCAN and BXCAN
#5228
+12
−32
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.
Changes:
curr_errordoesn't read PSR.BO/EW/EP.Problem:
When awaiting can::read() / try_read(), if the CAN controller enters ErrorWarning or ErrorPassive, the future resolves immediately if the RxFifo's are empty and the CAN controller is in ErrorPassive or ErrorWarning.
For async functions this can result in tight polling loops that:
Root cause is treating a bus error state (BusPassive, BusWarning, BusOff) as an error. Error states reflect the TEC or REC registers exceeding certain numbers, while the LEC is the error last detected on the bus. Additionally, LEC may be "reset" on read, EW, EP, and BO do not.
Fix:
Read no longer reads BO, EW, EP registers in PSR registers.
Possible Future Changes
I would recommend seperating the error checks from the can read function, and creating a dedicated error checking function that is exposed through properties.
Meaning you can detect errors outside of reads, giving a bit more versatility.