Clean up gpio code.
- Break out the input and output components into separate
subclasses.
- Fix some styleguide issues, including adding more useful
comments.
- Make stuff return bool instead of int like it should.
- Make the API simpler.
- Make failure to export or set pin direction FATAL.
(The rational for this is in the comments.)
It compiles, but remains untested.
diff --git a/bbb_cape/src/bbb/gpi.h b/bbb_cape/src/bbb/gpi.h
new file mode 100644
index 0000000..d63b9dc
--- /dev/null
+++ b/bbb_cape/src/bbb/gpi.h
@@ -0,0 +1,23 @@
+#ifndef BBB_CAPE_SRC_BBB_GPI_H_
+#define BBB_CAPE_SRC_BBB_GPI_H_
+
+#include "gpios.h"
+
+// Subclass of Pin for input pins.
+
+namespace bbb {
+
+class Gpi : public Pin {
+ public:
+ // See the base class for what these args mean.
+ Gpi(int bank, int pin);
+
+ // Read the current value of the pin.
+ // Returns 1 if it reads high, 0 for low.
+ // Returns -1 if fails to read the pin for some reason.
+ int Read();
+};
+
+} // namespace bbb
+
+#endif