Skip to content

Commit 2dba777

Browse files
ubiedakartben
authored andcommitted
sensor: adxl345: Add get_size_info API
Used by the sensor-shell in order to retrieve values, otherwise it crashes. Signed-off-by: Luis Ubieda <[email protected]>
1 parent 64d4fcd commit 2dba777

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

drivers/sensor/adi/adxl345/adxl345_decoder.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,33 @@ static bool adxl345_decoder_has_trigger(const uint8_t *buffer, enum sensor_trigg
259259
}
260260
}
261261

262+
static int adxl345_get_size_info(struct sensor_chan_spec channel, size_t *base_size,
263+
size_t *frame_size)
264+
{
265+
__ASSERT_NO_MSG(base_size != NULL);
266+
__ASSERT_NO_MSG(frame_size != NULL);
267+
268+
if (channel.chan_type >= SENSOR_CHAN_ALL) {
269+
return -ENOTSUP;
270+
}
271+
272+
switch (channel.chan_type) {
273+
case SENSOR_CHAN_ACCEL_XYZ:
274+
*base_size = sizeof(struct sensor_three_axis_data);
275+
*frame_size = sizeof(struct sensor_three_axis_sample_data);
276+
return 0;
277+
default:
278+
break;
279+
}
280+
281+
return -ENOTSUP;
282+
}
283+
262284
SENSOR_DECODER_API_DT_DEFINE() = {
263285
.get_frame_count = adxl345_decoder_get_frame_count,
264286
.decode = adxl345_decoder_decode,
265287
.has_trigger = adxl345_decoder_has_trigger,
288+
.get_size_info = adxl345_get_size_info,
266289
};
267290

268291
int adxl345_get_decoder(const struct device *dev, const struct sensor_decoder_api **decoder)

0 commit comments

Comments
 (0)