summaryrefslogtreecommitdiff
path: root/driver/stm_mems_common.h
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2017-02-10 10:36:15 -0800
committerchrome-bot <chrome-bot@chromium.org>2017-02-13 21:15:16 -0800
commitd910997f6a87cd63e196c501922f1c323a274592 (patch)
tree890cec529b7b295e51d52894e3e19a971e215ecf /driver/stm_mems_common.h
parent1a736ed9542eb4c94ab0a49dba7696cda7faf864 (diff)
downloadchrome-ec-d910997f6a87cd63e196c501922f1c323a274592.tar.gz
lis2dh: code cleanup
Make FIFO a stack variable to save static memory, Remove auto_inc argument, always set Remove constant for rate 0. Force board to declare sensor private data. Avoid name collision in stm_mems_common Include stm_mems_common.h in accel_lis2dh.h, caller only need to include accel_lis2dh.h. BUG=none BRANCH=none TEST=Compile with discovery_stmems board. Change-Id: Id52b54dd4ec3cf217247c5511ad5a506067ad293 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/441144 Tested-by: mario tesi <mario.tesi@st.com> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: mario tesi <mario.tesi@st.com>
Diffstat (limited to 'driver/stm_mems_common.h')
-rw-r--r--driver/stm_mems_common.h37
1 files changed, 14 insertions, 23 deletions
diff --git a/driver/stm_mems_common.h b/driver/stm_mems_common.h
index ca08de95de..5fa16936b7 100644
--- a/driver/stm_mems_common.h
+++ b/driver/stm_mems_common.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016 The Chromium OS Authors. All rights reserved.
+/* Copyright 2016 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.
*/
@@ -13,20 +13,13 @@
#include "accelgyro.h"
#include "console.h"
#include "i2c.h"
-#include "driver/accel_lis2dh.h"
/* Common debug funcions */
#define CPRINTF(format, args...) cprintf(CC_ACCEL, format "\n", ## args)
-/* Set auto increment subaddress on multiple access */
-#define AUTO_INC 0x80
-
/* X, Y, Z axis data len */
#define OUT_XYZ_SIZE 6
-/* Common define for poswer off ODR */
-#define ODR_POWER_OFF_VAL 0x00
-
#ifdef CONFIG_ACCEL_FIFO
#define FIFO_BUFFER_NUM_PATTERN 16
/* Define number of data to be read from FIFO each time
@@ -42,23 +35,20 @@
/**
* Read single register
*/
-inline int raw_read8(const int port, const int addr, const int reg,
+extern inline int raw_read8(const int port, const int addr, const int reg,
int *data_ptr);
/**
* Write single register
*/
-inline int raw_write8(const int port, const int addr, const int reg,
+extern inline int raw_write8(const int port, const int addr, const int reg,
int data);
/**
* Read n bytes for read
- * NOTE: Some chip use MSB for auto-increments in SUB address
- * MSB must be set for autoincrement in multi read when auto_inc
- * is set
*/
-int raw_read_n(const int port, const int addr, const uint8_t reg,
- uint8_t *data_ptr, const int len, int auto_inc);
+int st_raw_read_n(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
@@ -67,7 +57,7 @@ int raw_read_n(const int port, const int addr, const uint8_t reg,
* @mask: The mask to search
* @data: Data pointer
*/
-int write_data_with_mask(const struct motion_sensor_t *s, int reg,
+int st_write_data_with_mask(const struct motion_sensor_t *s, int reg,
uint8_t mask, uint8_t data);
/**
@@ -76,7 +66,7 @@ int write_data_with_mask(const struct motion_sensor_t *s, int reg,
* @res: Bit resolution
* @rnd: Round bit
*/
-int set_resolution(const struct motion_sensor_t *s, int res, int rnd);
+int st_set_resolution(const struct motion_sensor_t *s, int res, int rnd);
/**
* get_resolution - Get bit resolution
@@ -84,7 +74,7 @@ int set_resolution(const struct motion_sensor_t *s, int res, int rnd);
*
* TODO: must support multiple resolution
*/
-int get_resolution(const struct motion_sensor_t *s);
+int st_get_resolution(const struct motion_sensor_t *s);
/**
* set_offset - Set data offset
@@ -92,8 +82,8 @@ int get_resolution(const struct motion_sensor_t *s);
* @offset: offset vector
* @temp: Temp
*/
-int set_offset(const struct motion_sensor_t *s,
- const int16_t *offset, int16_t temp);
+int st_set_offset(const struct motion_sensor_t *s,
+ const int16_t *offset, int16_t temp);
/**
* get_offset - Get data offset
@@ -101,13 +91,14 @@ int set_offset(const struct motion_sensor_t *s,
* @offset: offset vector
* @temp: Temp
*/
-int get_offset(const struct motion_sensor_t *s, int16_t *offset, int16_t *temp);
+int st_get_offset(const struct motion_sensor_t *s,
+ int16_t *offset, int16_t *temp);
/**
* get_data_rate - Get data rate (ODR)
* @s: Motion sensor pointer
*/
-int get_data_rate(const struct motion_sensor_t *s);
+int st_get_data_rate(const struct motion_sensor_t *s);
/**
* normalize - Apply to LSB data sensitivity and rotation
@@ -115,7 +106,7 @@ int get_data_rate(const struct motion_sensor_t *s);
* @v: vector
* @data: LSB raw data
*/
-void normalize(const struct motion_sensor_t *s, vector_3_t v, uint8_t *data);
+void st_normalize(const struct motion_sensor_t *s, vector_3_t v, uint8_t *data);
/* Internal data structure for sensors */
struct stprivate_data {