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