This document consists of sections titled with Driver Overview, Data Structures, Enumerations, Functions, etc., each with an overview list and detailed documentation. It is recommended to read the Driver Overview first for it includes a comprehensive description of the peripheral, driver and driver changes. Other sections give detailed information for APIs, enums, macros, etc., for your further reference.
This structure holds the configuration for the CRC protocol.
uint32_t crc_config_t::u32CrcPolynomial |
Example polynomial: 0x1021 = 1_0000_0010_0001 = x^12+x^5+1
bool crc_config_t::bEnableComplementChecksum |
Enumerator |
---|
kCRC_Crc16 |
CRC-16/MAXIM protocol.
|
kCRC_Crc16CCITT |
CRC-16-CCITT protocol.
|
kCRC_Crc16Kermit |
CRC-16/KERMIT protocol.
|
kCRC_Crc32 |
CRC-32 protocol.
|
kCRC_Crc32Posix |
CRC-32/POSIX protocol.
|
Enumerator |
---|
kCRC_Bits16 |
Generate 16-bit CRC code.
|
kCRC_Bits32 |
Generate 32-bit CRC code.
|
Enumerator |
---|
kCRC_TransposeNone |
No transpose.
|
kCRC_TransposeBits |
Transpose bits in bytes.
|
kCRC_TransposeBitsAndBytes |
Transpose bytes and bits in bytes.
|
kCRC_TransposeBytes |
Transpose bytes.
|
void CRC_Init |
( |
CRC_Type * |
base, |
|
|
const crc_config_t * |
psConfig |
|
) |
| |
This function enables the clock gate in the SIM module for the CRC peripheral. It also configures the CRC module and starts a checksum computation by writing the seed.
- Parameters
-
base | CRC peripheral address. |
psConfig | CRC module configuration structure. |
void CRC_Deinit |
( |
CRC_Type * |
base | ) |
|
This function disables the clock gate in the SIM module for the CRC peripheral.
- Parameters
-
base | CRC peripheral address. |
The purpose of this API is to initialize the configuration structure to default value for CRC_Init to use. Provides the configuration of commonly used CRC protocols. refer to _crc_protocol_type.
This is an example:
- Parameters
-
psConfig | CRC protocol configuration structure. |
eCrcProtocol | CRC protocol type. refer to _crc_protocol_type |
static void CRC_SetSeedValue |
( |
CRC_Type * |
base, |
|
|
uint32_t |
u32CrcSeedValue |
|
) |
| |
|
inlinestatic |
This function is help to write a 16/32 bit CRC seed value.
- Parameters
-
base | CRC peripheral address. |
u32CrcSeedValue | The value of seed. |
static void CRC_SetPolynomial |
( |
CRC_Type * |
base, |
|
|
uint32_t |
u32CrcPolynomial |
|
) |
| |
|
inlinestatic |
Write a 16-bit or 32-bit polynomial to CRC Polynomial register for the CRC calculation.
- Parameters
-
base | CRC peripheral address. |
u32CrcPolynomial | The CRC polynomial. |
This function help to configure CRC type of transpose of write data.
- Parameters
-
base | CRC peripheral address. |
eTransposeIn | Type Of transpose for input. See _crc_transpose_type |
This function help to configure CRC type of transpose of read data.
- Parameters
-
base | CRC peripheral address. |
eTransposeOut | Type Of transpose for output. See _crc_transpose_type |
static void CRC_EnableComplementChecksum |
( |
CRC_Type * |
base, |
|
|
bool |
bEnable |
|
) |
| |
|
inlinestatic |
Set complement of read CRC checksum. Some CRC protocols require the final checksum to be XORed with 0xFFFFFFFF or 0xFFFF.
- Parameters
-
base | CRC peripheral address. |
bEnable | True or false. True if the result shall be complement of the actual checksum. |
static void CRC_SetProtocolWidth |
( |
CRC_Type * |
base, |
|
|
crc_bits_t |
eCrcBits |
|
) |
| |
|
inlinestatic |
Selects 16-bit or 32-bit CRC protocol.
- Parameters
-
base | CRC peripheral address. |
eCrcBits | 16 or 32 bit CRC protocol. See _crc_bits |
void CRC_WriteData |
( |
CRC_Type * |
base, |
|
|
const uint8_t * |
pu8Data, |
|
|
uint32_t |
u32DataSize |
|
) |
| |
Writes input data buffer bytes to the CRC data register. The configured type of transpose is applied.
- Parameters
-
base | CRC peripheral address. |
pu8Data | Input data stream, MSByte in data[0]. |
u32DataSize | Size in bytes of the input data buffer. |
static uint32_t CRC_Get32bitResult |
( |
CRC_Type * |
base | ) |
|
|
inlinestatic |
Reads the CRC data register (either an intermediate or the final checksum). The configured type of transpose and complement is applied.
- Parameters
-
base | CRC peripheral address. |
- Returns
- An intermediate or the final 32-bit checksum, after transpose and complement operations configured.
uint16_t CRC_Get16bitResult |
( |
CRC_Type * |
base | ) |
|
Reads the CRC data register (either an intermediate or the final checksum). The configured type of transpose and complement is applied.
- Parameters
-
base | CRC peripheral address. |
- Returns
- An intermediate or the final 16-bit checksum, after transpose and complement operations configured.