diff --git a/api/mraa/common.h b/api/mraa/common.h index 4f5f828..3c8aba3 100644 --- a/api/mraa/common.h +++ b/api/mraa/common.h @@ -208,6 +208,34 @@ unsigned int mraa_get_pin_count(); */ int mraa_get_uart_count(void); +/** + * Get the number of usable SPI buses, board must be initialised. + * + * @return number of usable SPI buses on the platform, returns -1 on failure. + */ +int mraa_get_spi_bus_count(void); + +/** + * Get the number of usable PWM pins, board must be initialised. + * + * @return number of PWMs on the current platform, -1 on failure. + */ +int mraa_get_pwm_count(void); + +/** + * Get the number of usable GPIOs, board must be initialised. + * + * @return number of usable external GPIO pins on the board, -1 on failure. + */ +int mraa_get_gpio_count(void); + +/** + * Get the number of usable analog pins, board must be initialised. + * + * @return number of usable ADC inputs on the platform and -1 on failure. + */ +int mraa_get_aio_bus_count(void); + /** * Get platform usable I2C bus count, board must be initialised. * diff --git a/src/mraa.c b/src/mraa.c index 86a0472..d4aa217 100644 --- a/src/mraa.c +++ b/src/mraa.c @@ -759,6 +759,42 @@ mraa_get_uart_count(void) return plat->uart_dev_count; } +int +mraa_get_spi_count(void) +{ + if (plat == NULL) { + return -1; + } + return plat->spi_bus_count; +} + +int +mraa_get_pwm_count(void) +{ + if (plat == NULL) { + return -1; + } + return plat->pwm_dev_count; +} + +int +mraa_get_gpio_count(void) +{ + if (plat == NULL) { + return -1; + } + return plat->gpio_count; +} + +int +mraa_get_aio_count(void) +{ + if (plat == NULL) { + return -1; + } + return plat->aio_count; +} + int mraa_get_i2c_bus_count() {