stm32f1xx_ll_crc.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. /**
  2. ******************************************************************************
  3. * @file stm32f1xx_ll_crc.h
  4. * @author MCD Application Team
  5. * @brief Header file of CRC LL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2016 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file
  13. * in the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. *
  16. ******************************************************************************
  17. */
  18. /* Define to prevent recursive inclusion -------------------------------------*/
  19. #ifndef STM32F1xx_LL_CRC_H
  20. #define STM32F1xx_LL_CRC_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32f1xx.h"
  26. /** @addtogroup STM32F1xx_LL_Driver
  27. * @{
  28. */
  29. #if defined(CRC)
  30. /** @defgroup CRC_LL CRC
  31. * @{
  32. */
  33. /* Private types -------------------------------------------------------------*/
  34. /* Private variables ---------------------------------------------------------*/
  35. /* Private constants ---------------------------------------------------------*/
  36. /* Private macros ------------------------------------------------------------*/
  37. /* Exported types ------------------------------------------------------------*/
  38. /* Exported constants --------------------------------------------------------*/
  39. /** @defgroup CRC_LL_Exported_Constants CRC Exported Constants
  40. * @{
  41. */
  42. /**
  43. * @}
  44. */
  45. /* Exported macro ------------------------------------------------------------*/
  46. /** @defgroup CRC_LL_Exported_Macros CRC Exported Macros
  47. * @{
  48. */
  49. /** @defgroup CRC_LL_EM_WRITE_READ Common Write and read registers Macros
  50. * @{
  51. */
  52. /**
  53. * @brief Write a value in CRC register
  54. * @param __INSTANCE__ CRC Instance
  55. * @param __REG__ Register to be written
  56. * @param __VALUE__ Value to be written in the register
  57. * @retval None
  58. */
  59. #define LL_CRC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, __VALUE__)
  60. /**
  61. * @brief Read a value in CRC register
  62. * @param __INSTANCE__ CRC Instance
  63. * @param __REG__ Register to be read
  64. * @retval Register value
  65. */
  66. #define LL_CRC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  67. /**
  68. * @}
  69. */
  70. /**
  71. * @}
  72. */
  73. /* Exported functions --------------------------------------------------------*/
  74. /** @defgroup CRC_LL_Exported_Functions CRC Exported Functions
  75. * @{
  76. */
  77. /** @defgroup CRC_LL_EF_Configuration CRC Configuration functions
  78. * @{
  79. */
  80. /**
  81. * @brief Reset the CRC calculation unit.
  82. * @note If Programmable Initial CRC value feature
  83. * is available, also set the Data Register to the value stored in the
  84. * CRC_INIT register, otherwise, reset Data Register to its default value.
  85. * @rmtoll CR RESET LL_CRC_ResetCRCCalculationUnit
  86. * @param CRCx CRC Instance
  87. * @retval None
  88. */
  89. __STATIC_INLINE void LL_CRC_ResetCRCCalculationUnit(CRC_TypeDef *CRCx)
  90. {
  91. SET_BIT(CRCx->CR, CRC_CR_RESET);
  92. }
  93. /**
  94. * @}
  95. */
  96. /** @defgroup CRC_LL_EF_Data_Management Data_Management
  97. * @{
  98. */
  99. /**
  100. * @brief Write given 32-bit data to the CRC calculator
  101. * @rmtoll DR DR LL_CRC_FeedData32
  102. * @param CRCx CRC Instance
  103. * @param InData value to be provided to CRC calculator between between Min_Data=0 and Max_Data=0xFFFFFFFF
  104. * @retval None
  105. */
  106. __STATIC_INLINE void LL_CRC_FeedData32(CRC_TypeDef *CRCx, uint32_t InData)
  107. {
  108. WRITE_REG(CRCx->DR, InData);
  109. }
  110. /**
  111. * @brief Return current CRC calculation result. 32 bits value is returned.
  112. * @rmtoll DR DR LL_CRC_ReadData32
  113. * @param CRCx CRC Instance
  114. * @retval Current CRC calculation result as stored in CRC_DR register (32 bits).
  115. */
  116. __STATIC_INLINE uint32_t LL_CRC_ReadData32(const CRC_TypeDef *CRCx)
  117. {
  118. return (uint32_t)(READ_REG(CRCx->DR));
  119. }
  120. /**
  121. * @brief Return data stored in the Independent Data(IDR) register.
  122. * @note This register can be used as a temporary storage location for one byte.
  123. * @rmtoll IDR IDR LL_CRC_Read_IDR
  124. * @param CRCx CRC Instance
  125. * @retval Value stored in CRC_IDR register (General-purpose 8-bit data register).
  126. */
  127. __STATIC_INLINE uint32_t LL_CRC_Read_IDR(CRC_TypeDef *CRCx)
  128. {
  129. return (uint32_t)(READ_REG(CRCx->IDR));
  130. }
  131. /**
  132. * @brief Store data in the Independent Data(IDR) register.
  133. * @note This register can be used as a temporary storage location for one byte.
  134. * @rmtoll IDR IDR LL_CRC_Write_IDR
  135. * @param CRCx CRC Instance
  136. * @param InData value to be stored in CRC_IDR register (8-bit) between Min_Data=0 and Max_Data=0xFF
  137. * @retval None
  138. */
  139. __STATIC_INLINE void LL_CRC_Write_IDR(CRC_TypeDef *CRCx, uint32_t InData)
  140. {
  141. *((uint8_t __IO *)(&CRCx->IDR)) = (uint8_t) InData;
  142. }
  143. /**
  144. * @}
  145. */
  146. #if defined(USE_FULL_LL_DRIVER)
  147. /** @defgroup CRC_LL_EF_Init Initialization and de-initialization functions
  148. * @{
  149. */
  150. ErrorStatus LL_CRC_DeInit(CRC_TypeDef *CRCx);
  151. /**
  152. * @}
  153. */
  154. #endif /* USE_FULL_LL_DRIVER */
  155. /**
  156. * @}
  157. */
  158. /**
  159. * @}
  160. */
  161. #endif /* defined(CRC) */
  162. /**
  163. * @}
  164. */
  165. #ifdef __cplusplus
  166. }
  167. #endif
  168. #endif /* STM32F1xx_LL_CRC_H */