59 lines
1.3 KiB
C
59 lines
1.3 KiB
C
/**
|
|
* @ingroup can
|
|
* @defgroup can_crc Cyclic redundancy check
|
|
* @brief brief
|
|
* @date Aug 25, 2015
|
|
* @author rheijden
|
|
* @copyright 2015 Dual Inventive Technology Centre B.V.
|
|
*
|
|
* @{
|
|
*/
|
|
#ifndef INCLUDE_DI_CAN_CRC_H_
|
|
#define INCLUDE_DI_CAN_CRC_H_
|
|
|
|
#include <stdint.h>
|
|
#include <stddef.h>
|
|
#include <stdbool.h>
|
|
|
|
#include <di/types.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
struct di_can_msg;
|
|
|
|
/**
|
|
* Check CAN message for valid CRC
|
|
* msg->msg should point to start of transfer payload data
|
|
* @note When CRC is valid
|
|
* * msg->msg points to new location
|
|
* * msg->size is size of actual data
|
|
* @return DNOK When valid CRC
|
|
* @return DNE_CAN_CRC When invalid CRC (or DNE_CAN_INVAL when msg->msg = NULL, msg->size = 0)
|
|
*/
|
|
di_errno_t di_can_crc_check(struct di_can_msg *msg, uint16_t crc);
|
|
|
|
/**
|
|
* Check if message has a valid CRC
|
|
* Message must contain a transfer payload
|
|
*/
|
|
bool di_can_crc_is_msg_valid(struct di_can_msg *msg);
|
|
|
|
/**
|
|
* Calculate CAN message CRC
|
|
* @param msg Message to calculate
|
|
* @param crc CRC result
|
|
* @return DNOK When message CRC is calculated
|
|
* @return DNE_CAN_INVAL When invalid msg.msg pointer or msg.size is incorrect
|
|
*/
|
|
di_errno_t di_can_crc_calc(const struct di_can_msg *msg, uint16_t *crc);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
/** @} */
|
|
|
|
#endif /* INCLUDE_DI_CAN_CRC_H_ */
|