diff options
author | Yuval Peress <peress@chromium.org> | 2020-01-16 11:20:01 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-03-09 23:02:12 +0000 |
commit | a00ace498da24a9288fd39f9728c8fd80cd54336 (patch) | |
tree | 98ea22bd6f4d1098bb9dfdaafb98795e1024eb27 /include/util.h | |
parent | 5ccb5c7cc9c448b66c6f8e0abbb2dd785da0efb7 (diff) | |
download | chrome-ec-a00ace498da24a9288fd39f9728c8fd80cd54336.tar.gz |
common: online_calibration: Fire MKBP event on new calibration
Implement online calibration for accelerometers and fire a new
MKBP event when a new calibration value is computed.
TEST=Added new unit tests
BRANCH=None
BUG=b:138303429,chromium:1023858
Change-Id: I31ec7164be0d8c7dac210a1ac4b94ec9ecd6a60a
Signed-off-by: Yuval Peress <peress@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2012847
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'include/util.h')
-rw-r--r-- | include/util.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/util.h b/include/util.h index a6de67e3d8..ed5ed26142 100644 --- a/include/util.h +++ b/include/util.h @@ -45,6 +45,17 @@ extern "C" { #define NULL ((void *)0) #endif +/** + * Ensure that value `v` is between `min` and `max`. + * + * @param v The value of interest. + * @param min The minimum allowed value for `v`. + * @param max The maximum allowed value for `v`. + * @return `v` if it is already between `min`/`max`, `min` if `v` was smaller + * than `min`, `max` if `v` was bigger than `max`. + */ +#define CLAMP(v, min, max) MIN(max, MAX(v, min)) + /* * Convert a pointer to a base struct into a pointer to the struct that * contains the base struct. This requires knowing where in the contained |