Zephyr Project API  3.4.0
A Scalable Open Source RTOS
sensor_decoder_api Struct Reference

Decodes a single raw data buffer. More...

#include <sensor.h>

Data Fields

int(* get_frame_count )(const uint8_t *buffer, uint16_t *frame_count)
 Get the number of frames in the current buffer. More...
 
int(* get_timestamp )(const uint8_t *buffer, uint64_t *timestamp_ns)
 Get the timestamp associated with the first frame. More...
 
int(* get_shift )(const uint8_t *buffer, enum sensor_channel channel_type, int8_t *shift)
 Get the shift count of a particular channel (multiplier) More...
 
int(* decode )(const uint8_t *buffer, sensor_frame_iterator_t *fit, sensor_channel_iterator_t *cit, enum sensor_channel *channels, q31_t *values, uint8_t max_count)
 Decode up to N samples from the buffer. More...
 

Detailed Description

Decodes a single raw data buffer.

Data buffers are provided on the :c:struct:rtio context that's supplied to c:func:sensor_read.

Field Documentation

◆ decode

int(* sensor_decoder_api::decode) (const uint8_t *buffer, sensor_frame_iterator_t *fit, sensor_channel_iterator_t *cit, enum sensor_channel *channels, q31_t *values, uint8_t max_count)

Decode up to N samples from the buffer.

This function will never wrap frames. If 1 channel is available in the current frame and max_count is 2, only 1 channel will be decoded and the frame iterator will be modified so that the next call to decode will begin at the next frame.

Parameters
[in]bufferThe buffer provided on the :c:struct:rtio context
[in,out]fitThe current frame iterator
[in,out]citThe current channel iterator
[out]channelsThe channels that were decoded
[out]valuesThe scaled data that was decoded
[in]max_countThe maximum number of channels to decode.
Returns

◆ get_frame_count

int(* sensor_decoder_api::get_frame_count) (const uint8_t *buffer, uint16_t *frame_count)

Get the number of frames in the current buffer.

Parameters
[in]bufferThe buffer provided on the :c:struct:rtio context.
[out]frame_countThe number of frames on the buffer (at least 1)
Returns
0 on success
<0 on error

◆ get_shift

int(* sensor_decoder_api::get_shift) (const uint8_t *buffer, enum sensor_channel channel_type, int8_t *shift)

Get the shift count of a particular channel (multiplier)

This value can be used by shifting the q31_t value resulting in the SI unit of the reading. It is guaranteed that the shift for a channel will not change between frames.

Parameters
[in]bufferThe buffer provided on the :c:struct:rtio context.
[in]channel_typeThe c:enum:sensor_channel to query
[out]shiftThe bit shift of the channel for this data buffer.
Returns
0 on success
-EINVAL if the channel_type doesn't exist in the buffer
<0 on error

◆ get_timestamp

int(* sensor_decoder_api::get_timestamp) (const uint8_t *buffer, uint64_t *timestamp_ns)

Get the timestamp associated with the first frame.

Parameters
[in]bufferThe buffer provided on the :c:struct:rtio context.
[out]timestamp_nsThe closest timestamp for when the first frame was generated as attained by :c:func:k_uptime_ticks.
Returns
0 on success
<0 on error

The documentation for this struct was generated from the following file: