From b7e8d969453cc8c641e354436aa67b03b6102530 Mon Sep 17 00:00:00 2001 From: Tapani Utriainen Date: Thu, 18 May 2017 20:56:04 +0800 Subject: [PATCH] mraa: add a function that returns the number of uarts available Signed-off-by: Tapani Utriainen Signed-off-by: Brendan Le Foll --- api/mraa/common.h | 7 +++++++ api/mraa/common.hpp | 12 ++++++++++++ src/mraa.c | 9 +++++++++ 3 files changed, 28 insertions(+) diff --git a/api/mraa/common.h b/api/mraa/common.h index 61063f4..4f5f828 100644 --- a/api/mraa/common.h +++ b/api/mraa/common.h @@ -201,6 +201,13 @@ int mraa_get_platform_combined_type(); */ unsigned int mraa_get_pin_count(); +/** + * Get the number of usable UARTs, board must be initialised. + * + * @return number of usable UARTs on the platform, returns -1 on failure. + */ +int mraa_get_uart_count(void); + /** * Get platform usable I2C bus count, board must be initialised. * diff --git a/api/mraa/common.hpp b/api/mraa/common.hpp index 0619a36..1640d1a 100644 --- a/api/mraa/common.hpp +++ b/api/mraa/common.hpp @@ -178,6 +178,18 @@ getPinCount() return mraa_get_pin_count(); } +/** + * Get platform usable UART count, board must be initialised. + * + * @return number of usable UARTs on the current platform. Function will + * return -1 on failure + */ +inline int +getUartCount() +{ + return mraa_get_uart_count(); +} + /** * Get platform usable I2C bus count, board must be initialised. * diff --git a/src/mraa.c b/src/mraa.c index d7d141d..86a0472 100644 --- a/src/mraa.c +++ b/src/mraa.c @@ -750,6 +750,15 @@ mraa_get_platform_version(int platform_offset) } } +int +mraa_get_uart_count(void) +{ + if (plat == NULL) { + return -1; + } + return plat->uart_dev_count; +} + int mraa_get_i2c_bus_count() {