| [1] | 1 | /**
|
|---|
| 2 | ******************************************************************************
|
|---|
| 3 | * @file stm32g0xx_ll_crc.h
|
|---|
| 4 | * @author MCD Application Team
|
|---|
| 5 | * @brief Header file of CRC LL module.
|
|---|
| 6 | ******************************************************************************
|
|---|
| 7 | * @attention
|
|---|
| 8 | *
|
|---|
| 9 | * <h2><center>© Copyright (c) 2018 STMicroelectronics.
|
|---|
| 10 | * All rights reserved.</center></h2>
|
|---|
| 11 | *
|
|---|
| 12 | * This software component is licensed by ST under BSD 3-Clause license,
|
|---|
| 13 | * the "License"; You may not use this file except in compliance with the
|
|---|
| 14 | * License. You may obtain a copy of the License at:
|
|---|
| 15 | * opensource.org/licenses/BSD-3-Clause
|
|---|
| 16 | *
|
|---|
| 17 | ******************************************************************************
|
|---|
| 18 | */
|
|---|
| 19 |
|
|---|
| 20 | /* Define to prevent recursive inclusion -------------------------------------*/
|
|---|
| 21 | #ifndef STM32G0xx_LL_CRC_H
|
|---|
| 22 | #define STM32G0xx_LL_CRC_H
|
|---|
| 23 |
|
|---|
| 24 | #ifdef __cplusplus
|
|---|
| 25 | extern "C" {
|
|---|
| 26 | #endif
|
|---|
| 27 |
|
|---|
| 28 | /* Includes ------------------------------------------------------------------*/
|
|---|
| 29 | #include "stm32g0xx.h"
|
|---|
| 30 |
|
|---|
| 31 | /** @addtogroup STM32G0xx_LL_Driver
|
|---|
| 32 | * @{
|
|---|
| 33 | */
|
|---|
| 34 |
|
|---|
| 35 | #if defined(CRC)
|
|---|
| 36 |
|
|---|
| 37 | /** @defgroup CRC_LL CRC
|
|---|
| 38 | * @{
|
|---|
| 39 | */
|
|---|
| 40 |
|
|---|
| 41 | /* Private types -------------------------------------------------------------*/
|
|---|
| 42 | /* Private variables ---------------------------------------------------------*/
|
|---|
| 43 | /* Private constants ---------------------------------------------------------*/
|
|---|
| 44 | /* Private macros ------------------------------------------------------------*/
|
|---|
| 45 |
|
|---|
| 46 | /* Exported types ------------------------------------------------------------*/
|
|---|
| 47 | /* Exported constants --------------------------------------------------------*/
|
|---|
| 48 | /** @defgroup CRC_LL_Exported_Constants CRC Exported Constants
|
|---|
| 49 | * @{
|
|---|
| 50 | */
|
|---|
| 51 |
|
|---|
| 52 | /** @defgroup CRC_LL_EC_POLYLENGTH Polynomial length
|
|---|
| 53 | * @{
|
|---|
| 54 | */
|
|---|
| 55 | #define LL_CRC_POLYLENGTH_32B 0x00000000U /*!< 32 bits Polynomial size */
|
|---|
| 56 | #define LL_CRC_POLYLENGTH_16B CRC_CR_POLYSIZE_0 /*!< 16 bits Polynomial size */
|
|---|
| 57 | #define LL_CRC_POLYLENGTH_8B CRC_CR_POLYSIZE_1 /*!< 8 bits Polynomial size */
|
|---|
| 58 | #define LL_CRC_POLYLENGTH_7B (CRC_CR_POLYSIZE_1 | CRC_CR_POLYSIZE_0) /*!< 7 bits Polynomial size */
|
|---|
| 59 | /**
|
|---|
| 60 | * @}
|
|---|
| 61 | */
|
|---|
| 62 |
|
|---|
| 63 | /** @defgroup CRC_LL_EC_INDATA_REVERSE Input Data Reverse
|
|---|
| 64 | * @{
|
|---|
| 65 | */
|
|---|
| 66 | #define LL_CRC_INDATA_REVERSE_NONE 0x00000000U /*!< Input Data bit order not affected */
|
|---|
| 67 | #define LL_CRC_INDATA_REVERSE_BYTE CRC_CR_REV_IN_0 /*!< Input Data bit reversal done by byte */
|
|---|
| 68 | #define LL_CRC_INDATA_REVERSE_HALFWORD CRC_CR_REV_IN_1 /*!< Input Data bit reversal done by half-word */
|
|---|
| 69 | #define LL_CRC_INDATA_REVERSE_WORD (CRC_CR_REV_IN_1 | CRC_CR_REV_IN_0) /*!< Input Data bit reversal done by word */
|
|---|
| 70 | /**
|
|---|
| 71 | * @}
|
|---|
| 72 | */
|
|---|
| 73 |
|
|---|
| 74 | /** @defgroup CRC_LL_EC_OUTDATA_REVERSE Output Data Reverse
|
|---|
| 75 | * @{
|
|---|
| 76 | */
|
|---|
| 77 | #define LL_CRC_OUTDATA_REVERSE_NONE 0x00000000U /*!< Output Data bit order not affected */
|
|---|
| 78 | #define LL_CRC_OUTDATA_REVERSE_BIT CRC_CR_REV_OUT /*!< Output Data bit reversal done by bit */
|
|---|
| 79 | /**
|
|---|
| 80 | * @}
|
|---|
| 81 | */
|
|---|
| 82 |
|
|---|
| 83 | /** @defgroup CRC_LL_EC_Default_Polynomial_Value Default CRC generating polynomial value
|
|---|
| 84 | * @brief Normal representation of this polynomial value is
|
|---|
| 85 | * 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 .
|
|---|
| 86 | * @{
|
|---|
| 87 | */
|
|---|
| 88 | #define LL_CRC_DEFAULT_CRC32_POLY 0x04C11DB7U /*!< Default CRC generating polynomial value */
|
|---|
| 89 | /**
|
|---|
| 90 | * @}
|
|---|
| 91 | */
|
|---|
| 92 |
|
|---|
| 93 | /** @defgroup CRC_LL_EC_Default_InitValue Default CRC computation initialization value
|
|---|
| 94 | * @{
|
|---|
| 95 | */
|
|---|
| 96 | #define LL_CRC_DEFAULT_CRC_INITVALUE 0xFFFFFFFFU /*!< Default CRC computation initialization value */
|
|---|
| 97 | /**
|
|---|
| 98 | * @}
|
|---|
| 99 | */
|
|---|
| 100 |
|
|---|
| 101 | /**
|
|---|
| 102 | * @}
|
|---|
| 103 | */
|
|---|
| 104 |
|
|---|
| 105 | /* Exported macro ------------------------------------------------------------*/
|
|---|
| 106 | /** @defgroup CRC_LL_Exported_Macros CRC Exported Macros
|
|---|
| 107 | * @{
|
|---|
| 108 | */
|
|---|
| 109 |
|
|---|
| 110 | /** @defgroup CRC_LL_EM_WRITE_READ Common Write and read registers Macros
|
|---|
| 111 | * @{
|
|---|
| 112 | */
|
|---|
| 113 |
|
|---|
| 114 | /**
|
|---|
| 115 | * @brief Write a value in CRC register
|
|---|
| 116 | * @param __INSTANCE__ CRC Instance
|
|---|
| 117 | * @param __REG__ Register to be written
|
|---|
| 118 | * @param __VALUE__ Value to be written in the register
|
|---|
| 119 | * @retval None
|
|---|
| 120 | */
|
|---|
| 121 | #define LL_CRC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, __VALUE__)
|
|---|
| 122 |
|
|---|
| 123 | /**
|
|---|
| 124 | * @brief Read a value in CRC register
|
|---|
| 125 | * @param __INSTANCE__ CRC Instance
|
|---|
| 126 | * @param __REG__ Register to be read
|
|---|
| 127 | * @retval Register value
|
|---|
| 128 | */
|
|---|
| 129 | #define LL_CRC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
|
|---|
| 130 | /**
|
|---|
| 131 | * @}
|
|---|
| 132 | */
|
|---|
| 133 |
|
|---|
| 134 | /**
|
|---|
| 135 | * @}
|
|---|
| 136 | */
|
|---|
| 137 |
|
|---|
| 138 |
|
|---|
| 139 | /* Exported functions --------------------------------------------------------*/
|
|---|
| 140 | /** @defgroup CRC_LL_Exported_Functions CRC Exported Functions
|
|---|
| 141 | * @{
|
|---|
| 142 | */
|
|---|
| 143 |
|
|---|
| 144 | /** @defgroup CRC_LL_EF_Configuration CRC Configuration functions
|
|---|
| 145 | * @{
|
|---|
| 146 | */
|
|---|
| 147 |
|
|---|
| 148 | /**
|
|---|
| 149 | * @brief Reset the CRC calculation unit.
|
|---|
| 150 | * @note If Programmable Initial CRC value feature
|
|---|
| 151 | * is available, also set the Data Register to the value stored in the
|
|---|
| 152 | * CRC_INIT register, otherwise, reset Data Register to its default value.
|
|---|
| 153 | * @rmtoll CR RESET LL_CRC_ResetCRCCalculationUnit
|
|---|
| 154 | * @param CRCx CRC Instance
|
|---|
| 155 | * @retval None
|
|---|
| 156 | */
|
|---|
| 157 | __STATIC_INLINE void LL_CRC_ResetCRCCalculationUnit(CRC_TypeDef *CRCx)
|
|---|
| 158 | {
|
|---|
| 159 | SET_BIT(CRCx->CR, CRC_CR_RESET);
|
|---|
| 160 | }
|
|---|
| 161 |
|
|---|
| 162 | /**
|
|---|
| 163 | * @brief Configure size of the polynomial.
|
|---|
| 164 | * @rmtoll CR POLYSIZE LL_CRC_SetPolynomialSize
|
|---|
| 165 | * @param CRCx CRC Instance
|
|---|
| 166 | * @param PolySize This parameter can be one of the following values:
|
|---|
| 167 | * @arg @ref LL_CRC_POLYLENGTH_32B
|
|---|
| 168 | * @arg @ref LL_CRC_POLYLENGTH_16B
|
|---|
| 169 | * @arg @ref LL_CRC_POLYLENGTH_8B
|
|---|
| 170 | * @arg @ref LL_CRC_POLYLENGTH_7B
|
|---|
| 171 | * @retval None
|
|---|
| 172 | */
|
|---|
| 173 | __STATIC_INLINE void LL_CRC_SetPolynomialSize(CRC_TypeDef *CRCx, uint32_t PolySize)
|
|---|
| 174 | {
|
|---|
| 175 | MODIFY_REG(CRCx->CR, CRC_CR_POLYSIZE, PolySize);
|
|---|
| 176 | }
|
|---|
| 177 |
|
|---|
| 178 | /**
|
|---|
| 179 | * @brief Return size of the polynomial.
|
|---|
| 180 | * @rmtoll CR POLYSIZE LL_CRC_GetPolynomialSize
|
|---|
| 181 | * @param CRCx CRC Instance
|
|---|
| 182 | * @retval Returned value can be one of the following values:
|
|---|
| 183 | * @arg @ref LL_CRC_POLYLENGTH_32B
|
|---|
| 184 | * @arg @ref LL_CRC_POLYLENGTH_16B
|
|---|
| 185 | * @arg @ref LL_CRC_POLYLENGTH_8B
|
|---|
| 186 | * @arg @ref LL_CRC_POLYLENGTH_7B
|
|---|
| 187 | */
|
|---|
| 188 | __STATIC_INLINE uint32_t LL_CRC_GetPolynomialSize(CRC_TypeDef *CRCx)
|
|---|
| 189 | {
|
|---|
| 190 | return (uint32_t)(READ_BIT(CRCx->CR, CRC_CR_POLYSIZE));
|
|---|
| 191 | }
|
|---|
| 192 |
|
|---|
| 193 | /**
|
|---|
| 194 | * @brief Configure the reversal of the bit order of the input data
|
|---|
| 195 | * @rmtoll CR REV_IN LL_CRC_SetInputDataReverseMode
|
|---|
| 196 | * @param CRCx CRC Instance
|
|---|
| 197 | * @param ReverseMode This parameter can be one of the following values:
|
|---|
| 198 | * @arg @ref LL_CRC_INDATA_REVERSE_NONE
|
|---|
| 199 | * @arg @ref LL_CRC_INDATA_REVERSE_BYTE
|
|---|
| 200 | * @arg @ref LL_CRC_INDATA_REVERSE_HALFWORD
|
|---|
| 201 | * @arg @ref LL_CRC_INDATA_REVERSE_WORD
|
|---|
| 202 | * @retval None
|
|---|
| 203 | */
|
|---|
| 204 | __STATIC_INLINE void LL_CRC_SetInputDataReverseMode(CRC_TypeDef *CRCx, uint32_t ReverseMode)
|
|---|
| 205 | {
|
|---|
| 206 | MODIFY_REG(CRCx->CR, CRC_CR_REV_IN, ReverseMode);
|
|---|
| 207 | }
|
|---|
| 208 |
|
|---|
| 209 | /**
|
|---|
| 210 | * @brief Return type of reversal for input data bit order
|
|---|
| 211 | * @rmtoll CR REV_IN LL_CRC_GetInputDataReverseMode
|
|---|
| 212 | * @param CRCx CRC Instance
|
|---|
| 213 | * @retval Returned value can be one of the following values:
|
|---|
| 214 | * @arg @ref LL_CRC_INDATA_REVERSE_NONE
|
|---|
| 215 | * @arg @ref LL_CRC_INDATA_REVERSE_BYTE
|
|---|
| 216 | * @arg @ref LL_CRC_INDATA_REVERSE_HALFWORD
|
|---|
| 217 | * @arg @ref LL_CRC_INDATA_REVERSE_WORD
|
|---|
| 218 | */
|
|---|
| 219 | __STATIC_INLINE uint32_t LL_CRC_GetInputDataReverseMode(CRC_TypeDef *CRCx)
|
|---|
| 220 | {
|
|---|
| 221 | return (uint32_t)(READ_BIT(CRCx->CR, CRC_CR_REV_IN));
|
|---|
| 222 | }
|
|---|
| 223 |
|
|---|
| 224 | /**
|
|---|
| 225 | * @brief Configure the reversal of the bit order of the Output data
|
|---|
| 226 | * @rmtoll CR REV_OUT LL_CRC_SetOutputDataReverseMode
|
|---|
| 227 | * @param CRCx CRC Instance
|
|---|
| 228 | * @param ReverseMode This parameter can be one of the following values:
|
|---|
| 229 | * @arg @ref LL_CRC_OUTDATA_REVERSE_NONE
|
|---|
| 230 | * @arg @ref LL_CRC_OUTDATA_REVERSE_BIT
|
|---|
| 231 | * @retval None
|
|---|
| 232 | */
|
|---|
| 233 | __STATIC_INLINE void LL_CRC_SetOutputDataReverseMode(CRC_TypeDef *CRCx, uint32_t ReverseMode)
|
|---|
| 234 | {
|
|---|
| 235 | MODIFY_REG(CRCx->CR, CRC_CR_REV_OUT, ReverseMode);
|
|---|
| 236 | }
|
|---|
| 237 |
|
|---|
| 238 | /**
|
|---|
| 239 | * @brief Configure the reversal of the bit order of the Output data
|
|---|
| 240 | * @rmtoll CR REV_OUT LL_CRC_GetOutputDataReverseMode
|
|---|
| 241 | * @param CRCx CRC Instance
|
|---|
| 242 | * @retval Returned value can be one of the following values:
|
|---|
| 243 | * @arg @ref LL_CRC_OUTDATA_REVERSE_NONE
|
|---|
| 244 | * @arg @ref LL_CRC_OUTDATA_REVERSE_BIT
|
|---|
| 245 | */
|
|---|
| 246 | __STATIC_INLINE uint32_t LL_CRC_GetOutputDataReverseMode(CRC_TypeDef *CRCx)
|
|---|
| 247 | {
|
|---|
| 248 | return (uint32_t)(READ_BIT(CRCx->CR, CRC_CR_REV_OUT));
|
|---|
| 249 | }
|
|---|
| 250 |
|
|---|
| 251 | /**
|
|---|
| 252 | * @brief Initialize the Programmable initial CRC value.
|
|---|
| 253 | * @note If the CRC size is less than 32 bits, the least significant bits
|
|---|
| 254 | * are used to write the correct value
|
|---|
| 255 | * @note LL_CRC_DEFAULT_CRC_INITVALUE could be used as value for InitCrc parameter.
|
|---|
| 256 | * @rmtoll INIT INIT LL_CRC_SetInitialData
|
|---|
| 257 | * @param CRCx CRC Instance
|
|---|
| 258 | * @param InitCrc Value to be programmed in Programmable initial CRC value register
|
|---|
| 259 | * @retval None
|
|---|
| 260 | */
|
|---|
| 261 | __STATIC_INLINE void LL_CRC_SetInitialData(CRC_TypeDef *CRCx, uint32_t InitCrc)
|
|---|
| 262 | {
|
|---|
| 263 | WRITE_REG(CRCx->INIT, InitCrc);
|
|---|
| 264 | }
|
|---|
| 265 |
|
|---|
| 266 | /**
|
|---|
| 267 | * @brief Return current Initial CRC value.
|
|---|
| 268 | * @note If the CRC size is less than 32 bits, the least significant bits
|
|---|
| 269 | * are used to read the correct value
|
|---|
| 270 | * @rmtoll INIT INIT LL_CRC_GetInitialData
|
|---|
| 271 | * @param CRCx CRC Instance
|
|---|
| 272 | * @retval Value programmed in Programmable initial CRC value register
|
|---|
| 273 | */
|
|---|
| 274 | __STATIC_INLINE uint32_t LL_CRC_GetInitialData(CRC_TypeDef *CRCx)
|
|---|
| 275 | {
|
|---|
| 276 | return (uint32_t)(READ_REG(CRCx->INIT));
|
|---|
| 277 | }
|
|---|
| 278 |
|
|---|
| 279 | /**
|
|---|
| 280 | * @brief Initialize the Programmable polynomial value
|
|---|
| 281 | * (coefficients of the polynomial to be used for CRC calculation).
|
|---|
| 282 | * @note LL_CRC_DEFAULT_CRC32_POLY could be used as value for PolynomCoef parameter.
|
|---|
| 283 | * @note Please check Reference Manual and existing Errata Sheets,
|
|---|
| 284 | * regarding possible limitations for Polynomial values usage.
|
|---|
| 285 | * For example, for a polynomial of degree 7, X^7 + X^6 + X^5 + X^2 + 1 is written 0x65
|
|---|
| 286 | * @rmtoll POL POL LL_CRC_SetPolynomialCoef
|
|---|
| 287 | * @param CRCx CRC Instance
|
|---|
| 288 | * @param PolynomCoef Value to be programmed in Programmable Polynomial value register
|
|---|
| 289 | * @retval None
|
|---|
| 290 | */
|
|---|
| 291 | __STATIC_INLINE void LL_CRC_SetPolynomialCoef(CRC_TypeDef *CRCx, uint32_t PolynomCoef)
|
|---|
| 292 | {
|
|---|
| 293 | WRITE_REG(CRCx->POL, PolynomCoef);
|
|---|
| 294 | }
|
|---|
| 295 |
|
|---|
| 296 | /**
|
|---|
| 297 | * @brief Return current Programmable polynomial value
|
|---|
| 298 | * @note Please check Reference Manual and existing Errata Sheets,
|
|---|
| 299 | * regarding possible limitations for Polynomial values usage.
|
|---|
| 300 | * For example, for a polynomial of degree 7, X^7 + X^6 + X^5 + X^2 + 1 is written 0x65
|
|---|
| 301 | * @rmtoll POL POL LL_CRC_GetPolynomialCoef
|
|---|
| 302 | * @param CRCx CRC Instance
|
|---|
| 303 | * @retval Value programmed in Programmable Polynomial value register
|
|---|
| 304 | */
|
|---|
| 305 | __STATIC_INLINE uint32_t LL_CRC_GetPolynomialCoef(CRC_TypeDef *CRCx)
|
|---|
| 306 | {
|
|---|
| 307 | return (uint32_t)(READ_REG(CRCx->POL));
|
|---|
| 308 | }
|
|---|
| 309 |
|
|---|
| 310 | /**
|
|---|
| 311 | * @}
|
|---|
| 312 | */
|
|---|
| 313 |
|
|---|
| 314 | /** @defgroup CRC_LL_EF_Data_Management Data_Management
|
|---|
| 315 | * @{
|
|---|
| 316 | */
|
|---|
| 317 |
|
|---|
| 318 | /**
|
|---|
| 319 | * @brief Write given 32-bit data to the CRC calculator
|
|---|
| 320 | * @rmtoll DR DR LL_CRC_FeedData32
|
|---|
| 321 | * @param CRCx CRC Instance
|
|---|
| 322 | * @param InData value to be provided to CRC calculator between between Min_Data=0 and Max_Data=0xFFFFFFFF
|
|---|
| 323 | * @retval None
|
|---|
| 324 | */
|
|---|
| 325 | __STATIC_INLINE void LL_CRC_FeedData32(CRC_TypeDef *CRCx, uint32_t InData)
|
|---|
| 326 | {
|
|---|
| 327 | WRITE_REG(CRCx->DR, InData);
|
|---|
| 328 | }
|
|---|
| 329 |
|
|---|
| 330 | /**
|
|---|
| 331 | * @brief Write given 16-bit data to the CRC calculator
|
|---|
| 332 | * @rmtoll DR DR LL_CRC_FeedData16
|
|---|
| 333 | * @param CRCx CRC Instance
|
|---|
| 334 | * @param InData 16 bit value to be provided to CRC calculator between between Min_Data=0 and Max_Data=0xFFFF
|
|---|
| 335 | * @retval None
|
|---|
| 336 | */
|
|---|
| 337 | __STATIC_INLINE void LL_CRC_FeedData16(CRC_TypeDef *CRCx, uint16_t InData)
|
|---|
| 338 | {
|
|---|
| 339 | __IO uint16_t *pReg;
|
|---|
| 340 |
|
|---|
| 341 | pReg = (__IO uint16_t *)(__IO void *)(&CRCx->DR); /* Derogation MisraC2012 R.11.5 */
|
|---|
| 342 | *pReg = InData;
|
|---|
| 343 | }
|
|---|
| 344 |
|
|---|
| 345 | /**
|
|---|
| 346 | * @brief Write given 8-bit data to the CRC calculator
|
|---|
| 347 | * @rmtoll DR DR LL_CRC_FeedData8
|
|---|
| 348 | * @param CRCx CRC Instance
|
|---|
| 349 | * @param InData 8 bit value to be provided to CRC calculator between between Min_Data=0 and Max_Data=0xFF
|
|---|
| 350 | * @retval None
|
|---|
| 351 | */
|
|---|
| 352 | __STATIC_INLINE void LL_CRC_FeedData8(CRC_TypeDef *CRCx, uint8_t InData)
|
|---|
| 353 | {
|
|---|
| 354 | *(uint8_t __IO *)(&CRCx->DR) = (uint8_t) InData;
|
|---|
| 355 | }
|
|---|
| 356 |
|
|---|
| 357 | /**
|
|---|
| 358 | * @brief Return current CRC calculation result. 32 bits value is returned.
|
|---|
| 359 | * @rmtoll DR DR LL_CRC_ReadData32
|
|---|
| 360 | * @param CRCx CRC Instance
|
|---|
| 361 | * @retval Current CRC calculation result as stored in CRC_DR register (32 bits).
|
|---|
| 362 | */
|
|---|
| 363 | __STATIC_INLINE uint32_t LL_CRC_ReadData32(CRC_TypeDef *CRCx)
|
|---|
| 364 | {
|
|---|
| 365 | return (uint32_t)(READ_REG(CRCx->DR));
|
|---|
| 366 | }
|
|---|
| 367 |
|
|---|
| 368 | /**
|
|---|
| 369 | * @brief Return current CRC calculation result. 16 bits value is returned.
|
|---|
| 370 | * @note This function is expected to be used in a 16 bits CRC polynomial size context.
|
|---|
| 371 | * @rmtoll DR DR LL_CRC_ReadData16
|
|---|
| 372 | * @param CRCx CRC Instance
|
|---|
| 373 | * @retval Current CRC calculation result as stored in CRC_DR register (16 bits).
|
|---|
| 374 | */
|
|---|
| 375 | __STATIC_INLINE uint16_t LL_CRC_ReadData16(CRC_TypeDef *CRCx)
|
|---|
| 376 | {
|
|---|
| 377 | return (uint16_t)READ_REG(CRCx->DR);
|
|---|
| 378 | }
|
|---|
| 379 |
|
|---|
| 380 | /**
|
|---|
| 381 | * @brief Return current CRC calculation result. 8 bits value is returned.
|
|---|
| 382 | * @note This function is expected to be used in a 8 bits CRC polynomial size context.
|
|---|
| 383 | * @rmtoll DR DR LL_CRC_ReadData8
|
|---|
| 384 | * @param CRCx CRC Instance
|
|---|
| 385 | * @retval Current CRC calculation result as stored in CRC_DR register (8 bits).
|
|---|
| 386 | */
|
|---|
| 387 | __STATIC_INLINE uint8_t LL_CRC_ReadData8(CRC_TypeDef *CRCx)
|
|---|
| 388 | {
|
|---|
| 389 | return (uint8_t)READ_REG(CRCx->DR);
|
|---|
| 390 | }
|
|---|
| 391 |
|
|---|
| 392 | /**
|
|---|
| 393 | * @brief Return current CRC calculation result. 7 bits value is returned.
|
|---|
| 394 | * @note This function is expected to be used in a 7 bits CRC polynomial size context.
|
|---|
| 395 | * @rmtoll DR DR LL_CRC_ReadData7
|
|---|
| 396 | * @param CRCx CRC Instance
|
|---|
| 397 | * @retval Current CRC calculation result as stored in CRC_DR register (7 bits).
|
|---|
| 398 | */
|
|---|
| 399 | __STATIC_INLINE uint8_t LL_CRC_ReadData7(CRC_TypeDef *CRCx)
|
|---|
| 400 | {
|
|---|
| 401 | return (uint8_t)(READ_REG(CRCx->DR) & 0x7FU);
|
|---|
| 402 | }
|
|---|
| 403 |
|
|---|
| 404 | /**
|
|---|
| 405 | * @brief Return data stored in the Independent Data(IDR) register.
|
|---|
| 406 | * @note This register can be used as a temporary storage location for one 32-bit long data.
|
|---|
| 407 | * @rmtoll IDR IDR LL_CRC_Read_IDR
|
|---|
| 408 | * @param CRCx CRC Instance
|
|---|
| 409 | * @retval Value stored in CRC_IDR register (General-purpose 32-bit data register).
|
|---|
| 410 | */
|
|---|
| 411 | __STATIC_INLINE uint32_t LL_CRC_Read_IDR(CRC_TypeDef *CRCx)
|
|---|
| 412 | {
|
|---|
| 413 | return (uint32_t)(READ_REG(CRCx->IDR));
|
|---|
| 414 | }
|
|---|
| 415 |
|
|---|
| 416 | /**
|
|---|
| 417 | * @brief Store data in the Independent Data(IDR) register.
|
|---|
| 418 | * @note This register can be used as a temporary storage location for one 32-bit long data.
|
|---|
| 419 | * @rmtoll IDR IDR LL_CRC_Write_IDR
|
|---|
| 420 | * @param CRCx CRC Instance
|
|---|
| 421 | * @param InData value to be stored in CRC_IDR register (32-bit) between Min_Data=0 and Max_Data=0xFFFFFFFF
|
|---|
| 422 | * @retval None
|
|---|
| 423 | */
|
|---|
| 424 | __STATIC_INLINE void LL_CRC_Write_IDR(CRC_TypeDef *CRCx, uint32_t InData)
|
|---|
| 425 | {
|
|---|
| 426 | *((uint32_t __IO *)(&CRCx->IDR)) = (uint32_t) InData;
|
|---|
| 427 | }
|
|---|
| 428 | /**
|
|---|
| 429 | * @}
|
|---|
| 430 | */
|
|---|
| 431 |
|
|---|
| 432 | #if defined(USE_FULL_LL_DRIVER)
|
|---|
| 433 | /** @defgroup CRC_LL_EF_Init Initialization and de-initialization functions
|
|---|
| 434 | * @{
|
|---|
| 435 | */
|
|---|
| 436 |
|
|---|
| 437 | ErrorStatus LL_CRC_DeInit(CRC_TypeDef *CRCx);
|
|---|
| 438 |
|
|---|
| 439 | /**
|
|---|
| 440 | * @}
|
|---|
| 441 | */
|
|---|
| 442 | #endif /* USE_FULL_LL_DRIVER */
|
|---|
| 443 |
|
|---|
| 444 | /**
|
|---|
| 445 | * @}
|
|---|
| 446 | */
|
|---|
| 447 |
|
|---|
| 448 | /**
|
|---|
| 449 | * @}
|
|---|
| 450 | */
|
|---|
| 451 |
|
|---|
| 452 | #endif /* defined(CRC) */
|
|---|
| 453 |
|
|---|
| 454 | /**
|
|---|
| 455 | * @}
|
|---|
| 456 | */
|
|---|
| 457 |
|
|---|
| 458 | #ifdef __cplusplus
|
|---|
| 459 | }
|
|---|
| 460 | #endif
|
|---|
| 461 |
|
|---|
| 462 | #endif /* STM32G0xx_LL_CRC_H */
|
|---|
| 463 |
|
|---|
| 464 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|---|