From: Thomas Ingleby Date: Wed, 21 Jan 2015 15:11:03 +0000 (+0000) Subject: mraa/platform: add mraa_get_pin_count() X-Git-Tag: v0.6.0~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=067487f9ece194bcddbc8ec998835817e2497457;hp=456646ca532572e14ec48e51193b7febe753e8a7;p=contrib%2Fmraa.git mraa/platform: add mraa_get_pin_count() Will return physical pin count. Closes #75 Signed-off-by: Thomas Ingleby --- diff --git a/api/mraa/common.h b/api/mraa/common.h index eb8f0a3..86525e9 100644 --- a/api/mraa/common.h +++ b/api/mraa/common.h @@ -278,6 +278,13 @@ void mraa_result_print(mraa_result_t result); */ mraa_platform_t mraa_get_platform_type(); +/** + * Get platform pincount, board must be initialised. + * + * @return uint of physical pin count on the in-use platform + */ +unsigned int mraa_get_pin_count(); + #ifdef __cplusplus } #endif diff --git a/api/mraa/common.hpp b/api/mraa/common.hpp index 875d434..c51cf22 100644 --- a/api/mraa/common.hpp +++ b/api/mraa/common.hpp @@ -128,6 +128,16 @@ inline std::string getPlatformName() } /** + * Return count of physical pins on the running platform + * + * @return uint of physical pins. + */ +inline unsigned int getPinCount() +{ + return mraa_get_pin_count(); +} + +/** * Sets the log level to use from 0-7 where 7 is very verbose. These are the * syslog log levels, see syslog(3) for more information on the levels. * diff --git a/src/mraa.c b/src/mraa.c index 9076316..91e48c1 100644 --- a/src/mraa.c +++ b/src/mraa.c @@ -307,3 +307,12 @@ mraa_get_platform_name() return "Unknown"; return plat->platform_name; } + +unsigned int +mraa_get_pin_count() +{ + if (plat == NULL) { + return 0; + } + return plat->phy_pin_count; +}