STM32G0 MCAL 0.0.1
Tiny MCAL for educational purpose.
|
This file contains the API and the configuration of the AUTOSAR Basic Software module CRC. More...
Functions | |
uint8 | Crc_CalculateCRC8 (const uint8 *Crc_DataPtr, uint32 Crc_Length, uint8 Crc_StartValue8, boolean Crc_IsFirstCall) |
Calculate a CRC of 8 bits | |
uint8 | Crc_CalculateCRC8H2F (const uint8 *Crc_DataPtr, uint32 Crc_Length, uint8 Crc_StartValue8H2F, boolean Crc_IsFirstCall) |
Calculate a CRC of 8 bits with other polynomial 0x2F | |
uint16 | Crc_CalculateCRC16 (const uint8 *Crc_DataPtr, uint32 Crc_Length, uint16 Crc_StartValue16, boolean Crc_IsFirstCall) |
Calculate a CRC of 16 bits and polynomial of 0x1021 | |
uint16 | Crc_CalculateCRC16ARC (const uint8 *Crc_DataPtr, uint32 Crc_Length, uint16 Crc_StartValue16, boolean Crc_IsFirstCall) |
Calculate a CRC of 16 bits and polynomial of 0xA001 | |
uint32 | Crc_CalculateCRC32 (const uint8 *Crc_DataPtr, uint32 Crc_Length, uint32 Crc_StartValue32, boolean Crc_IsFirstCall) |
Calculate a CRC of 32 bits and polynomial of 0x04C11DB7 | |
uint32 | Crc_CalculateCRC32P4 (const uint8 *Crc_DataPtr, uint32 Crc_Length, uint32 Crc_StartValue32, boolean Crc_IsFirstCall) |
Calculate a CRC of 32 bits and polynomial of F4’AC’FB’13h | |
uint64 | Crc_CalculateCRC64 (const uint8 *Crc_DataPtr, uint32 Crc_Length, uint64 Crc_StartValue64, boolean Crc_IsFirstCall) |
Calculate a CRC of 64 bits and polynomial of 42’F0’E1’EB’A9’EA’36’93h | |
uint8 | Crc_GetVersionInfo (Std_VersionInfoType *Versioninfo) |
Fuunction to assign values to VersionInfo structure | |
This file contains the API and the configuration of the AUTOSAR Basic Software module CRC.
The Crc library contains the following routines for CRC calculation • CRC8: SAEJ1850 • CRC8H2F: CRC8 0x2F polynomial • CRC16 • CRC32 • CRC32P4: CRC32 0xF4ACFB13 polynomial • CRC64: CRC-64-ECMA
This library was designed like a Runtime calculation: Slower execution, but small code size (no ROM table)
uint16 Crc_CalculateCRC16 | ( | const uint8 * | Crc_DataPtr, |
uint32 | Crc_Length, | ||
uint16 | Crc_StartValue16, | ||
boolean | Crc_IsFirstCall ) |
Calculate a CRC of 16 bits and polynomial of 0x1021
The function calculates the a 16 bit CRC according to the standard of AUTOSAR with their respective paramters.
First is necessary to know if is the first time to use the function and it is assigned a value for our CRC calculation. The function calculates the CRC through a for cycle, one of them is to know what of all bytes is in the calculation and the other is to move the bit of the respective byte.
The function uses bit shift to calculate the CRC according with the process.
Crc_DataPtr | Pointer to start address of data block to be calculated. |
Crc_Length | Length of data block to be calculated in bytes. |
Crc_StartValue16 | Start value when the algorithm starts. |
Crc_IsFirstCall | boolean variable to know if is the first time that we used the function. |
crcValue | the value of crc (16 bits) according with parameters and specifications of this function |
< Polynomial of CRC16
< Value of CRC if is first call
< Number of shift bits on crc calculation
< Number of bits of a byte
< Most significant bit of 2 bytes
uint16 Crc_CalculateCRC16ARC | ( | const uint8 * | Crc_DataPtr, |
uint32 | Crc_Length, | ||
uint16 | Crc_StartValue16, | ||
boolean | Crc_IsFirstCall ) |
Calculate a CRC of 16 bits and polynomial of 0xA001
The function calculates the a 16 bit CRC with data reflected according to the standard of AUTOSAR with their respective paramters.
In this case AUTOSAR specify a 0x8005 polynomial but the function need that the input data are relfected so the reflected data of 0x8005 is 0xA001.
First is necessary to know if is the first time to use the function and it is assigned a value for our CRC calculation. The function calculates the CRC through a for cycle, one of them is to know what of all bytes is in the calculation and the other is to move the bit of the respective byte.
The function uses bit shift to calculate the CRC according with the process.
Crc_DataPtr | Pointer to start address of data block to be calculated. |
Crc_Length | Length of data block to be calculated in bytes. |
Crc_StartValue16 | Start value when the algorithm starts. |
Crc_IsFirstCall | boolean variable to know if is the first time that we used the function. |
crcValue | the value of crc (16 bits) according with parameters and specifications of this function |
< Polynomial of CRC16ARC
< Less significant bit
uint32 Crc_CalculateCRC32 | ( | const uint8 * | Crc_DataPtr, |
uint32 | Crc_Length, | ||
uint32 | Crc_StartValue32, | ||
boolean | Crc_IsFirstCall ) |
Calculate a CRC of 32 bits and polynomial of 0x04C11DB7
The function calculates the a 32 bit CRC with data reflected according to the standard of AUTOSAR with their respective paramters.
In this case AUTOSAR specify a 0x04C11DB7 polynomial but the function need that the input data are relfected so the reflected data of 0x04C11DB7 is 0xEDB88320.
First is necessary to know if is the first time to use the function and it is assigned a value for our CRC calculation. The function calculates the CRC through a for cycle, one of them is to know what of all bytes is in the calculation and the other is to move the bit of the respective byte.
The function uses bit shift to calculate the CRC according with the process.
Crc_DataPtr | Pointer to start address of data block to be calculated. |
Crc_Length | Length of data block to be calculated in bytes. |
Crc_StartValue32 | Start value when the algorithm starts. |
Crc_IsFirstCall | boolean variable to know if is the first time that we used the function. |
crcValue | the value of crc (32 bits) according with parameters and specifications of this function |
< Polynomial of CRC32
< Value of CRC if is first call
< Value of CRC if is first call
< Less significant bit
< Value of CRC if is first call
uint32 Crc_CalculateCRC32P4 | ( | const uint8 * | Crc_DataPtr, |
uint32 | Crc_Length, | ||
uint32 | Crc_StartValue32, | ||
boolean | Crc_IsFirstCall ) |
Calculate a CRC of 32 bits and polynomial of F4’AC’FB’13h
The function calculates the a 32 bit CRC with data reflected according to the standard of AUTOSAR with their respective paramters.
In this case AUTOSAR specify a F4’AC’FB’13h polynomial but the function need that the input data are relfected so the reflected and is needed to assign the first CRC value the value of their XOR in this case 0xFFFFFFFF.
First is necessary to know if is the first time to use the function and it is assigned a value for our CRC calculation. The function calculates the CRC through a for cycle, one of them is to know what of all bytes is in the calculation and the other is to move the bit of the respective byte.
The function uses bit shift to calculate the CRC according with the process.
Crc_DataPtr | Pointer to start address of data block to be calculated. |
Crc_Length | Length of data block to be calculated in bytes. |
Crc_StartValue32 | Start value when the algorithm starts. |
Crc_IsFirstCall | boolean variable to know if is the first time that we used the function. |
crcValue | the value of crc (32 bits) according with parameters and specifications of this function |
< Value of CRC if is first call
< Value of CRC if is first call
< Less significant bit
< Polynomial of CRC32P4
< Value of CRC if is first call
uint64 Crc_CalculateCRC64 | ( | const uint8 * | Crc_DataPtr, |
uint32 | Crc_Length, | ||
uint64 | Crc_StartValue64, | ||
boolean | Crc_IsFirstCall ) |
Calculate a CRC of 64 bits and polynomial of 42’F0’E1’EB’A9’EA’36’93h
The function calculates the a 32 bit CRC with data reflected according to the standard of AUTOSAR with their respective paramters.
In this case AUTOSAR specify a 42’F0’E1’EB’A9’EA’36’93h polynomial but the function need that the input data are relfected so the reflected and is needed to assign the first CRC value the value of their XOR in this case 0xFFFFFFFFFFFFFFFF.
First is necessary to know if is the first time to use the function and it is assigned a value for our CRC calculation. The function calculates the CRC through a for cycle, one of them is to know what of all bytes is in the calculation and the other is to move the bit of the respective byte.
The function uses bit shift to calculate the CRC according with the process.
Crc_DataPtr | Pointer to start address of data block to be calculated. |
Crc_Length | Length of data block to be calculated in bytes. |
Crc_StartValue64 | Start value when the algorithm starts. |
Crc_IsFirstCall | boolean variable to know if is the first time that we used the function. |
crcValue | the value of crc (64 bits) according with parameters and specifications of this function |
< Value of CRC if is first call
< Value of CRC if is first call
< Less significant bit
< Polynomial of CRC64
< Value of CRC if is first call
uint8 Crc_CalculateCRC8 | ( | const uint8 * | Crc_DataPtr, |
uint32 | Crc_Length, | ||
uint8 | Crc_StartValue8, | ||
boolean | Crc_IsFirstCall ) |
Calculate a CRC of 8 bits
The function calculates the a 8 bit CRC according to the standard of AUTOSAR with their respective paramters.
First is necessary to know if is the first time to use the function and it is assigned a value for our CRC calculation. The function calculates the CRC through a for cycle, one of them is to know what of all bytes is in the calculation and the other is to move the bit of the respective byte.
The function uses bit shift to calculate the CRC according with the process.
Crc_DataPtr | Pointer to start address of data block to be calculated. |
Crc_Length | Length of data block to be calculated in bytes. |
Crc_StartValue8 | Start value when the algorithm starts. |
Crc_IsFirstCall | boolean variable to know if is the first time that we used the function. |
crcValue | the value of crc (8 bits) according with parameters and specifications of this function |
< Polynomial of CRC8_SAEJ1850
< Value of CRC if is first call
< Number of bits of a byte
< Most significant bit of a byte
uint8 Crc_CalculateCRC8H2F | ( | const uint8 * | Crc_DataPtr, |
uint32 | Crc_Length, | ||
uint8 | Crc_StartValue8H2F, | ||
boolean | Crc_IsFirstCall ) |
Calculate a CRC of 8 bits with other polynomial 0x2F
The function calculates the a 8 bit CRC according to the standard of AUTOSAR with their respective paramters.
First is necessary to know if is the first time to use the function and it is assigned a value for our CRC calculation. The function calculates the CRC through a for cycle, one of them is to know what of all bytes is in the calculation and the other is to move the bit of the respective byte.
The function uses bit shift to calculate the CRC according with the process.
Crc_DataPtr | Pointer to start address of data block to be calculated. |
Crc_Length | Length of data block to be calculated in bytes. |
Crc_StartValue8H2F | Start value when the algorithm starts. |
Crc_IsFirstCall | boolean variable to know if is the first time that we used the function. |
crcValue | the value of crc (8 bits) according with parameters and specifications of this function |
< Polynomial of CRC8H2F
< Value of CRC if is first call
< Number of bits of a byte
< Most significant bit of a byte
uint8 Crc_GetVersionInfo | ( | Std_VersionInfoType * | Versioninfo | ) |
Fuunction to assign values to VersionInfo structure
This service returns the version information of this module.
The function assign values to VersionInfo structure to know the vendorID, moduleID, sw_major_version, sw_minor_version and sw_patch_version.
The function returns a TRUE if the members of structure have a value this part of code is inly for test porpuses.
Versioninfo | Variable that locates the version information of CRC. |
status |
< CRC Vendor ID VALUE
< CRC MODULE ID VALUE
< CRC_SW_MAJOR_VERSION ID VALUE
< CRC_SW_MINOR_VERSION ID VALUE
< CRC_SW_PATCH_VERSION ID VALUE