summaryrefslogtreecommitdiff
path: root/driver/accelgyro_bmi160.c
diff options
context:
space:
mode:
Diffstat (limited to 'driver/accelgyro_bmi160.c')
-rw-r--r--driver/accelgyro_bmi160.c261
1 files changed, 120 insertions, 141 deletions
diff --git a/driver/accelgyro_bmi160.c b/driver/accelgyro_bmi160.c
index 184e20c9f5..0a736760d0 100644
--- a/driver/accelgyro_bmi160.c
+++ b/driver/accelgyro_bmi160.c
@@ -1,4 +1,4 @@
-/* Copyright 2015 The Chromium OS Authors. All rights reserved.
+/* Copyright 2015 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -9,6 +9,7 @@
*/
#include "accelgyro.h"
+#include "builtin/assert.h"
#include "common.h"
#include "console.h"
#include "accelgyro_bmi_common.h"
@@ -25,25 +26,22 @@
#include "util.h"
#define CPUTS(outstr) cputs(CC_ACCEL, outstr)
-#define CPRINTF(format, args...) cprintf(CC_ACCEL, format, ## args)
-#define CPRINTS(format, args...) cprints(CC_ACCEL, format, ## args)
+#define CPRINTF(format, args...) cprintf(CC_ACCEL, format, ##args)
+#define CPRINTS(format, args...) cprints(CC_ACCEL, format, ##args)
#ifdef CONFIG_ACCELGYRO_BMI160_INT_EVENT
#define ACCELGYRO_BMI160_INT_ENABLE
#endif
-STATIC_IF(CONFIG_BMI_ORIENTATION_SENSOR) void irq_set_orientation(
- struct motion_sensor_t *s,
- int interrupt);
+STATIC_IF(CONFIG_BMI_ORIENTATION_SENSOR)
+void irq_set_orientation(struct motion_sensor_t *s, int interrupt);
STATIC_IF(ACCELGYRO_BMI160_INT_ENABLE)
- volatile uint32_t last_interrupt_timestamp;
+volatile uint32_t last_interrupt_timestamp;
-static int wakeup_time[] = {
- [MOTIONSENSE_TYPE_ACCEL] = 4,
- [MOTIONSENSE_TYPE_GYRO] = 80,
- [MOTIONSENSE_TYPE_MAG] = 1
-};
+static int wakeup_time[] = { [MOTIONSENSE_TYPE_ACCEL] = 4,
+ [MOTIONSENSE_TYPE_GYRO] = 80,
+ [MOTIONSENSE_TYPE_MAG] = 1 };
/**
* Control access to the compass on the secondary i2c interface:
@@ -51,14 +49,12 @@ static int wakeup_time[] = {
* 1: manual access, we can issue i2c to the compass
* 0: data access: BMI160 gather data periodically from the compass.
*/
-static __maybe_unused int bmi160_sec_access_ctrl(
- const int port,
- const uint16_t i2c_spi_addr_flags,
- const int enable)
+static __maybe_unused int
+bmi160_sec_access_ctrl(const int port, const uint16_t i2c_spi_addr_flags,
+ const int enable)
{
int mag_if_ctrl;
- bmi_read8(port, i2c_spi_addr_flags,
- BMI160_MAG_IF_1, &mag_if_ctrl);
+ bmi_read8(port, i2c_spi_addr_flags, BMI160_MAG_IF_1, &mag_if_ctrl);
if (enable) {
mag_if_ctrl |= BMI160_MAG_MANUAL_EN;
mag_if_ctrl &= ~BMI160_MAG_READ_BURST_MASK;
@@ -68,42 +64,36 @@ static __maybe_unused int bmi160_sec_access_ctrl(
mag_if_ctrl &= ~BMI160_MAG_READ_BURST_MASK;
mag_if_ctrl |= BMI160_MAG_READ_BURST_8;
}
- return bmi_write8(port, i2c_spi_addr_flags,
- BMI160_MAG_IF_1, mag_if_ctrl);
+ return bmi_write8(port, i2c_spi_addr_flags, BMI160_MAG_IF_1,
+ mag_if_ctrl);
}
/**
* Read register from compass.
* Assuming we are in manual access mode, read compass i2c register.
*/
-int bmi160_sec_raw_read8(const int port,
- const uint16_t i2c_spi_addr_flags,
+int bmi160_sec_raw_read8(const int port, const uint16_t i2c_spi_addr_flags,
const uint8_t reg, int *data_ptr)
{
/* Only read 1 bytes */
- bmi_write8(port, i2c_spi_addr_flags,
- BMI160_MAG_I2C_READ_ADDR, reg);
- return bmi_read8(port, i2c_spi_addr_flags,
- BMI160_MAG_I2C_READ_DATA, data_ptr);
+ bmi_write8(port, i2c_spi_addr_flags, BMI160_MAG_I2C_READ_ADDR, reg);
+ return bmi_read8(port, i2c_spi_addr_flags, BMI160_MAG_I2C_READ_DATA,
+ data_ptr);
}
/**
* Write register from compass.
* Assuming we are in manual access mode, write to compass i2c register.
*/
-int bmi160_sec_raw_write8(const int port,
- const uint16_t i2c_spi_addr_flags,
+int bmi160_sec_raw_write8(const int port, const uint16_t i2c_spi_addr_flags,
const uint8_t reg, int data)
{
- bmi_write8(port, i2c_spi_addr_flags,
- BMI160_MAG_I2C_WRITE_DATA, data);
- return bmi_write8(port, i2c_spi_addr_flags,
- BMI160_MAG_I2C_WRITE_ADDR, reg);
+ bmi_write8(port, i2c_spi_addr_flags, BMI160_MAG_I2C_WRITE_DATA, data);
+ return bmi_write8(port, i2c_spi_addr_flags, BMI160_MAG_I2C_WRITE_ADDR,
+ reg);
}
-static int set_data_rate(const struct motion_sensor_t *s,
- int rate,
- int rnd)
+static int set_data_rate(const struct motion_sensor_t *s, int rate, int rnd)
{
int ret, normalized_rate;
uint8_t reg_val;
@@ -115,8 +105,7 @@ static int set_data_rate(const struct motion_sensor_t *s,
bmi_enable_fifo(s, 0);
/* go to suspend mode */
- ret = bmi_write8(s->port, s->i2c_spi_addr_flags,
- BMI160_CMD_REG,
+ ret = bmi_write8(s->port, s->i2c_spi_addr_flags, BMI160_CMD_REG,
BMI160_CMD_MODE_SUSPEND(s->type));
msleep(3);
data->odr = 0;
@@ -130,8 +119,7 @@ static int set_data_rate(const struct motion_sensor_t *s,
return ret;
} else if (data->odr == 0) {
/* back from suspend mode. */
- ret = bmi_write8(s->port, s->i2c_spi_addr_flags,
- BMI160_CMD_REG,
+ ret = bmi_write8(s->port, s->i2c_spi_addr_flags, BMI160_CMD_REG,
BMI160_CMD_MODE_NORMAL(s->type));
msleep(wakeup_time[s->type]);
}
@@ -146,8 +134,7 @@ static int set_data_rate(const struct motion_sensor_t *s,
*/
mutex_lock(s->mutex);
- ret = bmi_set_reg8(s, BMI_CONF_REG(s->type),
- reg_val, BMI_ODR_MASK);
+ ret = bmi_set_reg8(s, BMI_CONF_REG(s->type), reg_val, BMI_ODR_MASK);
if (ret != EC_SUCCESS)
goto accel_cleanup;
@@ -165,9 +152,9 @@ static int set_data_rate(const struct motion_sensor_t *s,
* for at least MIN_BATCH_WINDOW_US.
* Given odr is in mHz, multiply by 1000x
*/
- moc->batch_size = MAX(
- MAG_CAL_MIN_BATCH_SIZE,
- (data->odr * 1000) / (MAG_CAL_MIN_BATCH_WINDOW_US));
+ moc->batch_size =
+ MAX(MAG_CAL_MIN_BATCH_SIZE,
+ (data->odr * 1000) / (MAG_CAL_MIN_BATCH_WINDOW_US));
CPRINTS("Batch size: %d", moc->batch_size);
}
@@ -183,17 +170,16 @@ accel_cleanup:
return ret;
}
-static int set_offset(const struct motion_sensor_t *s,
- const int16_t *offset,
- int16_t temp)
+static int set_offset(const struct motion_sensor_t *s, const int16_t *offset,
+ int16_t temp)
{
int ret, val98;
intv3_t v = { offset[X], offset[Y], offset[Z] };
rotate_inv(v, *s->rot_standard_ref, v);
- ret = bmi_read8(s->port, s->i2c_spi_addr_flags,
- BMI160_OFFSET_EN_GYR98, &val98);
+ ret = bmi_read8(s->port, s->i2c_spi_addr_flags, BMI160_OFFSET_EN_GYR98,
+ &val98);
if (ret != 0)
return ret;
@@ -258,8 +244,8 @@ static int perform_calib(struct motion_sensor_t *s, int enable)
else
val = BMI160_FOC_ACC_MINUS_1G;
val = (BMI160_FOC_ACC_0G << BMI160_FOC_ACC_X_OFFSET) |
- (BMI160_FOC_ACC_0G << BMI160_FOC_ACC_Y_OFFSET) |
- (val << BMI160_FOC_ACC_Z_OFFSET);
+ (BMI160_FOC_ACC_0G << BMI160_FOC_ACC_Y_OFFSET) |
+ (val << BMI160_FOC_ACC_Z_OFFSET);
en_flag = BMI160_OFFSET_ACC_EN;
/*
* Temporary set range to minimum to run calibration with
@@ -285,12 +271,11 @@ static int perform_calib(struct motion_sensor_t *s, int enable)
/* Unreachable due to sensor type check above. */
ASSERT(false);
return EC_RES_INVALID_PARAM;
- /* LCOV_EXCL_STOP */
+ /* LCOV_EXCL_STOP */
}
- ret = bmi_write8(s->port, s->i2c_spi_addr_flags,
- BMI160_FOC_CONF, val);
- ret = bmi_write8(s->port, s->i2c_spi_addr_flags,
- BMI160_CMD_REG, BMI160_CMD_START_FOC);
+ ret = bmi_write8(s->port, s->i2c_spi_addr_flags, BMI160_FOC_CONF, val);
+ ret = bmi_write8(s->port, s->i2c_spi_addr_flags, BMI160_CMD_REG,
+ BMI160_CMD_START_FOC);
deadline.val = get_time().val + timeout.val;
do {
if (timestamp_expired(deadline, NULL)) {
@@ -298,8 +283,8 @@ static int perform_calib(struct motion_sensor_t *s, int enable)
goto end_perform_calib;
}
msleep(50);
- ret = bmi_read8(s->port, s->i2c_spi_addr_flags,
- BMI160_STATUS, &status);
+ ret = bmi_read8(s->port, s->i2c_spi_addr_flags, BMI160_STATUS,
+ &status);
if (ret != EC_SUCCESS)
goto end_perform_calib;
} while ((status & BMI160_FOC_RDY) == 0);
@@ -319,8 +304,7 @@ end_perform_calib:
*/
#ifdef CONFIG_GESTURE_HOST_DETECTION
static int manage_activity(const struct motion_sensor_t *s,
- enum motionsensor_activity activity,
- int enable,
+ enum motionsensor_activity activity, int enable,
const struct ec_motion_sense_activity *param)
{
int ret;
@@ -332,23 +316,23 @@ static int manage_activity(const struct motion_sensor_t *s,
if (enable) {
/* We should use parameters from caller */
bmi_write8(s->port, s->i2c_spi_addr_flags,
- BMI160_INT_MOTION_3,
- BMI160_MOTION_PROOF_TIME(
- CONFIG_GESTURE_SIGMO_PROOF_MS) <<
- BMI160_MOTION_PROOF_OFF |
- BMI160_MOTION_SKIP_TIME(
- CONFIG_GESTURE_SIGMO_SKIP_MS) <<
- BMI160_MOTION_SKIP_OFF |
- BMI160_MOTION_SIG_MOT_SEL);
+ BMI160_INT_MOTION_3,
+ BMI160_MOTION_PROOF_TIME(
+ CONFIG_GESTURE_SIGMO_PROOF_MS)
+ << BMI160_MOTION_PROOF_OFF |
+ BMI160_MOTION_SKIP_TIME(
+ CONFIG_GESTURE_SIGMO_SKIP_MS)
+ << BMI160_MOTION_SKIP_OFF |
+ BMI160_MOTION_SIG_MOT_SEL);
bmi_write8(s->port, s->i2c_spi_addr_flags,
- BMI160_INT_MOTION_1,
- BMI160_MOTION_TH(s,
- CONFIG_GESTURE_SIGMO_THRES_MG));
+ BMI160_INT_MOTION_1,
+ BMI160_MOTION_TH(
+ s, CONFIG_GESTURE_SIGMO_THRES_MG));
}
ret = bmi_enable_reg8(s, BMI160_INT_EN_0,
BMI160_INT_ANYMO_X_EN |
- BMI160_INT_ANYMO_Y_EN |
- BMI160_INT_ANYMO_Z_EN,
+ BMI160_INT_ANYMO_Y_EN |
+ BMI160_INT_ANYMO_Z_EN,
enable);
if (ret)
ret = EC_RES_UNAVAILABLE;
@@ -358,8 +342,7 @@ static int manage_activity(const struct motion_sensor_t *s,
#ifdef CONFIG_GESTURE_SENSOR_DOUBLE_TAP
case MOTIONSENSE_ACTIVITY_DOUBLE_TAP: {
/* Set double tap interrupt */
- ret = bmi_enable_reg8(s, BMI160_INT_EN_0,
- BMI160_INT_D_TAP_EN,
+ ret = bmi_enable_reg8(s, BMI160_INT_EN_0, BMI160_INT_D_TAP_EN,
enable);
if (ret)
ret = EC_RES_UNAVAILABLE;
@@ -382,6 +365,13 @@ static int manage_activity(const struct motion_sensor_t *s,
}
#endif
+#ifdef CONFIG_BODY_DETECTION
+static int get_rms_noise(const struct motion_sensor_t *s)
+{
+ return bmi_get_rms_noise(s, BMI160_ACCEL_RMS_NOISE_100HZ);
+}
+#endif
+
/** Requires that the passed sensor `*s` is an accelerometer */
static __maybe_unused int
config_accel_interrupt(const struct motion_sensor_t *s)
@@ -389,18 +379,18 @@ config_accel_interrupt(const struct motion_sensor_t *s)
int ret, tmp;
mutex_lock(s->mutex);
- bmi_write8(s->port, s->i2c_spi_addr_flags,
- BMI160_CMD_REG, BMI160_CMD_FIFO_FLUSH);
- bmi_write8(s->port, s->i2c_spi_addr_flags,
- BMI160_CMD_REG, BMI160_CMD_INT_RESET);
+ bmi_write8(s->port, s->i2c_spi_addr_flags, BMI160_CMD_REG,
+ BMI160_CMD_FIFO_FLUSH);
+ bmi_write8(s->port, s->i2c_spi_addr_flags, BMI160_CMD_REG,
+ BMI160_CMD_INT_RESET);
if (IS_ENABLED(CONFIG_GESTURE_SENSOR_DOUBLE_TAP)) {
- bmi_write8(s->port, s->i2c_spi_addr_flags,
- BMI160_INT_TAP_0,
- BMI160_TAP_DUR(s, CONFIG_GESTURE_TAP_MAX_INTERSTICE_T));
+ bmi_write8(s->port, s->i2c_spi_addr_flags, BMI160_INT_TAP_0,
+ BMI160_TAP_DUR(s,
+ CONFIG_GESTURE_TAP_MAX_INTERSTICE_T));
ret = bmi_write8(s->port, s->i2c_spi_addr_flags,
- BMI160_INT_TAP_1,
- BMI160_TAP_TH(s, CONFIG_GESTURE_TAP_THRES_MG));
+ BMI160_INT_TAP_1,
+ BMI160_TAP_TH(s, CONFIG_GESTURE_TAP_THRES_MG));
}
/* only use orientation sensor on the lid sensor */
if (IS_ENABLED(CONFIG_BMI_ORIENTATION_SENSOR) &&
@@ -415,17 +405,16 @@ config_accel_interrupt(const struct motion_sensor_t *s)
if (IS_ENABLED(CONFIG_ACCELGYRO_BMI160_INT2_OUTPUT)) {
ret = bmi_write8(s->port, s->i2c_spi_addr_flags,
- BMI160_INT_LATCH, BMI160_LATCH_5MS);
+ BMI160_INT_LATCH, BMI160_LATCH_5MS);
} else {
/* Also, configure int2 as an external input. */
ret = bmi_write8(s->port, s->i2c_spi_addr_flags,
- BMI160_INT_LATCH,
- BMI160_INT2_INPUT_EN | BMI160_LATCH_5MS);
+ BMI160_INT_LATCH,
+ BMI160_INT2_INPUT_EN | BMI160_LATCH_5MS);
}
/* configure int1 as an interrupt */
- ret = bmi_write8(s->port, s->i2c_spi_addr_flags,
- BMI160_INT_OUT_CTRL,
+ ret = bmi_write8(s->port, s->i2c_spi_addr_flags, BMI160_INT_OUT_CTRL,
BMI160_INT_CTRL(1, OUTPUT_EN));
/* Map activity interrupt to int 1 */
@@ -439,15 +428,14 @@ config_accel_interrupt(const struct motion_sensor_t *s)
/* enable orientation interrupt for lid sensor only */
tmp |= BMI160_INT_ORIENT;
}
- ret = bmi_write8(s->port, s->i2c_spi_addr_flags,
- BMI160_INT_MAP_REG(1), tmp);
+ ret = bmi_write8(s->port, s->i2c_spi_addr_flags, BMI160_INT_MAP_REG(1),
+ tmp);
if (IS_ENABLED(ACCELGYRO_BMI160_INT_ENABLE)) {
/* map fifo water mark to int 1 */
- ret = bmi_write8(s->port, s->i2c_spi_addr_flags,
- BMI160_INT_FIFO_MAP,
- BMI160_INT_MAP(1, FWM) |
- BMI160_INT_MAP(1, FFULL));
+ ret = bmi_write8(
+ s->port, s->i2c_spi_addr_flags, BMI160_INT_FIFO_MAP,
+ BMI160_INT_MAP(1, FWM) | BMI160_INT_MAP(1, FFULL));
/*
* Configure fifo watermark to int whenever there's any data in
@@ -457,13 +445,13 @@ config_accel_interrupt(const struct motion_sensor_t *s)
BMI160_FIFO_CONFIG_0, 1);
if (IS_ENABLED(CONFIG_ACCELGYRO_BMI160_INT2_OUTPUT))
ret = bmi_write8(s->port, s->i2c_spi_addr_flags,
- BMI160_FIFO_CONFIG_1,
- BMI160_FIFO_HEADER_EN);
+ BMI160_FIFO_CONFIG_1,
+ BMI160_FIFO_HEADER_EN);
else
ret = bmi_write8(s->port, s->i2c_spi_addr_flags,
- BMI160_FIFO_CONFIG_1,
- BMI160_FIFO_TAG_INT2_EN |
- BMI160_FIFO_HEADER_EN);
+ BMI160_FIFO_CONFIG_1,
+ BMI160_FIFO_TAG_INT2_EN |
+ BMI160_FIFO_HEADER_EN);
/* Set fifo*/
bmi_enable_reg8(s, BMI160_INT_EN_1,
@@ -475,17 +463,15 @@ config_accel_interrupt(const struct motion_sensor_t *s)
#ifdef ACCELGYRO_BMI160_INT_ENABLE
#ifdef CONFIG_BMI_ORIENTATION_SENSOR
-static void irq_set_orientation(struct motion_sensor_t *s,
- int interrupt)
+static void irq_set_orientation(struct motion_sensor_t *s, int interrupt)
{
- int shifted_masked_orientation =
- (interrupt >> 24) & BMI160_ORIENT_XY_MASK;
+ int shifted_masked_orientation = (interrupt >> 24) &
+ BMI160_ORIENT_XY_MASK;
if (BMI_GET_DATA(s)->raw_orientation != shifted_masked_orientation) {
enum motionsensor_orientation orientation =
MOTIONSENSE_ORIENTATION_UNKNOWN;
- BMI_GET_DATA(s)->raw_orientation =
- shifted_masked_orientation;
+ BMI_GET_DATA(s)->raw_orientation = shifted_masked_orientation;
switch (shifted_masked_orientation) {
case BMI160_ORIENT_PORTRAIT:
@@ -509,7 +495,7 @@ static void irq_set_orientation(struct motion_sensor_t *s,
*motion_orientation_ptr(s) = orientation;
}
}
-#endif /* CONFIG_BMI_ORIENTATION_SENSOR */
+#endif /* CONFIG_BMI_ORIENTATION_SENSOR */
/**
* bmi160_interrupt - called when the sensor activates the interrupt line.
@@ -531,15 +517,14 @@ void bmi160_interrupt(enum gpio_signal signal)
* For now, we just print out. We should set a bitmask motion sense code will
* act upon.
*/
-static int irq_handler(struct motion_sensor_t *s,
- uint32_t *event)
+static int irq_handler(struct motion_sensor_t *s, uint32_t *event)
{
uint32_t interrupt;
int8_t has_read_fifo = 0;
int rv;
if ((s->type != MOTIONSENSE_TYPE_ACCEL) ||
- (!(*event & CONFIG_ACCELGYRO_BMI160_INT_EVENT)))
+ (!(*event & CONFIG_ACCELGYRO_BMI160_INT_EVENT)))
return EC_ERROR_NOT_HANDLED;
do {
@@ -554,11 +539,11 @@ static int irq_handler(struct motion_sensor_t *s,
if (IS_ENABLED(CONFIG_GESTURE_SENSOR_DOUBLE_TAP) &&
(interrupt & BMI160_D_TAP_INT))
*event |= TASK_EVENT_MOTION_ACTIVITY_INTERRUPT(
- MOTIONSENSE_ACTIVITY_DOUBLE_TAP);
+ MOTIONSENSE_ACTIVITY_DOUBLE_TAP);
if (IS_ENABLED(CONFIG_GESTURE_SIGMO) &&
(interrupt & BMI160_SIGMOT_INT))
*event |= TASK_EVENT_MOTION_ACTIVITY_INTERRUPT(
- MOTIONSENSE_ACTIVITY_SIG_MOTION);
+ MOTIONSENSE_ACTIVITY_SIG_MOTION);
if (interrupt & (BMI160_FWM_INT | BMI160_FFULL_INT)) {
bmi_load_fifo(s, last_interrupt_timestamp);
has_read_fifo = 1;
@@ -572,26 +557,25 @@ static int irq_handler(struct motion_sensor_t *s,
return EC_SUCCESS;
}
-#endif /* ACCELGYRO_BMI160_INT_ENABLE */
+#endif /* ACCELGYRO_BMI160_INT_ENABLE */
static int init(struct motion_sensor_t *s)
{
int ret = 0, tmp, i;
struct accelgyro_saved_data_t *saved_data = BMI_GET_SAVED_DATA(s);
- ret = bmi_read8(s->port, s->i2c_spi_addr_flags,
- BMI160_CHIP_ID, &tmp);
+ ret = bmi_read8(s->port, s->i2c_spi_addr_flags, BMI160_CHIP_ID, &tmp);
if (ret)
return EC_ERROR_UNKNOWN;
if (tmp != BMI160_CHIP_ID_MAJOR && tmp != BMI168_CHIP_ID_MAJOR) {
/* The device may be lock on paging mode. Try to unlock it. */
- bmi_write8(s->port, s->i2c_spi_addr_flags,
- BMI160_CMD_REG, BMI160_CMD_EXT_MODE_EN_B0);
- bmi_write8(s->port, s->i2c_spi_addr_flags,
- BMI160_CMD_REG, BMI160_CMD_EXT_MODE_EN_B1);
- bmi_write8(s->port, s->i2c_spi_addr_flags,
- BMI160_CMD_REG, BMI160_CMD_EXT_MODE_EN_B2);
+ bmi_write8(s->port, s->i2c_spi_addr_flags, BMI160_CMD_REG,
+ BMI160_CMD_EXT_MODE_EN_B0);
+ bmi_write8(s->port, s->i2c_spi_addr_flags, BMI160_CMD_REG,
+ BMI160_CMD_EXT_MODE_EN_B1);
+ bmi_write8(s->port, s->i2c_spi_addr_flags, BMI160_CMD_REG,
+ BMI160_CMD_EXT_MODE_EN_B2);
bmi_write8(s->port, s->i2c_spi_addr_flags,
BMI160_CMD_EXT_MODE_ADDR, BMI160_CMD_PAGING_EN);
bmi_write8(s->port, s->i2c_spi_addr_flags,
@@ -599,17 +583,15 @@ static int init(struct motion_sensor_t *s)
return EC_ERROR_ACCESS_DENIED;
}
-
if (s->type == MOTIONSENSE_TYPE_ACCEL) {
struct bmi_drv_data_t *data = BMI_GET_DATA(s);
/* Reset the chip to be in a good state */
- bmi_write8(s->port, s->i2c_spi_addr_flags,
- BMI160_CMD_REG, BMI160_CMD_SOFT_RESET);
+ bmi_write8(s->port, s->i2c_spi_addr_flags, BMI160_CMD_REG,
+ BMI160_CMD_SOFT_RESET);
msleep(1);
data->flags &= ~(BMI_FLAG_SEC_I2C_ENABLED |
- (BMI_FIFO_ALL_MASK <<
- BMI_FIFO_FLAG_OFFSET));
+ (BMI_FIFO_ALL_MASK << BMI_FIFO_FLAG_OFFSET));
if (IS_ENABLED(CONFIG_GESTURE_HOST_DETECTION)) {
data->enabled_activities = 0;
data->disabled_activities = 0;
@@ -621,8 +603,8 @@ static int init(struct motion_sensor_t *s)
BIT(MOTIONSENSE_ACTIVITY_DOUBLE_TAP);
}
/* To avoid gyro wakeup */
- bmi_write8(s->port, s->i2c_spi_addr_flags,
- BMI160_PMU_TRIGGER, 0);
+ bmi_write8(s->port, s->i2c_spi_addr_flags, BMI160_PMU_TRIGGER,
+ 0);
}
#ifdef CONFIG_BMI_SEC_I2C
@@ -633,8 +615,8 @@ static int init(struct motion_sensor_t *s)
* To be able to configure the real magnetometer, we must set
* the BMI160 magnetometer part (a pass through) in normal mode.
*/
- bmi_write8(s->port, s->i2c_spi_addr_flags,
- BMI160_CMD_REG, BMI160_CMD_MODE_NORMAL(s->type));
+ bmi_write8(s->port, s->i2c_spi_addr_flags, BMI160_CMD_REG,
+ BMI160_CMD_MODE_NORMAL(s->type));
msleep(wakeup_time[s->type]);
if ((data->flags & BMI_FLAG_SEC_I2C_ENABLED) == 0) {
@@ -670,21 +652,18 @@ static int init(struct motion_sensor_t *s)
BMI160_CMD_EXT_MODE_ADDR, &ext_page_reg);
/* Set the i2c address of the compass */
- ret = bmi_write8(s->port, s->i2c_spi_addr_flags,
- BMI160_MAG_IF_0,
- I2C_STRIP_FLAGS(
- CONFIG_ACCELGYRO_SEC_ADDR_FLAGS)
- << 1);
+ ret = bmi_write8(
+ s->port, s->i2c_spi_addr_flags, BMI160_MAG_IF_0,
+ I2C_STRIP_FLAGS(CONFIG_ACCELGYRO_SEC_ADDR_FLAGS)
+ << 1);
/* Enable the secondary interface as I2C */
- ret = bmi_write8(s->port, s->i2c_spi_addr_flags,
- BMI160_IF_CONF,
- BMI160_IF_MODE_AUTO_I2C <<
- BMI160_IF_MODE_OFF);
+ ret = bmi_write8(
+ s->port, s->i2c_spi_addr_flags, BMI160_IF_CONF,
+ BMI160_IF_MODE_AUTO_I2C << BMI160_IF_MODE_OFF);
data->flags |= BMI_FLAG_SEC_I2C_ENABLED;
}
-
bmi160_sec_access_ctrl(s->port, s->i2c_spi_addr_flags, 1);
ret = bmm150_init(s);
@@ -746,7 +725,7 @@ const struct accelgyro_drv bmi160_drv = {
.list_activities = bmi_list_activities,
#endif
#ifdef CONFIG_BODY_DETECTION
- .get_rms_noise = bmi_get_rms_noise,
+ .get_rms_noise = get_rms_noise,
#endif
};