rfal_crc.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /******************************************************************************
  2. * \attention
  3. *
  4. * <h2><center>&copy; COPYRIGHT 2020 STMicroelectronics</center></h2>
  5. *
  6. * Licensed under ST MYLIBERTY SOFTWARE LICENSE AGREEMENT (the "License");
  7. * You may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at:
  9. *
  10. * www.st.com/myliberty
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
  15. * AND SPECIFICALLY DISCLAIMING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
  17. * See the License for the specific language governing permissions and
  18. * limitations under the License.
  19. *
  20. ******************************************************************************/
  21. /*
  22. * PROJECT: ST25R391x firmware
  23. * Revision:
  24. * LANGUAGE: ISO C99
  25. */
  26. /*! \file rfal_crc.h
  27. *
  28. * \author Ulrich Herrmann
  29. *
  30. * \brief CRC calculation module
  31. *
  32. */
  33. /*!
  34. *
  35. */
  36. #ifndef RFAL_CRC_H_
  37. #define RFAL_CRC_H_
  38. /*
  39. ******************************************************************************
  40. * INCLUDES
  41. ******************************************************************************
  42. */
  43. #include "../platform.h"
  44. /*
  45. ******************************************************************************
  46. * GLOBAL FUNCTION PROTOTYPES
  47. ******************************************************************************
  48. */
  49. /*!
  50. *****************************************************************************
  51. * \brief Calculate CRC according to CCITT standard.
  52. *
  53. * This function takes \a length bytes from \a buf and calculates the CRC
  54. * for this data. The result is returned.
  55. * \note This implementation calculates the CRC with LSB first, i.e. all
  56. * bytes are "read" from right to left.
  57. *
  58. * \param[in] preloadValue : Initial value of CRC calculation.
  59. * \param[in] buf : buffer to calculate the CRC for.
  60. * \param[in] length : size of the buffer.
  61. *
  62. * \return 16 bit long crc value.
  63. *
  64. *****************************************************************************
  65. */
  66. extern uint16_t rfalCrcCalculateCcitt(uint16_t preloadValue, const uint8_t* buf, uint16_t length);
  67. #endif /* RFAL_CRC_H_ */