hc32_ll_crc.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /**
  2. *******************************************************************************
  3. * @file hc32_ll_crc.h
  4. * @brief This file contains all the functions prototypes of the CRC driver
  5. * library.
  6. @verbatim
  7. Change Logs:
  8. Date Author Notes
  9. 2022-12-31 CDT First version
  10. @endverbatim
  11. *******************************************************************************
  12. * Copyright (C) 2022, Xiaohua Semiconductor Co., Ltd. All rights reserved.
  13. *
  14. * This software component is licensed by XHSC under BSD 3-Clause license
  15. * (the "License"); You may not use this file except in compliance with the
  16. * License. You may obtain a copy of the License at:
  17. * opensource.org/licenses/BSD-3-Clause
  18. *
  19. *******************************************************************************
  20. */
  21. #ifndef __HC32_LL_CRC_H__
  22. #define __HC32_LL_CRC_H__
  23. /* C binding of definitions if building with C++ compiler */
  24. #ifdef __cplusplus
  25. extern "C"
  26. {
  27. #endif
  28. /*******************************************************************************
  29. * Include files
  30. ******************************************************************************/
  31. #include "hc32_ll_def.h"
  32. #include "hc32f4xx.h"
  33. #include "hc32f4xx_conf.h"
  34. /**
  35. * @addtogroup LL_Driver
  36. * @{
  37. */
  38. /**
  39. * @addtogroup LL_CRC
  40. * @{
  41. */
  42. #if (LL_CRC_ENABLE == DDL_ON)
  43. /*******************************************************************************
  44. * Global type definitions ('typedef')
  45. ******************************************************************************/
  46. /**
  47. * @defgroup CRC_Global_Types CRC Global Types
  48. * @{
  49. */
  50. /**
  51. * @brief CRC initialization structure definition
  52. */
  53. typedef struct {
  54. uint32_t u32Protocol; /*!< Specifies CRC Protocol.
  55. This parameter can be a value of @ref CRC_Protocol_Control_Bit */
  56. uint32_t u32InitValue; /*!< Specifies initial CRC value and value upper 16 bit is ignored when using CRC16.
  57. This parameter can be a value of @ref CRC_Initial_Value */
  58. } stc_crc_init_t;
  59. /**
  60. * @}
  61. */
  62. /*******************************************************************************
  63. * Global pre-processor symbols/macros ('#define')
  64. ******************************************************************************/
  65. /**
  66. * @defgroup CRC_Global_Macros CRC Global Macros
  67. * @{
  68. */
  69. /**
  70. * @defgroup CRC_Protocol_Control_Bit CRC Protocol Control Bit
  71. * @note: - CRC16 polynomial is X^16 + X^12 + X^5 + 1
  72. * - CRC32 polynomial is X^32 + X^26 + X^23 + X^22 + X^16 + X^12 + X^11 + \
  73. * X^10 + X^8 + X^7 + X^5 + X^4 + X^2 + X + 1
  74. * @{
  75. */
  76. #define CRC_CRC16 (0x0UL)
  77. #define CRC_CRC32 (CRC_CR_CR)
  78. /**
  79. * @}
  80. */
  81. /**
  82. * @defgroup CRC_Initial_Value CRC Initial Value
  83. * @{
  84. */
  85. #define CRC16_INIT_VALUE (0xFFFFUL)
  86. #define CRC32_INIT_VALUE (0xFFFFFFFFUL)
  87. /**
  88. * @}
  89. */
  90. /**
  91. * @}
  92. */
  93. /*******************************************************************************
  94. * Global variable definitions ('extern')
  95. ******************************************************************************/
  96. /*******************************************************************************
  97. Global function prototypes (definition in C source)
  98. ******************************************************************************/
  99. /**
  100. * @addtogroup CRC_Global_Functions
  101. * @{
  102. */
  103. int32_t CRC_StructInit(stc_crc_init_t *pstcCrcInit);
  104. int32_t CRC_Init(const stc_crc_init_t *pstcCrcInit);
  105. void CRC_DeInit(void);
  106. en_flag_status_t CRC_GetResultStatus(void);
  107. uint32_t CRC_AccumulateData8(const uint8_t au8Data[], uint32_t u32Len);
  108. uint32_t CRC_AccumulateData16(const uint16_t au16Data[], uint32_t u32Len);
  109. uint32_t CRC_AccumulateData32(const uint32_t au32Data[], uint32_t u32Len);
  110. uint32_t CRC_CalculateData8(uint32_t u32InitValue, const uint8_t au8Data[], uint32_t u32Len);
  111. uint32_t CRC_CalculateData16(uint32_t u32InitValue, const uint16_t au16Data[], uint32_t u32Len);
  112. uint32_t CRC_CalculateData32(uint32_t u32InitValue, const uint32_t au32Data[], uint32_t u32Len);
  113. en_flag_status_t CRC_CheckData8(uint32_t u32InitValue, const uint8_t au8Data[],
  114. uint32_t u32Len, uint32_t u32ExpectValue);
  115. en_flag_status_t CRC_CheckData16(uint32_t u32InitValue, const uint16_t au16Data[],
  116. uint32_t u32Len, uint32_t u32ExpectValue);
  117. en_flag_status_t CRC_CheckData32(uint32_t u32InitValue, const uint32_t au32Data[],
  118. uint32_t u32Len, uint32_t u32ExpectValue);
  119. /**
  120. * @}
  121. */
  122. #endif /* LL_CRC_ENABLE */
  123. /**
  124. * @}
  125. */
  126. /**
  127. * @}
  128. */
  129. #ifdef __cplusplus
  130. }
  131. #endif
  132. #endif /* __HC32_LL_CRC_H__ */
  133. /*******************************************************************************
  134. * EOF (not truncated)
  135. ******************************************************************************/