ConOpSys V2970  P004.07
ANVILEX control operating system
System_Timer_Base.h
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 //! @file System_Timer_Base.h
3 //! @brief System timer base class header file.
4 //! @attention No special attention requered.
5 //! @copyright (C) 2015-2020 ANVILEX LLC
6 //! $HeadURL: https://192.168.3.4:8443/svn/P004_07/ConOpSys/Engine/System_Timer_Base.h $
7 //! $Revision: 2871 $
8 //! $Date: 2021-09-17 14:54:52 +0500 (Fr, 17 Sep 2021) $
9 //! $Author: ggavrituhin $
10 //------------------------------------------------------------------------------
11 //
12 // Redistribution and use in source and binary forms, with or without
13 // modification, are permitted provided that the following conditions are met:
14 //
15 // 1. Redistributions of source code must retain the above copyright notice,
16 // this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright notice,
19 // this list of conditions and the following disclaimer in the documentation
20 // and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of ANVILEX nor the names of its contributors may be
23 // used to endorse or promote products derived from this software without
24 // specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
30 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 // POSSIBILITY OF SUCH DAMAGE.
37 //
38 //------------------------------------------------------------------------------
39 
40 //------------------------------------------------------------------------------
41 // Protecting header files from mutual, recursive inclusion.
42 //------------------------------------------------------------------------------
43 
44 #pragma once
45 
46 //------------------------------------------------------------------------------
47 // Include standard libraries header files
48 //------------------------------------------------------------------------------
49 
50 //------------------------------------------------------------------------------
51 // Include thrid party header files
52 //------------------------------------------------------------------------------
53 
54 //------------------------------------------------------------------------------
55 // Include ConOpSys header files
56 //------------------------------------------------------------------------------
57 
58 #include "Timer_Base.h"
59 
60 //------------------------------------------------------------------------------
61 // Class definitions
62 //------------------------------------------------------------------------------
63 
64 //! @brief System timer base class
66 {
67 
68  //----------------------------------------------------------------------------
69  // Public defines, methods and variables
70  //----------------------------------------------------------------------------
71 
72  public:
73 
74  //!-------------------------------------------------------------------------
75  //! @brief System timer class constructor method
76  //! @note None
77  //! \par Override
78  //! Not allowed
79  //! @attention Don't call this method directly.
80  //--------------------------------------------------------------------------
81 
82 // TSystem_Timer_Base();
83 
84  //!-------------------------------------------------------------------------
85  //! @brief System timer class destructor method
86  //! @note None
87  //! \par Override
88  //! Not allowed
89  //! @attention Don't call this method directly.
90  //--------------------------------------------------------------------------
91 
92 // virtual ~TSystem_Timer_Base();
93 
94  //!-------------------------------------------------------------------------
95  //! @brief Provides a system timer tick value in timer ticks as U32
96  //! @note None
97  //! @return U32 - Actual timer tick value
98  //! \par Override
99  //! Not allowed
100  //! @attention This method requered only for compatibility.
101  //--------------------------------------------------------------------------
102 
103  U32 Get_Tick();
104 
105  //!-------------------------------------------------------------------------
106  //! @brief Get actual system time in timer ticks.
107  //! @note Replacement for function Get_System_Time()
108  //! @param None
109  //! @return U32 - Actual time in timer ticks.
110  //! \par Override
111  //! Not allowed
112  //! @attention None
113  //--------------------------------------------------------------------------
114 
115  virtual U32 Get_Actual_Time();
116 
117  //!-------------------------------------------------------------------------
118  //! @brief System timer interrupt method.
119  //! @note None
120  //! @return None
121  //! \par Override
122  //! Not allowed
123  //! @attention None
124  //--------------------------------------------------------------------------
125 
126  VOID Interrupt();
127 
128  //!-------------------------------------------------------------------------
129  //! @brief Perform blocked delay given in ms.
130  //! @note None
131  //! @param [in] u32_Delay_Value - Blocked delay time in milliseconds.
132  //! @return None
133  //! \par Override
134  //! Not allowed
135  //! @attention Don't use this function within 1 ms task.
136  //--------------------------------------------------------------------------
137 
138  VOID Delay_ms( U32 u32_Delay_Value );
139 
140  //!-------------------------------------------------------------------------
141  //! @brief Get delta time in seconds.
142  //! @note None
143  //! @param [in] u32_Start_Timestamp - Timer start timestamp.
144  //! @param [in] u32_End_Timestamp - Timer end timestamp.
145  //! @return F32 - Time span in seconds.
146  //! \par Override
147  //! Not allowed
148  //! @attention None
149  //--------------------------------------------------------------------------
150 
151  F32 Get_Delta_Time( U32 u32_Start_Timestamp, U32 u32_End_Timestamp );
152 
153  //!-------------------------------------------------------------------------
154  //! @brief Return statis of the timeout.
155  //! @note None
156  //! @param [in] u32_Start_Timestamp - Timer start timestamp.
157  //! @param [in] u32_Timeout - Timeout value in millisecconds.
158  //! @return BOOL - Timeout status
159  //! @retval false - Timeout elapsed
160  //! @retval true - Timeout in profress
161  //! \par Override
162  //! Not allowed
163  //! @attention None
164  //--------------------------------------------------------------------------
165 
166  BOOL Is_Timeout_ms( U32 u32_Start_Timestamp, U32 u32_Timeout );
167 
168  //!-------------------------------------------------------------------------
169  //! @brief Return timespan in milliseconds.
170  //! @note None
171  //! @param [in] u32_Start_Timestamp - Timer start timestamp.
172  //! @return U32 - Actual timespan in milliseconds
173  //! @retval false - Timeout elapsed
174  //! @retval true - Timeout in profress
175  //! \par Override
176  //! Not allowed
177  //! @attention None
178  //--------------------------------------------------------------------------
179 
180  U32 Get_Timespan_ms( U32 u32_Start_Timestamp );
181 
182  //----------------------------------------------------------------------------
183  // Protected defines, methods and variables
184  //----------------------------------------------------------------------------
185 
186  protected:
187 
188  //--------------------------------------------------------------------------
189  // Protected variables
190  //--------------------------------------------------------------------------
191 
192  //! @brief Timer tick counter
193  volatile U32 u32_Tick_Counter = (U32)0;
194 
195  //----------------------------------------------------------------------------
196  // Private defines, methods and variables
197  //----------------------------------------------------------------------------
198 
199  private:
200 
201 };
202 
203 //------------------------------------------------------------------------------
204 // End of file
205 //------------------------------------------------------------------------------
int BOOL
Boolean datatype definition.
Definition: Defines.h:124
void VOID
Datatypesess datatype definition.
Definition: Defines.h:105
unsigned long U32
Binary 32-Bit unsigned integer datatype defenition.
Definition: Defines.h:203
float F32
IEEE-754 32-Bit single presession floating point numbers datatype defenition.
Definition: Defines.h:324
Timer base class header file.
System timer base class.
Definition: System_Timer_Base.h:66
virtual U32 Get_Actual_Time()
Get actual system time in timer ticks.
Definition: System_Timer_Base.cpp:76
VOID Delay_ms(U32 u32_Delay_Value)
Perform blocked delay given in ms.
Definition: System_Timer_Base.cpp:103
volatile U32 u32_Tick_Counter
Timer tick counter.
Definition: System_Timer_Base.h:193
VOID Interrupt()
System timer interrupt method.
Definition: System_Timer_Base.cpp:88
BOOL Is_Timeout_ms(U32 u32_Start_Timestamp, U32 u32_Timeout)
Return statis of the timeout.
Definition: System_Timer_Base.cpp:178
F32 Get_Delta_Time(U32 u32_Start_Timestamp, U32 u32_End_Timestamp)
Get delta time in seconds.
Definition: System_Timer_Base.cpp:118
U32 Get_Tick()
System timer class constructor method.
Definition: System_Timer_Base.cpp:64
U32 Get_Timespan_ms(U32 u32_Start_Timestamp)
Return timespan in milliseconds.
Definition: System_Timer_Base.cpp:222
User timer base class.
Definition: Timer_Base.h:66