ConOpSys V2970  P004.07
ANVILEX control operating system
CRC_7.h
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 //! @file CRC_7.h
3 //! @brief Cyclic reduncancy check (CRC-7) class header file.
4 //! @par Algorithm name
5 //! CRC-7
6 //! @par Polynome
7 //! ?
8 //! @par Initial value
9 //! 0x00
10 //! @par Application
11 //! ?
12 //! @attention No special attention requered.
13 //! @copyright (C) 2015-2020 ANVILEX LLC
14 //! $HeadURL: https://192.168.3.4:8443/svn/P004_07/ConOpSys/Common/CRC_7.h $
15 //! $Revision: 2796 $
16 //! $Date: 2021-07-12 02:57:34 +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 definitons
82 //------------------------------------------------------------------------------
83 
84 //! @brief Cyclic redundancy check (CRC-7) class
85 class TCRC_7
86 {
87 
88  //----------------------------------------------------------------------------
89  // Public defines, methods and variables
90  //----------------------------------------------------------------------------
91 
92  public:
93 
94  //!-------------------------------------------------------------------------
95  //! @brief Check CRC of the data buffer
96  //! @note None
97  //! @param [in] *void_Data - Pointer to the data buffer
98  //! @param [in] u32_Size - Size of the data buffer
99  //! @param [in] u8_Expected_CRC - Expected CRC of the data buffer
100  //! @return BOOL - Data buffer CRC checking status
101  //! @retval false - CRC of the buffer not match to expected CRC
102  //! @retval true - CRC of the buffer match to expected CRC
103  //! \par Override
104  //! Not allowed
105  //! @attention None
106  //! @dotfile TCRC_7__Check.dt
107  //--------------------------------------------------------------------------
108 
109  BOOL Check( VOID *void_Data, U32 u32_Size, U8 u8_Expected_CRC );
110 
111  //!-------------------------------------------------------------------------
112  //! @brief Calculate CRC of the data buffer
113  //! @note None
114  //! @param [in] *void_Data - Pointer to the data buffer
115  //! @param [in] u32_Size - Size of the data buffer
116  //! @return U8 - Calculated CRC of the data buffer
117  //! \par Override
118  //! Not allowed
119  //! @attention None
120  //! @dotfile TCRC_7__Calculate.dt
121  //--------------------------------------------------------------------------
122 
123  U8 Calculate( VOID *void_Data, U32 u32_Size );
124 
125  //!-------------------------------------------------------------------------
126  //! @brief Update CRC with new data value
127  //! @note None
128  //! @param [in, out] &u8_CRC - Actual CRC value
129  //! @param [in] u8_Data - Data value
130  //! @return None
131  //! \par Override
132  //! Not allowed
133  //! @attention None
134  //! @dotfile TCRC_7__Update.dt
135  //--------------------------------------------------------------------------
136 
137  VOID Update( U8 &u8_CRC, U8 u8_Data );
138 
139  //----------------------------------------------------------------------------
140  // Protected methods and variables
141  //----------------------------------------------------------------------------
142 
143  protected:
144 
145  //----------------------------------------------------------------------------
146  // Private defines, methods and variables
147  //----------------------------------------------------------------------------
148 
149  private:
150 
151 };
152 
153 //------------------------------------------------------------------------------
154 // End of file
155 //------------------------------------------------------------------------------
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-7) class.
Definition: CRC_7.h:86
VOID Update(U8 &u8_CRC, U8 u8_Data)
Update CRC with new data value.
Definition: CRC_7.cpp:135
BOOL Check(VOID *void_Data, U32 u32_Size, U8 u8_Expected_CRC)
Check CRC of the data buffer.
Definition: CRC_7.cpp:99
U8 Calculate(VOID *void_Data, U32 u32_Size)
Calculate CRC of the data buffer.
Definition: CRC_7.cpp:111