no-OS
iio.h
Go to the documentation of this file.
1 /***************************************************************************/
41 #ifndef IIO_H_
42 #define IIO_H_
43 
44 /******************************************************************************/
45 /***************************** Include Files **********************************/
46 /******************************************************************************/
47 
48 #include "iio_types.h"
49 #include "no-os/uart.h"
50 #ifdef ENABLE_IIO_NETWORK
51 #include "tcp_socket.h"
52 #endif
53 
54 /******************************************************************************/
55 /*************************** Types Declarations *******************************/
56 /******************************************************************************/
57 
60 #ifdef ENABLE_IIO_NETWORK
61  USE_NETWORK
62 #endif
63 };
64 
65 struct iio_desc;
66 
68  char *name;
69  void *dev;
71  /*
72  * IIO buffer implementation can use a user provided buffer in raw_buf.
73  * If raw_buf is NULL and iio_device has buffer callback function set,
74  * it will allocate memory for it when needed.
75  */
76  int8_t *raw_buf;
77  /* Length of raw_buf */
78  uint32_t raw_buf_len;
79 };
80 
83  union {
85 #ifdef ENABLE_IIO_NETWORK
86  struct tcp_socket_init_param *tcp_socket_init_param;
87 #endif
88  };
90  int32_t nb_devs;
91 };
92 
93 /******************************************************************************/
94 /************************ Functions Declarations ******************************/
95 /******************************************************************************/
96 
97 /* Set communication ops and read/write ops that will be called from
98  * "libtinyiiod". */
99 int iio_init(struct iio_desc **desc, struct iio_init_param *init_param);
100 /* Free the resources allocated by iio_init(). */
101 int iio_remove(struct iio_desc *desc);
102 /* Execut an iio step. */
103 int iio_step(struct iio_desc *desc);
104 
105 int32_t iio_parse_value(char *buf, enum iio_val fmt,
106  int32_t *val, int32_t *val2);
107 int iio_format_value(char *buf, uint32_t len, enum iio_val fmt,
108  int32_t size, int32_t *vals);
109 
110 /* DMA buffer functions. */
111 /* Get buffer addr where to write iio_buffer.size bytes */
112 int iio_buffer_get_block(struct iio_buffer *buffer, void **addr);
113 /* To be called to mark last iio_buffer_read as done */
114 int iio_buffer_block_done(struct iio_buffer *buffer);
115 
116 /* Trigger buffer functions. */
117 /* Write to buffer iio_buffer.bytes_per_scan bytes from data */
118 int iio_buffer_push_scan(struct iio_buffer *buffer, void *data);
119 /* Read from buffer iio_buffer.bytes_per_scan bytes into data */
120 int iio_buffer_pop_scan(struct iio_buffer *buffer, void *data);
121 
122 #endif /* IIO_H_ */
IS_ERR_VALUE
#define IS_ERR_VALUE(x)
Definition: error.h:65
iio_device::read_dev
int32_t(* read_dev)(void *dev, void *buff, uint32_t nb_samples)
Definition: iio_types.h:232
IIO_DIRECTION_INPUT
@ IIO_DIRECTION_INPUT
Definition: iio_types.h:191
IIO_VAL_INT_PLUS_MICRO_DB
@ IIO_VAL_INT_PLUS_MICRO_DB
Definition: iio_types.h:59
iio_init_param::phy_type
enum pysical_link_type phy_type
Definition: iio.h:82
iio_remove
int iio_remove(struct iio_desc *desc)
Free the resources allocated by "iio_init()".
Definition: iio.c:1470
IIO_ANGL_VEL
@ IIO_ANGL_VEL
Definition: iio_types.h:74
IIO_VAL_INT
@ IIO_VAL_INT
Definition: iio_types.h:56
iio_channel
Struct describing the scan type.
Definition: iio_types.h:159
IIO_VAL_INT_PLUS_NANO
@ IIO_VAL_INT_PLUS_NANO
Definition: iio_types.h:58
scan_type::sign
char sign
Definition: iio_types.h:144
iio_buffer_pop_scan
int iio_buffer_pop_scan(struct iio_buffer *buffer, void *data)
Definition: iio.c:1031
IIO_SHARED_BY_TYPE
@ IIO_SHARED_BY_TYPE
Definition: iio_types.h:111
iio_remove
int iio_remove(struct iio_desc *desc)
Free the resources allocated by "iio_init()".
Definition: iio.c:1470
IIO_SEPARATE
@ IIO_SEPARATE
Definition: iio_types.h:110
iio_device::channels
struct iio_channel * channels
Definition: iio_types.h:221
min
#define min(x, y)
Definition: util.h:63
iiod_ops::open
int(* open)(struct iiod_ctx *ctx, const char *device, uint32_t samples, uint32_t mask, bool cyclic)
Definition: iiod.h:108
iio_dev_priv::name
const char * name
Definition: iio.c:151
iiod_ctx::instance
void * instance
Definition: iiod.h:72
IIO_VAL_FRACTIONAL_LOG2
@ IIO_VAL_FRACTIONAL_LOG2
Definition: iio_types.h:62
iio_device_data::dev
void * dev
Definition: iio_types.h:209
iio_init
int iio_init(struct iio_desc **desc, struct iio_init_param *init_param)
Set communication ops and read/write ops that will be called from "libtinyiiod".
Definition: iio.c:1362
iiod.h
Header file of iiod.
iiod_conn_data::conn
void * conn
Definition: iiod.h:79
iio_desc
Definition: iio.c:164
iio_ch_info
Structure holding channel attributess.
Definition: iio_types.h:94
iio_dev_priv::dev_id
char dev_id[21]
Definition: iio.c:149
IIO_VAL_INT_PLUS_MICRO
@ IIO_VAL_INT_PLUS_MICRO
Definition: iio_types.h:57
iio_buffer::bytes_per_scan
uint32_t bytes_per_scan
Definition: iio_types.h:201
iio_attribute::show
int(* show)(void *device, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t priv)
Definition: iio_types.h:131
scan_type::is_big_endian
bool is_big_endian
Definition: iio_types.h:152
iio_channel::diferential
bool diferential
Definition: iio_types.h:187
iiod_desc
Definition: iiod_private.h:163
scan_type::storagebits
uint8_t storagebits
Definition: iio_types.h:148
IIO_VAL_FRACTIONAL
@ IIO_VAL_FRACTIONAL
Definition: iio_types.h:61
iio_dev_priv::dev_descriptor
struct iio_device * dev_descriptor
Definition: iio.c:159
iiod_attr::channel
const char * channel
Definition: iiod.h:67
iio_desc::uart_desc
struct uart_desc * uart_desc
Definition: iio.c:172
cb_end_async_write
int32_t cb_end_async_write(struct circular_buffer *desc)
iio_buffer_push_scan
int iio_buffer_push_scan(struct iio_buffer *buffer, void *data)
Definition: iio.c:1022
iio_desc::xml_desc
char * xml_desc
Definition: iio.c:168
iio_buffer_priv::public
struct iio_buffer public
Definition: iio.c:129
iiod_init_param::xml_len
uint32_t xml_len
Definition: iiod.h:169
cb_prepare_async_write
int32_t cb_prepare_async_write(struct circular_buffer *desc, uint32_t raw_size_to_write, void **write_buff, uint32_t *raw_size_avilable)
iio_init_param
Definition: iio.h:81
iio_desc::iiod
struct iiod_desc * iiod
Definition: iio.c:165
cb_prepare_async_read
int32_t cb_prepare_async_read(struct circular_buffer *desc, uint32_t raw_size_to_read, void **read_buff, uint32_t *raw_size_avilable)
device
Definition: ad9361_util.h:75
iio_buffer_priv::raw_buf
int8_t * raw_buf
Definition: iio.c:133
iio_device::write_dev
int32_t(* write_dev)(void *dev, void *buff, uint32_t nb_samples)
Definition: iio_types.h:237
IIO_ALTVOLTAGE
@ IIO_ALTVOLTAGE
Definition: iio_types.h:73
iio_channel::ch_type
enum iio_chan_type ch_type
Definition: iio_types.h:163
cb_remove
int32_t cb_remove(struct circular_buffer *desc)
iio_buffer_block_done
int iio_buffer_block_done(struct iio_buffer *buffer)
Definition: iio.c:1010
iio_device::post_disable
int32_t(* post_disable)(void *dev)
Definition: iio_types.h:243
attr_fun_params::ch_info
struct iio_ch_info * ch_info
Definition: iio.c:124
iio_attr_type
iio_attr_type
Definition: iiod.h:51
iio_buffer_priv
Definition: iio.c:127
iio_buffer_pop_scan
int iio_buffer_pop_scan(struct iio_buffer *buffer, void *data)
Definition: iio.c:1031
iio_channel::channel2
int channel2
Definition: iio_types.h:169
iio_buffer_priv::cb
struct circular_buffer cb
Definition: iio.c:131
iiod_ops::close
int(* close)(struct iiod_ctx *ctx, const char *device)
Definition: iiod.h:111
iio_device::debug_reg_read
int32_t(* debug_reg_read)(void *dev, uint32_t reg, uint32_t *readval)
Definition: iio_types.h:248
iiod_conn_add
int32_t iiod_conn_add(struct iiod_desc *desc, struct iiod_conn_data *data, uint32_t *new_conn_id)
Definition: iiod.c:399
iiod_init_param::instance
void * instance
Definition: iiod.h:162
iio_init
int iio_init(struct iio_desc **desc, struct iio_init_param *init_param)
Set communication ops and read/write ops that will be called from "libtinyiiod".
Definition: iio.c:1362
iio_channel::ch_out
bool ch_out
Definition: iio_types.h:179
IIOD_PORT
#define IIOD_PORT
Definition: iio.c:70
IIO_SHARED_BY_ALL
@ IIO_SHARED_BY_ALL
Definition: iio_types.h:113
iiod_ctx
Definition: iiod.h:70
iiod_init_param
Definition: iiod.h:159
iio_channel::channel
int channel
Definition: iio_types.h:165
iio_device::pre_enable
int32_t(* pre_enable)(void *dev, uint32_t mask)
Definition: iio_types.h:241
iio.h
Header file of iio.
iio_attribute::shared
enum iio_attribute_shared shared
Definition: iio_types.h:129
scan_type::shift
uint8_t shift
Definition: iio_types.h:150
IIOD_MAX_CONNECTIONS
#define IIOD_MAX_CONNECTIONS
Definition: iiod.h:47
iio_attribute::store
int(* store)(void *device, char *buf, uint32_t len, const struct iio_ch_info *channel, intptr_t priv)
Definition: iio_types.h:134
IIO_MOD_Y
@ IIO_MOD_Y
Definition: iio_types.h:86
uart.h
Header file of UART interface.
iio_attribute::name
const char * name
Definition: iio_types.h:122
iio_buffer_priv::allocated
bool allocated
Definition: iio.c:139
iio_desc::devs
struct iio_dev_priv * devs
Definition: iio.c:170
iio_buffer_block_done
int iio_buffer_block_done(struct iio_buffer *buffer)
Definition: iio.c:1010
iiod_init_param::xml
char * xml
Definition: iiod.h:167
iiod_ops::refill_buffer
int(* refill_buffer)(struct iiod_ctx *ctx, const char *device)
Definition: iiod.h:117
cb_init
int32_t cb_init(struct circular_buffer **desc, uint32_t size)
iio_init_param::nb_devs
int32_t nb_devs
Definition: iio.h:90
iio_channel::name
const char * name
Definition: iio_types.h:161
iio_device::debug_attributes
struct iio_attribute * debug_attributes
Definition: iio_types.h:225
iiod_init_param::ops
struct iiod_ops * ops
Definition: iiod.h:160
IIO_VAL_CHAR
@ IIO_VAL_CHAR
Definition: iio_types.h:63
iio_device::submit
int32_t(* submit)(struct iio_device_data *dev)
Definition: iio_types.h:245
iiod_conn_data::buf
char * buf
Definition: iiod.h:81
iiod_init
int32_t iiod_init(struct iiod_desc **desc, struct iiod_init_param *param)
Definition: iiod.c:354
iio_buffer::size
uint32_t size
Definition: iio_types.h:199
iiod_ops::write_buffer
int(* write_buffer)(struct iiod_ctx *ctx, const char *device, const char *buf, uint32_t bytes)
Definition: iiod.h:120
circular_buffer::buff
int8_t * buff
Definition: circular_buffer.h:77
iio_buffer_get_block
int iio_buffer_get_block(struct iio_buffer *buffer, void **addr)
Definition: iio.c:977
cb_size
int32_t cb_size(struct circular_buffer *desc, uint32_t *size)
iio_device_init::name
char * name
Definition: iio.h:68
IIO_ATTR_TYPE_DEVICE
@ IIO_ATTR_TYPE_DEVICE
Definition: iiod.h:56
cb_cfg
int32_t cb_cfg(struct circular_buffer *desc, int8_t *buf, uint32_t size)
iio_buffer_direction
iio_buffer_direction
Definition: iio_types.h:190
iio_attribute
Structure holding pointers to show and store functions.
Definition: iio_types.h:120
iio_desc::conns
struct circular_buffer * conns
Definition: iio.c:176
iiod_ctx::conn
void * conn
Definition: iiod.h:74
iiod_remove
void iiod_remove(struct iiod_desc *desc)
Definition: iiod.c:382
circular_buffer.h
Circular buffer library header.
error.h
Error codes definition.
cb_write
int32_t cb_write(struct circular_buffer *desc, const void *data, uint32_t nb_elements)
attr_fun_params::len
uint32_t len
Definition: iio.c:123
iio_buffer
Definition: iio_types.h:195
REG_ACCESS_ATTRIBUTE
#define REG_ACCESS_ATTRIBUTE
Definition: iio.c:72
iio_buffer_priv::initalized
bool initalized
Definition: iio.c:137
iio_buffer::active_mask
uint32_t active_mask
Definition: iio_types.h:197
iiod_ops::read_attr
int(* read_attr)(struct iiod_ctx *ctx, const char *device, struct iiod_attr *attr, char *buf, uint32_t len)
Definition: iiod.h:129
iio_buffer::buf
struct circular_buffer * buf
Definition: iio_types.h:205
iio_init_param::devs
struct iio_device_init * devs
Definition: iio.h:89
IIO_ATTR_TYPE_DEBUG
@ IIO_ATTR_TYPE_DEBUG
Definition: iiod.h:52
IIO_CURRENT
@ IIO_CURRENT
Definition: iio_types.h:72
iio_parse_value
int32_t iio_parse_value(char *buf, enum iio_val fmt, int32_t *val, int32_t *val2)
Definition: iio.c:503
delay.h
Header file of Delay functions.
iio_desc::recv
int(* recv)(void *conn, uint8_t *buf, uint32_t len)
Definition: iio.c:173
IIO_VOLTAGE
@ IIO_VOLTAGE
Definition: iio_types.h:71
IIOD_CONN_BUFFER_SIZE
#define IIOD_CONN_BUFFER_SIZE
Definition: iio.c:73
iio_init_param::uart_desc
struct uart_desc * uart_desc
Definition: iio.h:84
iio_dev_priv::dev_data
struct iio_device_data dev_data
Definition: iio.c:155
cb_end_async_read
int32_t cb_end_async_read(struct circular_buffer *desc)
iio_dev_priv
Links a physical device instance "void *dev_instance" with a "iio_device *iio" that describes capabil...
Definition: iio.c:147
iio_device_data::buffer
struct iio_buffer * buffer
Definition: iio_types.h:210
iio_val
iio_val
Definition: iio_types.h:55
iio_dev_priv::buffer
struct iio_buffer_priv buffer
Definition: iio.c:161
IIO_CAPACITANCE
@ IIO_CAPACITANCE
Definition: iio_types.h:76
IIO_DIRECTION_OUTPUT
@ IIO_DIRECTION_OUTPUT
Definition: iio_types.h:192
iiod_attr::name
const char * name
Definition: iiod.h:66
iiod_conn_data
Definition: iiod.h:77
iio_format_value
int iio_format_value(char *buf, uint32_t len, enum iio_val fmt, int32_t size, int32_t *vals)
Definition: iio.c:549
iio_desc::send
int(* send)(void *conn, uint8_t *buf, uint32_t len)
Definition: iio.c:174
iio_device::buffer_attributes
struct iio_attribute * buffer_attributes
Definition: iio_types.h:227
iiod_ops::read_buffer
int(* read_buffer)(struct iiod_ctx *ctx, const char *device, char *buf, uint32_t bytes)
Definition: iiod.h:114
iio_dev_priv::dev_instance
void * dev_instance
Definition: iio.c:153
attr_fun_params::buf
char * buf
Definition: iio.c:122
uart_read
int32_t uart_read(struct uart_desc *desc, uint8_t *data, uint32_t bytes_number)
Read data from UART. Blocking function.
Definition: uart.c:271
uart_desc
Stucture holding the UART descriptor.
Definition: uart.h:120
iio_channel::attributes
struct iio_attribute * attributes
Definition: iio_types.h:177
iio_types.h
Header file for iio_types.
iio_device::num_ch
uint16_t num_ch
Definition: iio_types.h:219
iio_channel::scan_type
struct scan_type * scan_type
Definition: iio_types.h:175
USE_UART
@ USE_UART
Definition: iio.h:59
IIO_MOD_X
@ IIO_MOD_X
Definition: iio_types.h:85
iio_device_init::dev_descriptor
struct iio_device * dev_descriptor
Definition: iio.h:70
IIO_TEMP
@ IIO_TEMP
Definition: iio_types.h:75
iio_dev_priv::active_reg_addr
uint32_t active_reg_addr
Definition: iio.c:157
bswap_constant_32
#define bswap_constant_32(x)
Definition: util.h:93
iio_desc::phy_desc
void * phy_desc
Definition: iio.c:167
iio_buffer::dir
enum iio_buffer_direction dir
Definition: iio_types.h:203
circular_buffer
Circular buffer descriptor.
Definition: circular_buffer.h:73
IIO_ATTR_TYPE_CH_IN
@ IIO_ATTR_TYPE_CH_IN
Definition: iiod.h:55
iio_device_init::dev
void * dev
Definition: iio.h:69
NULL
#define NULL
Definition: wrapper.h:64
iiod_attr::type
enum iio_attr_type type
Definition: iiod.h:60
iio_channel::modified
bool modified
Definition: iio_types.h:182
iio_desc::nb_devs
uint32_t nb_devs
Definition: iio.c:171
iio_channel::scan_index
int scan_index
Definition: iio_types.h:173
SUCCESS
#define SUCCESS
Definition: error.h:52
IIO_ATTR_TYPE_CH_OUT
@ IIO_ATTR_TYPE_CH_OUT
Definition: iiod.h:54
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:96
iio_device
Structure holding channels and attributes of a device.
Definition: iio_types.h:217
iio_device_init::raw_buf_len
uint32_t raw_buf_len
Definition: iio.h:78
iiod_ops::send
int(* send)(struct iiod_ctx *ctx, uint8_t *buf, uint32_t len)
Definition: iiod.h:97
shift_right
#define shift_right(x, s)
Definition: util.h:117
iiod_ops::write_attr
int(* write_attr)(struct iiod_ctx *ctx, const char *device, struct iiod_attr *attr, char *buf, uint32_t len)
Definition: iiod.h:132
iiod_ops::push_buffer
int(* push_buffer)(struct iiod_ctx *ctx, const char *device)
Definition: iiod.h:123
max
#define max(x, y)
Definition: util.h:68
div_s64
int64_t div_s64(int64_t dividend, int32_t divisor)
attr_fun_params
Definition: iio.c:120
iio_step
int iio_step(struct iio_desc *desc)
Execute an iio step.
Definition: iio.c:1074
cb_read
int32_t cb_read(struct circular_buffer *desc, void *data, uint32_t nb_elements)
iiod_conn_step
int32_t iiod_conn_step(struct iiod_desc *desc, uint32_t conn_id)
Definition: iiod.c:829
attr_fun_params::dev_instance
void * dev_instance
Definition: iio.c:121
iiod_ops
Definition: iiod.h:87
IIO_ATTR_TYPE_BUFFER
@ IIO_ATTR_TYPE_BUFFER
Definition: iiod.h:53
iiod_attr
Definition: iiod.h:59
list.h
List library header.
pysical_link_type
pysical_link_type
Definition: iio.h:58
iio_buffer_get_block
int iio_buffer_get_block(struct iio_buffer *buffer, void **addr)
Definition: iio.c:977
iio_format_value
int iio_format_value(char *buf, uint32_t len, enum iio_val fmt, int32_t size, int32_t *vals)
Definition: iio.c:549
iio_device_data
Definition: iio_types.h:208
iio_device::debug_reg_write
int32_t(* debug_reg_write)(void *dev, uint32_t reg, uint32_t writeval)
Definition: iio_types.h:250
iio_device_init
Definition: iio.h:67
uart_write
int32_t uart_write(struct uart_desc *desc, const uint8_t *data, uint32_t bytes_number)
Write data to UART. Blocking function.
Definition: uart.c:318
iio_desc::xml_size
uint32_t xml_size
Definition: iio.c:169
iio_device_init::raw_buf
int8_t * raw_buf
Definition: iio.h:76
util.h
Implementation of utility functions.
dev_id
dev_id
Definition: ad9361.h:3334
FAILURE
#define FAILURE
Definition: error.h:56
iiod_conn_remove
int32_t iiod_conn_remove(struct iiod_desc *desc, uint32_t conn_id, struct iiod_conn_data *data)
Definition: iiod.c:429
div_s64_rem
int64_t div_s64_rem(int64_t dividend, int32_t divisor, int32_t *remainder)
iiod_ops::recv
int(* recv)(struct iiod_ctx *ctx, uint8_t *buf, uint32_t len)
Definition: iiod.h:98
IIO_SHARED_BY_DIR
@ IIO_SHARED_BY_DIR
Definition: iio_types.h:112
iio_buffer_priv::raw_buf_len
uint32_t raw_buf_len
Definition: iio.c:135
iio_step
int iio_step(struct iio_desc *desc)
Execute an iio step.
Definition: iio.c:1074
iio_channel::address
unsigned long address
Definition: iio_types.h:171
iio_buffer_push_scan
int iio_buffer_push_scan(struct iio_buffer *buffer, void *data)
Definition: iio.c:1022
iio_device::attributes
struct iio_attribute * attributes
Definition: iio_types.h:223
IIO_VAL_INT_MULTIPLE
@ IIO_VAL_INT_MULTIPLE
Definition: iio_types.h:60
iio_parse_value
int32_t iio_parse_value(char *buf, enum iio_val fmt, int32_t *val, int32_t *val2)
Definition: iio.c:503
iio_channel::indexed
bool indexed
Definition: iio_types.h:185
iio_desc::iiod_ops
struct iiod_ops iiod_ops
Definition: iio.c:166
scan_type::realbits
uint8_t realbits
Definition: iio_types.h:146