mraa  2.0.0
Low Level Skeleton Library for Communication on GNU/Linux platforms
Data Structures | Functions | Typedefs
iio.h File Reference

API Description

An iio context represents an IIO device

/* initialize iio */
iio = mraa_iio_init(IIO_DEV);
if (iio == NULL) {
fprintf(stderr, "Failed to initialize IIO device\n");
return EXIT_FAILURE;
}
status = mraa_iio_write_float(iio, "in_accel_scale", 0.019163);
if (status != MRAA_SUCCESS) {
fprintf(stderr, "Failed to write scale to IIO device\n");
goto err_exit;
}
status = mraa_iio_read_float(iio, "in_accel_scale", &iio_float);
if (status != MRAA_SUCCESS) {
fprintf(stderr, "Failed to read scale from IIO device\n");
goto err_exit;
}
fprintf(stdout, "IIO scale: %f\n", iio_float);
status = mraa_iio_write_int(iio, "scan_elements/in_accel_x_en", 1);
if (status != MRAA_SUCCESS) {
fprintf(stderr, "Failed to enable axis of the IIO device\n");
goto err_exit;
}
status = mraa_iio_read_int(iio, "scan_elements/in_accel_x_en", &iio_int);
if (status != MRAA_SUCCESS) {
fprintf(stderr, "Failed to read enable status from IIO device\n");
goto err_exit;
}
fprintf(stdout, "IIO enable status: %d\n", iio_int);
status = mraa_iio_trigger_buffer(iio, interrupt, (void*) iio);
if (status != MRAA_SUCCESS) {
fprintf(stderr, "Failed to set IIO buffer trigger\n");
goto err_exit;
}
/* wait for the trigger */
fprintf(stdout, "Waiting for the trigger...\n");
sleep(100);
/* close IIO device */

Go to the source code of this file.

Data Structures

struct  mraa_iio_channel
 
struct  mraa_iio_event
 

Functions

mraa_iio_context mraa_iio_init (int device)
 
mraa_result_t mraa_iio_trigger_buffer (mraa_iio_context dev, void(*fptr)(char *, void *), void *args)
 
const char * mraa_iio_get_device_name (mraa_iio_context dev)
 
int mraa_iio_get_device_num_by_name (const char *name)
 
int mraa_iio_read_size (mraa_iio_context dev)
 
mraa_iio_channelmraa_iio_get_channels (mraa_iio_context dev)
 
int mraa_iio_get_channel_count (mraa_iio_context dev)
 
mraa_result_t mraa_iio_read_float (mraa_iio_context dev, const char *filename, float *data)
 
mraa_result_t mraa_iio_read_int (mraa_iio_context dev, const char *filename, int *data)
 
mraa_result_t mraa_iio_read_string (mraa_iio_context dev, const char *filename, char *data, int max_len)
 
mraa_result_t mraa_iio_write_float (mraa_iio_context dev, const char *attr_chan, const float data)
 
mraa_result_t mraa_iio_write_int (mraa_iio_context dev, const char *attr_chan, const int data)
 
mraa_result_t mraa_iio_write_string (mraa_iio_context dev, const char *attr_chan, const char *data)
 
mraa_result_t mraa_iio_get_channel_data (mraa_iio_context dev)
 
mraa_result_t mraa_iio_get_event_data (mraa_iio_context dev)
 
mraa_result_t mraa_iio_event_poll (mraa_iio_context dev, struct iio_event_data *data)
 
mraa_result_t mraa_iio_event_setup_callback (mraa_iio_context dev, void(*fptr)(struct iio_event_data *data, void *args), void *args)
 
mraa_result_t mraa_iio_event_extract_event (struct iio_event_data *event, int *chan_type, int *modifier, int *type, int *direction, int *channel, int *channel2, int *different)
 
mraa_result_t mraa_iio_get_mount_matrix (mraa_iio_context dev, const char *sysfs_name, float mm[9])
 
mraa_result_t mraa_iio_create_trigger (mraa_iio_context dev, const char *trigger)
 
mraa_result_t mraa_iio_update_channels (mraa_iio_context dev)
 
mraa_result_t mraa_iio_close (mraa_iio_context dev)
 

Typedefs

typedef struct _iio * mraa_iio_context
 

Function Documentation

mraa_iio_context mraa_iio_init ( int  device)

Initialise iio context

Parameters
deviceiio device to use
Returns
i2c context or NULL

Here is the caller graph for this function:

mraa_result_t mraa_iio_trigger_buffer ( mraa_iio_context  dev,
void(*)(char *, void *)  fptr,
void *  args 
)

Trigger buffer

Parameters
devThe iio context
fptrCallback
argsArguments
Returns
Result of operation
const char* mraa_iio_get_device_name ( mraa_iio_context  dev)

Get device name

Parameters
devThe iio context
Returns
Name of the device

Here is the caller graph for this function:

int mraa_iio_get_device_num_by_name ( const char *  name)

Get device number

Parameters
nameName of the device
Returns
Device Number

Here is the caller graph for this function:

int mraa_iio_read_size ( mraa_iio_context  dev)

Read size

Parameters
devThe iio context
Returns
Size
mraa_iio_channel* mraa_iio_get_channels ( mraa_iio_context  dev)

Get channels

Parameters
devThe iio context
Returns
Channels
int mraa_iio_get_channel_count ( mraa_iio_context  dev)

Get channels count

Parameters
devThe iio context
Returns
Channels count
mraa_result_t mraa_iio_read_float ( mraa_iio_context  dev,
const char *  filename,
float *  data 
)

Read float from file

Parameters
devThe iio context
filenameFilename
dataData
Returns
Result of operation

Here is the caller graph for this function:

mraa_result_t mraa_iio_read_int ( mraa_iio_context  dev,
const char *  filename,
int *  data 
)

Read int from file

Parameters
devThe iio context
filenameFilename
dataData
Returns
Result of operation

Here is the caller graph for this function:

mraa_result_t mraa_iio_read_string ( mraa_iio_context  dev,
const char *  filename,
char *  data,
int  max_len 
)

Read String from file

Parameters
devThe iio context
filenameFilename
dataData
max_lenMax lenght to read
Returns
Result of operation
mraa_result_t mraa_iio_write_float ( mraa_iio_context  dev,
const char *  attr_chan,
const float  data 
)

Write float

Parameters
devThe iio context
attr_chanChannel attributes
dataFloat to write
Returns
Result of operation

Here is the caller graph for this function:

mraa_result_t mraa_iio_write_int ( mraa_iio_context  dev,
const char *  attr_chan,
const int  data 
)

Write int

Parameters
devThe iio context
attr_chanChannel attributes
dataInt to write
Returns
Result of operation

Here is the caller graph for this function:

mraa_result_t mraa_iio_write_string ( mraa_iio_context  dev,
const char *  attr_chan,
const char *  data 
)

Write string

Parameters
devThe iio context
attr_chanChannel attributes
dataString to write
Returns
Result of operation
mraa_result_t mraa_iio_get_channel_data ( mraa_iio_context  dev)

Get channel data

Parameters
devThe iio context
Returns
Result of operation
mraa_result_t mraa_iio_get_event_data ( mraa_iio_context  dev)

Get event data

Parameters
devThe iio context
Returns
Result of operation
mraa_result_t mraa_iio_event_poll ( mraa_iio_context  dev,
struct iio_event_data data 
)

Event poll

Parameters
devThe iio context
dataData
Returns
Result of operation
mraa_result_t mraa_iio_event_setup_callback ( mraa_iio_context  dev,
void(*)(struct iio_event_data *data, void *args)  fptr,
void *  args 
)

Setup event callback

Parameters
devThe iio context
fptrCallback
argsArguments
Returns
Result of operation

Here is the caller graph for this function:

mraa_result_t mraa_iio_event_extract_event ( struct iio_event_data event,
int *  chan_type,
int *  modifier,
int *  type,
int *  direction,
int *  channel,
int *  channel2,
int *  different 
)

Extract event

Parameters
eventEvent
chan_typeChannel type
modifierModifier
typeType
directionDirection
channelChannel
channel2Channel2
differentDifferent
Returns
Result of operation

Here is the caller graph for this function:

mraa_result_t mraa_iio_get_mount_matrix ( mraa_iio_context  dev,
const char *  sysfs_name,
float  mm[9] 
)

Get mount matrix

Parameters
devThe iio context
sysfs_nameSysfs name
mmMatrix
Returns
Result of operation
mraa_result_t mraa_iio_create_trigger ( mraa_iio_context  dev,
const char *  trigger 
)

Create trigger

Parameters
devThe iio context
triggerTrigger name
Returns
Result of operation
mraa_result_t mraa_iio_update_channels ( mraa_iio_context  dev)

Update channels

Parameters
devThe iio context
Returns
Result of operation
mraa_result_t mraa_iio_close ( mraa_iio_context  dev)

De-inits an mraa_iio_context device

Parameters
devThe iio context
Returns
Result of operation

Here is the caller graph for this function:

Typedef Documentation

typedef struct _iio* mraa_iio_context

Opaque pointer definition to the internal struct _iio

Include dependency graph for iio.h: