#include "common.h"
#include "mraa.h"
-#include "mraa_func.h"
#include "mraa_adv_func.h"
+#include "iio.h"
+
+// Bionic does not implement pthread cancellation API
+#ifndef __BIONIC__
+#define HAVE_PTHREAD_CANCEL
+#endif
// general status failures for internal functions
#define MRAA_PLATFORM_NO_INIT -3
void *isr_args; /**< args return when interupt service request triggered */
pthread_t thread_id; /**< the isr handler thread id */
int isr_value_fp; /**< the isr file pointer on the value */
+#ifndef HAVE_PTHREAD_CANCEL
+ int isr_control_pipe[2]; /**< a pipe used to interrupt the isr from polling the value fd*/
+#endif
mraa_boolean_t isr_thread_terminating; /**< is the isr thread being terminated? */
mraa_boolean_t owner; /**< If this context originally exported the pin */
mraa_result_t (*mmap_write) (mraa_gpio_context dev, int value);
};
/**
+ * A structure representing an IIO device
+ */
+struct _iio {
+ int num; /**< IIO device number */
+ char* name; /**< IIO device name */
+ int fp; /**< IIO device in /dev */
+ int fp_event; /**< event file descriptor for IIO device */
+ void (* isr)(char* data); /**< the interupt service request */
+ void *isr_args; /**< args return when interupt service request triggered */
+ void (* isr_event)(struct iio_event_data* data, void* args); /**< the event interupt service request */
+ int chan_num;
+ pthread_t thread_id; /**< the isr handler thread id */
+ mraa_iio_channel* channels;
+ int event_num;
+ mraa_iio_event* events;
+ int datasize;
+};
+
+/**
* A bitfield representing the capabilities of a pin.
*/
typedef struct {
unsigned int def_uart_dev; /**< Position in array of defult uart */
unsigned int uart_dev_count; /**< Usable spi Count */
mraa_uart_dev_t uart_dev[6]; /**< Array of UARTs */
+ mraa_boolean_t no_bus_mux; /**< i2c/spi/adc/pwm/uart bus muxing setup not required */
int pwm_default_period; /**< The default PWM period is US */
int pwm_max_period; /**< Maximum period in us */
int pwm_min_period; /**< Minimum period in us */
/*@}*/
} mraa_board_t;
-
+typedef struct {
+ struct _iio* iio_devices; /**< Pointer to IIO devices */
+ uint8_t iio_device_count; /**< IIO device count */
+} mraa_iio_info_t;