no-OS
iio_types.h
Go to the documentation of this file.
1 /***************************************************************************/
39 #ifndef IIO_TYPES_H_
40 #define IIO_TYPES_H_
41 
42 /******************************************************************************/
43 /***************************** Include Files **********************************/
44 /******************************************************************************/
45 
46 #include <stdbool.h>
47 #include <stdint.h>
48 #include "no_os_circular_buffer.h"
49 
50 /******************************************************************************/
51 /*************************** Types Declarations *******************************/
52 /******************************************************************************/
53 
54 
55 enum iio_val {
64 };
65 
87 };
88 
102 };
103 
108 struct iio_ch_info {
110  int16_t ch_num;
112  bool ch_out;
118  uint32_t address;
119 };
120 
121 #define END_ATTRIBUTES_ARRAY {.name = NULL}
122 
128 };
129 
136  const char *name;
138  intptr_t priv;
145  int (*show)(void *device, char *buf, uint32_t len,
146  const struct iio_ch_info *channel, intptr_t priv);
148  int (*store)(void *device, char *buf, uint32_t len,
149  const struct iio_ch_info *channel, intptr_t priv);
150 };
151 
156 struct scan_type {
158  char sign;
160  uint8_t realbits;
162  uint8_t storagebits;
164  uint8_t shift;
167 };
168 
173 struct iio_channel {
175  const char *name;
179  int channel;
183  int channel2;
185  unsigned long address;
193  bool ch_out;
196  bool modified;
199  bool indexed;
200  /* Set if the channel is differential. */
202 };
203 
207 };
208 
210  bool is_cyclic;
211  uint32_t buff_index;
212 };
213 
214 struct iio_buffer {
215  /* Mask with active channels */
216  uint32_t active_mask;
217  /* Size in bytes */
218  uint32_t size;
219  /* Number of bytes per sample * number of active channels */
220  uint32_t bytes_per_scan;
221  /* Number of requested samples */
222  uint32_t samples;
223  /* Buffer direction */
225  /* Buffer where data is stored */
227  /* Stores cyclic buffer specific information */
229 };
230 
232  void *dev;
234 };
235 
236 struct iio_trigger {
243  int (*enable)(void *trig);
245  int (*disable)(void *trig);
246 };
247 
252 struct iio_device {
257  uint16_t num_ch;
266  /* Numbers of bytes will be:
267  * samples * (storage_size_of_first_active_ch / 8) * nb_active_channels
268  * DEPRECATED.
269  */
270  int32_t (*read_dev)(void *dev, void *buff, uint32_t nb_samples);
271  /* Numbers of bytes will be:
272  * samples * (storage_size_of_first_active_ch / 8) * nb_active_channels
273  * DEPRECATED.
274  */
275  int32_t (*write_dev)(void *dev, void *buff, uint32_t nb_samples);
276 
277  /* Bufer callbacks */
279  int32_t (*pre_enable)(void *dev, uint32_t mask);
281  int32_t (*post_disable)(void *dev);
283  int32_t (*submit)(struct iio_device_data *dev);
285  int32_t (*trigger_handler)(struct iio_device_data *dev);
286 
287  /* Read device register */
288  int32_t (*debug_reg_read)(void *dev, uint32_t reg, uint32_t *readval);
289  /* Write device register */
290  int32_t (*debug_reg_write)(void *dev, uint32_t reg, uint32_t writeval);
291 
292 };
293 
294 #endif /* IIO_TYPES_H_ */
IIO_ACCEL
@ IIO_ACCEL
Definition: iio_types.h:77
iio_device::read_dev
int32_t(* read_dev)(void *dev, void *buff, uint32_t nb_samples)
Definition: iio_types.h:270
IIO_COUNT
@ IIO_COUNT
Definition: iio_types.h:84
IIO_DIRECTION_INPUT
@ IIO_DIRECTION_INPUT
Definition: iio_types.h:205
iio_buffer::samples
uint32_t samples
Definition: iio_types.h:222
IIO_VAL_INT_PLUS_MICRO_DB
@ IIO_VAL_INT_PLUS_MICRO_DB
Definition: iio_types.h:59
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:173
IIO_VAL_INT_PLUS_NANO
@ IIO_VAL_INT_PLUS_NANO
Definition: iio_types.h:58
scan_type::sign
char sign
Definition: iio_types.h:158
IIO_SHARED_BY_TYPE
@ IIO_SHARED_BY_TYPE
Definition: iio_types.h:125
IIO_SEPARATE
@ IIO_SEPARATE
Definition: iio_types.h:124
iio_device::channels
struct iio_channel * channels
Definition: iio_types.h:259
IIO_VAL_FRACTIONAL_LOG2
@ IIO_VAL_FRACTIONAL_LOG2
Definition: iio_types.h:62
iio_device_data::dev
void * dev
Definition: iio_types.h:232
iio_ch_info
Structure holding channel attributess.
Definition: iio_types.h:108
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:220
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:145
IIO_MOD_PITCH
@ IIO_MOD_PITCH
Definition: iio_types.h:99
scan_type::is_big_endian
bool is_big_endian
Definition: iio_types.h:166
iio_channel::diferential
bool diferential
Definition: iio_types.h:201
IIO_MOD_Z
@ IIO_MOD_Z
Definition: iio_types.h:97
scan_type::storagebits
uint8_t storagebits
Definition: iio_types.h:162
IIO_VAL_FRACTIONAL
@ IIO_VAL_FRACTIONAL
Definition: iio_types.h:61
iio_trigger::disable
int(* disable)(void *trig)
Definition: iio_types.h:245
iio_ch_info::ch_out
bool ch_out
Definition: iio_types.h:112
device
Definition: ad9361_util.h:75
IIO_RESISTANCE
@ IIO_RESISTANCE
Definition: iio_types.h:78
iio_device::write_dev
int32_t(* write_dev)(void *dev, void *buff, uint32_t nb_samples)
Definition: iio_types.h:275
IIO_ALTVOLTAGE
@ IIO_ALTVOLTAGE
Definition: iio_types.h:73
iio_channel::ch_type
enum iio_chan_type ch_type
Definition: iio_types.h:177
iio_device::post_disable
int32_t(* post_disable)(void *dev)
Definition: iio_types.h:281
iio_channel::channel2
int channel2
Definition: iio_types.h:183
iio_device::debug_reg_read
int32_t(* debug_reg_read)(void *dev, uint32_t reg, uint32_t *readval)
Definition: iio_types.h:288
iio_chan_type
IIO channel types.
iio_attribute::priv
intptr_t priv
Definition: iio_types.h:138
iio_channel::ch_out
bool ch_out
Definition: iio_types.h:193
IIO_SHARED_BY_ALL
@ IIO_SHARED_BY_ALL
Definition: iio_types.h:127
iio_channel::channel
int channel
Definition: iio_types.h:179
iio_device::pre_enable
int32_t(* pre_enable)(void *dev, uint32_t mask)
Definition: iio_types.h:279
iio_attribute::shared
enum iio_attribute_shared shared
Definition: iio_types.h:143
scan_type::shift
uint8_t shift
Definition: iio_types.h:164
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:148
IIO_MOD_Y
@ IIO_MOD_Y
Definition: iio_types.h:96
iio_attribute::name
const char * name
Definition: iio_types.h:136
iio_ch_info::differential
bool differential
Definition: iio_types.h:116
iio_channel::name
const char * name
Definition: iio_types.h:175
iio_device::debug_attributes
struct iio_attribute * debug_attributes
Definition: iio_types.h:263
IIO_VAL_CHAR
@ IIO_VAL_CHAR
Definition: iio_types.h:63
iio_attribute_shared
iio_attribute_shared
Definition: iio_types.h:123
iio_device::submit
int32_t(* submit)(struct iio_device_data *dev)
Definition: iio_types.h:283
iio_buffer::size
uint32_t size
Definition: iio_types.h:218
iio_buffer::cyclic_info
struct iio_cyclic_buffer_info cyclic_info
Definition: iio_types.h:228
iio_buffer_direction
iio_buffer_direction
Definition: iio_types.h:204
iio_attribute
Structure holding pointers to show and store functions.
Definition: iio_types.h:134
IIO_NO_MOD
@ IIO_NO_MOD
Definition: iio_types.h:94
iio_buffer
Definition: iio_types.h:214
iio_buffer::active_mask
uint32_t active_mask
Definition: iio_types.h:216
no_os_circular_buffer.h
Circular buffer library header.
iio_buffer::buf
struct no_os_circular_buffer * buf
Definition: iio_types.h:226
IIO_CURRENT
@ IIO_CURRENT
Definition: iio_types.h:72
IIO_MOD_YAW
@ IIO_MOD_YAW
Definition: iio_types.h:100
IIO_VOLTAGE
@ IIO_VOLTAGE
Definition: iio_types.h:71
IIO_ANGL
@ IIO_ANGL
Definition: iio_types.h:82
IIO_MOD_TEMP_AMBIENT
@ IIO_MOD_TEMP_AMBIENT
Definition: iio_types.h:98
iio_device_data::buffer
struct iio_buffer * buffer
Definition: iio_types.h:233
iio_val
iio_val
Definition: iio_types.h:55
iio_cyclic_buffer_info::buff_index
uint32_t buff_index
Definition: iio_types.h:211
IIO_CAPACITANCE
@ IIO_CAPACITANCE
Definition: iio_types.h:76
IIO_DIRECTION_OUTPUT
@ IIO_DIRECTION_OUTPUT
Definition: iio_types.h:206
iio_device::buffer_attributes
struct iio_attribute * buffer_attributes
Definition: iio_types.h:265
iio_ch_info::address
uint32_t address
Definition: iio_types.h:118
iio_channel::attributes
struct iio_attribute * attributes
Definition: iio_types.h:191
iio_device::num_ch
uint16_t num_ch
Definition: iio_types.h:257
iio_channel::scan_type
struct scan_type * scan_type
Definition: iio_types.h:189
IIO_MOD_X
@ IIO_MOD_X
Definition: iio_types.h:95
IIO_TEMP
@ IIO_TEMP
Definition: iio_types.h:75
iio_ch_info::type
enum iio_chan_type type
Definition: iio_types.h:114
IIO_MOD_ROLL
@ IIO_MOD_ROLL
Definition: iio_types.h:101
iio_device::trigger_handler
int32_t(* trigger_handler)(struct iio_device_data *dev)
Definition: iio_types.h:285
iio_buffer::dir
enum iio_buffer_direction dir
Definition: iio_types.h:224
iio_device::irq_desc
struct no_os_irq_ctrl_desc * irq_desc
Definition: iio_types.h:255
iio_trigger
Definition: iio_types.h:236
iio_channel::modified
bool modified
Definition: iio_types.h:196
iio_channel::scan_index
int scan_index
Definition: iio_types.h:187
IIO_MAGN
@ IIO_MAGN
Definition: iio_types.h:79
iio_modifier
IIO channel modifier.
iio_ch_info::ch_num
int16_t ch_num
Definition: iio_types.h:110
iio_device
Structure holding channels and attributes of a device.
Definition: iio_types.h:252
IIO_INCLI
@ IIO_INCLI
Definition: iio_types.h:80
iio_cyclic_buffer_info::is_cyclic
bool is_cyclic
Definition: iio_types.h:210
no_os_circular_buffer
Circular buffer descriptor.
Definition: no_os_circular_buffer.h:73
iio_trigger::attributes
struct iio_attribute * attributes
Definition: iio_types.h:241
IIO_ROT
@ IIO_ROT
Definition: iio_types.h:83
iio_trigger::enable
int(* enable)(void *trig)
Definition: iio_types.h:243
scan_type
Definition: iio_types.h:156
iio_trigger::is_synchronous
bool is_synchronous
Definition: iio_types.h:239
IIO_DELTA_ANGL
@ IIO_DELTA_ANGL
Definition: iio_types.h:85
iio_device_data
Definition: iio_types.h:231
iio_device::debug_reg_write
int32_t(* debug_reg_write)(void *dev, uint32_t reg, uint32_t writeval)
Definition: iio_types.h:290
IIO_VELOCITY
@ IIO_VELOCITY
Definition: iio_types.h:81
no_os_irq_ctrl_desc
Definition: no_os_irq.h:129
IIO_SHARED_BY_DIR
@ IIO_SHARED_BY_DIR
Definition: iio_types.h:126
iio_channel::address
unsigned long address
Definition: iio_types.h:185
IIO_DELTA_VELOCITY
@ IIO_DELTA_VELOCITY
Definition: iio_types.h:86
iio_device::attributes
struct iio_attribute * attributes
Definition: iio_types.h:261
IIO_VAL_INT_MULTIPLE
@ IIO_VAL_INT_MULTIPLE
Definition: iio_types.h:60
iio_cyclic_buffer_info
Definition: iio_types.h:209
iio_channel::indexed
bool indexed
Definition: iio_types.h:199
scan_type::realbits
uint8_t realbits
Definition: iio_types.h:160