ConOpSys V2970  P004.07
ANVILEX control operating system
CRC_32.h
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 //! @file CRC_32.h
3 //! @brief Cyclic reduncancy check (CRC-32) class header file.
4 //! @par Algorithm name
5 //! CRC-32
6 //! @par Polynom
7 //! ???
8 //! @par Initial value
9 //! 0x00000000
10 //! @par Application
11 //! ???
12 //! @attention No special attention requered.
13 //! @copyright (C) 2015-2020 GmbH
14 //! $HeadURL: https://192.168.3.4:8443/svn/P004_07/ConOpSys/Common/CRC_32.h $
15 //! $Revision: 2797 $
16 //! $Date: 2021-07-12 16:13:33 +0500 (Mo, 12 Jul 2021) $
17 //! $Author: minch $
18 //------------------------------------------------------------------------------
19 //
20 // Redistribution and use in source and binary forms, with or without
21 // modification, are permitted provided that the following conditions are met:
22 //
23 // 1. Redistributions of source code must retain the above copyright notice,
24 // this list of conditions and the following disclaimer.
25 //
26 // 2. Redistributions in binary form must reproduce the above copyright notice,
27 // this list of conditions and the following disclaimer in the documentation
28 // and/or other materials provided with the distribution.
29 //
30 // 3. Neither the name of ANVILEX nor the names of its contributors may be
31 // used to endorse or promote products derived from this software without
32 // specific prior written permission.
33 //
34 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
35 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
36 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
37 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
38 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
39 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
40 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
41 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
42 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
43 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
44 // POSSIBILITY OF SUCH DAMAGE.
45 //
46 //------------------------------------------------------------------------------
47 
48 //------------------------------------------------------------------------------
49 // Protecting header files from mutual, recursive inclusion.
50 //------------------------------------------------------------------------------
51 
52 #pragma once
53 
54 //------------------------------------------------------------------------------
55 // Include standard libraries header files
56 //------------------------------------------------------------------------------
57 
58 //------------------------------------------------------------------------------
59 // Include thrid party header files
60 //------------------------------------------------------------------------------
61 
62 //------------------------------------------------------------------------------
63 // Include ConOpSys header files
64 //------------------------------------------------------------------------------
65 
66 #include "Defines.h"
67 
68 //------------------------------------------------------------------------------
69 // Include ConOpSys application header files
70 //------------------------------------------------------------------------------
71 
72 //------------------------------------------------------------------------------
73 // Global defines
74 //------------------------------------------------------------------------------
75 
76 //------------------------------------------------------------------------------
77 // Global macros
78 //------------------------------------------------------------------------------
79 
80 //------------------------------------------------------------------------------
81 // Class definitions
82 //------------------------------------------------------------------------------
83 
84 //! @brief Cyclic redundancy check (CRC-32) class
85 class TCRC_32
86 {
87 
88  //----------------------------------------------------------------------------
89  // Public defines, methods and variables
90  //----------------------------------------------------------------------------
91 
92  public:
93 
94  //!-------------------------------------------------------------------------
95  //! @brief Class constructor method
96  //! @note None
97  //! \par Override
98  //! Not allowed
99  //! @attention Don't call this method directly.
100  //! \par UML diagram
101  //! @dotfile TCRC_32__TCRC_32.dt
102  //--------------------------------------------------------------------------
103 
104  TCRC_32();
105 
106  //!-------------------------------------------------------------------------
107  //! @brief initialise internal CRC value to initial value
108  //! @note None
109  //! \par Override
110  //! Not allowed
111  //! @attention None
112  //! \par UML diagram
113  //! @dotfile TCRC_32__Initialise.dt
114  //--------------------------------------------------------------------------
115 
116  VOID Initialise();
117 
118  //!-------------------------------------------------------------------------
119  //! @brief Check CRC of the data buffer
120  //! @note None
121  //! @param [in] *void_Data - Pointer to the data buffer
122  //! @param [in] u32_Size - Size of the data buffer
123  //! @param [in] u32_Expected_CRC - Expected CRC of the data buffer
124  //! @return BOOL - Data buffer CRC checking status
125  //! @retval false - CRC of the buffer not match to expected CRC
126  //! @retval true - CRC of the buffer match to expected CRC
127  //! \par Override
128  //! Not allowed
129  //! @attention None
130  //! \par UML diagram
131  //! @dotfile TCRC_32__Check.dt
132  //--------------------------------------------------------------------------
133 
134  BOOL Check( VOID *void_Data, U32 u32_Size, U32 u32_Expected_CRC );
135 
136  //!-------------------------------------------------------------------------
137  //! @brief Calculate CRC of the data buffer
138  //! @note None
139  //! @param [in] *void_Data - Pointer to the data buffer
140  //! @param [in] u32_Size - Size of the data buffer
141  //! @return U32 - Calculated CRC of the data buffer
142  //! \par Override
143  //! Not allowed
144  //! @attention None
145  //! \par UML diagram
146  //! @dotfile TCRC_32__Calculate.dt
147  //--------------------------------------------------------------------------
148 
149  U32 Calculate( VOID *void_Data, U32 u32_Size );
150 
151  //!-------------------------------------------------------------------------
152  //! @brief Update CRC with new data value
153  //! @note None
154  //! @param [in, out] &u32_CRC - Actual CRC value
155  //! @param [in] u8_Data - Data value
156  //! @return None
157  //! \par Override
158  //! Not allowed
159  //! @attention None
160  //! \par UML diagram
161  //! @dotfile TCRC_32__Update.dt
162  //--------------------------------------------------------------------------
163 
164  VOID Update( U32 &u32_CRC, U8 u8_Data );
165 
166  //!-------------------------------------------------------------------------
167  //! @brief Update CRC with new data value
168  //! @note None
169  //! @param [in] u8_Data - Data value
170  //! @return None
171  //! \par Override
172  //! Not allowed
173  //! @attention None
174  //! \par UML diagram
175  //! @dotfile TCRC_32__Update.dt
176  //--------------------------------------------------------------------------
177 
178  VOID Update( U8 u8_Data );
179 
180  //!-------------------------------------------------------------------------
181  //! @brief Update CRC with new data from data buffer
182  //! @note None
183  //! @param [in, out] &u32_CRC - Actual CRC value
184  //! @param [in] *u8_Data - Pointer to the data buffer
185  //! @param [in] u32_Length - Data buffer length
186  //! @return None
187  //! \par Override
188  //! Not allowed
189  //! @attention None
190  //! \par UML diagram
191  //! @dotfile TCRC_32__Update.dt
192  //--------------------------------------------------------------------------
193 
194  VOID Update( U32 &u32_CRC, U8 *u8_Data, U32 u32_Length );
195 
196  //!-------------------------------------------------------------------------
197  //! @brief Update CRC with new data value
198  //! @note None
199  //! @param [in, out] &u32_CRC - Actual CRC value
200  //! @param [in] u32_Data - Data value
201  //! @return None
202  //! \par Override
203  //! Not allowed
204  //! @attention None
205  //! \par UML diagram
206  //! @dotfile TCRC_32__Update.dt
207  //--------------------------------------------------------------------------
208 
209  VOID Update( U32 &u32_CRC, U32 u32_Data );
210 
211  //----------------------------------------------------------------------------
212  // Protected defines, methods and variables
213  //----------------------------------------------------------------------------
214 
215  protected:
216 
217  //----------------------------------------------------------------------------
218  // Private defines, methods and variables
219  //----------------------------------------------------------------------------
220 
221  private:
222 
223  //! @brief CRC internal storage variable
225 
226 };
227 
228 //------------------------------------------------------------------------------
229 // End of file
230 //------------------------------------------------------------------------------
ConOpSys data type definitions header file.
int BOOL
Boolean datatype definition.
Definition: Defines.h:124
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) class.
Definition: CRC_32.h:86
TCRC_32()
Class constructor method.
Definition: CRC_32.cpp:137
VOID Update(U32 &u32_CRC, U8 u8_Data)
Update CRC with new data value.
Definition: CRC_32.cpp:197
VOID Initialise()
initialise internal CRC value to initial value
Definition: CRC_32.cpp:149
U32 u32_CRC_Intern
CRC internal storage variable.
Definition: CRC_32.h:224
U32 Calculate(VOID *void_Data, U32 u32_Size)
Calculate CRC of the data buffer.
Definition: CRC_32.cpp:173
BOOL Check(VOID *void_Data, U32 u32_Size, U32 u32_Expected_CRC)
Check CRC of the data buffer.
Definition: CRC_32.cpp:161