crc.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /**************************************************************************//**
  2. * @file crc.h
  3. * @version V1.00
  4. * $Revision: 2 $
  5. * $Date: 15/12/01 9:57a $
  6. * @brief NUC472/NUC442 series CRC driver header file
  7. *
  8. * @note
  9. * Copyright (C) 2015 Nuvoton Technology Corp. All rights reserved.
  10. *****************************************************************************/
  11. #ifndef __CRC_H__
  12. #define __CRC_H__
  13. #ifdef __cplusplus
  14. extern "C"
  15. {
  16. #endif
  17. /** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver
  18. @{
  19. */
  20. /** @addtogroup NUC472_442_CRC_Driver CRC Driver
  21. @{
  22. */
  23. /** @addtogroup NUC472_442_CRC_EXPORTED_CONSTANTS CRC Exported Constants
  24. @{
  25. */
  26. /*---------------------------------------------------------------------------------------------------------*/
  27. /* CRC Polynomial Mode Constant Definitions */
  28. /*---------------------------------------------------------------------------------------------------------*/
  29. #define CRC_CCITT 0x00000000UL /*!<CRC Polynomial Mode - CCITT */
  30. #define CRC_8 0x40000000UL /*!<CRC Polynomial Mode - CRC8 */
  31. #define CRC_16 0x80000000UL /*!<CRC Polynomial Mode - CRC16 */
  32. #define CRC_32 0xC0000000UL /*!<CRC Polynomial Mode - CRC32 */
  33. /*---------------------------------------------------------------------------------------------------------*/
  34. /* Checksum, Write data Constant Definitions */
  35. /*---------------------------------------------------------------------------------------------------------*/
  36. #define CRC_CHECKSUM_COM 0x08000000UL /*!<CRC Checksum Complement */
  37. #define CRC_CHECKSUM_RVS 0x02000000UL /*!<CRC Checksum Reverse */
  38. #define CRC_WDATA_COM 0x04000000UL /*!<CRC Write Data Complement */
  39. #define CRC_WDATA_RVS 0x01000000UL /*!<CRC Write Data Reverse */
  40. /*---------------------------------------------------------------------------------------------------------*/
  41. /* CPU Write Data Length Constant Definitions */
  42. /*---------------------------------------------------------------------------------------------------------*/
  43. #define CRC_CPU_WDATA_8 0x00000000UL /*!<CRC CPU Write Data length is 8-bit */
  44. #define CRC_CPU_WDATA_16 0x10000000UL /*!<CRC CPU Write Data length is 16-bit */
  45. #define CRC_CPU_WDATA_32 0x20000000UL /*!<CRC CPU Write Data length is 32-bit */
  46. /*@}*/ /* end of group NUC472_442_CRC_EXPORTED_CONSTANTS */
  47. /** @addtogroup NUC472_442_CRC_EXPORTED_FUNCTIONS CRC Exported Functions
  48. @{
  49. */
  50. /**
  51. * @brief Set CRC Seed Value
  52. *
  53. * @param[in] u32Seed Seed value
  54. *
  55. * @return None
  56. *
  57. * @details This macro is used to set CRC seed value.
  58. *
  59. * @note User must to perform CRC_RST(CRC_CTL[1] CRC Engine Reset) to reload the new seed value
  60. * to CRC controller.
  61. */
  62. #define CRC_SET_SEED(u32Seed) { CRC->SEED = (u32Seed); CRC->CTL |= CRC_CTL_CRCRST_Msk; }
  63. /**
  64. * @brief Get CRC Seed Value
  65. *
  66. * @param None
  67. *
  68. * @return CRC seed value
  69. *
  70. * @details This macro gets the current CRC seed value.
  71. */
  72. #define CRC_GET_SEED() (CRC->SEED)
  73. /**
  74. * @brief CRC Write Data
  75. *
  76. * @param[in] u32Data Write data
  77. *
  78. * @return None
  79. *
  80. * @details User can write data directly to CRC Write Data Register(CRC_DAT) by this macro to perform CRC operation.
  81. */
  82. #define CRC_WRITE_DATA(u32Data) (CRC->DAT = (u32Data))
  83. void CRC_Open(uint32_t u32Mode, uint32_t u32Attribute, uint32_t u32Seed, uint32_t u32DataLen);
  84. uint32_t CRC_GetChecksum(void);
  85. /*@}*/ /* end of group NUC472_442_CRC_EXPORTED_FUNCTIONS */
  86. /*@}*/ /* end of group NUC472_442_CRC_Driver */
  87. /*@}*/ /* end of group NUC472_442_Device_Driver */
  88. #ifdef __cplusplus
  89. }
  90. #endif
  91. #endif //__CRC_H__
  92. /*** (C) COPYRIGHT 2015 Nuvoton Technology Corp. ***/