L4 HAL Drivers
Embed:
(wiki syntax)
Show/hide line numbers
stm32l4xx_hal_crc.h
Go to the documentation of this file.
00001 /** 00002 ****************************************************************************** 00003 * @file stm32l4xx_hal_crc.h 00004 * @author MCD Application Team 00005 * @version V1.1.0 00006 * @date 16-September-2015 00007 * @brief Header file of CRC HAL module. 00008 ****************************************************************************** 00009 * @attention 00010 * 00011 * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> 00012 * 00013 * Redistribution and use in source and binary forms, with or without modification, 00014 * are permitted provided that the following conditions are met: 00015 * 1. Redistributions of source code must retain the above copyright notice, 00016 * this list of conditions and the following disclaimer. 00017 * 2. Redistributions in binary form must reproduce the above copyright notice, 00018 * this list of conditions and the following disclaimer in the documentation 00019 * and/or other materials provided with the distribution. 00020 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00021 * may be used to endorse or promote products derived from this software 00022 * without specific prior written permission. 00023 * 00024 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00025 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00026 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00027 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00028 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00029 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00030 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00031 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00032 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00033 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00034 * 00035 ****************************************************************************** 00036 */ 00037 00038 /* Define to prevent recursive inclusion -------------------------------------*/ 00039 #ifndef __STM32L4xx_HAL_CRC_H 00040 #define __STM32L4xx_HAL_CRC_H 00041 00042 #ifdef __cplusplus 00043 extern "C" { 00044 #endif 00045 00046 /* Includes ------------------------------------------------------------------*/ 00047 #include "stm32l4xx_hal_def.h" 00048 00049 /** @addtogroup STM32L4xx_HAL_Driver 00050 * @{ 00051 */ 00052 00053 /** @addtogroup CRC 00054 * @{ 00055 */ 00056 00057 /* Exported types ------------------------------------------------------------*/ 00058 00059 /** @defgroup CRC_Exported_Types CRC Exported Types 00060 * @{ 00061 */ 00062 00063 /** 00064 * @brief CRC HAL State Structure definition 00065 */ 00066 typedef enum 00067 { 00068 HAL_CRC_STATE_RESET = 0x00, /*!< CRC not yet initialized or disabled */ 00069 HAL_CRC_STATE_READY = 0x01, /*!< CRC initialized and ready for use */ 00070 HAL_CRC_STATE_BUSY = 0x02, /*!< CRC internal process is ongoing */ 00071 HAL_CRC_STATE_TIMEOUT = 0x03, /*!< CRC timeout state */ 00072 HAL_CRC_STATE_ERROR = 0x04 /*!< CRC error state */ 00073 }HAL_CRC_StateTypeDef; 00074 00075 00076 00077 /** 00078 * @brief CRC Init Structure definition 00079 */ 00080 typedef struct 00081 { 00082 uint8_t DefaultPolynomialUse; /*!< This parameter is a value of @ref CRC_Default_Polynomial and indicates if default polynomial is used. 00083 If set to DEFAULT_POLYNOMIAL_ENABLE, resort to default 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 In that case, there is no need to set GeneratingPolynomial field. 00086 If otherwise set to DEFAULT_POLYNOMIAL_DISABLE, GeneratingPolynomial and CRCLength fields must be set. */ 00087 00088 uint8_t DefaultInitValueUse; /*!< This parameter is a value of @ref CRC_Default_InitValue_Use and indicates if default init value is used. 00089 If set to DEFAULT_INIT_VALUE_ENABLE, resort to default 00090 0xFFFFFFFF value. In that case, there is no need to set InitValue field. 00091 If otherwise set to DEFAULT_INIT_VALUE_DISABLE, InitValue field must be set. */ 00092 00093 uint32_t GeneratingPolynomial; /*!< Set CRC generating polynomial as a 7, 8, 16 or 32-bit long value for a polynomial degree 00094 respectively equal to 7, 8, 16 or 32. This field is written in normal representation, 00095 e.g., for a polynomial of degree 7, X^7 + X^6 + X^5 + X^2 + 1 is written 0x65. 00096 No need to specify it if DefaultPolynomialUse is set to DEFAULT_POLYNOMIAL_ENABLE. */ 00097 00098 uint32_t CRCLength; /*!< This parameter is a value of @ref CRC_Polynomial_Sizes and indicates CRC length. 00099 Value can be either one of 00100 @arg CRC_POLYLENGTH_32B (32-bit CRC), 00101 @arg CRC_POLYLENGTH_16B (16-bit CRC), 00102 @arg CRC_POLYLENGTH_8B (8-bit CRC), 00103 @arg CRC_POLYLENGTH_7B (7-bit CRC). */ 00104 00105 uint32_t InitValue; /*!< Init value to initiate CRC computation. No need to specify it if DefaultInitValueUse 00106 is set to DEFAULT_INIT_VALUE_ENABLE. */ 00107 00108 uint32_t InputDataInversionMode; /*!< This parameter is a value of @ref CRCEx_Input_Data_Inversion and specifies input data inversion mode. 00109 Can be either one of the following values 00110 @arg CRC_INPUTDATA_INVERSION_NONE, no input data inversion 00111 @arg CRC_INPUTDATA_INVERSION_BYTE, byte-wise inversion, 0x1A2B3C4D becomes 0x58D43CB2 00112 @arg CRC_INPUTDATA_INVERSION_HALFWORD, halfword-wise inversion, 0x1A2B3C4D becomes 0xD458B23C 00113 @arg CRC_INPUTDATA_INVERSION_WORD, word-wise inversion, 0x1A2B3C4D becomes 0xB23CD458 */ 00114 00115 uint32_t OutputDataInversionMode; /*!< This parameter is a value of @ref CRCEx_Output_Data_Inversion and specifies output data (i.e. CRC) inversion mode. 00116 Can be either 00117 @arg CRC_OUTPUTDATA_INVERSION_DISABLE: no CRC inversion, 00118 @arg CRC_OUTPUTDATA_INVERSION_ENABLE: CRC 0x11223344 is converted into 0x22CC4488 */ 00119 }CRC_InitTypeDef; 00120 00121 00122 00123 /** 00124 * @brief CRC Handle Structure definition 00125 */ 00126 typedef struct 00127 { 00128 CRC_TypeDef *Instance; /*!< Register base address */ 00129 00130 CRC_InitTypeDef Init; /*!< CRC configuration parameters */ 00131 00132 HAL_LockTypeDef Lock; /*!< CRC Locking object */ 00133 00134 __IO HAL_CRC_StateTypeDef State; /*!< CRC communication state */ 00135 00136 uint32_t InputDataFormat; /*!< This parameter is a value of @ref CRC_Input_Buffer_Format and specifies input data format. 00137 Can be either 00138 @arg CRC_INPUTDATA_FORMAT_BYTES, input data is a stream of bytes (8-bit data) 00139 @arg CRC_INPUTDATA_FORMAT_HALFWORDS, input data is a stream of half-words (16-bit data) 00140 @arg CRC_INPUTDATA_FORMAT_WORDS, input data is a stream of words (32-bit data) 00141 00142 Note that constant CRC_INPUT_FORMAT_UNDEFINED is defined but an initialization error 00143 must occur if InputBufferFormat is not one of the three values listed above */ 00144 }CRC_HandleTypeDef; 00145 00146 00147 /** 00148 * @} 00149 */ 00150 00151 /* Exported constants --------------------------------------------------------*/ 00152 /** @defgroup CRC_Exported_Constants CRC Exported Constants 00153 * @{ 00154 */ 00155 00156 /** @defgroup CRC_Default_Polynomial_Value Default CRC generating polynomial 00157 * @{ 00158 */ 00159 #define DEFAULT_CRC32_POLY 0x04C11DB7 /*!< 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 */ 00160 /** 00161 * @} 00162 */ 00163 00164 /** @defgroup CRC_Default_InitValue Default CRC computation initialization value 00165 * @{ 00166 */ 00167 #define DEFAULT_CRC_INITVALUE 0xFFFFFFFF /*!< Initial CRC default value */ 00168 /** 00169 * @} 00170 */ 00171 00172 /** @defgroup CRC_Default_Polynomial Indicates whether or not default polynomial is used 00173 * @{ 00174 */ 00175 #define DEFAULT_POLYNOMIAL_ENABLE ((uint8_t)0x00) /*!< Enable default generating polynomial 0x04C11DB7 */ 00176 #define DEFAULT_POLYNOMIAL_DISABLE ((uint8_t)0x01) /*!< Disable default generating polynomial 0x04C11DB7 */ 00177 /** 00178 * @} 00179 */ 00180 00181 /** @defgroup CRC_Default_InitValue_Use Indicates whether or not default init value is used 00182 * @{ 00183 */ 00184 #define DEFAULT_INIT_VALUE_ENABLE ((uint8_t)0x00) /*!< Enable initial CRC default value */ 00185 #define DEFAULT_INIT_VALUE_DISABLE ((uint8_t)0x01) /*!< Disable initial CRC default value */ 00186 /** 00187 * @} 00188 */ 00189 00190 /** @defgroup CRC_Polynomial_Sizes Polynomial sizes to configure the IP 00191 * @{ 00192 */ 00193 #define CRC_POLYLENGTH_32B ((uint32_t)0x00000000) /*!< Resort to a 32-bit long generating polynomial */ 00194 #define CRC_POLYLENGTH_16B ((uint32_t)CRC_CR_POLYSIZE_0) /*!< Resort to a 16-bit long generating polynomial */ 00195 #define CRC_POLYLENGTH_8B ((uint32_t)CRC_CR_POLYSIZE_1) /*!< Resort to a 8-bit long generating polynomial */ 00196 #define CRC_POLYLENGTH_7B ((uint32_t)CRC_CR_POLYSIZE) /*!< Resort to a 7-bit long generating polynomial */ 00197 /** 00198 * @} 00199 */ 00200 00201 /** @defgroup CRC_Polynomial_Size_Definitions CRC polynomial possible sizes actual definitions 00202 * @{ 00203 */ 00204 #define HAL_CRC_LENGTH_32B 32 /*!< 32-bit long CRC */ 00205 #define HAL_CRC_LENGTH_16B 16 /*!< 16-bit long CRC */ 00206 #define HAL_CRC_LENGTH_8B 8 /*!< 8-bit long CRC */ 00207 #define HAL_CRC_LENGTH_7B 7 /*!< 7-bit long CRC */ 00208 /** 00209 * @} 00210 */ 00211 00212 /** @defgroup CRC_Input_Buffer_Format Input Buffer Format 00213 * @{ 00214 */ 00215 /* WARNING: CRC_INPUT_FORMAT_UNDEFINED is created for reference purposes but 00216 * an error is triggered in HAL_CRC_Init() if InputDataFormat field is set 00217 * to CRC_INPUT_FORMAT_UNDEFINED: the format MUST be defined by the user for 00218 * the CRC APIs to provide a correct result */ 00219 #define CRC_INPUTDATA_FORMAT_UNDEFINED ((uint32_t)0x00000000) /*!< Undefined input data format */ 00220 #define CRC_INPUTDATA_FORMAT_BYTES ((uint32_t)0x00000001) /*!< Input data in byte format */ 00221 #define CRC_INPUTDATA_FORMAT_HALFWORDS ((uint32_t)0x00000002) /*!< Input data in half-word format */ 00222 #define CRC_INPUTDATA_FORMAT_WORDS ((uint32_t)0x00000003) /*!< Input data in word format */ 00223 /** 00224 * @} 00225 */ 00226 00227 /** @defgroup CRC_Aliases CRC API aliases 00228 * @{ 00229 */ 00230 #define HAL_CRC_Input_Data_Reverse HAL_CRCEx_Input_Data_Reverse /*!< Aliased to HAL_CRCEx_Input_Data_Reverse for inter STM32 series compatibility */ 00231 #define HAL_CRC_Output_Data_Reverse HAL_CRCEx_Output_Data_Reverse /*!< Aliased to HAL_CRCEx_Output_Data_Reverse for inter STM32 series compatibility */ 00232 /** 00233 * @} 00234 */ 00235 00236 /** 00237 * @} 00238 */ 00239 00240 00241 /* Exported macros -----------------------------------------------------------*/ 00242 /** @defgroup CRC_Exported_Macros CRC Exported Macros 00243 * @{ 00244 */ 00245 00246 /** @brief Reset CRC handle state. 00247 * @param __HANDLE__: CRC handle. 00248 * @retval None 00249 */ 00250 #define __HAL_CRC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_CRC_STATE_RESET) 00251 00252 /** 00253 * @brief Reset CRC Data Register. 00254 * @param __HANDLE__: CRC handle 00255 * @retval None 00256 */ 00257 #define __HAL_CRC_DR_RESET(__HANDLE__) ((__HANDLE__)->Instance->CR |= CRC_CR_RESET) 00258 00259 /** 00260 * @brief Set CRC INIT non-default value 00261 * @param __HANDLE__: CRC handle 00262 * @param __INIT__: 32-bit initial value 00263 * @retval None 00264 */ 00265 #define __HAL_CRC_INITIALCRCVALUE_CONFIG(__HANDLE__, __INIT__) ((__HANDLE__)->Instance->INIT = (__INIT__)) 00266 00267 /** 00268 * @brief Store a 8-bit data in the Independent Data(ID) register. 00269 * @param __HANDLE__: CRC handle 00270 * @param __VALUE__: 8-bit value to be stored in the ID register 00271 * @retval None 00272 */ 00273 #define __HAL_CRC_SET_IDR(__HANDLE__, __VALUE__) (WRITE_REG((__HANDLE__)->Instance->IDR, (__VALUE__))) 00274 00275 /** 00276 * @brief Return the 8-bit data stored in the Independent Data(ID) register. 00277 * @param __HANDLE__: CRC handle 00278 * @retval 8-bit value of the ID register 00279 */ 00280 #define __HAL_CRC_GET_IDR(__HANDLE__) (((__HANDLE__)->Instance->IDR) & CRC_IDR_IDR) 00281 /** 00282 * @} 00283 */ 00284 00285 00286 /* Private macros --------------------------------------------------------*/ 00287 /** @addtogroup CRC_Private_Macros CRC Private Macros 00288 * @{ 00289 */ 00290 00291 #define IS_DEFAULT_POLYNOMIAL(DEFAULT) (((DEFAULT) == DEFAULT_POLYNOMIAL_ENABLE) || \ 00292 ((DEFAULT) == DEFAULT_POLYNOMIAL_DISABLE)) 00293 00294 00295 #define IS_DEFAULT_INIT_VALUE(VALUE) (((VALUE) == DEFAULT_INIT_VALUE_ENABLE) || \ 00296 ((VALUE) == DEFAULT_INIT_VALUE_DISABLE)) 00297 00298 #define IS_CRC_POL_LENGTH(LENGTH) (((LENGTH) == CRC_POLYLENGTH_32B) || \ 00299 ((LENGTH) == CRC_POLYLENGTH_16B) || \ 00300 ((LENGTH) == CRC_POLYLENGTH_8B) || \ 00301 ((LENGTH) == CRC_POLYLENGTH_7B)) 00302 00303 #define IS_CRC_INPUTDATA_FORMAT(FORMAT) (((FORMAT) == CRC_INPUTDATA_FORMAT_BYTES) || \ 00304 ((FORMAT) == CRC_INPUTDATA_FORMAT_HALFWORDS) || \ 00305 ((FORMAT) == CRC_INPUTDATA_FORMAT_WORDS)) 00306 00307 /** 00308 * @} 00309 */ 00310 00311 /* Include CRC HAL Extended module */ 00312 #include "stm32l4xx_hal_crc_ex.h" 00313 00314 /* Exported functions --------------------------------------------------------*/ 00315 /** @defgroup CRC_Exported_Functions CRC Exported Functions 00316 * @{ 00317 */ 00318 00319 /* Initialization and de-initialization functions ****************************/ 00320 /** @defgroup CRC_Exported_Functions_Group1 Initialization and de-initialization functions 00321 * @{ 00322 */ 00323 HAL_StatusTypeDef HAL_CRC_Init(CRC_HandleTypeDef *hcrc); 00324 HAL_StatusTypeDef HAL_CRC_DeInit (CRC_HandleTypeDef *hcrc); 00325 void HAL_CRC_MspInit(CRC_HandleTypeDef *hcrc); 00326 void HAL_CRC_MspDeInit(CRC_HandleTypeDef *hcrc); 00327 /** 00328 * @} 00329 */ 00330 00331 /* Peripheral Control functions ***********************************************/ 00332 /** @defgroup CRC_Exported_Functions_Group2 Peripheral Control functions 00333 * @{ 00334 */ 00335 uint32_t HAL_CRC_Accumulate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength); 00336 uint32_t HAL_CRC_Calculate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength); 00337 /** 00338 * @} 00339 */ 00340 00341 /* Peripheral State and Error functions ***************************************/ 00342 /** @defgroup CRC_Exported_Functions_Group3 Peripheral State functions 00343 * @{ 00344 */ 00345 HAL_CRC_StateTypeDef HAL_CRC_GetState(CRC_HandleTypeDef *hcrc); 00346 /** 00347 * @} 00348 */ 00349 00350 /** 00351 * @} 00352 */ 00353 00354 /** 00355 * @} 00356 */ 00357 00358 /** 00359 * @} 00360 */ 00361 00362 #ifdef __cplusplus 00363 } 00364 #endif 00365 00366 #endif /* __STM32L4xx_HAL_CRC_H */ 00367 00368 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 00369
Generated on Tue Jul 12 2022 10:58:09 by 1.7.2