ConOpSys V2970  P004.07
ANVILEX control operating system
Timer_Base.h
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 //! @file Timer_Base.h
3 //! @brief 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/Timer_Base.h $
7 //! $Revision: 2760 $
8 //! $Date: 2021-07-03 05:48:40 +0500 (Sa, 03 Jul 2021) $
9 //! $Author: minch $
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 "Defines.h"
59 
60 //------------------------------------------------------------------------------
61 // Class definitions
62 //------------------------------------------------------------------------------
63 
64 //! @brief User timer base class
66 {
67 
68  //----------------------------------------------------------------------------
69  // Public defines, methods and variables
70  //----------------------------------------------------------------------------
71 
72  public:
73 
74  //!-------------------------------------------------------------------------
75  //! @brief User timer class constructor method
76  //! @note None
77  //! \par Override
78  //! Not allowed
79  //! @attention Don't call this method directly.
80  //--------------------------------------------------------------------------
81 
82  TTimer_Base();
83 
84  //!-------------------------------------------------------------------------
85  //! @brief User 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 ~TTimer_Base();
93 
94  //!-------------------------------------------------------------------------
95  //! @brief User timer interrupt method.
96  //! @note This method should be called from hardware interrupt service routine.
97  //! @return None
98  //! \par Override
99  //! Not allowed
100  //! @attention None
101  //--------------------------------------------------------------------------
102 
103  VOID Interrupt();
104 
105  //!-------------------------------------------------------------------------
106  //! @brief Set user timer input clock frequency method.
107  //! @note None
108  //! @param [in] u32_Clock - Timer input clock in herz
109  //! @return BOOL - Execution status
110  //! @retval false - Execution without errors
111  //! @retval true - Execution without any errors
112  //! \par Override
113  //! Optional
114  //! @attention None
115  //--------------------------------------------------------------------------
116 
117  virtual BOOL Configure_Clock( U32 u32_Clock );
118 
119  //!-------------------------------------------------------------------------
120  //! @brief Set user timer interrupt frequency method.
121  //! @note None
122  //! @param [in] f32_Frequency - Timer inperrupt frequency in herz
123  //! @return BOOL - Execution status
124  //! @retval false - Execution without errors
125  //! @retval true - Execution without any errors
126  //! \par Override
127  //! Optional
128  //! @attention None
129  //--------------------------------------------------------------------------
130 
131  BOOL Set_Interrupt_Frequency( F32 f32_Frequency );
132 
133  //!-------------------------------------------------------------------------
134  //! @brief Enable interrupt method.
135  //! @note None
136  //! @param [in] u32_Interrupt_Priority - Timer inperrupt priority
137  //! @return None
138  //! \par Override
139  //! Required
140  //! @attention None
141  //--------------------------------------------------------------------------
142 
143  virtual VOID Interrupt_Enable( U32 u32_Interrupt_Priority ) = 0;
144 
145  //!-------------------------------------------------------------------------
146  //! @brief Disable interrupt method.
147  //! @note None
148  //! @return None
149  //! \par Override
150  //! Required
151  //! @attention None
152  //--------------------------------------------------------------------------
153 
154  virtual VOID Interrupt_Disable() = 0;
155 
156  //!-------------------------------------------------------------------------
157  //! @brief Start timer operation method.
158  //! @note None
159  //! @return None
160  //! \par Override
161  //! Required
162  //! @attention None
163  //--------------------------------------------------------------------------
164 
165  virtual VOID Start() = 0;
166 
167  //!-------------------------------------------------------------------------
168  //! @brief Stop timer operation method.
169  //! @note None
170  //! @return None
171  //! \par Override
172  //! Required
173  //! @attention None
174  //--------------------------------------------------------------------------
175 
176  virtual VOID Stop() = 0;
177 
178  //!-------------------------------------------------------------------------
179  //! @brief Get timer resolution in seconds.
180  //! @note None
181  //! @return None
182  //! \par Override
183  //! Not allowed
184  //! @attention None
185  //--------------------------------------------------------------------------
186 
188 
189  //!-------------------------------------------------------------------------
190  //! @brief Get timer resolution in miliseconds.
191  //! @note None
192  //! @return None
193  //! \par Override
194  //! Not allowed
195  //! @attention None
196  //--------------------------------------------------------------------------
197 
199 
200  //!-------------------------------------------------------------------------
201  //! @brief Get timer resolution in microseconds.
202  //! @note None
203  //! @return None
204  //! \par Override
205  //! Not allowed
206  //! @attention None
207  //--------------------------------------------------------------------------
208 
210 
211  //!-------------------------------------------------------------------------
212  //! @brief Get timer resolution in nanoseconds.
213  //! @note None
214  //! @return None
215  //! \par Override
216  //! Not allowed
217  //! @attention None
218  //--------------------------------------------------------------------------
219 
221 
222  //!-------------------------------------------------------------------------
223  //! @brief Get Get interrupt frequency in herz.
224  //! @note None
225  //! @return None
226  //! \par Override
227  //! Not allowed
228  //! @attention None
229  //--------------------------------------------------------------------------
230 
232 
233  //!-------------------------------------------------------------------------
234  //! @brief Get interrupt period in seconds.
235  //! @note None
236  //! @return None
237  //! \par Override
238  //! Not allowed
239  //! @attention None
240  //--------------------------------------------------------------------------
241 
243 
244  //!-------------------------------------------------------------------------
245  //! @brief Convert time to interrupt loops method.
246  //! @note None
247  //! @param [in] f32_Time_Span - Time span value in seconds for convertion to interrupt loops.
248  //! @return U32 - Interrupt loop count
249  //! \par Override
250  //! Not allowed
251  //! @attention None
252  //--------------------------------------------------------------------------
253 
254  U32 Time_To_Execution_Loops( F32 f32_Time_Span );
255 
256  //!-------------------------------------------------------------------------
257  //! @brief User timer initialisation method.
258  //! @note None
259  //! @return None
260  //! \par Override
261  //! Optional
262  //! @attention None
263  //--------------------------------------------------------------------------
264 
265  VOID Init();
266 
267  //!-------------------------------------------------------------------------
268  //! @brief User timer finalisation method.
269  //! @note None
270  //! @return None
271  //! \par Override
272  //! Optional
273  //! @attention None
274  //--------------------------------------------------------------------------
275 
276  VOID Done();
277 
278  //----------------------------------------------------------------------------
279  // Protected defines, methods and variables
280  //----------------------------------------------------------------------------
281 
282  protected:
283 
284  //--------------------------------------------------------------------------
285  // Protected variables
286  //--------------------------------------------------------------------------
287 
288  //! @brief Initialisation error
290 
291  //! @brief Timer input frequency in Hz
293 
294  //! @brief Timer clock in herz
296 
297  //! @brief Timer counter preset value
299 
300  //! @brief Timer resolution in seconds
302 
303  //! @brief Timer resolution in miliseconds
305 
306  //! @brief Timer resolution in microseconds
308 
309  //! @brief Timer resolution in nanoseconds
311 
312  //! @brief Interrupt frequency in herz
314 
315  //! @brief Interrupt period in seconds
317 
318  //----------------------------------------------------------------------------
319  // Private defines, methods and variables
320  //----------------------------------------------------------------------------
321 
322  private:
323 
324  //--------------------------------------------------------------------------
325  // Private variables
326  //--------------------------------------------------------------------------
327 
328 };
329 
330 //------------------------------------------------------------------------------
331 // End of file
332 //------------------------------------------------------------------------------
ConOpSys data type definitions header file.
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
User timer base class.
Definition: Timer_Base.h:66
virtual VOID Stop()=0
Stop timer operation method.
F32 f32_Resolution_ms
Timer resolution in miliseconds.
Definition: Timer_Base.h:304
VOID Done()
User timer finalisation method.
Definition: Timer_Base.cpp:88
VOID Init()
User timer initialisation method.
Definition: Timer_Base.cpp:80
U32 Time_To_Execution_Loops(F32 f32_Time_Span)
Convert time to interrupt loops method.
Definition: Timer_Base.cpp:287
TTimer_Base()
User timer class constructor method.
Definition: Timer_Base.cpp:64
F32 f32_Interrupt_Period
Interrupt period in seconds.
Definition: Timer_Base.h:316
F32 f32_Interrupt_Frequency
Interrupt frequency in herz.
Definition: Timer_Base.h:313
BOOL bool_Initialisation_Error
Initialisation error.
Definition: Timer_Base.h:289
virtual VOID Start()=0
Start timer operation method.
BOOL Set_Interrupt_Frequency(F32 f32_Frequency)
Set user timer interrupt frequency method.
Definition: Timer_Base.cpp:166
virtual VOID Interrupt_Disable()=0
Disable interrupt method.
F32 Get_Interrupt_Period()
Get interrupt period in seconds.
Definition: Timer_Base.cpp:275
virtual VOID Interrupt_Enable(U32 u32_Interrupt_Priority)=0
Enable interrupt method.
F32 Get_Resolution_ns()
Get timer resolution in nanoseconds.
Definition: Timer_Base.cpp:251
virtual ~TTimer_Base()
User timer class destructor method.
Definition: Timer_Base.cpp:72
F32 f32_Input_Clock
Timer input frequency in Hz.
Definition: Timer_Base.h:292
U32 u32_Timer_Clock
Timer clock in herz.
Definition: Timer_Base.h:295
F32 Get_Resolution_ms()
Get timer resolution in miliseconds.
Definition: Timer_Base.cpp:227
F32 f32_Resolution_ns
Timer resolution in nanoseconds.
Definition: Timer_Base.h:310
VOID Interrupt()
User timer interrupt method.
Definition: Timer_Base.cpp:100
F32 Get_Resolution_us()
Get timer resolution in microseconds.
Definition: Timer_Base.cpp:239
F32 f32_Resolution_us
Timer resolution in microseconds.
Definition: Timer_Base.h:307
F32 f32_Resolution_s
Timer resolution in seconds.
Definition: Timer_Base.h:301
U32 u32_Timer_Counts
Timer counter preset value.
Definition: Timer_Base.h:298
F32 Get_Resolution_s()
Get timer resolution in seconds.
Definition: Timer_Base.cpp:215
F32 Get_Interrupt_Frequency()
Get Get interrupt frequency in herz.
Definition: Timer_Base.cpp:263
virtual BOOL Configure_Clock(U32 u32_Clock)
Set user timer input clock frequency method.
Definition: Timer_Base.cpp:111