Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions drivers/sensor/tdk/icm45686/icm45686.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ static int icm45686_init(const struct device *dev)
.lpf = DT_INST_PROP_OR(inst, gyro_lpf, 0), \
}, \
.fifo_watermark = DT_INST_PROP_OR(inst, fifo_watermark, 0), \
.fifo_watermark_equals = DT_INST_PROP(inst, fifo_watermark_equals), \
}, \
.int_gpio = GPIO_DT_SPEC_INST_GET_OR(inst, int_gpios, {0}), \
}; \
Expand Down
1 change: 1 addition & 0 deletions drivers/sensor/tdk/icm45686/icm45686.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ struct icm45686_config {
uint8_t lpf : 3;
} gyro;
uint16_t fifo_watermark;
bool fifo_watermark_equals : 1;
} settings;
struct gpio_dt_spec int_gpio;
};
Expand Down
7 changes: 5 additions & 2 deletions drivers/sensor/tdk/icm45686/icm45686_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ static void icm45686_complete_handler(struct rtio *ctx,
{
const struct device *dev = (const struct device *)arg;
struct icm45686_data *data = dev->data;
const struct icm45686_config *cfg = dev->config;
const struct sensor_read_config *read_cfg = data->stream.iodev_sqe->sqe.iodev->data;
const bool wm_gt_ths = !cfg->settings.fifo_watermark_equals;
uint8_t int_status = data->stream.data.int_status;
int err;

Expand All @@ -152,7 +154,7 @@ static void icm45686_complete_handler(struct rtio *ctx,

if (should_flush_fifo(read_cfg, int_status)) {
uint8_t write_reg = REG_FIFO_CONFIG2_FIFO_FLUSH(true) |
REG_FIFO_CONFIG2_FIFO_WM_GT_THS(true);
REG_FIFO_CONFIG2_FIFO_WM_GT_THS(wm_gt_ths);
LOG_WRN("Flushing FIFO: %d", int_status);

err = icm45686_prep_reg_write_rtio_async(&data->bus, REG_FIFO_CONFIG2, &write_reg,
Expand Down Expand Up @@ -367,6 +369,7 @@ void icm45686_stream_submit(const struct device *dev,
const struct sensor_read_config *read_cfg = iodev_sqe->sqe.iodev->data;
struct icm45686_data *data = dev->data;
const struct icm45686_config *cfg = dev->config;
const bool wm_gt_ths = !cfg->settings.fifo_watermark_equals;
uint8_t val = 0;
int err;

Expand Down Expand Up @@ -468,7 +471,7 @@ void icm45686_stream_submit(const struct device *dev,
uint16_t fifo_ths = data->stream.settings.enabled.fifo_ths ?
cfg->settings.fifo_watermark : 0;

val = REG_FIFO_CONFIG2_FIFO_WM_GT_THS(true) |
val = REG_FIFO_CONFIG2_FIFO_WM_GT_THS(wm_gt_ths) |
REG_FIFO_CONFIG2_FIFO_FLUSH(true);
err = icm45686_reg_write_rtio(&data->bus, REG_FIFO_CONFIG2, &val, 1);
if (err) {
Expand Down
9 changes: 9 additions & 0 deletions dts/bindings/sensor/invensense,icm45686-common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,12 @@ properties:
Specify the FIFO watermark level in frame count.
Default is power-up configuration (disabled).
Valid range: 0 - 104

fifo-watermark-equals:
type: boolean
description: |
This value changes the FIFO watermark interrupt behavior by only triggering when the number
of samples is equal to the threshold (count = watermark).

Otherwise, it will generate interrupts when the level is greater or equals the FIFO Watermark
Threshold (count >= watermark).