mraa  1.8.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

mraa_iio_context iio_device0 = mraa_iio_init(0);
if (iio_device0 == NULL) {
return EXIT_FAILURE;
}
float iio_float;
int iio_int;
ret = mraa_iio_write_float(iio_device0, "in_accel_scale", 0.019163);
if (ret == MRAA_SUCCESS) {
fprintf(stdout, "IIO write success\n");
}
ret = mraa_iio_read_float(iio_device0, "in_accel_scale", &iio_float);
if (ret == MRAA_SUCCESS) {
fprintf(stdout, "IIO read %f\n", iio_float);
}
ret = mraa_iio_write_int(iio_device0, "scan_elements/in_accel_x_en", 1);
if (ret == MRAA_SUCCESS) {
fprintf(stdout, "IIO write success\n");
}
ret = mraa_iio_read_int(iio_device0, "scan_elements/in_accel_x_en", &iio_int);
if (ret == MRAA_SUCCESS) {
fprintf(stdout, "IIO read %d\n", iio_int);
}
if (mraa_iio_trigger_buffer(iio_device0, interrupt, (void*)iio_device0) == MRAA_SUCCESS) {
sleep(100);
return EXIT_SUCCESS;
}
/*
struct iio_event_data event;
iio_device6 = mraa_iio_init(6);
if (iio_device6 == NULL) {
return EXIT_FAILURE;
}
mraa_iio_write_int(iio_device6, "events/in_proximity2_thresh_either_en", 1);
// Blocking until event fired
if (mraa_iio_event_poll(iio_device6, &event) == MRAA_SUCCESS) {
event_interrupt(&event); //just to show data
}
if (mraa_iio_event_setup_callback(iio_device6, event_interrupt, NULL) == MRAA_SUCCESS) {
sleep(100);
return EXIT_SUCCESS;
}*/

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: