crc.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /******************************************************************************
  2. * Copyright (C) 2021, Xiaohua Semiconductor Co., Ltd. All rights reserved.
  3. *
  4. * This software component is licensed by XHSC under BSD 3-Clause license
  5. * (the "License"); You may not use this file except in compliance with the
  6. * License. You may obtain a copy of the License at:
  7. * opensource.org/licenses/BSD-3-Clause
  8. *
  9. ******************************************************************************/
  10. /******************************************************************************
  11. * @file crc.h
  12. *
  13. * @brief Header file for CRC functions
  14. *
  15. * @author MADS Team
  16. *
  17. ******************************************************************************/
  18. #ifndef __CRC_H__
  19. #define __CRC_H__
  20. /******************************************************************************
  21. * Include files
  22. ******************************************************************************/
  23. #include "sysctrl.h"
  24. /* C binding of definitions if building with C++ compiler */
  25. #ifdef __cplusplus
  26. extern "C"
  27. {
  28. #endif
  29. /**
  30. ******************************************************************************
  31. ** \defgroup CrcGroup Cyclic Redundancy Check (CRC)
  32. **
  33. ******************************************************************************/
  34. //@{
  35. /******************************************************************************
  36. * Global type definitions
  37. ******************************************************************************/
  38. /******************************************************************************
  39. * Global definitions
  40. ******************************************************************************/
  41. /******************************************************************************
  42. * Local type definitions ('typedef')
  43. ******************************************************************************/
  44. /******************************************************************************
  45. * Global variable definitions ('extern')
  46. ******************************************************************************/
  47. /******************************************************************************
  48. * Global function prototypes (definition in C source)
  49. ******************************************************************************/
  50. //CRC16 编码值获取
  51. uint16_t CRC16_Get8(uint8_t* pu8Data, uint32_t u32Len);
  52. uint16_t CRC16_Get16(uint16_t* pu16Data, uint32_t u32Len);
  53. uint16_t CRC16_Get32(uint32_t* pu32Data, uint32_t u32Len);
  54. //CRC16 校验
  55. en_result_t CRC16_Check8(uint8_t* pu8Data, uint32_t u32Len, uint16_t u16CRC);
  56. en_result_t CRC16_Check16(uint16_t* pu16Data, uint32_t u32Len, uint16_t u16CRC);
  57. en_result_t CRC16_Check32(uint32_t* pu32Data, uint32_t u32Len, uint16_t u16CRC);
  58. //CRC32 编码值获取
  59. uint32_t CRC32_Get8(uint8_t* pu8Data, uint32_t u32Len);
  60. uint32_t CRC32_Get16(uint16_t* pu16Data, uint32_t u32Len);
  61. uint32_t CRC32_Get32(uint32_t* pu32Data, uint32_t u32Len);
  62. //CRC32 校验
  63. en_result_t CRC32_Check8(uint8_t* pu8Data, uint32_t u32Len, uint32_t u32CRC);
  64. en_result_t CRC32_Check16(uint16_t* pu16Data, uint32_t u32Len, uint32_t u32CRC);
  65. en_result_t CRC32_Check32(uint32_t* pu32Data, uint32_t u32Len, uint32_t u32CRC);
  66. //@} // CRC Group
  67. #ifdef __cplusplus
  68. }
  69. #endif
  70. #endif /* __CRC_H__ */
  71. /******************************************************************************
  72. * EOF (not truncated)
  73. ******************************************************************************/