crc.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. This software is subject to the license described in the License.txt file
  3. included with this software distribution. You may not use this file except
  4. in compliance with this license.
  5. Copyright (c) Dynastream Innovations Inc. 2016
  6. All rights reserved.
  7. */
  8. #if !defined(CRC_H)
  9. #define CRC_H
  10. #include "types.h"
  11. #if defined(__cplusplus)
  12. extern "C" {
  13. #endif
  14. //////////////////////////////////////////////////////////////////////////////////
  15. // Public Function Prototypes
  16. //////////////////////////////////////////////////////////////////////////////////
  17. // The functions below follow the pattern described here, where X is the
  18. // type and x is the bit-width:
  19. //X CRC_Calcx(const void *pvDataPtr_, ULONG ulSize_);
  20. ///////////////////////////////////////////////////////////////////////
  21. // Calculate the CRC of a block of data
  22. // Parameters:
  23. // *pvDataPtr_: Pointer to block of data.
  24. // ulSize_: Length of the block of data.
  25. // Returns the CRC.
  26. ///////////////////////////////////////////////////////////////////////
  27. //X CRC_UpdateCRCx(X uxCRC_, const void *pvDataPtr_, ULONG ulSize_);
  28. ///////////////////////////////////////////////////////////////////////
  29. // Calculate the CRC of a block of data given an initial CRC seed.
  30. // Useful for continuing a CRC calculation from a previous one.
  31. // Parameters:
  32. // uxCRC_: CRC seed.
  33. // *pvDataPtr_: Pointer to block of data.
  34. // ulSize_: Length of the block of data.
  35. // Returns the CRC.
  36. ///////////////////////////////////////////////////////////////////////
  37. //X CRC_Getx(X uxCRC_, UCHAR ucByte_);
  38. ///////////////////////////////////////////////////////////////////////
  39. // Get the CRC for a single byte.
  40. // Parameters:
  41. // uxCRC_: CRC seed.
  42. // ucByte_: Byte on which to calculate the CRC.
  43. // Returns the CRC.
  44. ///////////////////////////////////////////////////////////////////////
  45. UCHAR CRC_Calc8(const void *pvDataPtr_, ULONG ulSize_);
  46. UCHAR CRC_UpdateCRC8(UCHAR ucCRC_, const void *pvDataPtr_, ULONG ulSize_);
  47. UCHAR CRC_Get8(UCHAR ucCRC_, UCHAR ucByte_);
  48. USHORT CRC_Calc16(const void *pvDataPtr_, ULONG ulSize_);
  49. USHORT CRC_UpdateCRC16(USHORT usCRC_, const volatile void *pvDataPtr_, ULONG ulSize_);
  50. USHORT CRC_UpdateCRC16Short(USHORT usCRC_, UCHAR MEM_TYPE *pucDataPtr_, USHORT usSize_);
  51. USHORT CRC_Get16(USHORT usCRC_, UCHAR ucByte_);
  52. ULONG CRC_Calc32(const void *pvDataPtr_, ULONG ulSize_);
  53. ULONG CRC_UpdateCRC32(ULONG ulCRC_, const void *pvDataPtr_, ULONG ulSize_);
  54. ULONG CRC_Get32(UCHAR ucByte);
  55. #if defined(__cplusplus)
  56. }
  57. #endif
  58. #endif // !defined(CRC_H)