OS  v1.7.5
Documentation
Loading...
Searching...
No Matches
clock.hpp
1#ifndef QOS_CPP_CLOCK
2#define QOS_CPP_CLOCK
3
4#include "include/types.hpp"
5#include "config/config.h"
6
7namespace qOS {
8
16
19
21 /*cstat -CERT-FLP34-C -MISRAC++2008-5-0-5 -MISRAC++2008-5-0-7*/
22 constexpr qOS::duration_t operator "" _ms( unsigned long long int x )
23 {
24 return static_cast<qOS::duration_t>( x );
25 }
26 constexpr qOS::duration_t operator "" _sec( unsigned long long int x )
27 {
28 return static_cast<qOS::duration_t>( 1000U*x );
29 }
30 constexpr qOS::duration_t operator "" _sec( long double x )
31 {
32 return static_cast<qOS::duration_t>( 1000U*x );
33 }
34 constexpr qOS::duration_t operator "" _minutes( unsigned long long int x )
35 {
36 return static_cast<qOS::duration_t>( 60000U*x );
37 }
38 constexpr qOS::duration_t operator "" _minutes( long double x )
39 {
40 return static_cast<qOS::duration_t>( 60000U*x );
41 }
42 constexpr qOS::duration_t operator "" _hours( unsigned long long int x )
43 {
44 return static_cast<qOS::duration_t>( 3600000U*x );
45 }
46 constexpr qOS::duration_t operator "" _hours( long double x )
47 {
48 return static_cast<qOS::duration_t>( 3600000U*x );
49 }
50 constexpr qOS::duration_t operator "" _days( unsigned long long int x )
51 {
52 return static_cast<qOS::duration_t>( 86400000U*x );
53 }
54 constexpr qOS::duration_t operator "" _days( long double x )
55 {
56 return static_cast<qOS::duration_t>( 86400000*x );
57 }
58 /*cstat +CERT-FLP34-C +MISRAC++2008-5-0-5 +MISRAC++2008-5-0-7*/
74 using getTickFcn_t = clock_t (*)( void );
75
79 class clock final {
80 protected:
82 static volatile qOS::clock_t sysTick_Epochs; // skipcq: CXX-W2009
83 static qOS::clock_t internalTick( void ) noexcept;
84 clock();
86 public:
87 clock( clock &other ) = delete;
88 void operator=( const clock & ) = delete;
93 static getTickFcn_t getTick; // skipcq: CXX-W2009
104 static void sysTick( void ) noexcept;
114 static bool timeDeadLineCheck( const qOS::clock_t ti, const qOS::clock_t td ) noexcept;
120 static bool setTickProvider( const getTickFcn_t provider ) noexcept;
122 static const qOS::duration_t NONE;
125 };
126
128}
129
130
131
132#endif /*QOS_CPP_CLOCK*/
A class to encapsulate the OS clock.
Definition clock.hpp:79
static const qOS::duration_t NONE
To specify a null time value.
Definition clock.hpp:122
void operator=(const clock &)=delete
static bool setTickProvider(const getTickFcn_t provider) noexcept
Set the clock-tick provider function.
static getTickFcn_t getTick
Return the current tick used by the OS.
Definition clock.hpp:93
static bool timeDeadLineCheck(const qOS::clock_t ti, const qOS::clock_t td) noexcept
Perform a timestamp check. This function computes the amount of time elapsed between the current inst...
clock(clock &other)=delete
static const qOS::duration_t IMMEDIATE
To specify a non-wait time value.
Definition clock.hpp:124
static void sysTick(void) noexcept
Feed the system tick.
timeCount_t duration_t
The typedef that specified an time quantity, usually expressed in milliseconds.
Definition clock.hpp:18
clock_t(*)(void) getTickFcn_t
Pointer to a function that gets the current hardware tick value.
Definition clock.hpp:74
timeCount_t clock_t
A unsigned integer to hold ticks count. Epochs counter.
Definition clock.hpp:15
unsigned long timeCount_t
A type to instantiate a variable to hold a time count.
Definition types.hpp:130
OS/Kernel interfaces.
Definition bytebuffer.hpp:7