Peripheral features and how this peripheral works
A Cyclic Redundancy Check (CRC) or polynomial code checksum is a hash function designed to detect data integrity. The 88MW320/322 CRC unit calculates a short, fixed-length binary sequence, known as the CRC code. For each block of data, CRC code and original data are sent or stored together. When a block of data is used, the same CRC calculation is processed. If the new CRC does not match the one pre-calculated earlier in the block of data, then the block contains a data error and the device may take corrective action, such as resending or requesting the block again. Otherwise the data is assumed to be error free (though, with some small probability, it may contain undetected errors; this is the fundamental nature of error-checking).
Features
- Supports 32-bit parallel bit stream input, and supports up to 32-bit CRC output
- Supports up to 2^32 (4294967296) byte length to calculate CRC
- Supports the following CRC standards
- CRC-16-CCITT, the polynomial is x^16+x^12+x^5+1
- CRC-16-IBM, the polynomial is x^16+x^15+x^2+1
- CRC-16-T10-DIF, the polynomial is x^16+x^15+x^11+x^9+x^8+x^7+x^5+x^4+x^2+x+1
- CRC-32-IEEE 802.3, the polynomial is x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1
- CRC-16-DNP, the polynomial is x^16+x^13+x^12+x^11+x^10+x^8+x^6+x^5+x^2+1
How this peripheral works
- Configure the CRC MODE properly, enable CRC
- Write stream in and waiting for calculation finished
- Get CRC calculation result
How this driver is designed to make this peripheral works.
- Call CRC_Init() function to initialize the CRC module
- Call CRC_SetMode() to select the work mode.
- Call CRC_Calculate() to calculate the CRC for input data block.
Enumerator |
---|
kCRC_16BitsCcitt |
CRC mode: CRC-16-CCITT.
|
kCRC_16BitsIbm |
CRC mode: CRC-16-IBM.
|
kCRC_16BitsT10Dif |
CRC mode: CRC-16-T10-DIF.
|
kCRC_32BitsIeee |
CRC mode: CRC-32-IEEE.
|
kCRC_16BitsDnp |
CRC mode: CRC-16-DNP.
|
void CRC_Init |
( |
CRC_Type * |
base | ) |
|
Call this function to initialize the CRC module.
- Parameters
-
base | CRC peripheral base address |
void CRC_Deinit |
( |
CRC_Type * |
base | ) |
|
- Parameters
-
base | CRC peripheral base address |
static void CRC_SetMode |
( |
CRC_Type * |
base, |
|
|
crc_mode_t |
crcMode |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | CRC peripheral base address. |
crcMode | The CRC work mode to set. |
static void CRC_Enable |
( |
CRC_Type * |
base, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
This function enable/disables the CRC.
- Parameters
-
base | CRC peripheral base address. |
enable | Use true to enable, false to disable. |
static void CRC_FeedData |
( |
CRC_Type * |
base, |
|
|
uint32_t |
data |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | CRC peripheral address. |
data | input data. |
static void CRC_SetStreamLen |
( |
CRC_Type * |
base, |
|
|
uint32_t |
strLen |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | CRC peripheral address. |
strLen | stream length in byte. |
static uint32_t CRC_GetResult |
( |
CRC_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
base | CRC peripheral base address. |
- Returns
- CRC calculation result.
uint32_t CRC_Calculate |
( |
CRC_Type * |
base, |
|
|
const uint8_t * |
dataStr, |
|
|
uint32_t |
dataLen |
|
) |
| |
- Parameters
-
base | CRC peripheral base address. |
dataStr | input data stream. |
dataLen | data length in byte. |
- Returns
- CRC calculation result.
static void CRC_EnableInterrupt |
( |
CRC_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
base | CRC peripheral base address. |
static void CRC_DisableInterrupt |
( |
CRC_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
base | CRC peripheral base address. |
static void CRC_ClearInterruptStatus |
( |
CRC_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
base | CRC peripheral base address. |
static bool CRC_GetInterruptStatus |
( |
CRC_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
base | CRC peripheral base address. |
- Returns
- true if interrupt flag is asserted, else false.
static bool CRC_GetRawInterruptStatus |
( |
CRC_Type * |
base | ) |
|
|
inlinestatic |
This function is similar with CRC_GetInterruptStatus, the only difference is, the raw interrupt status is not affected by interrupt enable status.
- Parameters
-
base | CRC peripheral base address. |
- Returns
- true if CRC status is asserted, else false.