|
STM32G474xx HAL用户手册
|
00001 /** 00002 ****************************************************************************** 00003 * @file stm32g4xx_ll_crc.h 00004 * @author MCD Application Team 00005 * @brief Header file of CRC LL module. 00006 ****************************************************************************** 00007 * @attention 00008 * 00009 * Copyright (c) 2019 STMicroelectronics. 00010 * All rights reserved. 00011 * 00012 * This software is licensed under terms that can be found in the LICENSE file 00013 * in the root directory of this software component. 00014 * If no LICENSE file comes with this software, it is provided AS-IS. 00015 * 00016 ****************************************************************************** 00017 */ 00018 00019 /* Define to prevent recursive inclusion -------------------------------------*/ 00020 #ifndef STM32G4xx_LL_CRC_H 00021 #define STM32G4xx_LL_CRC_H 00022 00023 #ifdef __cplusplus 00024 extern "C" { 00025 #endif 00026 00027 /* Includes ------------------------------------------------------------------*/ 00028 #include "stm32g4xx.h" 00029 00030 /** @addtogroup STM32G4xx_LL_Driver 00031 * @{ 00032 */ 00033 00034 #if defined(CRC) 00035 00036 /** @defgroup CRC_LL CRC 00037 * @{ 00038 */ 00039 00040 /* Private types -------------------------------------------------------------*/ 00041 /* Private variables ---------------------------------------------------------*/ 00042 /* Private constants ---------------------------------------------------------*/ 00043 /* Private macros ------------------------------------------------------------*/ 00044 00045 /* Exported types ------------------------------------------------------------*/ 00046 /* Exported constants --------------------------------------------------------*/ 00047 /** @defgroup CRC_LL_Exported_Constants CRC Exported Constants 00048 * @{ 00049 */ 00050 00051 /** @defgroup CRC_LL_EC_POLYLENGTH Polynomial length 00052 * @{ 00053 */ 00054 #define LL_CRC_POLYLENGTH_32B 0x00000000U /*!< 32 bits Polynomial size */ 00055 #define LL_CRC_POLYLENGTH_16B CRC_CR_POLYSIZE_0 /*!< 16 bits Polynomial size */ 00056 #define LL_CRC_POLYLENGTH_8B CRC_CR_POLYSIZE_1 /*!< 8 bits Polynomial size */ 00057 #define LL_CRC_POLYLENGTH_7B (CRC_CR_POLYSIZE_1 | CRC_CR_POLYSIZE_0) /*!< 7 bits Polynomial size */ 00058 /** 00059 * @} 00060 */ 00061 00062 /** @defgroup CRC_LL_EC_INDATA_REVERSE Input Data Reverse 00063 * @{ 00064 */ 00065 #define LL_CRC_INDATA_REVERSE_NONE 0x00000000U /*!< Input Data bit order not affected */ 00066 #define LL_CRC_INDATA_REVERSE_BYTE CRC_CR_REV_IN_0 /*!< Input Data bit reversal done by byte */ 00067 #define LL_CRC_INDATA_REVERSE_HALFWORD CRC_CR_REV_IN_1 /*!< Input Data bit reversal done by half-word */ 00068 #define LL_CRC_INDATA_REVERSE_WORD (CRC_CR_REV_IN_1 | CRC_CR_REV_IN_0) /*!< Input Data bit reversal done by word */ 00069 /** 00070 * @} 00071 */ 00072 00073 /** @defgroup CRC_LL_EC_OUTDATA_REVERSE Output Data Reverse 00074 * @{ 00075 */ 00076 #define LL_CRC_OUTDATA_REVERSE_NONE 0x00000000U /*!< Output Data bit order not affected */ 00077 #define LL_CRC_OUTDATA_REVERSE_BIT CRC_CR_REV_OUT /*!< Output Data bit reversal done by bit */ 00078 /** 00079 * @} 00080 */ 00081 00082 /** @defgroup CRC_LL_EC_Default_Polynomial_Value Default CRC generating polynomial value 00083 * @brief Normal representation of this polynomial value is 00084 * X^32 + X^26 + X^23 + X^22 + X^16 + X^12 + X^11 + X^10 +X^8 + X^7 + X^5 + X^4 + X^2 + X + 1 . 00085 * @{ 00086 */ 00087 #define LL_CRC_DEFAULT_CRC32_POLY 0x04C11DB7U /*!< Default CRC generating polynomial value */ 00088 /** 00089 * @} 00090 */ 00091 00092 /** @defgroup CRC_LL_EC_Default_InitValue Default CRC computation initialization value 00093 * @{ 00094 */ 00095 #define LL_CRC_DEFAULT_CRC_INITVALUE 0xFFFFFFFFU /*!< Default CRC computation initialization value */ 00096 /** 00097 * @} 00098 */ 00099 00100 /** 00101 * @} 00102 */ 00103 00104 /* Exported macro ------------------------------------------------------------*/ 00105 /** @defgroup CRC_LL_Exported_Macros CRC Exported Macros 00106 * @{ 00107 */ 00108 00109 /** @defgroup CRC_LL_EM_WRITE_READ Common Write and read registers Macros 00110 * @{ 00111 */ 00112 00113 /** 00114 * @brief Write a value in CRC register 00115 * @param __INSTANCE__ CRC Instance 00116 * @param __REG__ Register to be written 00117 * @param __VALUE__ Value to be written in the register 00118 * @retval None 00119 */ 00120 #define LL_CRC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, __VALUE__) 00121 00122 /** 00123 * @brief Read a value in CRC register 00124 * @param __INSTANCE__ CRC Instance 00125 * @param __REG__ Register to be read 00126 * @retval Register value 00127 */ 00128 #define LL_CRC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__) 00129 /** 00130 * @} 00131 */ 00132 00133 /** 00134 * @} 00135 */ 00136 00137 00138 /* Exported functions --------------------------------------------------------*/ 00139 /** @defgroup CRC_LL_Exported_Functions CRC Exported Functions 00140 * @{ 00141 */ 00142 00143 /** @defgroup CRC_LL_EF_Configuration CRC Configuration functions 00144 * @{ 00145 */ 00146 00147 /** 00148 * @brief Reset the CRC calculation unit. 00149 * @note If Programmable Initial CRC value feature 00150 * is available, also set the Data Register to the value stored in the 00151 * CRC_INIT register, otherwise, reset Data Register to its default value. 00152 * @rmtoll CR RESET LL_CRC_ResetCRCCalculationUnit 00153 * @param CRCx CRC Instance 00154 * @retval None 00155 */ 00156 __STATIC_INLINE void LL_CRC_ResetCRCCalculationUnit(CRC_TypeDef *CRCx) 00157 { 00158 SET_BIT(CRCx->CR, CRC_CR_RESET); 00159 } 00160 00161 /** 00162 * @brief Configure size of the polynomial. 00163 * @rmtoll CR POLYSIZE LL_CRC_SetPolynomialSize 00164 * @param CRCx CRC Instance 00165 * @param PolySize This parameter can be one of the following values: 00166 * @arg @ref LL_CRC_POLYLENGTH_32B 00167 * @arg @ref LL_CRC_POLYLENGTH_16B 00168 * @arg @ref LL_CRC_POLYLENGTH_8B 00169 * @arg @ref LL_CRC_POLYLENGTH_7B 00170 * @retval None 00171 */ 00172 __STATIC_INLINE void LL_CRC_SetPolynomialSize(CRC_TypeDef *CRCx, uint32_t PolySize) 00173 { 00174 MODIFY_REG(CRCx->CR, CRC_CR_POLYSIZE, PolySize); 00175 } 00176 00177 /** 00178 * @brief Return size of the polynomial. 00179 * @rmtoll CR POLYSIZE LL_CRC_GetPolynomialSize 00180 * @param CRCx CRC Instance 00181 * @retval Returned value can be one of the following values: 00182 * @arg @ref LL_CRC_POLYLENGTH_32B 00183 * @arg @ref LL_CRC_POLYLENGTH_16B 00184 * @arg @ref LL_CRC_POLYLENGTH_8B 00185 * @arg @ref LL_CRC_POLYLENGTH_7B 00186 */ 00187 __STATIC_INLINE uint32_t LL_CRC_GetPolynomialSize(const CRC_TypeDef *CRC