From 3b36337be1e165db491bc591ae95be3577886465 Mon Sep 17 00:00:00 2001 From: Alec Berg Date: Tue, 22 Apr 2014 17:47:16 -0700 Subject: accel: add accel driver for lsm6ds0 This adds the basics for the accelerometer potion only of the ST lsm6ds0 accel/gyro. Still need to add the acceleration interrupt functionality, and all of the gyro portion of the chip. BUG=none BRANCH=none TEST=Tested on a samus prototype hacked up to have the lsm6ds0 connected to the EC i2c bus. Added motion sense task to the samus tasklist, added accelerometer information to the samus board file, and tested console functions interacting with accelerometer. The data seems reasonable, and can successfully change data rate and range. Change-Id: I7949d9c20642a40ede82dc291b2c80f01b0a7d8b Signed-off-by: Alec Berg Reviewed-on: https://chromium-review.googlesource.com/196426 Reviewed-by: Bill Richardson Reviewed-by: Randall Spangler --- driver/accelgyro_lsm6ds0.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 driver/accelgyro_lsm6ds0.h (limited to 'driver/accelgyro_lsm6ds0.h') diff --git a/driver/accelgyro_lsm6ds0.h b/driver/accelgyro_lsm6ds0.h new file mode 100644 index 0000000000..6c34570b15 --- /dev/null +++ b/driver/accelgyro_lsm6ds0.h @@ -0,0 +1,45 @@ +/* Copyright (c) 2014 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* LSM6DS0 accelerometer and gyro module for Chrome EC */ + +#ifndef __CROS_EC_ACCEL_LSM6DS0_H +#define __CROS_EC_ACCEL_LSM6DS0_H + +/* + * 7-bit address is 110101Xb. Where 'X' is determined + * by the voltage on the ADDR pin. + */ +#define LSM6DS0_ADDR0 0xd4 +#define LSM6DS0_ADDR1 0xd6 + +/* Chip specific registers. */ +#define LSM6DS0_CTRL_REG6_XL 0x20 +#define LSM6DS0_CTRL_REG8 0x22 +#define LSM6DS0_OUT_X_L_XL 0x28 +#define LSM6DS0_OUT_X_H_XL 0x29 +#define LSM6DS0_OUT_Y_L_XL 0x2a +#define LSM6DS0_OUT_Y_H_XL 0x2b +#define LSM6DS0_OUT_Z_L_XL 0x2c +#define LSM6DS0_OUT_Z_H_XL 0x2d + + +#define LSM6DS0_GSEL_2G (0 << 3) +#define LSM6DS0_GSEL_4G (2 << 3) +#define LSM6DS0_GSEL_8G (3 << 3) +#define LSM6DS0_GSEL_ALL (3 << 3) + +#define LSM6DS0_ODR_10HZ (1 << 5) +#define LSM6DS0_ODR_50HZ (2 << 5) +#define LSM6DS0_ODR_119HZ (3 << 5) +#define LSM6DS0_ODR_238HZ (4 << 5) +#define LSM6DS0_ODR_476HZ (5 << 5) +#define LSM6DS0_ODR_982HZ (6 << 5) +#define LSM6DS0_ODR_ALL (7 << 5) + +/* Sensor resolution in number of bits. This sensor has fixed resolution. */ +#define LSM6DS0_RESOLUTION 16 + +#endif /* __CROS_EC_ACCEL_LSM6DS0_H */ -- cgit v1.2.1