diff options
author | Aki <please@ignore.pl> | 2021-10-21 21:26:57 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2021-10-21 21:26:57 +0200 |
commit | 439f76609407da15096c1f2835b8eb7034211c88 (patch) | |
tree | 09b2bbc9d306efde51ec6e5a0d06981ec7381206 /library/src/gpio.cpp | |
parent | 4806f1efa843d690fcd3d0a721291adbc7e96a79 (diff) | |
download | hwd-439f76609407da15096c1f2835b8eb7034211c88.zip hwd-439f76609407da15096c1f2835b8eb7034211c88.tar.gz hwd-439f76609407da15096c1f2835b8eb7034211c88.tar.bz2 |
Renamed gpio source of library
Diffstat (limited to 'library/src/gpio.cpp')
-rw-r--r-- | library/src/gpio.cpp | 34 |
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 |