diff options
Diffstat (limited to 'driver/accelgyro_bmi260.c')
-rw-r--r-- | driver/accelgyro_bmi260.c | 50 |
1 files changed, 23 insertions, 27 deletions
diff --git a/driver/accelgyro_bmi260.c b/driver/accelgyro_bmi260.c index 405df5438b..56a3ab1a17 100644 --- a/driver/accelgyro_bmi260.c +++ b/driver/accelgyro_bmi260.c @@ -289,18 +289,17 @@ static int config_interrupt(const struct motion_sensor_t *s) ret = bmi_write8(s->port, s->i2c_spi_addr_flags, BMI260_INT1_IO_CTRL, BMI260_INT1_OUTPUT_EN); -#ifdef CONFIG_ACCELGYRO_BMI260_INT2_OUTPUT - /* TODO(chingkang): Test it if we want int2 as an interrupt */ - /* configure int2 as an interrupt */ - ret = bmi_write8(s->port, s->i2c_spi_addr_flags, - BMI260_INT2_IO_CTRL, - BMI260_INT2_OUTPUT_EN); -#else - /* configure int2 as an external input. */ - ret = bmi_write8(s->port, s->i2c_spi_addr_flags, - BMI260_INT2_IO_CTRL, - BMI260_INT2_INPUT_EN); -#endif + if (IS_ENABLED(CONFIG_ACCELGYRO_BMI260_INT2_OUTPUT)) + /* TODO(chingkang): Test it if we want int2 as an interrupt */ + /* configure int2 as an interrupt */ + ret = bmi_write8(s->port, s->i2c_spi_addr_flags, + BMI260_INT2_IO_CTRL, + BMI260_INT2_OUTPUT_EN); + else + /* configure int2 as an external input. */ + ret = bmi_write8(s->port, s->i2c_spi_addr_flags, + BMI260_INT2_IO_CTRL, + BMI260_INT2_INPUT_EN); if (IS_ENABLED(CONFIG_ACCEL_FIFO)) { /* map fifo water mark to int 1 */ @@ -317,17 +316,16 @@ static int config_interrupt(const struct motion_sensor_t *s) BMI260_FIFO_WTM_0, 1); ret = bmi_write8(s->port, s->i2c_spi_addr_flags, BMI260_FIFO_WTM_1, 0); -#ifdef CONFIG_ACCELGYRO_BMI260_INT2_OUTPUT - ret = bmi_write8(s->port, s->i2c_spi_addr_flags, - BMI260_FIFO_CONFIG_1, - BMI260_FIFO_HEADER_EN); -#else - ret = bmi_write8(s->port, s->i2c_spi_addr_flags, - BMI260_FIFO_CONFIG_1, - (BMI260_FIFO_TAG_INT_LEVEL << - BMI260_FIFO_TAG_INT2_EN_OFFSET) | - BMI260_FIFO_HEADER_EN); -#endif + if (IS_ENABLED(CONFIG_ACCELGYRO_BMI260_INT2_OUTPUT)) + ret = bmi_write8(s->port, s->i2c_spi_addr_flags, + BMI260_FIFO_CONFIG_1, + BMI260_FIFO_HEADER_EN); + else + ret = bmi_write8(s->port, s->i2c_spi_addr_flags, + BMI260_FIFO_CONFIG_1, + (BMI260_FIFO_TAG_INT_LEVEL << + BMI260_FIFO_TAG_INT2_EN_OFFSET) | + BMI260_FIFO_HEADER_EN); /* disable FIFO sensortime frame */ ret = bmi_write8(s->port, s->i2c_spi_addr_flags, BMI260_FIFO_CONFIG_0, 0); @@ -536,11 +534,9 @@ static int init(const struct motion_sensor_t *s) saved_data->odr = 0; bmi_set_range(s, s->default_range, 0); - if (s->type == MOTIONSENSE_TYPE_ACCEL) { -#ifdef CONFIG_ACCEL_INTERRUPTS + if (IS_ENABLED(CONFIG_ACCEL_INTERRUPTS) && + (s->type == MOTIONSENSE_TYPE_ACCEL)) ret = config_interrupt(s); -#endif - } return sensor_init_done(s); } |