There appear to be several places where the wrong bits are being masked/reset to zero in the LIS331.cpp library.
For example, at
|
data &= ~0xfc; // clear the low two bits of the register |
there's a line of code that reads:
data &= ~0xfc; // clear the low two bits of the register
Actually, this is clearing all bits except the low two bits of the register. The correct statement would be either data &= ~0x03; or data &= 0xfc; (note the presence/absence of tildes in each of these versions).
Similarly this occurs in
|
data &= ~0xe7; // clear bits 4:3 of the register |
data &= ~0xe7; // clear bits 4:3 of the register
which should be data &= ~0x18;.
I found these examples/bugs when looking at the code for LIS331::setFullScale(), which should be clearing bits 5:4 but actually clears everything except those bits:
void LIS331::setFullScale(fs_range range)
{
uint8_t data;
LIS331_read(CTRL_REG4, &data, 1);
data &= ~0xcf;
data |= range<<4;
LIS331_write(CTRL_REG4, &data, 1);
}
The third statement should read data &= ~0x30;.
Thanks,
Pm
There appear to be several places where the wrong bits are being masked/reset to zero in the LIS331.cpp library.
For example, at
SparkFun_LIS331_Arduino_Library/src/SparkFun_LIS331.cpp
Line 240 in fe80a5d
Actually, this is clearing all bits except the low two bits of the register. The correct statement would be either
data &= ~0x03;ordata &= 0xfc;(note the presence/absence of tildes in each of these versions).Similarly this occurs in
SparkFun_LIS331_Arduino_Library/src/SparkFun_LIS331.cpp
Line 245 in fe80a5d
which should be
data &= ~0x18;.I found these examples/bugs when looking at the code for LIS331::setFullScale(), which should be clearing bits 5:4 but actually clears everything except those bits:
The third statement should read
data &= ~0x30;.Thanks,
Pm