Minor style fixes and improvements for gpio code.
diff --git a/bbb_cape/src/bbb/gpi.cc b/bbb_cape/src/bbb/gpi.cc
index 9045eca..90c46d5 100644
--- a/bbb_cape/src/bbb/gpi.cc
+++ b/bbb_cape/src/bbb/gpi.cc
@@ -45,4 +45,4 @@
return atoi(&buf);
}
-} // namespace bbb
+} // namespace bbb
diff --git a/bbb_cape/src/bbb/gpi.h b/bbb_cape/src/bbb/gpi.h
index d63b9dc..be41a11 100644
--- a/bbb_cape/src/bbb/gpi.h
+++ b/bbb_cape/src/bbb/gpi.h
@@ -18,6 +18,6 @@
int Read();
};
-} // namespace bbb
+} // namespace bbb
#endif
diff --git a/bbb_cape/src/bbb/gpo.cc b/bbb_cape/src/bbb/gpo.cc
index 5926a7c..29c5ee6 100644
--- a/bbb_cape/src/bbb/gpo.cc
+++ b/bbb_cape/src/bbb/gpo.cc
@@ -18,7 +18,7 @@
}
}
-bool Gpo::DoSet(const int value) {
+bool Gpo::Set(const bool high) {
char val_path[64];
snprintf(val_path, sizeof(val_path), "/sys/class/gpio/gpio%d/value",
kernel_pin_);
@@ -28,10 +28,10 @@
return false;
}
- fprintf(handle_, "%d", value);
+ fprintf(handle_, "%d", high);
fclose(handle_);
return true;
}
-} // namespace bbb
+} // namespace bbb
diff --git a/bbb_cape/src/bbb/gpo.h b/bbb_cape/src/bbb/gpo.h
index 3d7b2ce..701e214 100644
--- a/bbb_cape/src/bbb/gpo.h
+++ b/bbb_cape/src/bbb/gpo.h
@@ -10,20 +10,12 @@
public:
// See the base class for what these args mean.
Gpo(int bank, int pin);
-
- // Methods set the pin to read either high or low.
- inline bool SetHigh() {
- return DoSet(1);
- }
- inline bool SetLow() {
- return DoSet(0);
- }
-
- private:
- // Does the actual pin setting.
- bool DoSet(const int value);
+ // Sets the pin to either high or low.
+ // If the argument is true, is sets it high.
+ // Otherwise, it sets it low.
+ bool Set(const bool high);
};
-} // namespace bbb
+} // namespace bbb
#endif
diff --git a/bbb_cape/src/bbb/uart_reader_main.cc b/bbb_cape/src/bbb/uart_reader_main.cc
index d42f319..52b6555 100644
--- a/bbb_cape/src/bbb/uart_reader_main.cc
+++ b/bbb_cape/src/bbb/uart_reader_main.cc
@@ -40,9 +40,9 @@
#if DO_RESET
if (!last_packet_time.IsWithin(Time::Now(), kPacketTimeout.ToNSec())) {
LOG(ERROR, "No good packets for too long. Resetting cape.\n");
- reset_pin.SetHigh();
+ reset_pin.Set(true);
::aos::time::SleepFor(Time::InSeconds(1));
- reset_pin.SetLow();
+ reset_pin.Set(false);
last_packet_time = Time::Now();
}