crc16.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
  2. *
  3. * The information contained herein is property of Nordic Semiconductor ASA.
  4. * Terms and conditions of usage are described in detail in NORDIC
  5. * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
  6. *
  7. * Licensees are granted free, non-transferable use of the information. NO
  8. * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
  9. * the file.
  10. *
  11. */
  12. /** @file
  13. *
  14. * @defgroup crc_compute CRC compute
  15. * @{
  16. * @ingroup hci_transport
  17. *
  18. * @brief This module implements CRC-16-CCITT (polynomial 0x1021) with 0xFFFF initial value.
  19. * The data can be passed in multiple blocks.
  20. */
  21. #ifndef CRC16_H__
  22. #define CRC16_H__
  23. #include <stdint.h>
  24. /**@brief Function for calculating CRC-16 in blocks.
  25. *
  26. * Feed each consecutive data block into this function, along with the current value of p_crc as
  27. * returned by the previous call of this function. The first call of this function should pass NULL
  28. * as the initial value of the crc in p_crc.
  29. *
  30. * @param[in] p_data The input data block for computation.
  31. * @param[in] size The size of the input data block in bytes.
  32. * @param[in] p_crc The previous calculated CRC-16 value or NULL if first call.
  33. *
  34. * @return The updated CRC-16 value, based on the input supplied.
  35. */
  36. uint16_t crc16_compute(uint8_t const * p_data, uint32_t size, uint16_t const * p_crc);
  37. #endif // CRC16_H__
  38. /** @} */