Skip to content

Commit

Permalink
sensor: icm42688: fix One-shot decoder to only return requested fields
Browse files Browse the repository at this point in the history
Otherwise clients will get the impression there are frames for values
that have not been retrieved.

Signed-off-by: Luis Ubieda <[email protected]>
  • Loading branch information
ubieda authored and kartben committed Feb 11, 2025
1 parent f850634 commit 4e4ec9c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions drivers/sensor/tdk/icm42688/icm42688_decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -515,12 +515,21 @@ static int icm42688_decoder_get_frame_count(const uint8_t *buffer,
uint16_t *frame_count)
{
const struct icm42688_fifo_data *data = (const struct icm42688_fifo_data *)buffer;
const struct icm42688_encoded_data *enc_data = (const struct icm42688_encoded_data *)buffer;
const struct icm42688_decoder_header *header = &data->header;

if (chan_spec.chan_idx != 0) {
return -ENOTSUP;
}

uint8_t channel_request = icm42688_encode_channel(chan_spec.chan_type);


if ((!enc_data->header.is_fifo) &&
(enc_data->channels & channel_request) != channel_request) {
return -ENODATA;
}

if (!header->is_fifo) {
switch (chan_spec.chan_type) {
case SENSOR_CHAN_ACCEL_X:
Expand Down

0 comments on commit 4e4ec9c

Please sign in to comment.