ft32f0xx_crc.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /**
  2. ******************************************************************************
  3. * @file ft32f0xx_crc.h
  4. * @author FMD AE
  5. * @brief This file contains all the functions prototypes for the CRC firmware
  6. * library.
  7. * @version V1.0.0
  8. * @data 2021-07-01
  9. ******************************************************************************
  10. */
  11. /* Define to prevent recursive inclusion -------------------------------------*/
  12. #ifndef __FT32F0XX_CRC_H
  13. #define __FT32F0XX_CRC_H
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. /*!< Includes ----------------------------------------------------------------*/
  18. #include "ft32f0xx.h"
  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 FT32F042 and FT32F072 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_PolynomialSizeSelect(uint32_t CRC_PolSize); /*!< Only applicable for FT32F042 and FT32F072 devices */
  59. void CRC_ReverseInputDataSelect(uint32_t CRC_ReverseInputData);
  60. void CRC_ReverseOutputDataCmd(FunctionalState NewState);
  61. void CRC_SetInitRegister(uint32_t CRC_InitValue);
  62. void CRC_SetPolynomial(uint32_t CRC_Pol);
  63. /* CRC computation ************************************************************/
  64. uint32_t CRC_CalcCRC(uint32_t CRC_Data);
  65. uint32_t CRC_CalcCRC16bits(uint16_t CRC_Data);
  66. uint32_t CRC_CalcCRC8bits(uint8_t CRC_Data);
  67. uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength);
  68. uint32_t CRC_GetCRC(void);
  69. /* Independent register (IDR) access (write/read) *****************************/
  70. void CRC_SetIDRegister(uint8_t CRC_IDValue);
  71. uint8_t CRC_GetIDRegister(void);
  72. #ifdef __cplusplus
  73. }
  74. #endif
  75. #endif /* __FT32F0XX_CRC_H */
  76. /**
  77. * @}
  78. */
  79. /**
  80. * @}
  81. */
  82. /************************ (C) COPYRIGHT FMD *****END OF FILE****/