mraa  2.0.0
Low Level Skeleton Library for Communication on GNU/Linux platforms
iio.h
Go to the documentation of this file.
1 /*
2  * Author: Brendan Le Foll <brendan.le.foll@intel.com>
3  * Copyright (c) 2015 Intel Corporation.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
25 #pragma once
26 
27 #include "common.h"
28 #include "iio_kernel_headers.h"
29 
31 typedef struct {
33  int index;
35  int enabled;
37  char* type;
41  int signedd;
43  unsigned int offset;
45  uint64_t mask;
47  unsigned int bits_used;
49  unsigned int bytes;
51  unsigned int shift;
53  unsigned int location;
55 
57 typedef struct {
59  char* name;
61  int enabled;
63 
73 #ifdef __cplusplus
74 extern "C" {
75 #endif
76 
77 #include <stdlib.h>
78 #include <stdio.h>
79 #include <fcntl.h>
80 #include <stdint.h>
81 
82 #include "common.h"
83 
87 typedef struct _iio* mraa_iio_context;
88 
95 mraa_iio_context mraa_iio_init(int device);
96 
105 mraa_result_t mraa_iio_trigger_buffer(mraa_iio_context dev, void (*fptr)(char*, void*), void* args);
106 
113 const char* mraa_iio_get_device_name(mraa_iio_context dev);
114 
121 int mraa_iio_get_device_num_by_name(const char* name);
122 
129 int mraa_iio_read_size(mraa_iio_context dev);
130 
137 mraa_iio_channel* mraa_iio_get_channels(mraa_iio_context dev);
138 
145 int mraa_iio_get_channel_count(mraa_iio_context dev);
146 
155 mraa_result_t mraa_iio_read_float(mraa_iio_context dev, const char* filename, float* data);
156 
165 mraa_result_t mraa_iio_read_int(mraa_iio_context dev, const char* filename, int* data);
166 
176 mraa_result_t mraa_iio_read_string(mraa_iio_context dev, const char* filename, char* data, int max_len);
177 
186 mraa_result_t mraa_iio_write_float(mraa_iio_context dev, const char* attr_chan, const float data);
187 
196 mraa_result_t mraa_iio_write_int(mraa_iio_context dev, const char* attr_chan, const int data);
197 
206 mraa_result_t mraa_iio_write_string(mraa_iio_context dev, const char* attr_chan, const char* data);
207 
214 mraa_result_t mraa_iio_get_channel_data(mraa_iio_context dev);
215 
222 mraa_result_t mraa_iio_get_event_data(mraa_iio_context dev);
223 
231 mraa_result_t mraa_iio_event_poll(mraa_iio_context dev, struct iio_event_data* data);
232 
242 mraa_iio_event_setup_callback(mraa_iio_context dev, void (*fptr)(struct iio_event_data* data, void* args), void* args);
243 
258  int* chan_type,
259  int* modifier,
260  int* type,
261  int* direction,
262  int* channel,
263  int* channel2,
264  int* different);
265 
273 mraa_result_t mraa_iio_get_mount_matrix(mraa_iio_context dev, const char *sysfs_name, float mm[9]);
274 
282 mraa_result_t mraa_iio_create_trigger(mraa_iio_context dev, const char* trigger);
283 
290 mraa_result_t mraa_iio_update_channels(mraa_iio_context dev);
291 
298 mraa_result_t mraa_iio_close(mraa_iio_context dev);
299 
300 #ifdef __cplusplus
301 }
302 #endif
mraa_result_t mraa_iio_read_int(mraa_iio_context dev, const char *filename, int *data)
mraa_result_t mraa_iio_event_poll(mraa_iio_context dev, struct iio_event_data *data)
int mraa_iio_get_device_num_by_name(const char *name)
mraa_result_t mraa_iio_create_trigger(mraa_iio_context dev, const char *trigger)
int mraa_iio_get_channel_count(mraa_iio_context dev)
mraa_boolean_t lendian
Definition: iio.h:39
unsigned int mraa_boolean_t
Definition: common.h:78
int enabled
Definition: iio.h:35
mraa_result_t mraa_iio_close(mraa_iio_context dev)
mraa_result_t mraa_iio_get_event_data(mraa_iio_context dev)
mraa_result_t mraa_iio_write_float(mraa_iio_context dev, const char *attr_chan, const float data)
Definition: iio.h:31
mraa_result_t mraa_iio_get_mount_matrix(mraa_iio_context dev, const char *sysfs_name, float mm[9])
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)
mraa_result_t mraa_iio_read_float(mraa_iio_context dev, const char *filename, float *data)
unsigned int offset
Definition: iio.h:43
mraa_result_t mraa_iio_event_setup_callback(mraa_iio_context dev, void(*fptr)(struct iio_event_data *data, void *args), void *args)
unsigned int location
Definition: iio.h:53
mraa_result_t mraa_iio_update_channels(mraa_iio_context dev)
int index
Definition: iio.h:33
mraa_iio_context mraa_iio_init(int device)
int enabled
Definition: iio.h:61
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_write_string(mraa_iio_context dev, const char *attr_chan, const char *data)
uint64_t mask
Definition: iio.h:45
unsigned int bits_used
Definition: iio.h:47
int mraa_iio_read_size(mraa_iio_context dev)
char * name
Definition: iio.h:59
mraa_iio_channel * mraa_iio_get_channels(mraa_iio_context dev)
struct _iio * mraa_iio_context
Definition: iio.h:87
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_int(mraa_iio_context dev, const char *attr_chan, const int data)
Definition: iio.h:57
mraa_result_t
Definition: types.h:209
int signedd
Definition: iio.h:41
unsigned int shift
Definition: iio.h:51
unsigned int bytes
Definition: iio.h:49
mraa_result_t mraa_iio_get_channel_data(mraa_iio_context dev)
Definition: iio_kernel_headers.h:119
char * type
Definition: iio.h:37