blob: 64824624c5912aa182d2b45569b046d6df998023 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
/******************************************************************************
*
* @brief Cyclic redundancy check (CRC) header file.
*
******************************************************************************/
#ifndef CRC_H_
#define CRC_H_
#ifdef __cplusplus
extern "C" {
#endif
/******************************************************************************
* Includes
******************************************************************************/
/******************************************************************************
* Constants
******************************************************************************/
/******************************************************************************
* Macros
******************************************************************************/
/******************************************************************************
* CRC control bit definition
*
*//*! @addtogroup crc_controlbit
* @{
*******************************************************************************/
/*!
* @brief CRC control register bit definition.
*
*/
#define CRC_WIDTH_16BIT 0 /*!< select CRC16 protocol */
#define CRC_WIDTH_32BIT 1 /*!< select CRC32 protocol */
#define CRC_DATA_SEED 1 /*!< Write CRC Data Register are seed */
#define CRC_DATA_DATA 0 /*!< Write CRC Data Register are data */
#define CRC_READ_COMPLETE 1 /*!< Invert or complement read CRC Data register */
#define CRC_READ_NONE 0 /*!< No XOR on reading */
#define CRC_READ_TRANSPOSE_NONE 0 /*!< No transposition in read */
#define CRC_READ_TRANSPOSE_BIT 1 /*!< only bits in bytes are transposed in read */
#define CRC_READ_TRANSPOSE_ALL 2 /*!< both bits in bytes and bytes are transposed in read */
#define CRC_READ_TRANSPOSE_BYTE 3 /*!< only bytes are transposed in read */
#define CRC_WRITE_TRANSPOSE_NONE 0 /*!< No transposition write */
#define CRC_WRITE_TRANSPOSE_BIT 1 /*!< only bits in bytes are transposed in write */
#define CRC_WRITE_TRANSPOSE_ALL 2 /*!< both bits in bytes and bytes are transposed in write */
#define CRC_WRITE_TRANSPOSE_BYTE 3 /*!< only bytes are transposed in write */
/*! @} End of crc_controlbit */
/******************************************************************************
* Types
******************************************************************************/
/* CRC configuration structure
*/
/******************************************************************************
* CRC Configuration Structure type.
*
*//*! @addtogroup crc_config_type
* @{
*******************************************************************************/
/*!
* @brief CRC Configuration Structure.
*
*/
typedef struct
{
uint8_t bWidth : 1; /*!< 1: 32-bit CRC protocol , 0: 16-bit CRC protocol */
uint8_t bDataType : 1; /*!< 1: write seed , 0: write data */
uint8_t bFinalXOR : 1; /*!< 1: Invert or complement read , 0: No XOR on reading */
uint8_t bRESERVED : 1; /*!< reserved bit */
uint8_t bTransposeReadType : 2; /*!< type of transpose For read, see reference manual */
uint8_t bTransposeWriteType : 2; /*!< type of transpose For write, see reference manual */
uint32_t u32PolyData ; /*!< 32bit or 16-biy poly data */
} CRC_ConfigType, *CRC_ConfigPtr ;
/*! @} End of crc_config_type */
/******************************************************************************
* Global variables
******************************************************************************/
/******************************************************************************
* CRC API list
*
*//*! @addtogroup crc_api_list
* @{
*******************************************************************************/
/******************************************************************************
* Global functions
******************************************************************************/
void CRC_Init(CRC_ConfigType *pConfig);
uint32_t CRC_Cal16(uint32_t u32Seed, uint8_t *msg, uint32_t u32SizeBytes);
uint32_t CRC_Cal32(uint32_t u32Seed, uint8_t *msg, uint32_t u32SizeBytes);
void CRC_DeInit(void);
/*! @} End of crc_api_list */
#ifdef __cplusplus
}
#endif
#endif /* CRC_H_ */
|