hk32f0xx_crc.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /**
  2. ******************************************************************************
  3. * @file hk32f0xx_crc.h
  4. * @version V1.0.1
  5. * @date 2019-08-15
  6. *****************************************************************************
  7. */
  8. /* Define to prevent recursive inclusion -------------------------------------*/
  9. #ifndef __HK32F0XX_CRC_H
  10. #define __HK32F0XX_CRC_H
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. /*!< Includes ----------------------------------------------------------------*/
  15. #include "hk32f0xx.h"
  16. /** @addtogroup HK32F0xx_StdPeriph_Driver
  17. * @{
  18. */
  19. /** @addtogroup CRC
  20. * @{
  21. */
  22. /* Exported types ------------------------------------------------------------*/
  23. /* Exported constants --------------------------------------------------------*/
  24. /** @defgroup CRC_ReverseInputData
  25. * @{
  26. */
  27. #define CRC_ReverseInputData_No ((uint32_t)0x00000000) /*!< No reverse operation of Input Data */
  28. #define CRC_ReverseInputData_8bits CRC_CR_REV_IN_0 /*!< Reverse operation of Input Data on 8 bits */
  29. #define CRC_ReverseInputData_16bits CRC_CR_REV_IN_1 /*!< Reverse operation of Input Data on 16 bits */
  30. #define CRC_ReverseInputData_32bits CRC_CR_REV_IN /*!< Reverse operation of Input Data on 32 bits */
  31. #define IS_CRC_REVERSE_INPUT_DATA(DATA) (((DATA) == CRC_ReverseInputData_No) || \
  32. ((DATA) == CRC_ReverseInputData_8bits) || \
  33. ((DATA) == CRC_ReverseInputData_16bits) || \
  34. ((DATA) == CRC_ReverseInputData_32bits))
  35. /**
  36. * @}
  37. */
  38. /** @defgroup CRC_PolynomialSize
  39. * @brief Only applicable for HK32F042 and HK32F072 devices
  40. * @{
  41. */
  42. #define CRC_PolSize_7 CRC_CR_POLSIZE /*!< 7-bit polynomial for CRC calculation */
  43. #define CRC_PolSize_8 CRC_CR_POLSIZE_1 /*!< 8-bit polynomial for CRC calculation */
  44. #define CRC_PolSize_16 CRC_CR_POLSIZE_0 /*!< 16-bit polynomial for CRC calculation */
  45. #define CRC_PolSize_32 ((uint32_t)0x00000000)/*!< 32-bit polynomial for CRC calculation */
  46. #define IS_CRC_POL_SIZE(SIZE) (((SIZE) == CRC_PolSize_7) || \
  47. ((SIZE) == CRC_PolSize_8) || \
  48. ((SIZE) == CRC_PolSize_16) || \
  49. ((SIZE) == CRC_PolSize_32))
  50. /**
  51. * @}
  52. */
  53. /* Exported macro ------------------------------------------------------------*/
  54. /* Exported functions ------------------------------------------------------- */
  55. /* Configuration of the CRC computation unit **********************************/
  56. void CRC_DeInit(void);
  57. void CRC_ResetDR(void);
  58. void CRC_ReverseInputDataSelect(uint32_t CRC_ReverseInputData);
  59. void CRC_ReverseOutputDataCmd(FunctionalState NewState);
  60. void CRC_SetInitRegister(uint32_t CRC_InitValue);
  61. /* CRC computation ************************************************************/
  62. uint32_t CRC_CalcCRC(uint32_t CRC_Data);
  63. uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength);
  64. uint32_t CRC_GetCRC(void);
  65. /* Independent register (IDR) access (write/read) *****************************/
  66. void CRC_SetIDRegister(uint8_t CRC_IDValue);
  67. uint8_t CRC_GetIDRegister(void);
  68. #ifdef __cplusplus
  69. }
  70. #endif
  71. #endif /* __HK32F0XX_CRC_H */