Soletta™ Framework
Framework for making IoT devices

Full online documentation | C API Index
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
sol-iio.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Soletta (TM) Project
3  *
4  * Copyright (C) 2015 Intel Corporation. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #pragma once
20 
21 #include <sol-buffer.h>
22 #include <sol-common-buildopts.h>
23 
24 #include <linux/limits.h>
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
52 struct sol_iio_device;
54 
64 struct sol_iio_channel;
66 
72 typedef struct sol_iio_config {
73 #ifndef SOL_NO_API_VERSION
74 #define SOL_IIO_CONFIG_API_VERSION (2)
75  uint16_t api_version;
76 #endif
77  const char *trigger_name;
78  void (*sol_iio_reader_cb)(void *data, struct sol_iio_device *device);
79  const void *data;
82  char sampling_frequency_name[NAME_MAX];
84 
90 typedef struct sol_iio_channel_config {
91 #ifndef SOL_NO_API_VERSION
92 #define SOL_IIO_CHANNEL_CONFIG_API_VERSION (1)
93  uint16_t api_version;
94 #endif
95  double scale;
96  int offset;
99 
106 #define SOL_IIO_CHANNEL_CONFIG_INIT { \
107  SOL_SET_API_VERSION(.api_version = SOL_IIO_CHANNEL_CONFIG_API_VERSION, ) \
108  .scale = -1.0, .offset = 0, .use_custom_offset = false }
109 
121 struct sol_iio_device *sol_iio_open(int id, const struct sol_iio_config *config);
122 
128 void sol_iio_close(struct sol_iio_device *device);
129 
139 struct sol_iio_channel *sol_iio_add_channel(struct sol_iio_device *device, const char *name, const struct sol_iio_channel_config *config);
140 
153 int sol_iio_read_channel_value(struct sol_iio_channel *channel, double *value);
154 
165 int sol_iio_device_trigger(struct sol_iio_device *device);
166 
180 int sol_iio_device_start_buffer(struct sol_iio_device *device);
181 
217 int sol_iio_address_device(const char *commands);
218 
234 struct sol_str_slice
236 
248 int
250 
258 const char *sol_iio_channel_get_name(const struct sol_iio_channel *channel);
259 
260 
270 int sol_iio_device_get_scale(const struct sol_iio_device *device, const char *prefix_name, double *scale);
271 
281 int sol_iio_device_get_offset(const struct sol_iio_device *device, const char *prefix_name, double *offset);
282 
292 int sol_iio_device_get_sampling_frequency(const struct sol_iio_device *device, const char *prefix_name, int *sampling_frequency);
293 
298 #ifdef __cplusplus
299 }
300 #endif
void sol_iio_close(struct sol_iio_device *device)
Close an IIO device.
struct sol_str_slice sol_iio_read_channel_raw_buffer(struct sol_iio_channel *channel)
Returns raw buffer with channel sample.
struct sol_iio_device * sol_iio_open(int id, const struct sol_iio_config *config)
Open an IIO device.
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.
int sol_iio_device_trigger(struct sol_iio_device *device)
Manually 'pull' device current trigger.
int offset
Channel offset, to be added to raw readings.
Definition: sol-iio.h:96
int sol_iio_address_device(const char *commands)
Address an IIO device from a list of commands to find them.
A configuration struct for an IIO device.
Definition: sol-iio.h:72
void(* sol_iio_reader_cb)(void *data, struct sol_iio_device *device)
Callback to be called when get new device readings on buffer.
Definition: sol-iio.h:78
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.
bool use_custom_offset
If true, will use user defined offset on member offset of this struct.
Definition: sol-iio.h:97
static struct sol_buffer value
Definition: server.c:42
String slice type.
Definition: sol-str-slice.h:84
Data type to describe a direction vector.
Definition: sol-types.h:125
These are routines that Soletta provides for its buffer implementation.
uint16_t api_version
The API version.
Definition: sol-iio.h:93
int buffer_size
The size of reading buffer.
Definition: sol-iio.h:80
int sol_iio_device_start_buffer(struct sol_iio_device *device)
Start reading device buffer.
int sol_iio_mount_calibration(struct sol_iio_device *device, sol_direction_vector *value)
Perform the mount calibration.
struct sol_iio_channel_config sol_iio_channel_config
A configuration struct for an IIO channel.
const char * sol_iio_channel_get_name(const struct sol_iio_channel *channel)
Gets the configuration attribute name of a channel.
struct sol_iio_config sol_iio_config
A configuration struct for an IIO device.
int sol_iio_read_channel_value(struct sol_iio_channel *channel, double *value)
Read channel value.
const char * trigger_name
Name of IIO trigger to be used on this device.
Definition: sol-iio.h:77
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.
int sampling_frequency
Device sampling frequency.
Definition: sol-iio.h:81
A configuration struct for an IIO channel.
Definition: sol-iio.h:90
double scale
Channel scale, to be applied to raw readings.
Definition: sol-iio.h:95
uint16_t api_version
The API version.
Definition: sol-iio.h:75
const void * data
User defined data to be sent to sol_iio_reader_cb.
Definition: sol-iio.h:79
struct sol_iio_channel sol_iio_channel
An IIO channel handle.
Definition: sol-iio.h:65
struct sol_iio_device sol_iio_device
An IIO device handle.
Definition: sol-iio.h:53
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.
char sampling_frequency_name[NAME_MAX]
Sampling frequency sysfs node name.
Definition: sol-iio.h:82