copied everything over from 2012 and removed all of the actual robot code except the drivetrain stuff
git-svn-id: https://robotics.mvla.net/svn/frc971/2013/trunk/src@4078 f308d9b7-e957-4cde-b6ac-9a88185e7312
diff --git a/aos/common/control_loop/Timing.cpp b/aos/common/control_loop/Timing.cpp
new file mode 100644
index 0000000..63fda44
--- /dev/null
+++ b/aos/common/control_loop/Timing.cpp
@@ -0,0 +1,19 @@
+#include "aos/common/logging/logging.h"
+#include "aos/common/control_loop/Timing.h"
+
+#include "aos/common/time.h"
+
+namespace aos {
+namespace time {
+
+void PhasedLoopXMS(int ms, int offset) {
+ // TODO(brians): Rewrite this cleaner.
+ // TODO(brians): Tests!
+ int64_t period_nsec = Time::InMS(ms).nsec();
+ SleepUntil(Time::InNS((Time::Now().ToNSec() / period_nsec +
+ static_cast<int64_t>(1)) * period_nsec +
+ Time::InUS(offset).ToNSec()));
+}
+
+} // namespace timing
+} // namespace aos