diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2017-03-30 15:12:44 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-03-19 19:21:18 -0700 |
commit | 47f344713e3792b5b75ccd8d8d0f3797208e2de7 (patch) | |
tree | cde7cc10be1a00e593673335b220c0515ec06348 /driver/stm_mems_common.h | |
parent | 1f4d4f8a4ec219e84e9d1554f765ec6a4feb6039 (diff) | |
download | chrome-ec-47f344713e3792b5b75ccd8d8d0f3797208e2de7.tar.gz |
driver: lsm6dsm/lsm6dsl/lis2dh: Use STM MEMs common functions
LSM6DSM now use STM MEMs common functions already
used by LIS2DH12 device. Added st_raw_read_n_noinc
function to read i2c data not using auto increment
protocol.
BUG=b:73546254
BRANCH=master
TEST=Tested on discovery BOARD with LSM6DSM sensor connected on
I2C master bus interface of target board.
Using motion sense console commands is possible to enable, set data
rate, set full scale and show data from sensor (acc and gyro).
Commons function works properly for LSM6DSM.
Change-Id: I7a987306135a85abcfa9c1d3ba596fb70598fadc
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/465376
Diffstat (limited to 'driver/stm_mems_common.h')
-rw-r--r-- | driver/stm_mems_common.h | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/driver/stm_mems_common.h b/driver/stm_mems_common.h index 848c3d4825..b708812d63 100644 --- a/driver/stm_mems_common.h +++ b/driver/stm_mems_common.h @@ -14,14 +14,13 @@ #include "console.h" #include "i2c.h" -/* Common debug funcions */ -#define CPRINTF(format, args...) cprintf(CC_ACCEL, format "\n", ## args) - /* X, Y, Z axis data len */ #define OUT_XYZ_SIZE 6 +#define ST_NORMALIZE_RATE(_fS) (1 << __fls(_fs)) + #ifdef CONFIG_ACCEL_FIFO -#define FIFO_BUFFER_NUM_PATTERN 16 +#define FIFO_BUFFER_NUM_PATTERN 32 /* Define number of data to be read from FIFO each time * It must be a multiple of OUT_XYZ_SIZE. * In case of LSM6DSM FIFO contains pattern depending ODR @@ -45,13 +44,19 @@ extern inline int raw_write8(const int port, const int addr, const int reg, int data); /** - * Read n bytes for read + * st_raw_read_n - Read n bytes for read */ int st_raw_read_n(const int port, const int addr, const uint8_t reg, uint8_t *data_ptr, const int len); +/** + * st_raw_read_n_noinc - Read n bytes for read (no auto inc address) + */ +int st_raw_read_n_noinc(const int port, const int addr, const uint8_t reg, + uint8_t *data_ptr, const int len); + /** - * write_data_with_mask - Write register with mask + * st_write_data_with_mask - Write register with mask * @s: Motion sensor pointer * @reg: Device register * @mask: The mask to search @@ -61,15 +66,13 @@ int st_write_data_with_mask(const struct motion_sensor_t *s, int reg, uint8_t mask, uint8_t data); /** - * get_resolution - Get bit resolution + * st_get_resolution - Get bit resolution * @s: Motion sensor pointer - * - * TODO: must support multiple resolution */ int st_get_resolution(const struct motion_sensor_t *s); /** - * set_offset - Set data offset + * st_set_offset - Set data offset * @s: Motion sensor pointer * @offset: offset vector * @temp: Temp @@ -78,7 +81,7 @@ int st_set_offset(const struct motion_sensor_t *s, const int16_t *offset, int16_t temp); /** - * get_offset - Get data offset + * st_get_offset - Get data offset * @s: Motion sensor pointer * @offset: offset vector * @temp: Temp @@ -87,13 +90,13 @@ int st_get_offset(const struct motion_sensor_t *s, int16_t *offset, int16_t *temp); /** - * get_data_rate - Get data rate (ODR) + * st_get_data_rate - Get data rate (ODR) * @s: Motion sensor pointer */ int st_get_data_rate(const struct motion_sensor_t *s); /** - * normalize - Apply to LSB data sensitivity and rotation + * st_normalize - Apply to LSB data sensitivity and rotation * @s: Motion sensor pointer * @v: vector * @data: LSB raw data |