From c2677bea3bbba13dafbf74b5e49461314dfb4bce Mon Sep 17 00:00:00 2001 From: Kemal Hadimli Date: Thu, 18 Jan 2024 13:07:08 +0000 Subject: [PATCH] feat: Add `skip_reset` `bmi270_init`, preventing soft reset during init --- bmi2.c | 7 +++++++ bmi2.h | 2 ++ bmi270.c | 4 ++-- bmi270.h | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/bmi2.c b/bmi2.c index 1e537c6..14545cc 100644 --- a/bmi2.c +++ b/bmi2.c @@ -1880,6 +1880,11 @@ static int8_t validate_foc_accel_axis(int16_t avg_foc_data, struct bmi2_dev *dev * chip-id of the sensor. */ int8_t bmi2_sec_init(struct bmi2_dev *dev) +{ + return bmi2_sec_init_with_opt(dev, 0); +} + +int8_t bmi2_sec_init_with_opt(struct bmi2_dev *dev, uint8_t skip_reset) { /* Variable to define error */ int8_t rslt; @@ -1928,6 +1933,8 @@ int8_t bmi2_sec_init(struct bmi2_dev *dev) */ dev->remap = axes_remap; + if (skip_reset) return BMI2_OK; + /* Perform soft-reset to bring all register values to their * default values */ diff --git a/bmi2.h b/bmi2.h index 20acca9..cc2dc77 100644 --- a/bmi2.h +++ b/bmi2.h @@ -89,6 +89,8 @@ extern "C" { */ int8_t bmi2_sec_init(struct bmi2_dev *dev); +int8_t bmi2_sec_init_with_opt(struct bmi2_dev *dev, uint8_t skip_reset); + /*! * \ingroup bmi2ApiInit * \page bmi2_api_bmi2_set_spi_en bmi2_set_spi_en diff --git a/bmi270.c b/bmi270.c index 20f27bb..5b7d47b 100644 --- a/bmi270.c +++ b/bmi270.c @@ -1351,7 +1351,7 @@ static int8_t disable_sensor_features(uint64_t sensor_sel, struct bmi2_dev *dev) * 4) Updates the feature offset parameters in the device structure. * 5) Updates the maximum number of pages, in the device structure. */ -int8_t bmi270_init(struct bmi2_dev *dev) +int8_t bmi270_init(struct bmi2_dev *dev, uint8_t skip_reset) { /* Variable to define error */ int8_t rslt; @@ -1389,7 +1389,7 @@ int8_t bmi270_init(struct bmi2_dev *dev) } /* Initialize BMI2 sensor */ - rslt = bmi2_sec_init(dev); + rslt = bmi2_sec_init_with_opt(dev, skip_reset); if (rslt == BMI2_OK) { /* Assign the offsets of the feature input diff --git a/bmi270.h b/bmi270.h index c2c85ab..3954d87 100644 --- a/bmi270.h +++ b/bmi270.h @@ -150,7 +150,7 @@ extern "C" { * @retval 0 -> Success * @retval < 0 -> Fail */ -int8_t bmi270_init(struct bmi2_dev *dev); +int8_t bmi270_init(struct bmi2_dev *dev, uint8_t skip_reset); /** * \ingroup bmi270