Skip to content

I2C Mux - #121

Open
kshxtij wants to merge 8 commits into
masterfrom
mux-rewrite
Open

I2C Mux#121
kshxtij wants to merge 8 commits into
masterfrom
mux-rewrite

Conversation

@kshxtij

@kshxtij kshxtij commented May 30, 2023

Copy link
Copy Markdown
Contributor

Added to debug binary and works with hardware now.
Screenshot 2023-05-30 at 11 48 17

@kshxtij
kshxtij requested a review from ishmis as a code owner May 30, 2023 10:48

@ishmis ishmis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

minor changes only

Comment thread lib/debug/repl.cpp
// TODOLater: Figure out how to not hardcode this
std::array<std::unique_ptr<sensors::II2cMuxSensor<core::RawAccelerationData>>, 4>
accelerometers;
for (int i = 0; i < channels.size(); i++) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

++i

Comment thread lib/debug/repl.cpp
accelerometers[i]
= std::make_unique<sensors::Accelerometer>(std::move(*optional_accelerometer));
}
// sensors::I2cMux<core::RawAccelerationData, 4> mux(logger_, i2c, mux_address, accelerometers);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

?

Comment thread lib/debug/repl.cpp
= std::make_unique<sensors::Accelerometer>(std::move(*optional_accelerometer));
}
// sensors::I2cMux<core::RawAccelerationData, 4> mux(logger_, i2c, mux_address, accelerometers);
std::shared_ptr<sensors::I2cMux<core::RawAccelerationData, 4>> mux_ptr

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

core::kNumAccelerometers?

Comment thread lib/debug/repl.cpp
logger_.log(core::LogLevel::kFatal, "Failed to read the mux from bus %d", bus);
} else {
const std::array<core::RawAccelerationData, 4> mux_result = *value;
for (int i = 0; i < mux_result.size(); i++) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

std::size_t, ++i

logger_.log(core::LogLevel::kFatal, "Failure, mismatched device ID for accelerometer");
return std::nullopt;
}
const auto ctrl1_result = i2c_->writeByteToRegister(device_address_, kCtrl1Address, kCtrl1Value);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is this auto when we directly check it against failure state 2 lines later? Especially since we wouldn't fail if the return type got changed for whatever reason but would still compile?

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