diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2020-01-08 11:00:45 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-12-01 06:53:50 +0000 |
commit | c36ba0724bc7db8cdb12b66d24f4f4db60a80d65 (patch) | |
tree | c3d7d8fad09ffa4767b0f95eec4a4169e6a5a6a1 | |
parent | 97a515a2cdc555a27d348537a2f443ecbdb53f0b (diff) | |
download | chrome-ec-c36ba0724bc7db8cdb12b66d24f4f4db60a80d65.tar.gz |
driver/opt3100: Set min/max frequency that match the driver
Given we set integration time at 800ms, the host must be aware to not
set an ODR over 1Hz.
BUG=chromium:615059
BRANCH=nocturne
TEST=Check new max_frequency is indeed 1Hz on nocturne.
Change-Id: I44252073f59e00cdf4d13b4fa6d88448537c168e
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1991857
Reviewed-by: Nick Vaccaro <nvaccaro@google.com>
(cherry picked from commit a8ea3bfdbe928b9bcf2d3756a2fae16fe40132ae)
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2567037
-rw-r--r-- | driver/als_opt3001.c | 4 | ||||
-rw-r--r-- | driver/als_opt3001.h | 9 |
2 files changed, 8 insertions, 5 deletions
diff --git a/driver/als_opt3001.c b/driver/als_opt3001.c index e6332184c0..8f1e2bc775 100644 --- a/driver/als_opt3001.c +++ b/driver/als_opt3001.c @@ -214,8 +214,8 @@ static int opt3001_set_data_rate(const struct motion_sensor_t *s, * integrating over 800ms. * Do not allow range higher than 1Hz. */ - if (rate > 1000) - rate = 1000; + if (rate > OPT3001_LIGHT_MAX_FREQ) + rate = OPT3001_LIGHT_MAX_FREQ; } rv = opt3001_i2c_read(s->port, s->i2c_spi_addr_flags, OPT3001_REG_CONFIGURE, ®); diff --git a/driver/als_opt3001.h b/driver/als_opt3001.h index 6706734870..96b47232d1 100644 --- a/driver/als_opt3001.h +++ b/driver/als_opt3001.h @@ -36,9 +36,12 @@ enum opt3001_mode { #define OPT3001_MANUFACTURER_ID 0x5449 #define OPT3001_DEVICE_ID 0x3001 -/* Min and Max sampling frequency in mHz */ -#define OPT3001_LIGHT_MIN_FREQ 1250 -#define OPT3001_LIGHT_MAX_FREQ 10000 +/* + * Min and Max sampling frequency in mHz. + * Due to integration set at 800ms, we limit max frequency to 1Hz. + */ +#define OPT3001_LIGHT_MIN_FREQ 100 +#define OPT3001_LIGHT_MAX_FREQ 1000 #if (CONFIG_EC_MAX_SENSOR_FREQ_MILLIHZ <= OPT3001_LIGHT_MAX_FREQ) #error "EC too slow for light sensor" #endif |