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

Improve temperature reading #50

Merged
merged 3 commits into from
Oct 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix temperature reading with clang formatting
adam-3bian committed Oct 5, 2024
commit d75587ee6a23d84a463f11d7db4b771e297a43ba
3 changes: 2 additions & 1 deletion examples/all/i2c_example.cc
Original file line number Diff line number Diff line change
@@ -22,7 +22,8 @@ static void read_temperature_sensor_value(Mmio<OpenTitanI2c> i2c,
i2c->blocking_write(0x48, buf, 1, false);
if (i2c->blocking_read(0x48, buf, 2u))
{
uint16_t temp = (buf[0] << 8) | buf[1];
int16_t regValue = (buf[0] << 8) | buf[1];
int64_t temp = regValue * 1000000LL / 128;
Debug::log("The {} readout is {}", regName, temp);
adam-3bian marked this conversation as resolved.
Show resolved Hide resolved
}
else