aio: add aio swig object
authorBrendan Le Foll <brendan.le.foll@intel.com>
Thu, 1 May 2014 15:59:54 +0000 (16:59 +0100)
committerBrendan Le Foll <brendan.le.foll@intel.com>
Thu, 1 May 2014 15:59:54 +0000 (16:59 +0100)
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
src/CMakeLists.txt
src/maa.i

index 2498009..1da8763 100644 (file)
@@ -54,7 +54,7 @@ install (TARGETS maa DESTINATION lib)
 
 if (DOXYGEN_FOUND)
   set (CMAKE_SWIG_FLAGS -DDOXYGEN=${DOXYGEN_FOUND})
-  set (DOCFILES maa pwm i2c gpio)
+  set (DOCFILES maa pwm i2c gpio aio)
   foreach (_file ${DOCFILES})
     add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file}_doc.i
       COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/doxy2swig.py -n
index 2511888..e046bc5 100644 (file)
--- a/src/maa.i
+++ b/src/maa.i
@@ -4,6 +4,7 @@
     #include "pwm.h"
     #include "i2c.h"
     #include "spi.h"
+    #include "aio.h"
 %}
 
 %rename(get_version) maa_get_version();
@@ -192,3 +193,28 @@ typedef struct {
     return maa_spi_write($self, data);
   }
 }
+
+#### AIO ####
+
+%rename(Aio) maa_aio_context;
+
+typedef struct {
+    unsigned int channel;
+    FILE *adc_in_fp;
+} maa_aio_context;
+
+%nodefault maa_aio_context;
+%extend maa_aio_context {
+  maa_aio_context(unsigned int aio_channel)
+  {
+    return maa_aio_init(aio_channel);
+  }
+  ~maa_aio_context()
+  {
+    maa_aio_close($self);
+  }
+  unsigned int read()
+  {
+    return maa_aio_read_u16($self);
+  }
+}