crc32.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /**
  2. * \file crc32.h
  3. * Functions and types for CRC checks.
  4. *
  5. * Generated on Sat Sep 25 18:06:37 2010,
  6. * by pycrc v0.7.1, http://www.tty1.net/pycrc/
  7. * using the configuration:
  8. * Width = 32
  9. * Poly = 0x04c11db7
  10. * XorIn = 0xffffffff
  11. * ReflectIn = True
  12. * XorOut = 0xffffffff
  13. * ReflectOut = True
  14. * Algorithm = table-driven
  15. * Direct = True
  16. *****************************************************************************/
  17. #ifndef __CRC___H__
  18. #define __CRC___H__
  19. #include <arm/NXP/LPC17xx/LPC17xx.h>
  20. #include <stdlib.h>
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /**
  25. * The definition of the used algorithm.
  26. *****************************************************************************/
  27. #define CRC_ALGO_TABLE_DRIVEN 1
  28. /**
  29. * Calculate the initial crc value.
  30. *
  31. * \return The initial crc value.
  32. *****************************************************************************/
  33. static inline uint32_t crc_init( void )
  34. {
  35. return 0xffffffff;
  36. }
  37. /**
  38. * Update the crc value with new data.
  39. *
  40. * \param crc The current crc value.
  41. * \param data Pointer to a buffer of \a data_len bytes.
  42. * \param data_len Number of bytes in the \a data buffer.
  43. * \return The updated crc value.
  44. *****************************************************************************/
  45. uint32_t crc32_update( uint32_t crc, const unsigned char data );
  46. /**
  47. * Calculate the final crc value.
  48. *
  49. * \param crc The current crc value.
  50. * \return The final crc value.
  51. *****************************************************************************/
  52. static inline uint32_t crc32_finalize( uint32_t crc )
  53. {
  54. return crc ^ 0xffffffff;
  55. }
  56. #ifdef __cplusplus
  57. } /* closing brace for extern "C" */
  58. #endif
  59. #endif /* __CRC___H__ */