]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_M4F_MSP432_LaunchPad_IAR_CCS_Keil/driverlib/crc32.h
Final V8.2.1 release ready for tagging:
[freertos] / FreeRTOS / Demo / CORTEX_M4F_MSP432_LaunchPad_IAR_CCS_Keil / driverlib / crc32.h
1 /*
2  * -------------------------------------------
3  *    MSP432 DriverLib - v01_04_00_18 
4  * -------------------------------------------
5  *
6  * --COPYRIGHT--,BSD,BSD
7  * Copyright (c) 2015, Texas Instruments Incorporated
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  *
14  * *  Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  *
17  * *  Redistributions in binary form must reproduce the above copyright
18  *    notice, this list of conditions and the following disclaimer in the
19  *    documentation and/or other materials provided with the distribution.
20  *
21  * *  Neither the name of Texas Instruments Incorporated nor the names of
22  *    its contributors may be used to endorse or promote products derived
23  *    from this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
27  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
29  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
32  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
33  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
35  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  * --/COPYRIGHT--*/
37 #ifndef _CRC_32_H
38
39 //*****************************************************************************
40 //
41 //! \addtogroup crc32_api
42 //! @{
43 //
44 //*****************************************************************************
45
46 #include <stdint.h>
47
48 #define CRC16_MODE 0x00
49 #define CRC32_MODE 0x01
50
51 //*****************************************************************************
52 //
53 //! Sets the seed for the CRC.
54 //!
55 //! \param seed is the seed for the CRC to start generating a signature from.
56 //!        Modified bits are \b CRC16INIRESL0 of \b CRC16INIRESL0 register.
57 //!            \b CRC32INIRESL0 of \b CRC32INIRESL0 register
58 //! \param crcType selects between CRC32 and CRC16
59 //!            Valid values are \b CRC16_MODE and \b CRC32_MODE
60 //!
61 //! This function sets the seed for the CRC to begin generating a signature with
62 //! the given seed and all passed data. Using this function resets the CRC32
63 //! signature.
64 //!
65 //! \return NONE
66 //
67 //*****************************************************************************
68 extern void CRC32_setSeed(uint32_t seed, uint_fast8_t crcType);
69
70 //*****************************************************************************
71 //
72 //! Sets the 8 Bit data to add into the CRC module to generate a new signature.
73 //!
74 //! \param dataIn is the data to be added, through the CRC module, to the
75 //!       signature.
76 //!        Modified bits are \b CRC16DIB0 of \b CRC16DIB0 register.
77 //!                            \b CRC32DIB0 of \b CRC32DIB0 register.
78 //! \param crcType selects between CRC32 and CRC16
79 //!            Valid values are \b CRC16_MODE and \b CRC32_MODE
80 //!
81 //! This function sets the given data into the CRC module to generate the new
82 //! signature from the current signature and new data. Bit 0 is
83 //!    treated as LSB.
84 //!
85 //! \return NONE
86 //
87 //*****************************************************************************
88 extern void CRC32_set8BitData(uint8_t dataIn, uint_fast8_t crcType);
89
90 //*****************************************************************************
91 //
92 //! Sets the 16 Bit data to add into the CRC module to generate a new signature.
93 //!
94 //! \param dataIn is the data to be added, through the CRC module, to the
95 //!       signature.
96 //!        Modified bits are \b CRC16DIW0 of \b CRC16DIW0 register.
97 //!                          \b CRC32DIW0 of \b CRC32DIW0 register.
98 //! \param crcType selects between CRC32 and CRC16
99 //!            Valid values are \b CRC16_MODE and \b CRC32_MODE
100 //!
101 //! This function sets the given data into the CRC module to generate the new
102 //! signature from the current signature and new data. Bit 0 is
103 //!    treated as LSB
104 //!
105 //! \return NONE
106 //
107 //*****************************************************************************
108 extern void CRC32_set16BitData(uint16_t dataIn, uint_fast8_t crcType);
109
110 //*****************************************************************************
111 //
112 //! Sets the 32 Bit data to add into the CRC module to generate a new signature.
113 //!    Available only for CRC32_MODE and not for CRC16_MODE
114 //! \param dataIn is the data to be added, through the CRC module, to the
115 //!       signature.
116 //!        Modified bits are \b CRC32DIL0 of \b CRC32DIL0 register.
117 //!
118 //! This function sets the given data into the CRC module to generate the new
119 //! signature from the current signature and new data. Bit 0 is
120 //!    treated as LSB
121 //!
122 //! \return NONE
123 //
124 //*****************************************************************************
125 extern void CRC32_set32BitData(uint32_t dataIn);
126
127 //*****************************************************************************
128 //
129 //! Translates the data by reversing the bits in each 8 bit data and then sets
130 //! this data to add into the CRC module to generate a new signature.
131 //!
132 //! \param dataIn is the data to be added, through the CRC module, to the
133 //!       signature.
134 //!        Modified bits are \b CRC16DIRBB0 of \b CRC16DIRBB0 register.
135 //!                             \b CRC32DIRBB0 of \b CRC32DIRBB0 register.
136 //! \param crcType selects between CRC32 and CRC16
137 //!            Valid values are \b CRC16_MODE and \b CRC32_MODE
138 //!
139 //! This function first reverses the bits in each byte of the data and then
140 //! generates the new signature from the current signature and new translated
141 //! data. Bit 0 is treated as MSB.
142 //!
143 //! \return NONE
144 //
145 //*****************************************************************************
146 extern void CRC32_set8BitDataReversed(uint8_t dataIn, uint_fast8_t crcType);
147
148 //*****************************************************************************
149 //
150 //! Translates the data by reversing the bits in each 16 bit data and then
151 //!    sets this data to add into the CRC module to generate a new signature.
152 //!
153 //! \param dataIn is the data to be added, through the CRC module, to the
154 //!       signature.
155 //!        Modified bits are \b CRC16DIRBW0 of \b CRC16DIRBW0 register.
156 //!                             \b CRC32DIRBW0 of \b CRC32DIRBW0 register.
157 //! \param crcType selects between CRC32 and CRC16
158 //!            Valid values are \b CRC16_MODE and \b CRC32_MODE
159 //!
160 //! This function first reverses the bits in each byte of the data and then
161 //! generates the new signature from the current signature and new translated
162 //! data.  Bit 0 is treated as MSB.
163 //!
164 //! \return NONE
165 //
166 //*****************************************************************************
167 extern void CRC32_set16BitDataReversed(uint16_t dataIn, uint_fast8_t crcType);
168
169 //*****************************************************************************
170 //
171 //! Translates the data by reversing the bits in each 32 Bit Data and then
172 //!    sets this data to add into the CRC module to generate a new signature.
173 //!    Available only for CRC32 mode and not for CRC16 mode
174 //! \param dataIn is the data to be added, through the CRC module, to the
175 //!       signature.
176 //!        Modified bits are \b CRC32DIRBL0 of \b CRC32DIRBL0 register.
177 //!
178 //! This function first reverses the bits in each byte of the data and then
179 //! generates the new signature from the current signature and new translated
180 //! data.  Bit 0 is treated as MSB.
181 //!
182 //! \return NONE
183 //
184 //*****************************************************************************
185 extern void CRC32_set32BitDataReversed(uint32_t dataIn);
186
187 //*****************************************************************************
188 //
189 //! Returns the value of CRC Signature Result.
190 //!
191 //! \param crcType selects between CRC32 and CRC16
192 //!            Valid values are \b CRC16_MODE and \b CRC32_MODE
193 //!
194 //! This function returns the value of the signature result generated by the CRC.
195 //! Bit 0 is treated as LSB.
196 //! \return uint32_t Result
197 //
198 //*****************************************************************************
199 extern uint32_t CRC32_getResult(uint_fast8_t crcType);
200
201 //*****************************************************************************
202 //
203 //! Returns the bit-wise reversed format of the 32 bit Signature Result.
204 //!
205 //! \param crcType selects between CRC32 and CRC16
206 //!            Valid values are \b CRC16_MODE and \b CRC32_MODE
207 //!
208 //! This function returns the bit-wise reversed format of the Signature Result.
209 //! Bit 0 is treated as MSB.
210 //!
211 //! \return uint32_t Result
212 //
213 //*****************************************************************************
214 extern uint32_t CRC32_getResultReversed(uint_fast8_t crcType);
215
216 /* Defines for future devices that might have multiple instances */
217 #define CRC32_setSeedMultipleInstance(a,b,c) CRC32_setSeed(b,c)
218 #define CRC32_set8BitDataMultipleInstance(a,b,c)  CRC32_set8BitData(b,c)
219 #define CRC32_set16BitDataMultipleInstance(a,b,c) CRC32_set16BitData(b,c)
220 #define CRC32_set32BitDataMultipleInstance(a,b) CRC32_set32BitData(b)
221 #define CRC32_set8BitDataReversedMultipleInstance(a,b,c) CRC32_set8BitDataReversed(b,c)
222 #define CRC32_set16BitDataReversedMultipleInstance(a,b,c) CRC32_set16BitDataReversed(b,c)
223 #define CRC32_set32BitDataReversedMultipleInstance(a,b) CRC32_set32BitDataReversed(b)
224 #define CRC32_getResultMultipleInstance(a,b) CRC32_getResult()
225 #define CRC32_getResultReversedMultipleInstance(a,b) CRC32_getResultReversed(b)
226
227 //*****************************************************************************
228 //
229 // Close the Doxygen group.
230 //! @}
231 //
232 //*****************************************************************************
233
234
235 #endif