py32f002b_hal_crc.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /**
  2. ******************************************************************************
  3. * @file py32f002b_hal_crc.h
  4. * @author MCU Application Team
  5. * @brief Header file of CRC HAL 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_HAL_CRC_H
  32. #define __PY32F002B_HAL_CRC_H
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. /* Includes ------------------------------------------------------------------*/
  37. #include "py32f002b_hal_def.h"
  38. /** @addtogroup PY32F002B_HAL_Driver
  39. * @{
  40. */
  41. /** @addtogroup CRC
  42. * @{
  43. */
  44. /* Exported types ------------------------------------------------------------*/
  45. /** @defgroup CRC_Exported_Types CRC Exported Types
  46. * @{
  47. */
  48. /**
  49. * @brief CRC HAL State Structure definition
  50. */
  51. typedef enum
  52. {
  53. HAL_CRC_STATE_RESET = 0x00U, /*!< CRC not yet initialized or disabled */
  54. HAL_CRC_STATE_READY = 0x01U, /*!< CRC initialized and ready for use */
  55. HAL_CRC_STATE_BUSY = 0x02U, /*!< CRC internal process is ongoing */
  56. HAL_CRC_STATE_TIMEOUT = 0x03U, /*!< CRC timeout state */
  57. HAL_CRC_STATE_ERROR = 0x04U /*!< CRC error state */
  58. } HAL_CRC_StateTypeDef;
  59. /**
  60. * @brief CRC Handle Structure definition
  61. */
  62. typedef struct
  63. {
  64. CRC_TypeDef *Instance; /*!< Register base address */
  65. HAL_LockTypeDef Lock; /*!< CRC Locking object */
  66. __IO HAL_CRC_StateTypeDef State; /*!< CRC communication state */
  67. } CRC_HandleTypeDef;
  68. /**
  69. * @}
  70. */
  71. /* Exported macros -----------------------------------------------------------*/
  72. /** @defgroup CRC_Exported_Macros CRC Exported Macros
  73. * @{
  74. */
  75. /** @brief Reset CRC handle state.
  76. * @param __HANDLE__ CRC handle.
  77. * @retval None
  78. */
  79. #define __HAL_CRC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_CRC_STATE_RESET)
  80. /**
  81. * @brief Reset CRC Data Register.
  82. * @param __HANDLE__ CRC handle
  83. * @retval None
  84. */
  85. #define __HAL_CRC_DR_RESET(__HANDLE__) ((__HANDLE__)->Instance->CR |= CRC_CR_RESET)
  86. /**
  87. * @brief Store data in the Independent Data (ID) register.
  88. * @param __HANDLE__ CRC handle
  89. * @param __VALUE__ Value to be stored in the ID register
  90. * @note Refer to the Reference Manual to get the authorized __VALUE__ length in bits
  91. * @retval None
  92. */
  93. #define __HAL_CRC_SET_IDR(__HANDLE__, __VALUE__) (WRITE_REG((__HANDLE__)->Instance->IDR, (__VALUE__)))
  94. /**
  95. * @brief Return the data stored in the Independent Data (ID) register.
  96. * @param __HANDLE__ CRC handle
  97. * @note Refer to the Reference Manual to get the authorized __VALUE__ length in bits
  98. * @retval Value of the ID register
  99. */
  100. #define __HAL_CRC_GET_IDR(__HANDLE__) (((__HANDLE__)->Instance->IDR) & CRC_IDR_IDR)
  101. /**
  102. * @}
  103. */
  104. /* Exported functions --------------------------------------------------------*/
  105. /** @defgroup CRC_Exported_Functions CRC Exported Functions
  106. * @{
  107. */
  108. /* Initialization and de-initialization functions ****************************/
  109. /** @defgroup CRC_Exported_Functions_Group1 Initialization and de-initialization functions
  110. * @{
  111. */
  112. HAL_StatusTypeDef HAL_CRC_Init(CRC_HandleTypeDef *hcrc);
  113. HAL_StatusTypeDef HAL_CRC_DeInit(CRC_HandleTypeDef *hcrc);
  114. void HAL_CRC_MspInit(CRC_HandleTypeDef *hcrc);
  115. void HAL_CRC_MspDeInit(CRC_HandleTypeDef *hcrc);
  116. /**
  117. * @}
  118. */
  119. /* Peripheral Control functions ***********************************************/
  120. /** @defgroup CRC_Exported_Functions_Group2 Peripheral Control functions
  121. * @{
  122. */
  123. uint32_t HAL_CRC_Accumulate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength);
  124. uint32_t HAL_CRC_Calculate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength);
  125. /**
  126. * @}
  127. */
  128. /* Peripheral State and Error functions ***************************************/
  129. /** @defgroup CRC_Exported_Functions_Group3 Peripheral State functions
  130. * @{
  131. */
  132. HAL_CRC_StateTypeDef HAL_CRC_GetState(CRC_HandleTypeDef *hcrc);
  133. /**
  134. * @}
  135. */
  136. /**
  137. * @}
  138. */
  139. /**
  140. * @}
  141. */
  142. /**
  143. * @}
  144. */
  145. #ifdef __cplusplus
  146. }
  147. #endif
  148. #endif /* __PY32F002B_HAL_CRC_H */
  149. /************************ (C) COPYRIGHT Puya *****END OF FILE****/