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

Issue #26: Follow-up to size delay amount within uint8_t. #41

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
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
10 changes: 5 additions & 5 deletions src/F_LSM6DS3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ int LSM6DS3::init(calData cal, uint8_t address)
//initialize address variable and calibration data.
IMUAddress = address;

if (cal.valid == false)
if (cal.valid == false)
{
calibration = { 0 };
}
else
{
calibration = cal;
}
uint8_t IMUWhoAmI = checkReady(IMUAddress, 500);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem this is fixing is that 500 is outside the bounds of uint8_t. When compiling, I get the warning that this is being implicitly cast to 254 (the max value of uint8_t).

The same code in the F_LSM6DS3.cpp file only waits 100ms, and that should be fine here too.


uint8_t IMUWhoAmI = checkReady(IMUAddress, 100);
if (!(IMUWhoAmI == LSM6DS3_WHOAMI_DEFAULT_VALUE)) {
if (!(IMUWhoAmI == LSM6DS3TR_C_WHOAMI_DEFAULT_VALUE)) {
return -1;
Expand All @@ -26,7 +26,7 @@ int LSM6DS3::init(calData cal, uint8_t address)
// reset device
writeByteI2C(wire, IMUAddress, LSM6DS3_CTRL3_C, 0x01); // Toggle softreset
while (!checkReady(IMUAddress, 100)); // wait for reset

writeByteI2C(wire, IMUAddress, LSM6DS3_CTRL1_XL, 0x47); // Start up accelerometer, set range to +-16g, set output data rate to 104hz, BW_XL bits to 11.
writeByteI2C(wire, IMUAddress, LSM6DS3_CTRL2_G, 0x4C); // Start up gyroscope, set range to -+2000dps, output data rate to 104hz.
writeByteI2C(wire, IMUAddress, LSM6DS3_CTRL4_C, 0x80); // Set XL_BW_SCAL_ODR;
Expand Down Expand Up @@ -260,4 +260,4 @@ void LSM6DS3::calibrateAccelGyro(calData* cal)
cal->gyroBias[1] = (float)gyro_bias[1];
cal->gyroBias[2] = (float)gyro_bias[2];
cal->valid = true;
}
}
Loading