py32f002b_ll_crc.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. /**
  2. ******************************************************************************
  3. * @file py32f002b_ll_crc.h
  4. * @author MCU Application Team
  5. * @brief Header file of CRC LL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2023 Puya Semiconductor Co.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by Puya 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. * @attention
  19. *
  20. * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
  21. * All rights reserved.</center></h2>
  22. *
  23. * This software component is licensed by ST under BSD 3-Clause license,
  24. * the "License"; You may not use this file except in compliance with the
  25. * License. You may obtain a copy of the License at:
  26. * opensource.org/licenses/BSD-3-Clause
  27. *
  28. ******************************************************************************
  29. */
  30. /* Define to prevent recursive inclusion -------------------------------------*/
  31. #ifndef __PY32F002B_LL_CRC_H
  32. #define __PY32F002B_LL_CRC_H
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. /* Includes ------------------------------------------------------------------*/
  37. #include "py32f0xx.h"
  38. /** @addtogroup PY32F002B_LL_Driver
  39. * @{
  40. */
  41. #if defined(CRC)
  42. /** @defgroup CRC_LL CRC
  43. * @{
  44. */
  45. /* Private types -------------------------------------------------------------*/
  46. /* Private variables ---------------------------------------------------------*/
  47. /* Private constants ---------------------------------------------------------*/
  48. /* Private macros ------------------------------------------------------------*/
  49. /* Exported types ------------------------------------------------------------*/
  50. /* Exported constants --------------------------------------------------------*/
  51. /** @defgroup CRC_LL_Exported_Constants CRC Exported Constants
  52. * @{
  53. */
  54. /**
  55. * @}
  56. */
  57. /* Exported macro ------------------------------------------------------------*/
  58. /** @defgroup CRC_LL_Exported_Macros CRC Exported Macros
  59. * @{
  60. */
  61. /** @defgroup CRC_LL_EM_WRITE_READ Common Write and read registers Macros
  62. * @{
  63. */
  64. /**
  65. * @brief Write a value in CRC register
  66. * @param __INSTANCE__ CRC Instance
  67. * @param __REG__ Register to be written
  68. * @param __VALUE__ Value to be written in the register
  69. * @retval None
  70. */
  71. #define LL_CRC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, __VALUE__)
  72. /**
  73. * @brief Read a value in CRC register
  74. * @param __INSTANCE__ CRC Instance
  75. * @param __REG__ Register to be read
  76. * @retval Register value
  77. */
  78. #define LL_CRC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  79. /**
  80. * @}
  81. */
  82. /**
  83. * @}
  84. */
  85. /* Exported functions --------------------------------------------------------*/
  86. /** @defgroup CRC_LL_Exported_Functions CRC Exported Functions
  87. * @{
  88. */
  89. /** @defgroup CRC_LL_EF_Configuration CRC Configuration functions
  90. * @{
  91. */
  92. /**
  93. * @brief Reset the CRC calculation unit.
  94. * @rmtoll CR RESET LL_CRC_ResetCRCCalculationUnit
  95. * @param CRCx CRC Instance
  96. * @retval None
  97. */
  98. __STATIC_INLINE void LL_CRC_ResetCRCCalculationUnit(CRC_TypeDef *CRCx)
  99. {
  100. SET_BIT(CRCx->CR, CRC_CR_RESET);
  101. }
  102. /**
  103. * @}
  104. */
  105. /** @defgroup CRC_LL_EF_Data_Management Data_Management
  106. * @{
  107. */
  108. /**
  109. * @brief Write given 32-bit data to the CRC calculator
  110. * @rmtoll DR DR LL_CRC_FeedData32
  111. * @param CRCx CRC Instance
  112. * @param InData value to be provided to CRC calculator between between Min_Data=0 and Max_Data=0xFFFFFFFF
  113. * @retval None
  114. */
  115. __STATIC_INLINE void LL_CRC_FeedData32(CRC_TypeDef *CRCx, uint32_t InData)
  116. {
  117. WRITE_REG(CRCx->DR, InData);
  118. }
  119. /**
  120. * @brief Return current CRC calculation result. 32 bits value is returned.
  121. * @rmtoll DR DR LL_CRC_ReadData32
  122. * @param CRCx CRC Instance
  123. * @retval Current CRC calculation result as stored in CRC_DR register (32 bits).
  124. */
  125. __STATIC_INLINE uint32_t LL_CRC_ReadData32(CRC_TypeDef *CRCx)
  126. {
  127. return (uint32_t)(READ_REG(CRCx->DR));
  128. }
  129. /**
  130. * @brief Return data stored in the Independent Data(IDR) register.
  131. * @note This register can be used as a temporary storage location for one byte.
  132. * @rmtoll IDR IDR LL_CRC_Read_IDR
  133. * @param CRCx CRC Instance
  134. * @retval Value stored in CRC_IDR register (General-purpose 8-bit data register).
  135. */
  136. __STATIC_INLINE uint32_t LL_CRC_Read_IDR(CRC_TypeDef *CRCx)
  137. {
  138. return (uint32_t)(READ_REG(CRCx->IDR));
  139. }
  140. /**
  141. * @brief Store data in the Independent Data(IDR) register.
  142. * @note This register can be used as a temporary storage location for one byte.
  143. * @rmtoll IDR IDR LL_CRC_Write_IDR
  144. * @param CRCx CRC Instance
  145. * @param InData value to be stored in CRC_IDR register (8-bit) between Min_Data=0 and Max_Data=0xFF
  146. * @retval None
  147. */
  148. __STATIC_INLINE void LL_CRC_Write_IDR(CRC_TypeDef *CRCx, uint32_t InData)
  149. {
  150. *((uint8_t __IO *)(&CRCx->IDR)) = (uint8_t) InData;
  151. }
  152. /**
  153. * @}
  154. */
  155. #if defined(USE_FULL_LL_DRIVER)
  156. /** @defgroup CRC_LL_EF_Init Initialization and de-initialization functions
  157. * @{
  158. */
  159. ErrorStatus LL_CRC_DeInit(CRC_TypeDef *CRCx);
  160. /**
  161. * @}
  162. */
  163. #endif /* USE_FULL_LL_DRIVER */
  164. /**
  165. * @}
  166. */
  167. /**
  168. * @}
  169. */
  170. #endif /* defined(CRC) */
  171. /**
  172. * @}
  173. */
  174. #ifdef __cplusplus
  175. }
  176. #endif
  177. #endif /* PY32F002B_LL_CRC_H */
  178. /************************ (C) COPYRIGHT Puya *****END OF FILE****/