crc8_ex.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * crc8_ex.h
  3. *
  4. * Change Logs:
  5. * Date Author Notes
  6. * 2021-03-12 qiyongzhong first version
  7. */
  8. #ifndef __CRC8_EX_H__
  9. #define __CRC8_EX_H__
  10. #include "typedef.h"
  11. #include "crc_cfg.h"
  12. #ifdef CRCLIB_USING_CRC8_EX
  13. #define CRC8_EX_INIT_VAL 0xFF
  14. typedef struct{
  15. u8 table[256];
  16. }crc8_inst_t;
  17. /*
  18. * @brief initialize crc instance
  19. * @param hinst - instance handle
  20. * @param poly - polynomial of crc
  21. * @retval none
  22. */
  23. void crc8_ex_init(crc8_inst_t *hinst, u8 poly);
  24. /*
  25. * @brief cyclic calculation crc check value
  26. * @param hinst - instance handle
  27. * @param init_val - initial value
  28. * @param pdata - datas pointer
  29. * @param len - datas len
  30. * @retval calculated result
  31. */
  32. u8 crc8_ex_cyc_cal(crc8_inst_t *hinst, u8 init_val, u8 *pdata, u32 len);
  33. /*
  34. * @brief calculation crc check value, initial is 0xFFFF
  35. * @param hinst - instance handle
  36. * @param pdata - datas pointer
  37. * @param len - datas len
  38. * @retval calculated result
  39. */
  40. u8 crc8_ex_cal(crc8_inst_t *hinst, u8 *pdata, u32 len);
  41. #endif
  42. #endif