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

IM the new U - new setup procedure #6

Merged
merged 11 commits into from
Dec 20, 2023
Merged

IM the new U - new setup procedure #6

merged 11 commits into from
Dec 20, 2023

Conversation

brainuser5705
Copy link
Collaborator

IMU setup procedure has been simplified. I tested with BNO055-Sample, and all log messages work as intended. The changes made were referenced from the documentation regarding initial states and setup requirements of the device. I added inline comments for more details.

@mjmagee991 mjmagee991 requested a review from a team November 30, 2023 23:05
Copy link
Contributor

@mjmagee991 mjmagee991 left a comment

Choose a reason for hiding this comment

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

Great setup, but there are a couple things that should be changed to make the functionality a bit clearer

src/BNO055.cpp Outdated
uint8_t resetBytes[2] = {BNO055_SYS_TRIGGER_ADDR, 0x20};
i2c.write(i2cAddress, resetBytes, 2);
time::wait(30);
// We check that i2c is activated already. If it is, we check if it is in operational mode.
Copy link
Contributor

Choose a reason for hiding this comment

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

Update your comments to make it clearer that we're checking if the BNO's I2C is activated, not if the STM's I2C is activated

src/BNO055.cpp Outdated

// Check if i2c returns a detected device and reports a successful connection. Read the ID from chip id register (0x00)
// this is to make sure we are connected to the correct device.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is actually just to make sure we are connected to the device. There's no way we're going to have the wrong device connected

src/BNO055.cpp Outdated

time::wait(10);
uint8_t result;
// We read the ST_RESULT register that the startup POST self-test where the result for each sensor is put.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you reword this? I don't really understand what you're trying to say here

src/BNO055.cpp Outdated
i2c.write(i2cAddress, BNO055_ST_RESULT);
i2c.read(i2cAddress, &result);
// All four LSB bits of result should be 1 for successful test
if ((result & 0x15) == 0x15) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be if ((result & 0x0F) != 0x0F)? That would be how you check that all the least significant bits of the result are 1

src/BNO055.cpp Outdated
@@ -13,80 +13,69 @@ IMU::BNO055::BNO055(IO::I2C& i2C, uint8_t i2cSlaveAddress) : i2c(i2C) {
* @return a boolean indicating whether or not the device was successfully initialized
*/
bool IMU::BNO055::setup() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of returning a boolean here, you it would be a little cleaner if you defined an enum specific to the BNO that identifies what kind of error occurred

src/BNO055.cpp Show resolved Hide resolved
@mjmagee991 mjmagee991 requested a review from a team November 30, 2023 23:47
src/BNO055.cpp Show resolved Hide resolved
@brainuser5705
Copy link
Collaborator Author

Made the changes to the comments and made an enum for the boolean returns.

Copy link
Contributor

@mjmagee991 mjmagee991 left a comment

Choose a reason for hiding this comment

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

One nitpick, but otherwise looks great!

enum class BNO055Status {
FAIL_INIT = 0,
FAIL_SELF_TEST = 1,
SUCCESS = 2
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a nitpick, but generally, we have the successful state have a value of 0, and we call it "OK." It's not really an official standard, but it's pretty common across C code I've seen in my experience

@brainuser5705
Copy link
Collaborator Author

Awesome, thanks for the review! Do I have to wait for @ActuallyTaylor to approve before I merge? It says that merging is blocked until requested changes are addressed.

@ActuallyTaylor
Copy link
Member

It looks good @brainuser5705 you should be able to merge it now!

@brainuser5705 brainuser5705 merged commit b37597f into main Dec 20, 2023
1 check passed
@brainuser5705 brainuser5705 deleted the simplify-setup branch December 20, 2023 00:21
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