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.
41 void CRC32_setSeed(uint32_t seed, uint_fast8_t crcType)
43 ASSERT((CRC16_MODE == crcType) || (CRC32_MODE == crcType));
45 if (CRC16_MODE == crcType)
46 CRC32->rCRC16INIRES = seed;
49 CRC32->rCRC32INIRES_HI = ((seed & 0xFFFF0000) >> 16);
50 CRC32->rCRC32INIRES_LO = (seed & 0xFFFF);
54 void CRC32_set8BitData(uint8_t dataIn, uint_fast8_t crcType)
56 ASSERT((CRC16_MODE == crcType) || (CRC32_MODE == crcType));
58 if (CRC16_MODE == crcType)
59 HWREG8(CRC32_BASE + OFS_CRC16DI) = dataIn;
61 HWREG8(CRC32_BASE + OFS_CRC32DI) = dataIn;
64 void CRC32_set16BitData(uint16_t dataIn, uint_fast8_t crcType)
66 ASSERT((CRC16_MODE == crcType) || (CRC32_MODE == crcType));
68 if (CRC16_MODE == crcType)
69 CRC32->rCRC16DI = dataIn;
71 CRC32->rCRC32DI = dataIn;
74 void CRC32_set32BitData(uint32_t dataIn)
76 //CRC32->rCRC32DI = dataIn & 0xFFFF;
77 //CRC32->rCRC32DI = (uint16_t) ((dataIn & 0xFFFF0000) >> 16);
79 HWREG16(CRC32_BASE + OFS_CRC32DI) = dataIn & 0xFFFF;
80 HWREG16(CRC32_BASE + OFS_CRC32DI) = (uint16_t)(
81 (dataIn & 0xFFFF0000) >> 16);
84 void CRC32_set8BitDataReversed(uint8_t dataIn, uint_fast8_t crcType)
86 ASSERT((CRC16_MODE == crcType) || (CRC32_MODE == crcType));
88 if (CRC16_MODE == crcType)
89 HWREG8(CRC32_BASE + OFS_CRC16DIRB) = dataIn;
91 HWREG8(CRC32_BASE + OFS_CRC32DIRB) = dataIn;
94 void CRC32_set16BitDataReversed(uint16_t dataIn, uint_fast8_t crcType)
96 ASSERT((CRC16_MODE == crcType) || (CRC32_MODE == crcType));
98 if (CRC16_MODE == crcType)
99 CRC32->rCRC16DIRB = dataIn;
101 CRC32->rCRC32DIRB = dataIn;
104 void CRC32_set32BitDataReversed(uint32_t dataIn)
106 HWREG16(CRC32_BASE + OFS_CRC32DIRB) = dataIn & 0xFFFF;
107 HWREG16(CRC32_BASE + OFS_CRC32DIRB) = (uint16_t)(
108 (dataIn & 0xFFFF0000) >> 16);
109 //CRC32->rCRC32DIRB = dataIn & 0xFFFF;
110 //CRC32->rCRC32DIRB = (uint16_t) ((dataIn & 0xFFFF0000) >> 16);
113 uint32_t CRC32_getResult(uint_fast8_t crcType)
116 ASSERT((CRC16_MODE == crcType) || (CRC32_MODE == crcType));
118 if (CRC16_MODE == crcType)
119 return CRC32->rCRC16INIRES;
122 result = CRC32->rCRC32INIRES_HI;
123 result = (result << 16);
124 result |= CRC32->rCRC32INIRES_LO;
129 uint32_t CRC32_getResultReversed(uint_fast8_t crcType)
132 ASSERT((CRC16_MODE == crcType) || (CRC32_MODE == crcType));
134 if (CRC16_MODE == crcType)
135 return CRC32->rCRC16RESR;
138 result = CRC32->rCRC32RESR_HI;
139 result = (result << 16);
140 result |= CRC32->rCRC32RESR_LO;