fixed the gpio code
diff --git a/bbb_cape/src/bbb/gpios.h b/bbb_cape/src/bbb/gpios.h
index 4925f1b..1471b43 100644
--- a/bbb_cape/src/bbb/gpios.h
+++ b/bbb_cape/src/bbb/gpios.h
@@ -5,42 +5,28 @@
#include "aos/common/macros.h"
-// As it turns out, controlling the BBB's GPIO pins
-// from C++ is kind of a pain. The purpose of this
-// code is to provide a simple wrapper that masks
-// all the ugly stuff and exposes a nice API.
+// Controlling GPIO pins
+// from C++ is a pain. This code provides a simple wrapper that makes it easy to
+// use cleanly.
// Based on example from
// <http://learnbuildshare.wordpress.com/2013/05/29/beaglebone-black-digital-ouput/>
// This is a base class for all gpio related stuff.
-// Use either a gpi or gpo subclass if you want to do things.
+// Use either the Gpi or the Gpo subclass if you want to do things.
namespace bbb {
-class Pin {
- public:
- // Not strictly necessary for this to be virtual,
- // but it's a good idea.
- virtual ~Pin();
- // When you don't define this and use the
- // DISALLOW_COPY_AND_ASSIGN macro, the compiler
- // doesn't seem to create a default one.
- Pin();
-
+class GpioPin {
protected:
- // Set the pin direction.
- // 1 makes it an input.
- // 2 makes it an output and sets the initial state to low.
- bool DoPinDirSet(int direction);
- // Export the pin, so we can use it.
- // Here, for example, if you wanted to use
- // GPIO1_28, you would give it 1, 28 as arguments.
- bool InitPin(int bank, int pin);
+ // initial_value only matters if input is false.
+ GpioPin(int bank, int pin, bool input, bool initial_value = false);
+ virtual ~GpioPin();
- FILE *handle_ = NULL;
- int kernel_pin_ = -1;
+ FILE *value_handle_ = NULL;
+ const int bank_, pin_, kernel_pin_;
- DISALLOW_COPY_AND_ASSIGN(Pin);
+ private:
+ DISALLOW_COPY_AND_ASSIGN(GpioPin);
};
} // namespace bbb