2 * -------------------------------------------
3 * MSP432 DriverLib - v01_04_00_18
4 * -------------------------------------------
6 * --COPYRIGHT--,BSD,BSD
7 * Copyright (c) 2015, Texas Instruments Incorporated
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
14 * * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
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.
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.
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.
39 //*****************************************************************************
41 //! \addtogroup crc32_api
44 //*****************************************************************************
48 #define CRC16_MODE 0x00
49 #define CRC32_MODE 0x01
51 //*****************************************************************************
53 //! Sets the seed for the CRC.
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
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
67 //*****************************************************************************
68 extern void CRC32_setSeed(uint32_t seed, uint_fast8_t crcType);
70 //*****************************************************************************
72 //! Sets the 8 Bit data to add into the CRC module to generate a new signature.
74 //! \param dataIn is the data to be added, through the CRC module, to the
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
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
87 //*****************************************************************************
88 extern void CRC32_set8BitData(uint8_t dataIn, uint_fast8_t crcType);
90 //*****************************************************************************
92 //! Sets the 16 Bit data to add into the CRC module to generate a new signature.
94 //! \param dataIn is the data to be added, through the CRC module, to the
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
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
107 //*****************************************************************************
108 extern void CRC32_set16BitData(uint16_t dataIn, uint_fast8_t crcType);
110 //*****************************************************************************
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
116 //! Modified bits are \b CRC32DIL0 of \b CRC32DIL0 register.
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
124 //*****************************************************************************
125 extern void CRC32_set32BitData(uint32_t dataIn);
127 //*****************************************************************************
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.
132 //! \param dataIn is the data to be added, through the CRC module, to the
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
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.
145 //*****************************************************************************
146 extern void CRC32_set8BitDataReversed(uint8_t dataIn, uint_fast8_t crcType);
148 //*****************************************************************************
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.
153 //! \param dataIn is the data to be added, through the CRC module, to the
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
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.
166 //*****************************************************************************
167 extern void CRC32_set16BitDataReversed(uint16_t dataIn, uint_fast8_t crcType);
169 //*****************************************************************************
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
176 //! Modified bits are \b CRC32DIRBL0 of \b CRC32DIRBL0 register.
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.
184 //*****************************************************************************
185 extern void CRC32_set32BitDataReversed(uint32_t dataIn);
187 //*****************************************************************************
189 //! Returns the value of CRC Signature Result.
191 //! \param crcType selects between CRC32 and CRC16
192 //! Valid values are \b CRC16_MODE and \b CRC32_MODE
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
198 //*****************************************************************************
199 extern uint32_t CRC32_getResult(uint_fast8_t crcType);
201 //*****************************************************************************
203 //! Returns the bit-wise reversed format of the 32 bit Signature Result.
205 //! \param crcType selects between CRC32 and CRC16
206 //! Valid values are \b CRC16_MODE and \b CRC32_MODE
208 //! This function returns the bit-wise reversed format of the Signature Result.
209 //! Bit 0 is treated as MSB.
211 //! \return uint32_t Result
213 //*****************************************************************************
214 extern uint32_t CRC32_getResultReversed(uint_fast8_t crcType);
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)
227 //*****************************************************************************
229 // Close the Doxygen group.
232 //*****************************************************************************