You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/04/28 13:31:44 UTC
(nuttx) branch master updated: sensors/bmi270_uorb.c: move init sequence to register function
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 6621748fe8 sensors/bmi270_uorb.c: move init sequence to register function
6621748fe8 is described below
commit 6621748fe8125031a87e87909ff2496a66d79bb2
Author: raiden00pl <ra...@railab.me>
AuthorDate: Sun Apr 28 10:39:55 2024 +0200
sensors/bmi270_uorb.c: move init sequence to register function
otherwise default accel and gyro scale configured during registration is cleared
---
drivers/sensors/bmi270_uorb.c | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/drivers/sensors/bmi270_uorb.c b/drivers/sensors/bmi270_uorb.c
index 8e49383c43..68aaa9229f 100644
--- a/drivers/sensors/bmi270_uorb.c
+++ b/drivers/sensors/bmi270_uorb.c
@@ -177,14 +177,6 @@ static int bmi270_activate(FAR struct sensor_lowerhalf_s *lower,
if (start)
{
- /* Initialization sequence */
-
- ret = bmi270_init_seq(&priv->base);
- if (ret != 0)
- {
- return ret;
- }
-
/* Set normal mode */
bmi270_set_normal_imu(&priv->base);
@@ -633,8 +625,6 @@ int bmi270_register_uorb(int devno, FAR struct spi_dev_s *spi)
goto gyro_err;
}
- bmi270_accel_scale(tmp, 2);
-
/* Gyroscope register */
tmp = &dev->priv[BMI270_GYRO_IDX];
@@ -660,8 +650,6 @@ int bmi270_register_uorb(int devno, FAR struct spi_dev_s *spi)
goto gyro_err;
}
- bmi270_gyro_scale(tmp, 2000);
-
#ifdef CONFIG_SENSORS_BMI270_SPI
/* BMI270 detects communication bus is SPI by rising edge of CS. */
@@ -670,6 +658,19 @@ int bmi270_register_uorb(int devno, FAR struct spi_dev_s *spi)
up_udelay(200);
#endif
+ /* Initialization sequence */
+
+ ret = bmi270_init_seq(&tmp->base);
+ if (ret != 0)
+ {
+ return ret;
+ }
+
+ /* Set default scale */
+
+ bmi270_accel_scale(&dev->priv[BMI270_ACCEL_IDX], 2);
+ bmi270_gyro_scale(&dev->priv[BMI270_GYRO_IDX], 2000);
+
#ifdef CONFIG_SENSORS_BMI270_POLL
/* Create thread for polling sensor data */