blob: 3a58036463374bf900c9d0c3e74e6f544dc1d032 [file] [log] [blame]
brians343bc112013-02-10 01:53:46 +00001#include "aos/common/control_loop/Timing.h"
2
Brian Silvermanf665d692013-02-17 22:11:39 -08003#include <string.h>
4
5#include "aos/common/logging/logging.h"
brians343bc112013-02-10 01:53:46 +00006#include "aos/common/time.h"
7
8namespace aos {
9namespace time {
10
11void PhasedLoopXMS(int ms, int offset) {
brians343bc112013-02-10 01:53:46 +000012 // TODO(brians): Tests!
Brian Silverman7645d2f2013-03-30 18:53:56 -070013 const Time frequency = Time::InMS(ms);
14 SleepUntil((Time::Now() / frequency.ToNSec()) *
15 frequency.ToNSec() +
16 frequency + Time::InUS(offset));
brians343bc112013-02-10 01:53:46 +000017}
18
19} // namespace timing
20} // namespace aos