#ifndef IIO_COMMON_H_
#define IIO_COMMON_H_
-struct channel_parameters {
+#include <linux/ioctl.h>
+
+#define NO_OF_ULL_BYTES 8
+#define NO_OF_SHORT_VAL 4
+#define CH0_INDEX 0
+#define CH1_INDEX 1
+
+#define GET_DIFF_BIT(val) (((unsigned short)(val) >> 7) & 0x01)
+#define GET_DIR_VAL(val) ((val) & 0x0F)
+
+#define IOCTL_IIO_EVENT_FD _IOR('i', 0x90, int)
+
+struct channel_parameters
+{
char *prefix_str;
float scale;
float offset;
unsigned int buf_index;
};
+typedef struct iio_event_struct
+{
+ unsigned long long int event_id;
+ long long int timestamp;
+} iio_event_t;
+
+typedef enum event_id_field
+{
+ CH_TYPE = 4,
+ MODIFIER,
+ DIRECTION,
+ EVENT_TYPE,
+} event_id_field_t;
+
+typedef union ull_bytes
+{
+ unsigned long long num;
+ short int channels[NO_OF_SHORT_VAL];
+ unsigned char bytes[NO_OF_ULL_BYTES];
+} ull_bytes_t;
+
void sort_channels_by_index(struct channel_parameters *channels, int count);
int decode_channel_data_type(const char *device_dir, const char *ch_name, struct channel_parameters *ch_info);
int add_channel_to_array(const char *device_dir, const char *ch_name, struct channel_parameters *channel);