diff options
author | Ching-Kang Yen <chingkang@chromium.org> | 2020-01-16 16:11:40 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-01-31 03:14:22 +0000 |
commit | 036e9f7b214b763524497550aae0ee94df8fd536 (patch) | |
tree | 8bc2e0a15268dcd8a8ed8ef03af7c716d46e8d0a /include/math_util.h | |
parent | 876de6a603072fe121afe99fbda5d4f0e9efd266 (diff) | |
download | chrome-ec-036e9f7b214b763524497550aae0ee94df8fd536.tar.gz |
driver: bmi160: Fix rounding error in set_offset() and get_offset()
The original set_offset() and get_offset() codes in the
driver/accelgyro_bmi160 use simple divisions to write the data.
The more times the set_offset() and get_offset() is used, the
data will get closer to 0.
Fixing it by replacing simple division to round_divide(), division
that round to nearest, in the common/math_util.c.
BRANCH=octopus
BUG=b:146823505
TEST=Testing on octopus:ampton on branch [firmware-octopus-11297.B].
Checking the data did not rounding to 0.
Change-Id: Ide9df9e32fc501e63d6f952cb8254df7662afd23
Signed-off-by: Ching-Kang Yen <chingkang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2002998
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Commit-Queue: Gwendal Grignou <gwendal@chromium.org>
Diffstat (limited to 'include/math_util.h')
-rw-r--r-- | include/math_util.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/include/math_util.h b/include/math_util.h index 124801ff5d..a54eaf3618 100644 --- a/include/math_util.h +++ b/include/math_util.h @@ -210,4 +210,9 @@ void rotate(const intv3_t v, const mat33_fp_t R, intv3_t res); */ void rotate_inv(const intv3_t v, const mat33_fp_t R, intv3_t res); +/** + * Divide dividend by divisor and round it to the nearest integer. + */ +int round_divide(int64_t dividend, int divisor); + #endif /* __CROS_EC_MATH_UTIL_H */ |