summaryrefslogtreecommitdiff
path: root/library
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2021-10-21 21:45:51 +0200
committerAki <please@ignore.pl>2021-10-21 21:45:51 +0200
commitbc99c3926208af887e4ca9d318f1d4c4744de397 (patch)
treec772a92b74e0d292d86cfe5c6cdc7f0d8f8b958d /library
parent648be70f7b676a618fa1753c486e8cb5f4a593f5 (diff)
downloadhwd-bc99c3926208af887e4ca9d318f1d4c4744de397.zip
hwd-bc99c3926208af887e4ca9d318f1d4c4744de397.tar.gz
hwd-bc99c3926208af887e4ca9d318f1d4c4744de397.tar.bz2
Added memory interface to the library
Diffstat (limited to 'library')
-rw-r--r--library/include/hwd.h12
-rw-r--r--library/src/memory.cpp25
2 files changed, 37 insertions, 0 deletions
diff --git a/library/include/hwd.h b/library/include/hwd.h
index 3bec6be..fbd2fef 100644
--- a/library/include/hwd.h
+++ b/library/include/hwd.h
@@ -1,11 +1,23 @@
#pragma once
+#include <cstddef>
+#include <vector>
+
+
namespace hwd
{
+
namespace gpio
{
void set_mode(const unsigned port, const short mode);
void write(const unsigned port, const short value);
short read(const unsigned port);
} // namespace gpio
+
+namespace memory
+{
+std::vector<char> read(std::size_t len, std::size_t off);
+bool write(const std::vector<char> data, std::size_t off);
+} // namespace memory
+
} // namespace hwd
diff --git a/library/src/memory.cpp b/library/src/memory.cpp
new file mode 100644
index 0000000..c3c5b2a
--- /dev/null
+++ b/library/src/memory.cpp
@@ -0,0 +1,25 @@
+#include "hwd.h"
+
+#include <cstddef>
+#include <vector>
+
+#include "client.h"
+
+
+namespace hwd
+{
+namespace memory
+{
+
+std::vector<char> read(std::size_t len, std::size_t off)
+{
+ return get_client().call("memory/read", len, off).as<std::vector<char>>();
+}
+
+bool write(const std::vector<char> data, std::size_t off)
+{
+ return get_client().call("memory/write", data, off).as<bool>();
+}
+
+} // namespace memory
+} // namespace hwd