Skip to content
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

SNS - I2C Accelerometer #28

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

miksquared
Copy link

@miksquared miksquared commented Oct 14, 2024

Translate last year's accelerometer code into Rust.
Data sheet: https://www.st.com/resource/en/datasheet/lis2ds12.pdf

Copy link

linear bot commented Oct 14, 2024

@davidbeechey davidbeechey changed the title SNS - I2C Accelerometer (HYPE-28) SNS - I2C Accelerometer Oct 15, 2024
@davidbeechey davidbeechey marked this pull request as draft October 15, 2024 10:16
Copy link
Collaborator

@davidbeechey davidbeechey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct structure! You'll need to add pub mod accelerometer; to lib/sensors/src/lib.rs to include it (this will activate IDE features too)

Copy link
Collaborator

@davidbeechey davidbeechey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, thanks for including a detailed comment. Could you also add a brief description + data sheet link to the PR description and Linear issue?

lib/sensors/src/accelerometer.rs Outdated Show resolved Hide resolved
@davidbeechey davidbeechey marked this pull request as ready for review October 30, 2024 13:47
Copy link

@TomLonergan03 TomLonergan03 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good! there's a couple things i'm unsure on + i'm not too confident on the coding standards yous are using with rust, so ignore what I say as you wish lol

oh also run a format over it

lib/sensors/src/accelerometer.rs Outdated Show resolved Hide resolved
lib/sensors/src/accelerometer.rs Outdated Show resolved Hide resolved
lib/sensors/src/accelerometer.rs Outdated Show resolved Hide resolved
Comment on lines +123 to +128
pub fn from_byte(byte: u8) -> Self {
match byte {
LIS2DS12_DATA_NOT_READY => Self::DataNotReady,
_ => Self::Ok,
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this correct? the manual seems to say that only the DRDY bit matters for the data being ready, can there be other flags set in the status register that you don't care about for determining readiness?

Copy link
Collaborator

@davidbeechey davidbeechey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just fix @TomLonergan03's suggestions. A couple of tests would be good too, like the ones for the temperature sensor (you might need to merge main into your branch again to get MockI2c)

lib/sensors/src/accelerometer.rs Outdated Show resolved Hide resolved
lib/sensors/src/accelerometer.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@davidbeechey davidbeechey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nearly there. Just tests now I think

lib/sensors/src/accelerometer.rs Outdated Show resolved Hide resolved
Copy link

@TomLonergan03 TomLonergan03 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, see if there's a way to test DRDY status bit when your in the lab, and do what clippy/rustfmt want

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants