common.hpp: Added sub platform API calls.
[contrib/mraa.git] / api / mraa / common.hpp
index 94821e8..cf409ae 100644 (file)
@@ -214,4 +214,89 @@ setLogLevel(int level)
 {
     return mraa_set_log_level(level);
 }
+
+/**
+ * Detect presence of sub platform.
+ *
+ * @return bool true if sub platform is present and initialized, false otherwise
+ */
+inline bool
+hasSubPlatform()
+{
+    return static_cast<bool>(mraa_has_sub_platform());
+}
+
+
+/**
+ * Select main platform for platform info calls.
+ *
+ * @return bool true if main platform is available, false otherwise
+ */
+inline bool
+selectMainPlatform()
+{
+    return static_cast<bool>(mraa_select_main_platform());
+}
+
+/**
+ * Select sub platform for platform info calls.
+ *
+ * @return mraa_boolean_t true if sub platform is available, 0 otherwise
+ */
+inline bool
+selectSubPlatform()
+{
+    return static_cast<bool>(mraa_select_sub_platform());
+}
+
+    
+/**
+ * Check if sub platform is currently available and selected for platform info calls.
+ *
+ * @return bool true if sub platform is selected, false otherwise
+ */
+inline bool
+isSubPlatformSelected()
+{
+    return static_cast<bool>(mraa_is_sub_platform_selected());
+}
+
+
+/**
+ * Check if pin or bus id includes sub platform mask.
+ *
+ * @param int pin or bus number
+ *
+ * @return mraa_boolean_t 1 if pin or bus is for sub platform, 0 otherwise
+ */
+inline bool
+isSubPlatformId(int pin_or_bus_id)
+{
+    return static_cast<bool>(mraa_is_sub_platform_id(pin_or_bus_id));
+}
+
+/**
+ * Convert pin or bus index to corresponding sub platform id.
+ *
+ * @param int pin or bus index
+ *
+ * @return int sub platform pin or bus number
+ */
+inline int 
+getSubPlatformId(int pin_or_bus_index)
+{
+    return mraa_get_sub_platform_id(pin_or_bus_index);
+}
+
+/**
+ * Convert pin or bus sub platform id to index.
+ *
+ * @param int sub platform pin or bus id
+ *
+ * @return int pin or bus index
+ */
+int getSubPlatformIndex(int pin_or_bus_id)
+{
+    return mraa_get_sub_platform_index(pin_or_bus_id);
+}
 }