Soletta™ Framework
|
IIO (Linux Industrial I/O) API for Soletta. More...
Data Structures | |
struct | sol_iio_channel_config |
A configuration struct for an IIO channel. More... | |
struct | sol_iio_config |
A configuration struct for an IIO device. More... | |
Macros | |
#define | SOL_IIO_CHANNEL_CONFIG_INIT |
Macro that may be used for initialized a sol_iio_channel_config. More... | |
Typedefs | |
typedef struct sol_iio_channel | sol_iio_channel |
An IIO channel handle. More... | |
typedef struct sol_iio_channel_config | sol_iio_channel_config |
A configuration struct for an IIO channel. More... | |
typedef struct sol_iio_config | sol_iio_config |
A configuration struct for an IIO device. More... | |
typedef struct sol_iio_device | sol_iio_device |
An IIO device handle. More... | |
Functions | |
struct sol_iio_channel * | sol_iio_add_channel (struct sol_iio_device *device, const char *name, const struct sol_iio_channel_config *config) |
Add reading channel. More... | |
int | sol_iio_address_device (const char *commands) |
Address an IIO device from a list of commands to find them. More... | |
const char * | sol_iio_channel_get_name (const struct sol_iio_channel *channel) |
Gets the configuration attribute name of a channel. More... | |
void | sol_iio_close (struct sol_iio_device *device) |
Close an IIO device. More... | |
int | sol_iio_device_get_offset (const struct sol_iio_device *device, const char *prefix_name, double *offset) |
Gets the configuration offset attribute from one device. More... | |
int | sol_iio_device_get_sampling_frequency (const struct sol_iio_device *device, const char *prefix_name, int *sampling_frequency) |
Gets the configuration sampling_frequency attribute from one device. More... | |
int | sol_iio_device_get_scale (const struct sol_iio_device *device, const char *prefix_name, double *scale) |
Gets the configuration scale attribute from one device. More... | |
int | sol_iio_device_start_buffer (struct sol_iio_device *device) |
Start reading device buffer. More... | |
int | sol_iio_device_trigger (struct sol_iio_device *device) |
Manually 'pull' device current trigger. More... | |
int | sol_iio_mount_calibration (struct sol_iio_device *device, sol_direction_vector *value) |
Perform the mount calibration. More... | |
struct sol_iio_device * | sol_iio_open (int id, const struct sol_iio_config *config) |
Open an IIO device. More... | |
struct sol_str_slice | sol_iio_read_channel_raw_buffer (struct sol_iio_channel *channel) |
Returns raw buffer with channel sample. More... | |
int | sol_iio_read_channel_value (struct sol_iio_channel *channel, double *value) |
Read channel value. More... | |
IIO (Linux Industrial I/O) API for Soletta.
#define SOL_IIO_CHANNEL_CONFIG_INIT |
Macro that may be used for initialized a sol_iio_channel_config.
This macro will init a with default values a sol_iio_channel_config. It'll start with scale -1.0
and without custom offset.
Referenced by main().
An IIO channel handle.
typedef struct sol_iio_channel_config sol_iio_channel_config |
A configuration struct for an IIO channel.
typedef struct sol_iio_config sol_iio_config |
A configuration struct for an IIO device.
An IIO device handle.
struct sol_iio_channel* sol_iio_add_channel | ( | struct sol_iio_device * | device, |
const char * | name, | ||
const struct sol_iio_channel_config * | config | ||
) |
Add reading channel.
device | IIO handle of device to which channel is being add |
name | Name of channel. Eg 'in_anglvel_x'. |
config | Channel config. |
Referenced by main().
int sol_iio_address_device | ( | const char * | commands | ) |
Address an IIO device from a list of commands to find them.
IIO devices may exist on sysfs after being plugged, or need to be explicitly created if, for instance, they use I2C or SPI interfaces. This function provides a way of addressing an IIO device to get its IIO id from a series of space separated commands. Commands are processed from left to right and processing stops on first command that worked. IIO device id will be returned, or a negative number if no command resolved to an IIO device.
There are essentially five commands. It can be an absolute path (starting with '/') pointing to sysfs dir of device. Alternatively, it can be i2c/X-YYYY
, for i2c device, where X is the bus number and YYYY is the device number, eg, 7-0069
for device 0x69 on bus 7. If its a raw number, will be interpreted as IIO device id and this function will only check the id. It can also be device name, as it appears on 'name' file on sysfs. Finally, it can describe a command to create an IIO device. In this case, command is a combination on the form create,<bus_type>,<rel_path>,<devnumber>,<devname>
If device already exists, will just return its IIO id.
commands | space separated commands on format specified above. e.g. l3g4200d create,i2c,platform/80860F41:05,0x69,l3g4200d |
Referenced by main().
const char* sol_iio_channel_get_name | ( | const struct sol_iio_channel * | channel | ) |
Gets the configuration attribute name of a channel.
channel | sol_iio_channel structure which the name is desired. |
NULL
on error. void sol_iio_close | ( | struct sol_iio_device * | device | ) |
int sol_iio_device_get_offset | ( | const struct sol_iio_device * | device, |
const char * | prefix_name, | ||
double * | offset | ||
) |
Gets the configuration offset attribute from one device.
device | The sol_iio_device structure which the offset is desired |
prefix_name | pointer to the attribute name Eg: "in_anglvel_x" |
offset | data to be get from attribute name |
int sol_iio_device_get_sampling_frequency | ( | const struct sol_iio_device * | device, |
const char * | prefix_name, | ||
int * | sampling_frequency | ||
) |
Gets the configuration sampling_frequency attribute from one device.
device | The sol_iio_device structure which the sampling_frequency is desired |
prefix_name | pointer to the attribute name Eg: "in_anglvel" |
sampling_frequency | data to be get from attribute name |
int sol_iio_device_get_scale | ( | const struct sol_iio_device * | device, |
const char * | prefix_name, | ||
double * | scale | ||
) |
Gets the configuration scale attribute from one device.
device | The sol_iio_device structure which the scale is desired |
prefix_name | pointer to the attribute name Eg: "in_anglvel_x" |
scale | data to be get from attribute name |
int sol_iio_device_start_buffer | ( | struct sol_iio_device * | device | ) |
Start reading device buffer.
Reading on buffer should start after all channels were enabled (which is done when a channel is added using sol_iio_add_channel()). So, call this function after having added all channels. Reading here means that the buffer will be opened; when real readings happens the callback set on config will be called.
device | IIO handler of device on which reading will be performed |
Referenced by main().
int sol_iio_device_trigger | ( | struct sol_iio_device * | device | ) |
Manually 'pull' device current trigger.
If device current trigger has a 'trigger_now' file that start a reading on device, writes to it to produce a new reading
device | IIO handler of device to have its trigger manually 'pulled'. |
int sol_iio_mount_calibration | ( | struct sol_iio_device * | device, |
sol_direction_vector * | value | ||
) |
Perform the mount calibration.
This function is meaningful only when mount_matrix is supported.
device | device to get mount matrix |
value | data to be calibrated |
Referenced by iio_gyroscope_reader_cb().
struct sol_iio_device* sol_iio_open | ( | int | id, |
const struct sol_iio_config * | config | ||
) |
Open an IIO device.
Using different channel_id and the same configuration, one device can be opened multiple times
id | Id of iio device. It's the number which identifies device on file system. Can be found at '/sys/bus/iio/devices/iio:deviceX'. |
config | IIO config. |
Referenced by main().
struct sol_str_slice sol_iio_read_channel_raw_buffer | ( | struct sol_iio_channel * | channel | ) |
Returns raw buffer with channel sample.
This function is meaningful only when buffer is enabled. Useful for reading samples bigger than 64 bits. For channels with 64 or less bits, prefer sol_iio_read_channel_value
, with return a more meaningful value, adjusted by channel offset and scale.
channel | channel to get raw buffer |
int sol_iio_read_channel_value | ( | struct sol_iio_channel * | channel, |
double * | value | ||
) |
Read channel value.
If buffer is enabled, it will read from last buffer data. Callback 'sol_iio_reader_cb' is called when there are new data on buffer. If buffer is disabled, will read from channel file on sysfs.
channel | IIO channel handle to be read |
value | Where read value will be stored |
Referenced by iio_gyroscope_reader_cb().