STM32L4xx_HAL_Driver  1.14.0
stm32l4xx_ll_crc.h
Go to the documentation of this file.
1 
20 /* Define to prevent recursive inclusion -------------------------------------*/
21 #ifndef STM32L4xx_LL_CRC_H
22 #define STM32L4xx_LL_CRC_H
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 /* Includes ------------------------------------------------------------------*/
29 #include "stm32l4xx.h"
30 
35 #if defined(CRC)
36 
41 /* Private types -------------------------------------------------------------*/
42 /* Private variables ---------------------------------------------------------*/
43 /* Private constants ---------------------------------------------------------*/
44 /* Private macros ------------------------------------------------------------*/
45 
46 /* Exported types ------------------------------------------------------------*/
47 /* Exported constants --------------------------------------------------------*/
55 #define LL_CRC_POLYLENGTH_32B 0x00000000U
56 #define LL_CRC_POLYLENGTH_16B CRC_CR_POLYSIZE_0
57 #define LL_CRC_POLYLENGTH_8B CRC_CR_POLYSIZE_1
58 #define LL_CRC_POLYLENGTH_7B (CRC_CR_POLYSIZE_1 | CRC_CR_POLYSIZE_0)
66 #define LL_CRC_INDATA_REVERSE_NONE 0x00000000U
67 #define LL_CRC_INDATA_REVERSE_BYTE CRC_CR_REV_IN_0
68 #define LL_CRC_INDATA_REVERSE_HALFWORD CRC_CR_REV_IN_1
69 #define LL_CRC_INDATA_REVERSE_WORD (CRC_CR_REV_IN_1 | CRC_CR_REV_IN_0)
77 #define LL_CRC_OUTDATA_REVERSE_NONE 0x00000000U
78 #define LL_CRC_OUTDATA_REVERSE_BIT CRC_CR_REV_OUT
88 #define LL_CRC_DEFAULT_CRC32_POLY 0x04C11DB7U
96 #define LL_CRC_DEFAULT_CRC_INITVALUE 0xFFFFFFFFU
105 /* Exported macro ------------------------------------------------------------*/
106 
121 #define LL_CRC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, __VALUE__)
122 
129 #define LL_CRC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
130 
139 /* Exported functions --------------------------------------------------------*/
157 __STATIC_INLINE void LL_CRC_ResetCRCCalculationUnit(CRC_TypeDef *CRCx)
158 {
159  SET_BIT(CRCx->CR, CRC_CR_RESET);
160 }
161 
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 
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 
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 
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 
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 
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 
261 __STATIC_INLINE void LL_CRC_SetInitialData(CRC_TypeDef *CRCx, uint32_t InitCrc)
262 {
263  WRITE_REG(CRCx->INIT, InitCrc);
264 }
265 
274 __STATIC_INLINE uint32_t LL_CRC_GetInitialData(CRC_TypeDef *CRCx)
275 {
276  return (uint32_t)(READ_REG(CRCx->INIT));
277 }
278 
291 __STATIC_INLINE void LL_CRC_SetPolynomialCoef(CRC_TypeDef *CRCx, uint32_t PolynomCoef)
292 {
293  WRITE_REG(CRCx->POL, PolynomCoef);
294 }
295 
305 __STATIC_INLINE uint32_t LL_CRC_GetPolynomialCoef(CRC_TypeDef *CRCx)
306 {
307  return (uint32_t)(READ_REG(CRCx->POL));
308 }
309 
325 __STATIC_INLINE void LL_CRC_FeedData32(CRC_TypeDef *CRCx, uint32_t InData)
326 {
327  WRITE_REG(CRCx->DR, InData);
328 }
329 
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 
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 
363 __STATIC_INLINE uint32_t LL_CRC_ReadData32(CRC_TypeDef *CRCx)
364 {
365  return (uint32_t)(READ_REG(CRCx->DR));
366 }
367 
375 __STATIC_INLINE uint16_t LL_CRC_ReadData16(CRC_TypeDef *CRCx)
376 {
377  return (uint16_t)READ_REG(CRCx->DR);
378 }
379 
387 __STATIC_INLINE uint8_t LL_CRC_ReadData8(CRC_TypeDef *CRCx)
388 {
389  return (uint8_t)READ_REG(CRCx->DR);
390 }
391 
399 __STATIC_INLINE uint8_t LL_CRC_ReadData7(CRC_TypeDef *CRCx)
400 {
401  return (uint8_t)(READ_REG(CRCx->DR) & 0x7FU);
402 }
403 
412 __STATIC_INLINE uint32_t LL_CRC_Read_IDR(CRC_TypeDef *CRCx)
413 {
414  return (uint32_t)(READ_REG(CRCx->IDR));
415 }
416 
426 __STATIC_INLINE void LL_CRC_Write_IDR(CRC_TypeDef *CRCx, uint32_t InData)
427 {
428 #if (CRC_IDR_IDR == 0x0FFU)
429  *((uint8_t __IO *)(&CRCx->IDR)) = (uint8_t) InData;
430 #else
431  WRITE_REG(CRCx->IDR, InData);
432 #endif
433 }
438 #if defined(USE_FULL_LL_DRIVER)
439 
443 ErrorStatus LL_CRC_DeInit(CRC_TypeDef *CRCx);
444 
448 #endif /* USE_FULL_LL_DRIVER */
449 
458 #endif /* defined(CRC) */
459 
464 #ifdef __cplusplus
465 }
466 #endif
467 
468 #endif /* STM32L4xx_LL_CRC_H */
469 
470 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
__STATIC_INLINE uint32_t LL_CRC_GetOutputDataReverseMode(CRC_TypeDef *CRCx)
Configure the reversal of the bit order of the Output data CR REV_OUT LL_CRC_GetOutputDataReverseMod...
ErrorStatus LL_CRC_DeInit(CRC_TypeDef *CRCx)
De-initialize CRC registers (Registers restored to their default values).
__STATIC_INLINE uint32_t LL_CRC_ReadData32(CRC_TypeDef *CRCx)
Return current CRC calculation result. 32 bits value is returned. DR DR LL_CRC_ReadData32.
__STATIC_INLINE uint32_t LL_CRC_GetInputDataReverseMode(CRC_TypeDef *CRCx)
Return type of reversal for input data bit order CR REV_IN LL_CRC_GetInputDataReverseMode.
__STATIC_INLINE void LL_CRC_FeedData32(CRC_TypeDef *CRCx, uint32_t InData)
Write given 32-bit data to the CRC calculator DR DR LL_CRC_FeedData32.
__STATIC_INLINE uint8_t LL_CRC_ReadData8(CRC_TypeDef *CRCx)
Return current CRC calculation result. 8 bits value is returned.
__STATIC_INLINE uint16_t LL_CRC_ReadData16(CRC_TypeDef *CRCx)
Return current CRC calculation result. 16 bits value is returned.
__STATIC_INLINE void LL_CRC_ResetCRCCalculationUnit(CRC_TypeDef *CRCx)
Reset the CRC calculation unit.
__STATIC_INLINE uint8_t LL_CRC_ReadData7(CRC_TypeDef *CRCx)
Return current CRC calculation result. 7 bits value is returned.
__STATIC_INLINE uint32_t LL_CRC_GetInitialData(CRC_TypeDef *CRCx)
Return current Initial CRC value.
__STATIC_INLINE void LL_CRC_SetInputDataReverseMode(CRC_TypeDef *CRCx, uint32_t ReverseMode)
Configure the reversal of the bit order of the input data CR REV_IN LL_CRC_SetInputDataReverseMode.
__STATIC_INLINE void LL_CRC_FeedData16(CRC_TypeDef *CRCx, uint16_t InData)
Write given 16-bit data to the CRC calculator DR DR LL_CRC_FeedData16.
__STATIC_INLINE void LL_CRC_SetInitialData(CRC_TypeDef *CRCx, uint32_t InitCrc)
Initialize the Programmable initial CRC value.
__STATIC_INLINE uint32_t LL_CRC_Read_IDR(CRC_TypeDef *CRCx)
Return data stored in the Independent Data(IDR) register.
__STATIC_INLINE void LL_CRC_SetPolynomialSize(CRC_TypeDef *CRCx, uint32_t PolySize)
Configure size of the polynomial. CR POLYSIZE LL_CRC_SetPolynomialSize.
__STATIC_INLINE void LL_CRC_SetOutputDataReverseMode(CRC_TypeDef *CRCx, uint32_t ReverseMode)
Configure the reversal of the bit order of the Output data CR REV_OUT LL_CRC_SetOutputDataReverseMod...
__STATIC_INLINE void LL_CRC_SetPolynomialCoef(CRC_TypeDef *CRCx, uint32_t PolynomCoef)
Initialize the Programmable polynomial value (coefficients of the polynomial to be used for CRC calcu...
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)
__STATIC_INLINE uint32_t LL_CRC_GetPolynomialCoef(CRC_TypeDef *CRCx)
Return current Programmable polynomial value.
__STATIC_INLINE void LL_CRC_FeedData8(CRC_TypeDef *CRCx, uint8_t InData)
Write given 8-bit data to the CRC calculator DR DR LL_CRC_FeedData8.
__STATIC_INLINE uint32_t LL_CRC_GetPolynomialSize(CRC_TypeDef *CRCx)
Return size of the polynomial. CR POLYSIZE LL_CRC_GetPolynomialSize.
__STATIC_INLINE void LL_CRC_Write_IDR(CRC_TypeDef *CRCx, uint32_t InData)
Store data in the Independent Data(IDR) register.