Private
Public Access
2
0

api/mraa: add mraa_get_pin_name

Add mraa_get_pin_name to get the real world name of the pin.

Signed-off-by: Michael Ring <mail@michael-ring.org>
Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
This commit is contained in:
Michael Ring
2015-03-18 20:48:14 +01:00
committed by Thomas Ingleby
parent 62213fad77
commit 827e1974bf
3 changed files with 33 additions and 0 deletions

View File

@@ -149,6 +149,15 @@ mraa_platform_t mraa_get_platform_type();
*/
unsigned int mraa_get_pin_count();
/**
* Get name of pin, board must be initialised.
*
* @param pin number
*
* @return char* of pin name
*/
char* mraa_get_pin_name(int pin);
#ifdef __cplusplus
}
#endif

View File

@@ -151,6 +151,19 @@ inline unsigned int getPinCount()
return mraa_get_pin_count();
}
/**
* Get name of pin, board must be initialised.
*
* @param pin number
*
* @return char* of pin name
*/
inline std::string getPinName(int pin)
{
std::string ret_val(mraa_get_pin_name(pin));
return ret_val;
}
/**
* 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.

View File

@@ -327,6 +327,17 @@ mraa_file_exist(char *filename) {
return file_found;
}
char*
mraa_get_pin_name(int pin)
{
if (plat == NULL) {
return NULL;
}
if (pin > (plat->phy_pin_count -1) || pin < 0)
return NULL;
return (char*) plat->pins[pin].name;
}
char*
mraa_file_unglob(char *filename) {
glob_t results;