summaryrefslogtreecommitdiff
path: root/include/accelgyro.h
diff options
context:
space:
mode:
authorNick Vaccaro <nvaccaro@google.com>2019-03-27 13:58:07 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-05-06 19:14:50 -0700
commit106c145b07042ba39860f0ef9b1f379f896f5b5f (patch)
tree26d2fe31c630368a2ee25cfb405141615da578b5 /include/accelgyro.h
parentb817b8dec0924050d746dc4257971ee522886b86 (diff)
downloadchrome-ec-106c145b07042ba39860f0ef9b1f379f896f5b5f.tar.gz
driver: add tcs3400 ALS sensor chip driver
Implements a MOTIONSENSE_TYPE_LIGHT sensor using the clear channel of the tcs3400. BUG=b:124512628 BRANCH=master 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: I918cbf5513fb5eba20a27705c47545d3c0b3ca91 Signed-off-by: Nick Vaccaro <nvaccaro@google.com> Reviewed-on: https://chromium-review.googlesource.com/1541955 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Diffstat (limited to 'include/accelgyro.h')
-rw-r--r--include/accelgyro.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/accelgyro.h b/include/accelgyro.h
index 2d415621d1..0d00116ed6 100644
--- a/include/accelgyro.h
+++ b/include/accelgyro.h
@@ -152,6 +152,19 @@ struct accelgyro_saved_data_t {
uint16_t scale[3];
};
+/* Calibration data */
+struct als_calibration_t {
+ /*
+ * Scale, uscale, and offset are used to correct the raw 16 bit ALS
+ * data and then to convert it to 32 bit using the following equations:
+ * raw_value += offset;
+ * adjusted_value = raw_value * scale + raw_value * uscale / 10000;
+ */
+ uint16_t scale;
+ uint16_t uscale;
+ int16_t offset;
+};
+
#define SENSOR_APPLY_SCALE(_input, _scale) \
(((_input) * (_scale)) / MOTION_SENSE_DEFAULT_SCALE)