libiio
Classes | Macros | Functions
Debug and low-level functions

Classes

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

Macros

#define iio_device_debug_attr_read(dev, attr, ptr)
 Read the content of the given debug attribute. More...
 
#define iio_device_debug_attr_write(dev, attr, val)
 Set the value of the given debug attribute. More...
 

Functions

__api struct iio_channels_maskiio_create_channels_mask (unsigned int nb_channels)
 Create a new empty channels mask. More...
 
__api void iio_channels_mask_destroy (struct iio_channels_mask *mask)
 Destroy a channels mask. More...
 
__api __check_ret ssize_t iio_device_get_sample_size (const struct iio_device *dev, const struct iio_channels_mask *mask)
 Get the current sample size. More...
 
__api __check_ret __pure long iio_channel_get_index (const struct iio_channel *chn)
 Get the index of the given channel. More...
 
__api __check_ret __cnst const struct iio_data_formatiio_channel_get_data_format (const struct iio_channel *chn)
 Get a pointer to a channel's data format structure. More...
 
__api void iio_channel_convert (const struct iio_channel *chn, void *dst, const void *src)
 Convert the sample from hardware format to host format. More...
 
__api void iio_channel_convert_inverse (const struct iio_channel *chn, void *dst, const void *src)
 Convert the sample from host format to hardware format. More...
 
__api __check_ret __pure unsigned int iio_device_get_debug_attrs_count (const struct iio_device *dev)
 Enumerate the debug attributes of the given device. More...
 
__api __check_ret __pure const char * iio_device_get_debug_attr (const struct iio_device *dev, unsigned int index)
 Get the debug attribute present at the given index. More...
 
__api __check_ret __pure const char * iio_device_find_debug_attr (const struct iio_device *dev, const char *name)
 Try to find a debug attribute by its name. More...
 
__api __check_ret ssize_t iio_device_debug_attr_read_raw (const struct iio_device *dev, const char *attr, char *dst, size_t len)
 Read the content of the given debug attribute. More...
 
__api __check_ret ssize_t iio_device_debug_attr_write_raw (const struct iio_device *dev, const char *attr, const void *src, size_t len)
 Set the value of the given debug attribute. More...
 
__api __check_ret int iio_device_identify_filename (const struct iio_device *dev, const char *filename, struct iio_channel **chn, const char **attr)
 Identify the channel or debug attribute corresponding to a filename. More...
 
__api __check_ret int iio_device_reg_write (struct iio_device *dev, uint32_t address, uint32_t value)
 Set the value of a hardware register. More...
 
__api __check_ret int iio_device_reg_read (struct iio_device *dev, uint32_t address, uint32_t *value)
 Get the value of a hardware register. More...
 

Detailed Description

Macro Definition Documentation

◆ iio_device_debug_attr_read

#define iio_device_debug_attr_read (   dev,
  attr,
  ptr 
)
Value:
_Generic((ptr), \
bool *: iio_device_debug_attr_read_bool, \
long long *: iio_device_debug_attr_read_longlong, \
double *: iio_device_debug_attr_read_double)(dev, attr, ptr)

Read the content of the given debug attribute.

Parameters
devA pointer to an iio_device structure
attrA NULL-terminated string corresponding to the name of the debug attribute
ptrA pointer to a variable where the value should be stored
Returns
On success, 0 is returned
On error, a negative errno code is returned

◆ iio_device_debug_attr_write

#define iio_device_debug_attr_write (   dev,
  attr,
  val 
)
Value:
_Generic((val), \
const char *: iio_device_debug_attr_write_string, \
char *: iio_device_debug_attr_write_string, \
bool: iio_device_debug_attr_write_bool, \
long long: iio_device_debug_attr_write_longlong, \
double: iio_device_debug_attr_write_double)(dev, attr, val)

Set the value of the given debug attribute.

Parameters
devA pointer to an iio_device structure
attrA NULL-terminated string corresponding to the name of the debug attribute
valA double value to set the debug attribute to
Returns
On success, 0 is returned
On error, a negative errno code is returned

Function Documentation

◆ iio_channel_convert()

__api 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()

__api 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()

__api __check_ret __cnst 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()

__api __check_ret __pure 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_channels_mask_destroy()

__api 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()

__api 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_debug_attr_read_raw()

__api __check_ret ssize_t iio_device_debug_attr_read_raw ( const struct iio_device dev,
const char *  attr,
char *  dst,
size_t  len 
)

Read the content of the given debug attribute.

Parameters
devA pointer to an iio_device structure
attrA NULL-terminated string corresponding to the name of the debug attribute
dstA pointer to the memory area where the NULL-terminated string corresponding to the value read will be stored
lenThe available length of the memory area, in bytes
Returns
On success, the number of bytes written to the buffer
On error, a negative errno code is returned

◆ iio_device_debug_attr_write_raw()

__api __check_ret ssize_t iio_device_debug_attr_write_raw ( const struct iio_device dev,
const char *  attr,
const void *  src,
size_t  len 
)

Set the value of the given debug attribute.

Parameters
devA pointer to an iio_device structure
attrA NULL-terminated string corresponding to the name of the debug attribute
srcA pointer to the data to be written
lenThe number of bytes that should be written
Returns
On success, the number of bytes written
On error, a negative errno code is returned

◆ iio_device_find_debug_attr()

__api __check_ret __pure const char* 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

NOTE: This function is useful to detect the presence of a debug attribute. It can also be used to retrieve the name of a debug attribute as a pointer to a static string from a dynamically allocated string.

◆ iio_device_get_debug_attr()

__api __check_ret __pure const char* 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()

__api __check_ret __pure 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_sample_size()

__api __check_ret 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. If NULL, the current channel mask of the iio_device object is used.
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_identify_filename()

__api __check_ret int iio_device_identify_filename ( const struct iio_device dev,
const char *  filename,
struct iio_channel **  chn,
const char **  attr 
)

Identify the channel or debug attribute corresponding to a filename.

Parameters
devA pointer to an iio_device structure
filenameA NULL-terminated string corresponding to the filename
chnA pointer to a pointer of an iio_channel structure. The pointed pointer will be set to the address of the iio_channel structure if the filename correspond to the attribute of a channel, or NULL otherwise.
attrA pointer to a NULL-terminated string. The pointer pointer will be set to point to the name of the attribute corresponding to the filename.
Returns
On success, 0 is returned, and *chn and *attr are modified.
On error, a negative errno code is returned. *chn and *attr are not modified.

◆ iio_device_reg_read()

__api __check_ret 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()

__api __check_ret 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