From 6fe510a27f19f3191f1aac731cea6a40290d17b5 Mon Sep 17 00:00:00 2001 From: Noel Eck Date: Fri, 20 Jul 2018 11:18:38 -0700 Subject: [PATCH] Peripheralman: Remove IIO from ioinit for android Since peripheral manager does not build in the IIO source, ifdef's were added around the initio functionality for IIO. IMO this is an ugly fix, but I don't see a better way since the PERIPHERALMAN architecture is qualified throughout the CMake and source with ifdef's. Signed-off-by: Noel Eck --- api/mraa/initio.h | 6 ++++++ api/mraa/initio.hpp | 10 ++++++++++ src/initio/initio.c | 12 ++++++++++-- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/api/mraa/initio.h b/api/mraa/initio.h index d0ba23d..94fd83e 100644 --- a/api/mraa/initio.h +++ b/api/mraa/initio.h @@ -40,7 +40,11 @@ extern "C" { #include "aio.h" #include "gpio.h" #include "i2c.h" + +#if !defined(PERIPHERALMAN) #include "iio.h" +#endif + #include "pwm.h" #include "spi.h" #include "uart.h" @@ -53,8 +57,10 @@ typedef struct _mraa_io_descriptor { mraa_gpio_context* gpios; int n_i2c; mraa_i2c_context* i2cs; +#if !defined(PERIPHERALMAN) int n_iio; mraa_iio_context* iios; +#endif int n_pwm; mraa_pwm_context* pwms; int n_spi; diff --git a/api/mraa/initio.hpp b/api/mraa/initio.hpp index 3639dd9..ce08624 100644 --- a/api/mraa/initio.hpp +++ b/api/mraa/initio.hpp @@ -32,7 +32,11 @@ #include "aio.hpp" #include "gpio.hpp" #include "i2c.hpp" + +#if !defined(PERIPHERALMAN) #include "iio.hpp" +#endif + #include "pwm.hpp" #include "spi.hpp" #include "uart.hpp" @@ -67,10 +71,12 @@ class MraaIo i2cs.emplace_back(descs->i2cs[i]); } +#if !defined(PERIPHERALMAN) iios.reserve(descs->n_iio); for (int i = 0; i < descs->n_iio; ++i) { iios.emplace_back(descs->iios[i]); } +#endif pwms.reserve(descs->n_pwm); for (int i = 0; i < descs->n_pwm; ++i) { @@ -116,9 +122,11 @@ class MraaIo if (descs->n_i2c) { free(descs->i2cs); } +#if !defined(PERIPHERALMAN) if (descs->n_iio) { free(descs->iios); } +#endif if (descs->n_pwm) { free(descs->pwms); } @@ -140,7 +148,9 @@ class MraaIo std::vector aios; std::vector gpios; std::vector i2cs; +#if !defined(PERIPHERALMAN) std::vector iios; +#endif std::vector pwms; std::vector spis; std::vector uarts; diff --git a/src/initio/initio.c b/src/initio/initio.c index 52c2b5f..5e037cd 100644 --- a/src/initio/initio.c +++ b/src/initio/initio.c @@ -291,6 +291,7 @@ parse_pwm(char** proto, size_t n) return dev; } +#if !defined(PERIPHERALMAN) static mraa_iio_context parse_iio(char** proto, size_t n) { @@ -313,6 +314,7 @@ parse_iio(char** proto, size_t n) return dev; } +#endif static mraa_i2c_context parse_i2c(char** proto, size_t n) @@ -633,7 +635,9 @@ mraa_io_init(const char* strdesc, mraa_io_descriptor** desc) new_desc->gpios[new_desc->n_gpio++] = dev; } } - } else if (strncmp(str_tokens[0], IIO_KEY, strlen(IIO_KEY)) == 0 && + } +#if !defined(PERIPHERALMAN) + else if (strncmp(str_tokens[0], IIO_KEY, strlen(IIO_KEY)) == 0 && strlen(str_tokens[0]) == strlen(IIO_KEY)) { mraa_iio_context dev = parse_iio(str_tokens, num_desc_tokens); if (!dev) { @@ -650,7 +654,9 @@ mraa_io_init(const char* strdesc, mraa_io_descriptor** desc) new_desc->iios[new_desc->n_iio++] = dev; } } - } else if (strncmp(str_tokens[0], I2C_KEY, strlen(I2C_KEY)) == 0 && + } +#endif + else if (strncmp(str_tokens[0], I2C_KEY, strlen(I2C_KEY)) == 0 && strlen(str_tokens[0]) == strlen(I2C_KEY)) { mraa_i2c_context dev = parse_i2c(str_tokens, num_desc_tokens); if (!dev) { @@ -807,12 +813,14 @@ mraa_io_close(mraa_io_descriptor* desc) free(desc->i2cs); } +#if !defined(PERIPHERALMAN) for (int i = 0; i < desc->n_iio; ++i) { mraa_iio_close(desc->iios[i]); } if (desc->n_iio) { free(desc->iios); } +#endif for (int i = 0; i < desc->n_pwm; ++i) { mraa_pwm_close(desc->pwms[i]);