CTRE Phoenix C++ 5.33.1
SleepUs.h
Go to the documentation of this file.
1/* Copyright (C) Cross The Road Electronics 2024 */
2#pragma once
3
4#include <chrono>
5#include <thread>
6
7#ifdef __FRC_ROBORIO__
8#include <unistd.h>
9#endif
10
11namespace ctre {
12namespace phoenix {
13namespace platform {
14
15 /**
16 * @param timeUs How long to yield current thread in microseconds (us).
17 * If platform cannot honor us resolution, round to nearest
18 * value that platform can honor.
19 */
20 static inline void SleepUs(int timeUs)
21 {
22#ifdef __FRC_ROBORIO__
23 usleep(timeUs);
24#else
25 std::this_thread::sleep_for(std::chrono::microseconds(timeUs));
26#endif
27 }
28
29} // namespace platform
30} // namespace phoenix
31} // namespace ctre
static void SleepUs(int timeUs)
Definition: SleepUs.h:20
namespace ctre
Definition: paramEnum.h:5