ConOpSys V2970  P004.07
ANVILEX control operating system
CRC_32_Base.h
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 //! @file CRC_32_Base.h
3 //! @brief Cyclic reduncancy check (CRC-32) 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/Common/CRC_32_Base.h $
7 //! $Revision: 2796 $
8 //! $Date: 2021-07-12 02:57:34 +0500 (Mo, 12 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 // Include ConOpSys application header files
62 //------------------------------------------------------------------------------
63 
64 //------------------------------------------------------------------------------
65 // Global defines
66 //------------------------------------------------------------------------------
67 
68 //------------------------------------------------------------------------------
69 // Global macros
70 //------------------------------------------------------------------------------
71 
72 //------------------------------------------------------------------------------
73 // Class definitions
74 //------------------------------------------------------------------------------
75 
76 //! @brief Cyclic redundancy check (CRC-32) base class
78 {
79 
80  //----------------------------------------------------------------------------
81  // Public defines, methods and variables
82  //----------------------------------------------------------------------------
83 
84  public:
85 
86  //!-------------------------------------------------------------------------
87  //! @brief Get initial value of CRC
88  //! @note None
89  //! @return U16 - CRC initial value
90  //! \par Override
91  //! Requered
92  //! @attention None
93  //! @dotfile TCRC_32_Base__Init.dt
94  //--------------------------------------------------------------------------
95 
96  virtual U32 Init() = 0;
97 
98  //!-------------------------------------------------------------------------
99  //! @brief Check CRC of the data buffer
100  //! @note None
101  //! @param [in] *void_Data - Pointer to the data buffer
102  //! @param [in] u32_Size - Size of the data buffer
103  //! @param [in] u32_Expected_CRC - Expected CRC of the data buffer
104  //! @return BOOL - Data buffer CRC checking status
105  //! @retval false - CRC of the buffer not match to expected CRC
106  //! @retval true - CRC of the buffer match to expected CRC
107  //! \par Override
108  //! Not allowed
109  //! @attention None
110  //! @dotfile TCRC_32_Base__Check.dt
111  //--------------------------------------------------------------------------
112 
113  BOOL Check( VOID *void_Data, U32 u32_Size, U32 u32_Expected_CRC );
114 
115  //!-------------------------------------------------------------------------
116  //! @brief Calculate CRC of the data buffer
117  //! @note None
118  //! @param [in] *void_Data - Pointer to the data buffer
119  //! @param [in] u32_Size - Size of the data buffer
120  //! @return U32 - Calculated CRC of the data buffer
121  //! \par Override
122  //! Not allowed
123  //! @attention None
124  //! @dotfile TCRC_32_Base__Calculate.dt
125  //--------------------------------------------------------------------------
126 
127  virtual U32 Calculate( VOID *void_Data, U32 u32_Size );
128 
129  //!-------------------------------------------------------------------------
130  //! @brief Update CRC with new data value
131  //! @note None
132  //! @param [in,out] &u32_CRC - Actual CRC value
133  //! @param [in] u8_Data - Data value
134  //! @return None
135  //! \par Override
136  //! Not allowed
137  //! @attention None
138  //! @dotfile TCRC_32_Base__Update.dt
139  //--------------------------------------------------------------------------
140 
141  virtual VOID Update( U32 &u32_CRC, U8 u8_Data ) = 0;
142 
143  //!-------------------------------------------------------------------------
144  //! @brief Test CRC calulation
145  //! @note None
146  //! @return TRIL - Test CRC calculation status
147  //! @retval unset - Test method not implemented
148  //! @retval false - Test CRC calculation failed
149  //! @retval true - Test CRC calculation successed
150  //! \par Override
151  //! Not allowed
152  //! @attention Don't call this method directly
153  //! @dotfile TCRC_32_Base__Test.dt
154  //--------------------------------------------------------------------------
155 
156  virtual TRIL Test();
157 
158  //----------------------------------------------------------------------------
159  // Protected defines, methods and variables
160  //----------------------------------------------------------------------------
161 
162  protected:
163 
164  //----------------------------------------------------------------------------
165  // Private defines, methods and variables
166  //----------------------------------------------------------------------------
167 
168  private:
169 
170 };
171 
172 //------------------------------------------------------------------------------
173 // End of file
174 //------------------------------------------------------------------------------
ConOpSys data type definitions header file.
int BOOL
Boolean datatype definition.
Definition: Defines.h:124
int TRIL
Thrilean datatype defenition.
Definition: Defines.h:143
unsigned char U8
Binary 8-Bit unsigned integer datatype defenition.
Definition: Defines.h:183
void VOID
Datatypesess datatype definition.
Definition: Defines.h:105
unsigned long U32
Binary 32-Bit unsigned integer datatype defenition.
Definition: Defines.h:203
Cyclic redundancy check (CRC-32) base class.
Definition: CRC_32_Base.h:78
virtual VOID Update(U32 &u32_CRC, U8 u8_Data)=0
Update CRC with new data value.
virtual U32 Calculate(VOID *void_Data, U32 u32_Size)
Calculate CRC of the data buffer.
Definition: CRC_32_Base.cpp:62
BOOL Check(VOID *void_Data, U32 u32_Size, U32 u32_Expected_CRC)
Check CRC of the data buffer.
Definition: CRC_32_Base.cpp:50
virtual TRIL Test()
Test CRC calulation.
Definition: CRC_32_Base.cpp:86
virtual U32 Init()=0
Get initial value of CRC.