ALGO_CRC_ATY.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /**
  2. * @file ALGO_CRC_ATY.h
  3. *
  4. * @param Project ALGO_Algorithm_ATY_LIB
  5. *
  6. * @author ATY
  7. *
  8. * @copyright
  9. * - Copyright 2017 - 2025 MZ-ATY
  10. * - This code follows:
  11. * - MZ-ATY Various Contents Joint Statement -
  12. * <a href="https://mengze.top/MZ-ATY_VCJS">
  13. * https://mengze.top/MZ-ATY_VCJS</a>
  14. * - CC 4.0 BY-NC-SA -
  15. * <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/">
  16. * https://creativecommons.org/licenses/by-nc-sa/4.0/</a>
  17. * - Your use will be deemed to have accepted the terms of this statement.
  18. *
  19. * @brief Familiar functions of CRC16 Modbus(others to be supplemented) for all codes
  20. *
  21. * @version
  22. * - 1_01_200318 > ATY
  23. * -# Preliminary version, first Release
  24. * - 1_03_200318 > ATY
  25. * -# Add Conditional Compilation
  26. * -# Add user port
  27. * - 1_05_200722 > ATY
  28. * -# Change parameters
  29. **********************************************************************************
  30. */
  31. #ifndef __ALGO_CRC_ATY_H
  32. #define __ALGO_CRC_ATY_H
  33. #include "INCLUDE_ATY.h"
  34. #include "ALGO_AlgorithmBase_ATY.h"
  35. /******************************* For user *************************************/
  36. // #define __DEBUG_ALGO_CRC_ATY
  37. #define __CRC_CALC_ATY //use look-up table or calculate
  38. /******************************************************************************/
  39. uint16_t GenCrc16Modbus(uint8_t* buf, uint8_t size);
  40. uint8_t GenCrc16ModbusHL(uint8_t* buf, uint8_t size, uint8_t highLow);
  41. uint8_t CheckCrc16Modbus(uint8_t* buf, uint8_t size);
  42. #ifdef __DEBUG_ALGO_CRC_ATY
  43. void TestCrc16Modbus(void);
  44. #endif /* __DEBUG_ALGO_CRC_ATY */
  45. // http://api.ip33.com/ss/crc/c?data=12+32&width=16&poly=8005&init=FFFF&xor=0000&refin=true&refout=true
  46. // {
  47. // "code": 0,
  48. // "hex": "C58C",
  49. // "bin": "1100010110001100"
  50. // }
  51. #endif /* __ALGO_CRC_ATY_H */
  52. /******************************** End Of File *********************************/