crc8.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /****************************************************************************
  2. * include/crc8.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_CRC8_H
  21. #define __INCLUDE_CRC8_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: crc8part
  39. *
  40. * Description:
  41. * Continue CRC calculation on a part of the buffer using the polynomial
  42. * x^8+x^6+x^3+x^2+1 (Koopman, et al. "0xA6" poly).
  43. *
  44. ****************************************************************************/
  45. uint8_t crc8part(FAR const uint8_t *src, size_t len, uint8_t crc8val);
  46. /****************************************************************************
  47. * Name: crc8
  48. *
  49. * Description:
  50. * Return an 8-bit CRC of the contents of the 'src' buffer, length 'len'
  51. * using the polynomial x^8+x^6+x^3+x^2+1 (Koopman, et al. "0xA6" poly).
  52. *
  53. ****************************************************************************/
  54. uint8_t crc8(FAR const uint8_t *src, size_t len);
  55. /****************************************************************************
  56. * Name: crc8table
  57. *
  58. * Description:
  59. * Return a 8-bit CRC of the contents of the 'src' buffer, length 'len'
  60. * using a CRC with crc table used for calculation.
  61. *
  62. ****************************************************************************/
  63. uint8_t crc8table(const uint8_t table[256], const uint8_t *src,
  64. size_t len, uint8_t crc8val);
  65. /****************************************************************************
  66. * Name: crc8ccitt
  67. *
  68. * Description:
  69. * Return an 8-bit CRC of the contents of the 'src' buffer, length 'len'
  70. * using the polynomial x^8+x^2+x^1+1 (aka "0x07" poly).
  71. *
  72. ****************************************************************************/
  73. uint8_t crc8ccitt(FAR const uint8_t *src, size_t len);
  74. /****************************************************************************
  75. * Name: crc8part
  76. *
  77. * Description:
  78. * Continue CRC calculation on a part of the buffer using the polynomial
  79. * x^8+x^2+x^1+1 (aka "0x07" poly).
  80. *
  81. ****************************************************************************/
  82. uint8_t crc8ccittpart(FAR const uint8_t *src, size_t len, uint8_t crc8val);
  83. #undef EXTERN
  84. #ifdef __cplusplus
  85. }
  86. #endif
  87. #endif /* __INCLUDE_CRC8_H */