RTLib
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
system.h
Go to the documentation of this file.
1 /*
2  * This file is part of RTLib.
3  *
4  * Copyright (C) 2017-2018 Derppening <david.18.19.21@gmail.com>
5  *
6  * RTLib is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * RTLib is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with RTLib. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef RTLIB_LIB_SYSTEM_H_
21 #define RTLIB_LIB_SYSTEM_H_
22 
23 #include <cstdint>
24 
33 class System final {
34  public:
41  enum ClockResolution : uint32_t {
47  kLowRes = 1,
53  kStdRes = 1000,
59  kHighRes = 1000000
60  };
61 
67  System() = delete;
68 
77  static void Init(ClockResolution clock_res = kStdRes);
78 
89  static uint64_t GetUs();
100  static uint64_t GetMs();
110  static uint64_t GetS();
111 
122  static void DelayUs(uint64_t wait_us);
132  static void DelayMs(uint64_t wait_ms);
140  static void DelayS(uint64_t wait_s);
141 
142  private:
143  static bool has_init_;
144  static ClockResolution clock_res_;
145 };
146 
147 #endif // RTLIB_LIB_SYSTEM_H_
static uint64_t GetUs()
Returns the time since clock initialization.
Definition: system.cpp:56
static void Init(ClockResolution clock_res=kStdRes)
Initializes the timekeeping functionality.
Definition: system.cpp:37
static uint64_t GetMs()
Returns the time since clock initialization.
Definition: system.cpp:68
HAL implementation for system clock.
Definition: system.h:33
System()=delete
Default constructor for System.
Standard Clock Resolution.
Definition: system.h:53
static void DelayUs(uint64_t wait_us)
Temporarily halt program execution.
Definition: system.cpp:76
Low Clock Resolution.
Definition: system.h:47
static uint64_t GetS()
Returns the time since clock initialization.
Definition: system.cpp:72
static void DelayMs(uint64_t wait_ms)
Temporarily halt program execution.
Definition: system.cpp:81
static void DelayS(uint64_t wait_s)
Temporarily halt program execution.
Definition: system.cpp:85
ClockResolution
Enumeration of clock resolution.
Definition: system.h:41
High Clock Resolution.
Definition: system.h:59