Feat/configs and interupts#40
Open
elpiel wants to merge 11 commits intoeupn:masterfrom
Open
Conversation
…-and-interupts Signed-off-by: Lachezar Lechev <elpiel93@gmail.com>
feat: add 9DOF & 6DOF methods chore: move Accelerometer Gyroscope interrupt config structs to own file Signed-off-by: Lachezar Lechev <elpiel93@gmail.com>
Contributor
Author
|
Bug: setting up the Accelerometer configuration, makes the sensor return an error. Primarily I tried to set the range to +- 16G |
There was a problem hiding this comment.
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src/regs.rs:87
- The constant BNO055_SYS_TRIGGER_RST_INT_BIT has the same value (0x40) as BNO055_TEMP_SOURCE defined later, which could lead to confusion or potential errors if these registers are expected to be distinct.
pub(crate) const BNO055_SYS_TRIGGER_RST_INT_BIT: u8 = 0x40; // Clear interrupts command
Comment on lines
+151
to
+158
| impl From<u8> for GyrAmSamplesAwake { | ||
| fn from(regval: u8) -> Self { | ||
| match regval { | ||
| 0 => Self::Samples8, | ||
| 1 => Self::Samples16, | ||
| 2 => Self::Samples32, | ||
| 3 => Self::Samples64, | ||
| _ => Self::Samples8, // TODO: handle error case? |
There was a problem hiding this comment.
The default branch in the match for GyrAmSamplesAwake silently falls back to Samples8. Consider returning a Result or adding explicit error handling to avoid masking potential invalid register values.
Suggested change
| impl From<u8> for GyrAmSamplesAwake { | |
| fn from(regval: u8) -> Self { | |
| match regval { | |
| 0 => Self::Samples8, | |
| 1 => Self::Samples16, | |
| 2 => Self::Samples32, | |
| 3 => Self::Samples64, | |
| _ => Self::Samples8, // TODO: handle error case? | |
| impl TryFrom<u8> for GyrAmSamplesAwake { | |
| type Error = Error; | |
| fn try_from(regval: u8) -> Result<Self, Self::Error> { | |
| match regval { | |
| 0 => Ok(Self::Samples8), | |
| 1 => Ok(Self::Samples16), | |
| 2 => Ok(Self::Samples32), | |
| 3 => Ok(Self::Samples64), | |
| _ => Err(Error::InvalidGyrAmSamplesAwake(regval)), |
Contributor
Author
There was a problem hiding this comment.
Yes, I believe we should rewrite this part accordingly with bitfield instead.
Signed-off-by: Lachezar Lechev <elpiel93@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This is continuation of #13 with some additions and organization of the code.
Currently I'm able to write the Enable & Mask Interrupts registries and validate the value (fetching it again from the IC), however, using the GPIO and waiting for Interrupt triggered is not working.
I've also validated the firmware version of the IC for some of the interrupts
Maybe another set of eyes will spot an issue that I'm missing?!
Adds:
Also, should we add functions to fetch sequential registers with other data like quaternion, gravity vector etc?
Here's part of the code where i'm able to set these interrupts and update both the mask and INT_EN + validate the result at the end.
I've set the mode to NDOF (9DOF) first and update the interrupts below.