diff --git a/api/maa.h b/api/maa.h index ffd64c6..6fe7956 100644 --- a/api/maa.h +++ b/api/maa.h @@ -184,43 +184,6 @@ maa_result_t maa_init() __attribute__((constructor)); maa_result_t maa_init(); #endif -/** Check GPIO - * - * Will check input is valid for gpio and will also setup required multiplexers. - * @param pin the pin as read from the board surface. i.e IO3 would be 3/ - * @return the pin as found in the pinmap - */ -unsigned int maa_check_gpio(int pin); - -/** Check AIO - * - * Will check input is valid for aio and will also setup required multiplexers. - * @param pin the pin as read from the board surface. i.e A3 would be 3/ - * @return the pin as found in the pinmap - */ -unsigned int maa_check_aio(int pin); - -/** Check i2c interface, sets up multiplexer on device. - * - * @return unsigned int if using /dev/i2c-2 returned would be 2 - */ -unsigned int maa_check_i2c(); - -/** Check spi interface, sets up multiplexer on device. - * - * @return spi bus type - */ -maa_spi_bus_t* maa_check_spi(int bus); - -/** Check PWM - * - * Will check input is valid for pwm and will also setup required multiplexers. - * IF the pin also does gpio (strong chance), DO NOTHING, REV D is strange. - * @param pin the pin as read from the board surface. - * @return the pwm pin_info_t of that IO pin - */ -maa_pin_t* maa_check_pwm(int pin); - /** Get the version string of maa autogenerated from git tag * * The version returned may not be what is expected however it is a reliable diff --git a/src/aio/aio.c b/src/aio/aio.c index 58cfb39..1f90ece 100644 --- a/src/aio/aio.c +++ b/src/aio/aio.c @@ -27,6 +27,7 @@ #include #include "aio.h" +#include "maa_internal.h" struct _aio { unsigned int channel; @@ -59,7 +60,7 @@ static maa_result_t aio_get_valid_fp(maa_aio_context dev) */ maa_aio_context maa_aio_init(unsigned int aio_channel) { - int checked_pin = maa_check_aio(aio_channel); + int checked_pin = maa_setup_aio(aio_channel); if (checked_pin < 0) { switch(checked_pin) { case -1: diff --git a/src/gpio/gpio.c b/src/gpio/gpio.c index 69181cb..1a625c4 100644 --- a/src/gpio/gpio.c +++ b/src/gpio/gpio.c @@ -23,6 +23,7 @@ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "gpio.h" +#include "maa_internal.h" #include #include @@ -68,7 +69,7 @@ maa_gpio_get_valfp(maa_gpio_context dev) maa_gpio_context maa_gpio_init(int pin) { - int pinm = maa_check_gpio(pin); + int pinm = maa_setup_gpio(pin); if (pinm < 0) return NULL; diff --git a/src/i2c/i2c.c b/src/i2c/i2c.c index 496ede9..4f3f02c 100644 --- a/src/i2c/i2c.c +++ b/src/i2c/i2c.c @@ -24,6 +24,7 @@ #include "i2c.h" #include "smbus.h" +#include "maa_internal.h" struct _i2c { /*@{*/ @@ -31,12 +32,12 @@ struct _i2c { int fh; /**< the file handle to the /dev/i2c-* device */ int addr; /**< the address of the i2c slave */ /*@}*/ -}; +}; maa_i2c_context maa_i2c_init(int bus) { - int checked_pin = maa_check_i2c(bus); + int checked_pin = maa_setup_i2c(bus); if (checked_pin < 0) { switch(checked_pin) { case -1: diff --git a/src/maa.c b/src/maa.c index 6810c8a..215687c 100644 --- a/src/maa.c +++ b/src/maa.c @@ -27,6 +27,7 @@ #include #include "maa.h" +#include "maa_internal.h" #include "intel_galileo_rev_d.h" #include "gpio.h" #include "version.h" @@ -82,7 +83,7 @@ maa_setup_mux_mapped(maa_pin_t meta) } unsigned int -maa_check_gpio(int pin) +maa_setup_gpio(int pin) { if (plat == NULL) return -1; @@ -100,7 +101,7 @@ maa_check_gpio(int pin) } unsigned int -maa_check_aio(int aio) +maa_setup_aio(int aio) { if (plat == NULL) return -3; @@ -120,7 +121,7 @@ maa_check_aio(int aio) } unsigned int -maa_check_i2c(int bus_s) +maa_setup_i2c(int bus_s) { if (plat == NULL) return -3; @@ -145,7 +146,7 @@ maa_check_i2c(int bus_s) } maa_spi_bus_t* -maa_check_spi(int bus) +maa_setup_spi(int bus) { if (plat == NULL) return NULL; @@ -179,7 +180,7 @@ maa_check_spi(int bus) } maa_pin_t* -maa_check_pwm(int pin) +maa_setup_pwm(int pin) { if (plat == NULL) return NULL; diff --git a/src/pwm/pwm.c b/src/pwm/pwm.c index 25d1341..50786e8 100644 --- a/src/pwm/pwm.c +++ b/src/pwm/pwm.c @@ -26,6 +26,7 @@ #include #include "pwm.h" +#include "maa_internal.h" #define MAX_SIZE 64 #define SYSFS_PWM "/sys/class/pwm" @@ -131,7 +132,7 @@ maa_pwm_get_duty(maa_pwm_context dev) maa_pwm_context maa_pwm_init(int pin) { - maa_pin_t* pinm = maa_check_pwm(pin); + maa_pin_t* pinm = maa_setup_pwm(pin); if (pinm == NULL) return NULL; int chip = pinm->parent_id; diff --git a/src/spi/spi.c b/src/spi/spi.c index f1b6255..494d67e 100644 --- a/src/spi/spi.c +++ b/src/spi/spi.c @@ -30,12 +30,13 @@ #include #include "spi.h" +#include "maa_internal.h" #define MAX_SIZE 64 #define SPI_MAX_LENGTH 4096 /** - * A strucutre representing the SPI device + * A structure representing the SPI device */ struct _spi { /*@{*/ @@ -50,7 +51,7 @@ struct _spi { maa_spi_context maa_spi_init(int bus) { - maa_spi_bus_t *spi = maa_check_spi(bus); + maa_spi_bus_t *spi = maa_setup_spi(bus); if(bus < 0) { fprintf(stderr, "Failed. SPI platform Error\n"); return NULL;