Skip to content

Commit 9822e90

Browse files
committed
drivers/sensor: lsm6dsvxxx: add High-g data support in FIFO
Add support for High-g data in FIFO. The HG data wiil be marked in FIFO with LSM6DSV80X_XL_HG_TAG. Signed-off-by: Armando Visconti <[email protected]>
1 parent 286ca8e commit 9822e90

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

drivers/sensor/st/lsm6dsvxxx/lsm6dsv320x.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,7 @@ static void lsm6dsv320x_config_fifo(const struct device *dev, struct trigger_con
664664
lsm6dsv320x_sflp_data_rate_t sflp_odr = LSM6DSV320X_SFLP_120Hz;
665665
lsm6dsv320x_fifo_sflp_raw_t sflp_fifo = {0};
666666
lsm6dsv320x_sflp_gbias_t gbias;
667+
uint8_t xl_hg_batch = 0;
667668

668669
/* disable FIFO as first thing */
669670
lsm6dsv320x_fifo_mode_set(ctx, LSM6DSV320X_BYPASS_MODE);
@@ -678,6 +679,7 @@ static void lsm6dsv320x_config_fifo(const struct device *dev, struct trigger_con
678679
xl_batch = config->accel_batch;
679680
gy_batch = config->gyro_batch;
680681
temp_batch = config->temp_batch;
682+
xl_hg_batch = (lsm6dsv320x_is_hg_fs(config->accel_range)) ? 1 : 0;
681683

682684
fifo_mode = LSM6DSV320X_STREAM_MODE;
683685
fifo_wtm = config->fifo_wtm;
@@ -709,6 +711,7 @@ static void lsm6dsv320x_config_fifo(const struct device *dev, struct trigger_con
709711
/* Set FIFO batch rates */
710712
lsm6dsv320x_fifo_xl_batch_set(ctx, xl_batch);
711713
data->accel_batch_odr = xl_batch;
714+
lsm6dsv320x_fifo_hg_xl_batch_set(ctx, xl_hg_batch);
712715
lsm6dsv320x_fifo_gy_batch_set(ctx, gy_batch);
713716
data->gyro_batch_odr = gy_batch;
714717
#if defined(CONFIG_LSM6DSVXXX_ENABLE_TEMP)

drivers/sensor/st/lsm6dsvxxx/lsm6dsv80x.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,7 @@ static void lsm6dsv80x_config_fifo(const struct device *dev, struct trigger_conf
656656
lsm6dsv80x_sflp_data_rate_t sflp_odr = LSM6DSV80X_SFLP_120Hz;
657657
lsm6dsv80x_fifo_sflp_raw_t sflp_fifo = {0};
658658
lsm6dsv80x_sflp_gbias_t gbias;
659+
uint8_t xl_hg_batch = 0;
659660

660661
/* disable FIFO as first thing */
661662
lsm6dsv80x_fifo_mode_set(ctx, LSM6DSV80X_BYPASS_MODE);
@@ -670,6 +671,7 @@ static void lsm6dsv80x_config_fifo(const struct device *dev, struct trigger_conf
670671
xl_batch = config->accel_batch;
671672
gy_batch = config->gyro_batch;
672673
temp_batch = config->temp_batch;
674+
xl_hg_batch = (lsm6dsv80x_is_hg_fs(config->accel_range)) ? 1 : 0;
673675

674676
fifo_mode = LSM6DSV80X_STREAM_MODE;
675677
fifo_wtm = config->fifo_wtm;
@@ -701,6 +703,7 @@ static void lsm6dsv80x_config_fifo(const struct device *dev, struct trigger_conf
701703
/* Set FIFO batch rates */
702704
lsm6dsv80x_fifo_xl_batch_set(ctx, xl_batch);
703705
data->accel_batch_odr = xl_batch;
706+
lsm6dsv80x_fifo_hg_xl_batch_set(ctx, xl_hg_batch);
704707
lsm6dsv80x_fifo_gy_batch_set(ctx, gy_batch);
705708
data->gyro_batch_odr = gy_batch;
706709
#if defined(CONFIG_LSM6DSVXXX_ENABLE_TEMP)

drivers/sensor/st/lsm6dsvxxx/lsm6dsvxxx_decoder.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ static int lsm6dsvxxx_decoder_get_frame_count(const uint8_t *buffer,
162162
fifo_tag = (buffer[0] >> 3);
163163

164164
switch (fifo_tag) {
165+
case LSM6DSVXXX_XL_HG_TAG:
165166
case LSM6DSVXXX_XL_NC_TAG:
166167
tot_accel_fifo_words++;
167168
break;
@@ -292,6 +293,7 @@ static int lsm6dsvxxx_decode_fifo(const uint8_t *buffer, struct sensor_chan_spec
292293
fifo_tag = (buffer[0] >> 3);
293294

294295
switch (fifo_tag) {
296+
case LSM6DSVXXX_XL_HG_TAG:
295297
case LSM6DSVXXX_XL_NC_TAG: {
296298
struct sensor_three_axis_data *out = data_out;
297299
int16_t x, y, z;

0 commit comments

Comments
 (0)