summaryrefslogtreecommitdiff
path: root/library/src/gpio.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'library/src/gpio.cpp')
-rw-r--r--library/src/gpio.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/library/src/gpio.cpp b/library/src/gpio.cpp
new file mode 100644
index 0000000..18c3cff
--- /dev/null
+++ b/library/src/gpio.cpp
@@ -0,0 +1,34 @@
+#include <rpc/client.h>
+
+#include <hwd/internal.h>
+
+namespace hwd
+{
+
+static rpc::client & get_client()
+{
+ static rpc::client c(hwd::internal::host(), hwd::internal::port());
+ return c;
+}
+
+namespace gpio
+{
+
+void set_mode(const unsigned port, const short mode)
+{
+ get_client().call("gpio/set_mode", port, mode);
+}
+
+void write(const unsigned port, const short value)
+{
+ get_client().call("gpio/write", port, value);
+}
+
+short read(const unsigned port)
+{
+ return get_client().call("gpio/read", port).as<short>();
+}
+
+} // namespace gpio
+
+} // namespace hwd