ConOpSys V2970  P004.07
ANVILEX control operating system
CRC_16_Base.h
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 //! @file CRC_16_Base.h
3 //! @brief Cyclic reduncancy check (CRC-16) base class header file.
4 //! @copyright (C)2015-2020 ANVILEX LLC
5 //! @attention No special attention requered.
6 //! $HeadURL: https://192.168.3.4:8443/svn/P004_07/ConOpSys/Common/CRC_16_Base.h $
7 //! $Revision: 2797 $
8 //! $Date: 2021-07-12 16:13:33 +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 definition
74 //------------------------------------------------------------------------------
75 
76 //! @brief Cyclic redundancy check (CRC-16) 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  //! \par UML diagram
94  //! @dotfile TCRC_16_Base__Init.dt
95  //--------------------------------------------------------------------------
96 
97  virtual U16 Init() = 0;
98 
99  //!-------------------------------------------------------------------------
100  //! @brief Check CRC of the data buffer
101  //! @note None
102  //! @param [in] *void_Data - Pointer to the data buffer
103  //! @param [in] u32_Size - Size of the data buffer
104  //! @param [in] u16_Expected_CRC - Expected CRC of the data buffer
105  //! @return BOOL - Data buffer CRC checking status
106  //! @retval false - CRC of the buffer not match to expected CRC
107  //! @retval true - CRC of the buffer match to expected CRC
108  //! \par Override
109  //! Not allowed
110  //! @attention None
111  //! \par UML diagram
112  //! @dotfile TCRC_16_Base__Check.dt
113  //--------------------------------------------------------------------------
114 
115  BOOL Check( VOID *void_Data, U32 u32_Size, U16 u16_Expected_CRC );
116 
117  //!-------------------------------------------------------------------------
118  //! @brief Calculate CRC of the data buffer
119  //! @note None
120  //! @param [in] *void_Data - Pointer to the data buffer
121  //! @param [in] u32_Size - Size of the data buffer
122  //! @return U16 - Calculated CRC of the data buffer
123  //! \par Override
124  //! Not allowed
125  //! @attention None
126  //! \par UML diagram
127  //! @dotfile TCRC_16_Base__Calculate.dt
128  //--------------------------------------------------------------------------
129 
130  virtual U16 Calculate( VOID *void_Data, U32 u32_Size );
131 
132  //!-------------------------------------------------------------------------
133  //! @brief Update CRC with new data value
134  //! @note None
135  //! @param [in, out] &u16_CRC - Actual CRC value
136  //! @param [in] u8_Data - Data value
137  //! @return None
138  //! \par Override
139  //! Not allowed
140  //! @attention None
141  //! \par UML diagram
142  //! @dotfile TCRC_16_Base__Update.dt
143  //--------------------------------------------------------------------------
144 
145  virtual VOID Update( U16 &u16_CRC, U8 u8_Data ) = 0;
146 
147  //!-------------------------------------------------------------------------
148  //! @brief Test CRC calulation
149  //! @note None
150  //! @return TRIL - Test CRC calculation status
151  //! @retval unset - Test method not implemented
152  //! @retval false - Test CRC calculation failed
153  //! @retval true - Test CRC calculation successed
154  //! \par Override
155  //! Not allowed
156  //! @attention Don't call this method directly
157  //! \par UML diagram
158  //! @dotfile TCRC_16_Base__Test.dt
159  //--------------------------------------------------------------------------
160 
161  virtual TRIL Test();
162 
163  //----------------------------------------------------------------------------
164  // Protected defines, methods and variables
165  //----------------------------------------------------------------------------
166 
167  protected:
168 
169  //----------------------------------------------------------------------------
170  // Private defines, methods and variables
171  //----------------------------------------------------------------------------
172 
173  private:
174 
175 };
176 
177 //------------------------------------------------------------------------------
178 // End of file
179 //------------------------------------------------------------------------------
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
unsigned short U16
Binary 16-Bit unsigned integer datatype defenition.
Definition: Defines.h:193
Cyclic redundancy check (CRC-16) base class.
Definition: CRC_16_Base.h:78
BOOL Check(VOID *void_Data, U32 u32_Size, U16 u16_Expected_CRC)
Check CRC of the data buffer.
Definition: CRC_16_Base.cpp:58
virtual TRIL Test()
Test CRC calulation.
Definition: CRC_16_Base.cpp:94
virtual U16 Calculate(VOID *void_Data, U32 u32_Size)
Calculate CRC of the data buffer.
Definition: CRC_16_Base.cpp:70
virtual VOID Update(U16 &u16_CRC, U8 u8_Data)=0
Update CRC with new data value.
virtual U16 Init()=0
Get initial value of CRC.