-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Fix QMC5883P detection #14782
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 QMC5883P detection #14782
Conversation
|
Do you want to test this code? You can flash it directly from the Betaflight App:
WARNING: It may be unstable. Use only for testing! |
WalkthroughMove P-variant QMC5883 special configuration writes out of Changes
Sequence Diagram(s)sequenceDiagram
participant Probe as Detection Flow
participant Init as Initialization Flow
participant Chip as QMC5883P
Note over Probe,Chip `#e6f7ff`: Detect only verifies ID
Probe->>Chip: Read CHIP_ID
alt CHIP_ID matches
Probe-->>Probe: attach descriptor & handlers
Probe->>Init: invoke qmc5883Init
else mismatch
Probe-->>Probe: detection failed
end
Note over Init,Chip `#fff7e6`: Init performs gated sequential writes
Init->>Chip: Write XYZ_UNLOCK (expect ACK)
alt ACK OK
Init->>Chip: Write CONF1 (expect ACK)
alt ACK OK
Init->>Chip: Write CONF2 (expect ACK)
alt ACK OK
Init-->>Init: init success
else ACK FAIL
Init-->>Init: init fail (return false)
end
else ACK FAIL
Init-->>Init: init fail (return false)
end
else ACK FAIL
Init-->>Init: init fail (return false)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used🧠 Learnings (1)📓 Common learnings⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
🔇 Additional comments (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/main/drivers/compass/compass_qmc5883.c (1)
193-207: P-variant init writes look correct; consider minor consistency/clarity tweaksFunctionally this looks good: moving the P-variant unlock/CONF1/CONF2 writes into
qmc5883Initkeeps detection read-only while preserving the actual register configuration sequence, and the early returns on write failure are straightforward.Two minor, optional nits:
ackis now only meaningful for the L variant; for readability you could either:
- Limit
ack’s scope to the L branch, or- Use the same
ack = ack && busWriteRegister(...)pattern for the P branch as well so both variants use a consistent style.- The comment “(retaining original behavior)” might be a bit confusing now that the writes have moved from detect to init; something like “using the same register values as previously configured during detect” would be more precise.
Both are non-blocking; the current change is fine to ship as-is.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/main/drivers/compass/compass_qmc5883.c(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
- GitHub Check: CI / Build (SPRACINGH7EXTREME)
- GitHub Check: CI / Build (SPRACINGH7RF)
- GitHub Check: CI / Build (IFLIGHT_BLITZ_F722)
- GitHub Check: CI / Build (STM32H750)
- GitHub Check: CI / Build (STM32H735)
- GitHub Check: CI / Build (STM32H743)
- GitHub Check: CI / Build (AIRBOTG4AIO)
- GitHub Check: CI / Build (STM32H730)
- GitHub Check: CI / Build (STM32H725)
- GitHub Check: CI / Build (STM32H723)
- GitHub Check: CI / Build (RP2350B)
- GitHub Check: CI / Build (RP2350A)
- GitHub Check: CI / Build (APM32F405)
- GitHub Check: CI / Test
🔇 Additional comments (1)
src/main/drivers/compass/compass_qmc5883.c (1)
328-355: QMC5883P detect path is now cleanly ID-basedThe detect routine’s flow (set default I2C address if unset → read ID → bail out on NACK or wrong ID → attach descriptor and init/read callbacks) is straightforward and keeps detection side-effect free, which pairs well with moving all configuration into
qmc5883Init.No issues from this code path from a driver/detection standpoint.
Finally could test 5883P with a real device and needed to make a small adjustment in the code.
Tested with GEPRC M1025Q.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.