From d1de6a48c90ee864ac3ebbb625459f26ae2bba5e Mon Sep 17 00:00:00 2001 From: Brendan Le Foll Date: Thu, 1 May 2014 16:59:54 +0100 Subject: [PATCH] aio: add aio swig object Signed-off-by: Brendan Le Foll --- src/CMakeLists.txt | 2 +- src/maa.i | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2498009..1da8763 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 diff --git a/src/maa.i b/src/maa.i index 2511888..e046bc5 100644 --- 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); + } +} -- 2.7.4