This module provides configuration and utils to calculate the CRC for PRIME messages in a PLC network.
|
static uint16_t | _eval_crc_16 (const uint8_t *puc_buf_ptr, uint32_t ul_len, uint32_t ul_crc_init) |
| This function calculates the CRC16 of the input data. More...
|
|
static uint32_t | _eval_crc_32 (const uint8_t *puc_buf_ptr, uint32_t ul_len, uint32_t ul_crc_init) |
| This function calculates the CRC32 of the input data. More...
|
|
static uint8_t | _eval_crc_8 (const uint8_t *puc_buf_ptr, uint32_t ul_len, uint32_t ul_crc_init) |
| This function calculates the CRC8 of the input data. More...
|
|
static uint8_t | _eval_crc_8_usi (const uint8_t *puc_buf_ptr, uint32_t ul_len, uint32_t ul_crc_init) |
| This function calculates the CRC8 of the input data for USI. More...
|
|
uint32_t | pcrc_calculate_prime_crc (uint8_t *puc_buf, uint32_t ul_len, uint8_t uc_header_type, uint8_t uc_crc_type) |
| Calculates the CRC of the input buffer according to the PRIME spec. More...
|
|
void | pcrc_configure_sna (uint8_t *puc_sna) |
| Through this function, the SNA is configured for the PCRC service. More...
|
|
#define PCRC_CRC_INVALID 0xFFFFFFFF |
#define PCRC_HT_GENERIC 0 |
#define PCRC_HT_PROMOTION 1 |
#define PCRC_PROMOTION_CRC_LENGTH 13 |
Enumerator |
---|
PCRC_CRC_TYPE_8 |
|
PCRC_CRC_TYPE_16 |
|
PCRC_CRC_TYPE_24 |
|
PCRC_CRC_TYPE_32 |
|
static uint16_t _eval_crc_16 |
( |
const uint8_t * |
puc_buf_ptr, |
|
|
uint32_t |
ul_len, |
|
|
uint32_t |
ul_crc_init |
|
) |
| |
|
static |
This function calculates the CRC16 of the input data.
- Parameters
-
puc_buf_ptr | Pointer to the input data |
ul_len | Length of data to evaluate |
ul_crc_init | Initial value for the CRC calculation algorithm |
- Return values
-
Referenced by pcrc_calculate_prime_crc().
static uint32_t _eval_crc_32 |
( |
const uint8_t * |
puc_buf_ptr, |
|
|
uint32_t |
ul_len, |
|
|
uint32_t |
ul_crc_init |
|
) |
| |
|
static |
This function calculates the CRC32 of the input data.
- Parameters
-
puc_buf_ptr | Pointer to the input data |
ul_len | Length of data to evaluate |
ul_crc_init | Initial value for the CRC calculation algorithm |
- Return values
-
Referenced by pcrc_calculate_prime_crc(), and pcrc_configure_sna().
static uint8_t _eval_crc_8 |
( |
const uint8_t * |
puc_buf_ptr, |
|
|
uint32_t |
ul_len, |
|
|
uint32_t |
ul_crc_init |
|
) |
| |
|
static |
This function calculates the CRC8 of the input data.
- Parameters
-
puc_buf_ptr | Pointer to the input data |
ul_len | Length of data to evaluate |
ul_crc_init | Initial value for the CRC calculation algorithm |
- Return values
-
Referenced by pcrc_calculate_prime_crc(), and pcrc_configure_sna().
static uint8_t _eval_crc_8_usi |
( |
const uint8_t * |
puc_buf_ptr, |
|
|
uint32_t |
ul_len, |
|
|
uint32_t |
ul_crc_init |
|
) |
| |
|
static |
This function calculates the CRC8 of the input data for USI.
- Parameters
-
puc_buf_ptr | Pointer to the input data |
ul_len | Length of data to evaluate |
ul_crc_init | Initial value for the CRC calculation algorithm |
- Return values
-
Referenced by pcrc_calculate_prime_crc().
uint32_t pcrc_calculate_prime_crc |
( |
uint8_t * |
puc_buf, |
|
|
uint32_t |
ul_len, |
|
|
uint8_t |
uc_header_type, |
|
|
uint8_t |
uc_crc_type |
|
) |
| |
Calculates the CRC of the input buffer according to the PRIME spec.
- Parameters
-
puc_buf | Input buffer |
ul_len | Data length |
uc_header_type | Header Type |
uc_crc_type | CRC type (only needed for USI messages) |
- Return values
-
crc | value (PCRC_CRC_INVALID if SNA not configured and needed) |
References _eval_crc_16(), _eval_crc_32(), _eval_crc_8(), _eval_crc_8_usi(), PCRC_CRC_INVALID, PCRC_CRC_TYPE_16, PCRC_CRC_TYPE_32, PCRC_CRC_TYPE_8, PCRC_HT_BEACON, PCRC_HT_GENERIC, PCRC_HT_PROMOTION, PCRC_HT_USI, and PCRC_PROMOTION_CRC_LENGTH.
Referenced by _doEoMsg(), and _usi_encode_and_send().
void pcrc_configure_sna |
( |
uint8_t * |
puc_sna | ) |
|
const uint8_t puc_crc8_table[256] |
|
static |
uint8_t puc_SNA[SNA_SIZE] = {0, 0, 0, 0, 0, 0} |
|
static |
const uint32_t pul_crc32_table[256] |
|
static |
const uint16_t pus_crc16_table[256] |
|
static |
uint32_t ul_SNA_crc_32 = 0 |
|
static |