stm32f4xx_ll_crc.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_ll_crc.h
  4. * @author MCD Application Team
  5. * @brief Header file of CRC LL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  10. *
  11. * Redistribution and use in source and binary forms, with or without modification,
  12. * are permitted provided that the following conditions are met:
  13. * 1. Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  19. * may be used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  28. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. ******************************************************************************
  34. */
  35. /* Define to prevent recursive inclusion -------------------------------------*/
  36. #ifndef __STM32F4xx_LL_CRC_H
  37. #define __STM32F4xx_LL_CRC_H
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. /* Includes ------------------------------------------------------------------*/
  42. #include "stm32f4xx.h"
  43. /** @addtogroup STM32F4xx_LL_Driver
  44. * @{
  45. */
  46. #if defined(CRC)
  47. /** @defgroup CRC_LL CRC
  48. * @{
  49. */
  50. /* Private types -------------------------------------------------------------*/
  51. /* Private variables ---------------------------------------------------------*/
  52. /* Private constants ---------------------------------------------------------*/
  53. /* Private macros ------------------------------------------------------------*/
  54. /* Exported types ------------------------------------------------------------*/
  55. /* Exported constants --------------------------------------------------------*/
  56. /* Exported macro ------------------------------------------------------------*/
  57. /** @defgroup CRC_LL_Exported_Macros CRC Exported Macros
  58. * @{
  59. */
  60. /** @defgroup CRC_LL_EM_WRITE_READ Common Write and read registers Macros
  61. * @{
  62. */
  63. /**
  64. * @brief Write a value in CRC register
  65. * @param __INSTANCE__ CRC Instance
  66. * @param __REG__ Register to be written
  67. * @param __VALUE__ Value to be written in the register
  68. * @retval None
  69. */
  70. #define LL_CRC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  71. /**
  72. * @brief Read a value in CRC register
  73. * @param __INSTANCE__ CRC Instance
  74. * @param __REG__ Register to be read
  75. * @retval Register value
  76. */
  77. #define LL_CRC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  78. /**
  79. * @}
  80. */
  81. /**
  82. * @}
  83. */
  84. /* Exported functions --------------------------------------------------------*/
  85. /** @defgroup CRC_LL_Exported_Functions CRC Exported Functions
  86. * @{
  87. */
  88. /** @defgroup CRC_LL_EF_Configuration CRC Configuration functions
  89. * @{
  90. */
  91. /**
  92. * @brief Reset the CRC calculation unit.
  93. * @rmtoll CR RESET LL_CRC_ResetCRCCalculationUnit
  94. * @param CRCx CRC Instance
  95. * @retval None
  96. */
  97. __STATIC_INLINE void LL_CRC_ResetCRCCalculationUnit(CRC_TypeDef *CRCx)
  98. {
  99. WRITE_REG(CRCx->CR, CRC_CR_RESET);
  100. }
  101. /**
  102. * @}
  103. */
  104. /** @defgroup CRC_LL_EF_Data_Management Data_Management
  105. * @{
  106. */
  107. /**
  108. * @brief Write given 32-bit data to the CRC calculator
  109. * @rmtoll DR DR LL_CRC_FeedData32
  110. * @param CRCx CRC Instance
  111. * @param InData value to be provided to CRC calculator between between Min_Data=0 and Max_Data=0xFFFFFFFF
  112. * @retval None
  113. */
  114. __STATIC_INLINE void LL_CRC_FeedData32(CRC_TypeDef *CRCx, uint32_t InData)
  115. {
  116. WRITE_REG(CRCx->DR, InData);
  117. }
  118. /**
  119. * @brief Return current CRC calculation result. 32 bits value is returned.
  120. * @rmtoll DR DR LL_CRC_ReadData32
  121. * @param CRCx CRC Instance
  122. * @retval Current CRC calculation result as stored in CRC_DR register (32 bits).
  123. */
  124. __STATIC_INLINE uint32_t LL_CRC_ReadData32(CRC_TypeDef *CRCx)
  125. {
  126. return (uint32_t)(READ_REG(CRCx->DR));
  127. }
  128. /**
  129. * @brief Return data stored in the Independent Data(IDR) register.
  130. * @note This register can be used as a temporary storage location for one byte.
  131. * @rmtoll IDR IDR LL_CRC_Read_IDR
  132. * @param CRCx CRC Instance
  133. * @retval Value stored in CRC_IDR register (General-purpose 8-bit data register).
  134. */
  135. __STATIC_INLINE uint32_t LL_CRC_Read_IDR(CRC_TypeDef *CRCx)
  136. {
  137. return (uint32_t)(READ_REG(CRCx->IDR));
  138. }
  139. /**
  140. * @brief Store data in the Independent Data(IDR) register.
  141. * @note This register can be used as a temporary storage location for one byte.
  142. * @rmtoll IDR IDR LL_CRC_Write_IDR
  143. * @param CRCx CRC Instance
  144. * @param InData value to be stored in CRC_IDR register (8-bit) between between Min_Data=0 and Max_Data=0xFF
  145. * @retval None
  146. */
  147. __STATIC_INLINE void LL_CRC_Write_IDR(CRC_TypeDef *CRCx, uint32_t InData)
  148. {
  149. *((uint8_t __IO *)(&CRCx->IDR)) = (uint8_t) InData;
  150. }
  151. /**
  152. * @}
  153. */
  154. #if defined(USE_FULL_LL_DRIVER)
  155. /** @defgroup CRC_LL_EF_Init Initialization and de-initialization functions
  156. * @{
  157. */
  158. ErrorStatus LL_CRC_DeInit(CRC_TypeDef *CRCx);
  159. /**
  160. * @}
  161. */
  162. #endif /* USE_FULL_LL_DRIVER */
  163. /**
  164. * @}
  165. */
  166. /**
  167. * @}
  168. */
  169. #endif /* defined(CRC) */
  170. /**
  171. * @}
  172. */
  173. #ifdef __cplusplus
  174. }
  175. #endif
  176. #endif /* __STM32F4xx_LL_CRC_H */
  177. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/