My Project
Loading...
Searching...
No Matches
Debug and low-level functions

Classes

struct  iio_data_format
 Contains the format of a data sample. More...

Functions

struct iio_channels_mask * iio_create_channels_mask (unsigned int nb_channels)
 Create a new empty channels mask.
void iio_channels_mask_destroy (struct iio_channels_mask *mask)
 Destroy a channels mask.
ssize_t iio_device_get_sample_size (const struct iio_device *dev, const struct iio_channels_mask *mask)
 Get the current sample size.
long iio_channel_get_index (const struct iio_channel *chn)
 Get the index of the given channel.
const struct iio_data_format * iio_channel_get_data_format (const struct iio_channel *chn)
 Get a pointer to a channel's data format structure.
void iio_channel_convert (const struct iio_channel *chn, void *dst, const void *src)
 Convert the sample from hardware format to host format.
void iio_channel_convert_inverse (const struct iio_channel *chn, void *dst, const void *src)
 Convert the sample from host format to hardware format.
int iio_channel_refresh_format (struct iio_channel *chn)
 Refresh the data format of a scan element channel from hardware.
unsigned int iio_device_get_event_attrs_count (const struct iio_device *dev)
 Enumerate the event attributes of the given device.
const struct iio_attr * iio_device_get_event_attr (const struct iio_device *dev, unsigned int index)
 Get the event attribute present at the given index.
const struct iio_attr * iio_device_find_event_attr (const struct iio_device *dev, const char *name)
 Try to find an event attribute by its name.
unsigned int iio_device_get_debug_attrs_count (const struct iio_device *dev)
 Enumerate the debug attributes of the given device.
const struct iio_attr * iio_device_get_debug_attr (const struct iio_device *dev, unsigned int index)
 Get the debug attribute present at the given index.
const struct iio_attr * iio_device_find_debug_attr (const struct iio_device *dev, const char *name)
 Try to find a debug attribute by its name.
int iio_device_reg_write (struct iio_device *dev, uint32_t address, uint32_t value)
 Set the value of a hardware register.
int iio_device_reg_read (struct iio_device *dev, uint32_t address, uint32_t *value)
 Get the value of a hardware register.

Detailed Description

Function Documentation

◆ iio_channel_convert()

void iio_channel_convert ( const struct iio_channel * chn,
void * dst,
const void * src )

Convert the sample from hardware format to host format.

Parameters
chnA pointer to an iio_channel structure
dstA pointer to the destination buffer where the converted sample should be written
srcA pointer to the source buffer containing the sample

◆ iio_channel_convert_inverse()

void iio_channel_convert_inverse ( const struct iio_channel * chn,
void * dst,
const void * src )

Convert the sample from host format to hardware format.

Parameters
chnA pointer to an iio_channel structure
dstA pointer to the destination buffer where the converted sample should be written
srcA pointer to the source buffer containing the sample

◆ iio_channel_get_data_format()

const struct iio_data_format * iio_channel_get_data_format ( const struct iio_channel * chn)

Get a pointer to a channel's data format structure.

Parameters
chnA pointer to an iio_channel structure
Returns
A pointer to the channel's iio_data_format structure

◆ iio_channel_get_index()

long iio_channel_get_index ( const struct iio_channel * chn)

Get the index of the given channel.

Parameters
chnA pointer to an iio_channel structure
Returns
On success, the index of the specified channel
On error, a negative errno code is returned

◆ iio_channel_refresh_format()

int iio_channel_refresh_format ( struct iio_channel * chn)

Refresh the data format of a scan element channel from hardware.

Parameters
chnA pointer to an iio_channel structure
Returns
On success, 0 is returned
On error, a negative errno code is returned

This function re-reads the scan element type attribute from the kernel and updates the cached data format. Use this when the hardware format may have changed (e.g., after changing oversampling or resolution).

The channel must be a scan element. For non-scan-element channels, this returns -EINVAL.

IMPORTANT: Call this function BEFORE opening a new buffer stream after changing any attribute that affects channel format.

Example usage:

// Change hardware configuration
iio_channel_attr_write(chn, "oversampling_ratio", "8");
// Refresh the format (updates both client and server)
// Now safe to open buffer with updated format
buf_stream = iio_buffer_open(buf, mask);
struct iio_buffer_stream * iio_buffer_open(struct iio_buffer *buf, const struct iio_channels_mask *mask)
Open a buffer for data streaming.
int iio_channel_refresh_format(struct iio_channel *chn)
Refresh the data format of a scan element channel from hardware.

◆ iio_channels_mask_destroy()

void iio_channels_mask_destroy ( struct iio_channels_mask * mask)

Destroy a channels mask.

Parameters
maskA pointer to an iio_channels_mask structure

◆ iio_create_channels_mask()

struct iio_channels_mask * iio_create_channels_mask ( unsigned int nb_channels)

Create a new empty channels mask.

Parameters
nb_channelsThe number of channels in the mask
Returns
On success, a pointer to an iio_channels_mask structure
On error, NULL is returned

◆ iio_device_find_debug_attr()

const struct iio_attr * iio_device_find_debug_attr ( const struct iio_device * dev,
const char * name )

Try to find a debug attribute by its name.

Parameters
devA pointer to an iio_device structure
nameA NULL-terminated string corresponding to the name of the debug attribute
Returns
On success, a pointer to a static NULL-terminated string
If the name does not correspond to any known debug attribute of the given device, NULL is returned

◆ iio_device_find_event_attr()

const struct iio_attr * iio_device_find_event_attr ( const struct iio_device * dev,
const char * name )

Try to find an event attribute by its name.

Parameters
devA pointer to an iio_device structure
nameA NULL-terminated string corresponding to the name of the event attribute
Returns
On success, a pointer to an iio_attr structure
If the name does not correspond to any known event attribute of the given device, NULL is returned

◆ iio_device_get_debug_attr()

const struct iio_attr * iio_device_get_debug_attr ( const struct iio_device * dev,
unsigned int index )

Get the debug attribute present at the given index.

Parameters
devA pointer to an iio_device structure
indexThe index corresponding to the debug attribute
Returns
On success, a pointer to a static NULL-terminated string
If the index is invalid, NULL is returned

◆ iio_device_get_debug_attrs_count()

unsigned int iio_device_get_debug_attrs_count ( const struct iio_device * dev)

Enumerate the debug attributes of the given device.

Parameters
devA pointer to an iio_device structure
Returns
The number of debug attributes found

◆ iio_device_get_event_attr()

const struct iio_attr * iio_device_get_event_attr ( const struct iio_device * dev,
unsigned int index )

Get the event attribute present at the given index.

Parameters
devA pointer to an iio_device structure
indexThe index corresponding to the event attribute
Returns
On success, a pointer to an iio_attr structure
If the index is invalid, NULL is returned

◆ iio_device_get_event_attrs_count()

unsigned int iio_device_get_event_attrs_count ( const struct iio_device * dev)

Enumerate the event attributes of the given device.

Parameters
devA pointer to an iio_device structure
Returns
The number of event attributes found

◆ iio_device_get_sample_size()

ssize_t iio_device_get_sample_size ( const struct iio_device * dev,
const struct iio_channels_mask * mask )

Get the current sample size.

Parameters
devA pointer to an iio_device structure
maskA pointer to an iio_channels_mask structure.
Returns
On success, the sample size in bytes
On error, a negative errno code is returned

NOTE: The sample size is not constant and will change when channels get enabled or disabled.

◆ iio_device_reg_read()

int iio_device_reg_read ( struct iio_device * dev,
uint32_t address,
uint32_t * value )

Get the value of a hardware register.

Parameters
devA pointer to an iio_device structure
addressThe address of the register
valueA pointer to the variable where the value will be written
Returns
On success, 0 is returned
On error, a negative errno code is returned

◆ iio_device_reg_write()

int iio_device_reg_write ( struct iio_device * dev,
uint32_t address,
uint32_t value )

Set the value of a hardware register.

Parameters
devA pointer to an iio_device structure
addressThe address of the register
valueThe value to set the register to
Returns
On success, 0 is returned
On error, a negative errno code is returned