drivers/sensor: lsm6dso: Remove unneeded read/modify/write in shub read
The code in the ST HAL does a read/modify/write to change the bits in the LSM6DSO_FUNC_CFG_ACCESS register that control which register bank is active. All the other bits in the register are defined as zero. It's possible to simply set the register to the desired value without reading the contents first. This bank switch needs to be done twice for every sensor read when the sensor hub is used. The driver as it is can not keep up with the higher update rates of the lsm6dso. So any speed increase in this code allows for a higher update rate as well as reduced latency. Previously, a read of the lsm6dso's accel and gyro on a 400 kHz I2C bus with a 3-axis magnetometer on the sensor hub takes 2.69 ms. This drops that to 2.26 ms. This is enough to support the 417 Hz ODR. Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
This commit is contained in:
parent
8e80661db7
commit
0cfe9560d9
1 changed files with 5 additions and 5 deletions
|
@ -441,11 +441,11 @@ static int lsm6dso_shub_wait_completed(stmdev_ctx_t *ctx)
|
|||
|
||||
static inline void lsm6dso_shub_embedded_en(stmdev_ctx_t *ctx, bool on)
|
||||
{
|
||||
if (on) {
|
||||
(void) lsm6dso_mem_bank_set(ctx, LSM6DSO_SENSOR_HUB_BANK);
|
||||
} else {
|
||||
(void) lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK);
|
||||
}
|
||||
lsm6dso_func_cfg_access_t reg = {
|
||||
.reg_access = on ? LSM6DSO_SENSOR_HUB_BANK : LSM6DSO_USER_BANK
|
||||
};
|
||||
|
||||
lsm6dso_write_reg(ctx, LSM6DSO_FUNC_CFG_ACCESS, (uint8_t *)®, 1);
|
||||
|
||||
k_busy_wait(150);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue