-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Fix qmc5883l lockup #13467
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
Fix qmc5883l lockup #13467
Conversation
Data registers are locked until last/unlock register is read. New data are not stored when locked and DRDY is not set. On bus error, read may finish early (not reading unlock register) and thus cause driver lockup.
Do you want to test this code? You can flash it directly from Betaflight Configurator:
WARNING: It may be unstable. Use only for testing! |
Related or not?
betaflight/src/main/sensors/barometer.c Lines 461 to 466 in b9b4b77
Tested on master and this PR using cloud build. |
What baro is configured/detected? Is qmc5883l used on that target? |
Baro is DPS310, but there is no physical mag attached to the board. So unrelated to this - but peculiar |
That is strange - https://github.com/betaflight/betaflight/blob/master/src/main/drivers/barometer/barometer_dps310.c#L243 should always return true, it should end up in BARO_STATE_PRESSURE_READ And don't expect anything from HAL drivers when hardware error occurs. |
#define QMC5883L_REG_STATUS 0x06 | ||
#define QMC5883L_REG_STATUS_DRDY 0x01 | ||
#define QMC5883L_REG_STATUS_OVL 0x02 |
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.
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.
Output values are saturated, so OVL bit caries little extra information.
Some days ago I also worked on the issue of a not responding qmc5883l (data stuck in sensors tab). I first also worked on the DOR issue, but this did not completely solve my problem (but maybe my implementation was just not correct in doing so). I fixed it for me now, but this included some changes on the hardware interrupt handling and forcing some re-initialization. |
Data registers are locked until last/unlock register is read. New data are not stored when locked and DRDY is not set. On bus error, read may finish early (not reading unlock register) and thus cause driver lockup. Co-authored-by: Petr Ledvina <ledvinap@hp124.ekotip.cz>
Can I ask how this PR is progressing? I can't test it myself. |
Data registers are locked until last/unlock register is read. New data are not stored when locked and DRDY is not set.
On bus error, read may finish early (not reading unlock register) and thus cause driver lockup.