From 488727acb85c322375238ecfc0cb06174433e10c Mon Sep 17 00:00:00 2001 From: Douglas Hutchings <11douglash@berkeley.edu> Date: Thu, 28 Feb 2019 16:17:35 -0800 Subject: [PATCH] Fix bug regarding the setFullScale function on the H3LIS331DL Previous behaviour incorrectly set the ranges. Attempting to set a 100g range would actually set the data to come out in little endian order. Attempting to set a 200g range would actually set the data to come out in little endian order AND put the FS1/FS0 bits into an invalid state (10) Attempting to set a 400g range would actually set the data to come out in big endian order AND put the FS1/FS0 bits into an invalid state (10). Now we correctly set the range bits and leave little / big endian alone. --- src/SparkFun_LIS331.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SparkFun_LIS331.cpp b/src/SparkFun_LIS331.cpp index 7e5eb66..80f51c1 100755 --- a/src/SparkFun_LIS331.cpp +++ b/src/SparkFun_LIS331.cpp @@ -253,7 +253,7 @@ void LIS331::setFullScale(fs_range range) uint8_t data; LIS331_read(CTRL_REG4, &data, 1); data &= ~0xcf; - data |= range<<5; + data |= range<<4; LIS331_write(CTRL_REG4, &data, 1); }