diff options
author | Nick Vaccaro <nvaccaro@google.com> | 2019-04-10 17:28:16 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-05-07 17:22:34 -0700 |
commit | c9840a44d64f8037e83acec7d970c3627bea4f8c (patch) | |
tree | 38874c55fcf325c2f7342116c90d6f4b88b84468 /driver/als_tcs3400.h | |
parent | 7e910fa108c6e34b2f27f1980d1cd229a743454b (diff) | |
download | chrome-ec-c9840a44d64f8037e83acec7d970c3627bea4f8c.tar.gz |
driver: add tcs3400 RGB channel sensor driver
Implements a MOTIONSENSE_TYPE_LIGHT_RGB sensor using
the tcs3400.
BUG=b:129419982
BRANCH=master
CQ-DEPEND=CL:1541955
TEST=cherry-pick CLs to enable tcs3400 for flapjack and to add
alslog, build and flash to flapjack; boot flapjack, from ec console,
execute 'sysjump rw', then execute "alslog" to enable logging of als
data. Verify als data is generated and logged to ec console.
Change-Id: Ia8000d27ff4f9683ceb4c9522bc7f0fed20c2045
Signed-off-by: Nick Vaccaro <nvaccaro@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1551748
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Diffstat (limited to 'driver/als_tcs3400.h')
-rw-r--r-- | driver/als_tcs3400.h | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/driver/als_tcs3400.h b/driver/als_tcs3400.h index dff3d5cdb7..f695fdb387 100644 --- a/driver/als_tcs3400.h +++ b/driver/als_tcs3400.h @@ -81,16 +81,39 @@ enum tcs3400_mode { #error "EC too slow for light sensor" #endif +/* Individual channel scale value between 0 and 2 to a 32-bit value */ +#define TCS3400_SCALE(x) (x << 15) + #define TCS3400_DRV_DATA(_s) ((struct tcs3400_drv_data_t *)(_s)->drv_data) +#define TCS3400_RGB_DRV_DATA(_s) \ + ((struct tcs3400_rgb_drv_data_t *)(_s)->drv_data) -/* Private tcs3400 driver data */ +/* Private tcs3400 als driver data */ struct tcs3400_drv_data_t { - int rate; /* holds current sensor rate */ - int last_value; /* holds last als clear channel value */ - struct als_calibration_t als_cal; /* calibration data */ + int rate; /* holds current sensor rate */ + int last_value; /* holds last als clear channel value */ + struct als_calibration_t als_cal; /* calibration data */ +}; + +/* Private tcs3400 rgb driver data */ +struct tcs3400_rgb_drv_data_t { + /* + * device_scale and device_uscale are used to adjust raw rgb channel + * values prior to applying any channel-specific scaling required. + * raw_value += rgb_cal.offset; + * adjusted_value = raw_value * device_scale + + * raw_value * device_uscale / 10000; + */ + uint16_t device_scale; + uint16_t device_uscale; + + int rate; /* holds current sensor rate */ + int last_value[3]; /* holds last RGB values */ + struct rgb_calibration_t rgb_cal[3]; /* calibration data */ }; extern const struct accelgyro_drv tcs3400_drv; +extern const struct accelgyro_drv tcs3400_rgb_drv; void tcs3400_interrupt(enum gpio_signal signal); #endif /* __CROS_EC_ALS_TCS3400_H */ |