crc16.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /****************************************************************************
  2. * include/crc16.h
  3. *
  4. * Licensed to the Apache Software Foundation (ASF) under one or more
  5. * contributor license agreements. See the NOTICE file distributed with
  6. * this work for additional information regarding copyright ownership. The
  7. * ASF licenses this file to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance with the
  9. * License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  16. * License for the specific language governing permissions and limitations
  17. * under the License.
  18. *
  19. ****************************************************************************/
  20. #ifndef __INCLUDE_CRC16_H
  21. #define __INCLUDE_CRC16_H
  22. /****************************************************************************
  23. * Included Files
  24. ****************************************************************************/
  25. #include <sys/types.h>
  26. #include <stdint.h>
  27. /****************************************************************************
  28. * Public Function Prototypes
  29. ****************************************************************************/
  30. #ifdef __cplusplus
  31. #define EXTERN extern "C"
  32. extern "C"
  33. {
  34. #else
  35. #define EXTERN extern
  36. #endif
  37. /****************************************************************************
  38. * Name: crc16part
  39. *
  40. * Description:
  41. * Continue CRC calculation on a part of the buffer.
  42. *
  43. ****************************************************************************/
  44. uint16_t crc16part(FAR const uint8_t *src, size_t len, uint16_t crc16val);
  45. /****************************************************************************
  46. * Name: crc16
  47. *
  48. * Description:
  49. * Return a 16-bit CRC of the contents of the 'src' buffer, length 'len'
  50. *
  51. ****************************************************************************/
  52. uint16_t crc16(FAR const uint8_t *src, size_t len);
  53. #undef EXTERN
  54. #ifdef __cplusplus
  55. }
  56. #endif
  57. #endif /* __INCLUDE_CRC16_H */