Private
Public Access
2
0

mraa.c: Added common function to init io from a description

Signed-off-by: Houman Brinjcargorabi <houman.brinjcargorabi@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Houman brinjcargorabi
2016-05-23 13:55:57 +01:00
committed by Brendan Le Foll
parent a9de84b74a
commit bcf1584fbe
3 changed files with 188 additions and 0 deletions

View File

@@ -293,6 +293,19 @@ mraa_result_t mraa_add_subplatform(mraa_platform_t subplatformtype, const char*
*/
mraa_result_t mraa_remove_subplatform(mraa_platform_t subplatformtype);
/**
* Create IO using a description in the format:
* [io]-[pin]
* [io]-[raw]-[pin]
* [io]-[raw]-[id]-[pin]
* [io]-[raw]-[path]
*
* @param IO description
*
* @return void* to IO context or NULL
*/
void* mraa_init_io(const char* desc);
#ifdef __cplusplus
}
#endif

View File

@@ -309,4 +309,22 @@ removeSubplatform(Platform subplatformtype)
return (Result) mraa_remove_subplatform((mraa_platform_t) subplatformtype);
}
/**
* Create IO using a description in the format:
* [io]-[pin]
* [io]-[raw]-[pin]
* [io]-[raw]-[id]-[pin]
* [io]-[raw]-[path]
*
* @param IO description
*
* @return class T initialised using pointer to IO or NULL
*/
template <class T>
inline T*
initIo(std::string desc)
{
return new T(mraa_init_io(desc.c_str()));
}
}