1 /*********************************************************************************************************//** 2 * @file ht32f5xxxx_crc.h 3 * @version $Rev:: 5031 $ 4 * @date $Date:: 2020-11-03 #$ 5 * @brief The header file of the CRC library. 6 ************************************************************************************************************* 7 * @attention 8 * 9 * Firmware Disclaimer Information 10 * 11 * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the 12 * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the 13 * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and 14 * other intellectual property laws. 15 * 16 * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the 17 * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties 18 * other than HOLTEK and the customer. 19 * 20 * 3. The program technical documentation, including the code, is provided "as is" and for customer reference 21 * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including 22 * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including 23 * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. 24 * 25 * <h2><center>Copyright (C) Holtek Semiconductor Inc. All rights reserved</center></h2> 26 ************************************************************************************************************/ 27 28 /* Define to prevent recursive inclusion -------------------------------------------------------------------*/ 29 #ifndef __HT32F5XXXX_CRC_H 30 #define __HT32F5XXXX_CRC_H 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 /* Includes ------------------------------------------------------------------------------------------------*/ 37 #include "ht32.h" 38 39 /** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver 40 * @{ 41 */ 42 43 /** @addtogroup CRC 44 * @{ 45 */ 46 47 48 /* Exported types ------------------------------------------------------------------------------------------*/ 49 /** @defgroup CRC_Exported_Types CRC exported types 50 * @{ 51 */ 52 53 /* Definition of CRC Init Structure */ 54 typedef enum 55 { 56 CRC_CCITT_POLY = 0, 57 CRC_16_POLY = 1, 58 CRC_32_POLY = 2, 59 CRC_USER_DEFINE = 0xF 60 } CRC_Mode; 61 62 typedef struct 63 { 64 CRC_Mode Mode; 65 u32 uSeed; 66 u32 uCR; 67 } CRC_InitTypeDef; 68 /** 69 * @} 70 */ 71 72 /* Exported constants --------------------------------------------------------------------------------------*/ 73 /** @defgroup CRC_Exported_Constants CRC exported constants 74 * @{ 75 */ 76 #define IS_CRC_POLY(POLY) ((POLY == CRC_CCITT_POLY) || \ 77 (POLY == CRC_16_POLY) || \ 78 (POLY == CRC_32_POLY) || \ 79 (POLY == CRC_USER_DEFINE)) 80 81 #define CRC_NORMAL_WR (0) 82 #define CRC_BIT_RVS_WR (1UL << 2) 83 #define CRC_BYTE_RVS_WR (1UL << 3) 84 #define CRC_CMPL_WR (1UL << 4) 85 86 #define CRC_NORMAL_SUM (0) 87 #define CRC_BIT_RVS_SUM (1UL << 5) 88 #define CRC_BYTE_RVS_SUM (1UL << 6) 89 #define CRC_CMPL_SUM (1UL << 7) 90 91 #define IS_CRC_MOD(MOD) ((MOD & 0xFFFFFF00) == 0) 92 /** 93 * @} 94 */ 95 96 /* Exported functions --------------------------------------------------------------------------------------*/ 97 /** @defgroup CRC_Exported_Functions CRC exported functions 98 * @{ 99 */ 100 void CRC_DeInit(HT_CRC_TypeDef* HT_CRCn); 101 void CRC_Init(HT_CRC_TypeDef* HT_CRCn, CRC_InitTypeDef* CRC_InitStruct); 102 u32 CRC_Process(HT_CRC_TypeDef* HT_CRCn, u8 *buffer, u32 length); 103 104 u16 CRC_CCITT(u16 seed, u8 *buffer, u32 length); 105 u16 CRC_16(u16 seed, u8 *buffer, u32 length); 106 u32 CRC_32(u32 seed, u8 *buffer, u32 length); 107 /** 108 * @} 109 */ 110 111 112 /** 113 * @} 114 */ 115 116 /** 117 * @} 118 */ 119 120 #ifdef __cplusplus 121 } 122 #endif 123 124 #endif 125