apm32f0xx_crc.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*!
  2. * @file apm32f0xx_crc.h
  3. *
  4. * @brief This file contains all the functions prototypes for the CRC firmware library
  5. *
  6. * @version V1.0.3
  7. *
  8. * @date 2022-09-20
  9. *
  10. * @attention
  11. *
  12. * Copyright (C) 2020-2022 Geehy Semiconductor
  13. *
  14. * You may not use this file except in compliance with the
  15. * GEEHY COPYRIGHT NOTICE (GEEHY SOFTWARE PACKAGE LICENSE).
  16. *
  17. * The program is only for reference, which is distributed in the hope
  18. * that it will be useful and instructional for customers to develop
  19. * their software. Unless required by applicable law or agreed to in
  20. * writing, the program is distributed on an "AS IS" BASIS, WITHOUT
  21. * ANY WARRANTY OR CONDITIONS OF ANY KIND, either express or implied.
  22. * See the GEEHY SOFTWARE PACKAGE LICENSE for the governing permissions
  23. * and limitations under the License.
  24. */
  25. /* Define to prevent recursive inclusion */
  26. #ifndef __APM32F0XX_CRC_H
  27. #define __APM32F0XX_CRC_H
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. /* Includes */
  32. #include "apm32f0xx.h"
  33. /** @addtogroup APM32F0xx_StdPeriphDriver
  34. @{
  35. */
  36. /** @addtogroup CRC_Driver
  37. @{
  38. */
  39. /** @defgroup CRC_Macros Macros
  40. @{
  41. */
  42. /**@} end of group CRC_Macros */
  43. /** @defgroup CRC_Enumerations Enumerations
  44. @{
  45. */
  46. /**
  47. * @brief CRC Reverse Input Data
  48. */
  49. typedef enum
  50. {
  51. CRC_REVERSE_INPUT_DATA_NO = ((uint8_t)0x00), /*!< Bit order not affected */
  52. CRC_REVERSE_INPUT_DATA_8B = ((uint8_t)0x01), /*!< Bit reversal done by byte */
  53. CRC_REVERSE_INPUT_DATA_16B = ((uint8_t)0x02), /*!< Bit reversal done by half-word */
  54. CRC_REVERSE_INPUT_DATA_32B = ((uint8_t)0x03), /*!< Bit reversal done by word */
  55. } CRC_REVERSE_INPUT_DATA_T;
  56. /**
  57. * @brief CRC Polynomial Size
  58. */
  59. typedef enum
  60. {
  61. CRC_POLYNOMIAL_SIZE_7 = ((uint8_t)0x03), /*!< 7-bit polynomial for CRC calculation */
  62. CRC_POLYNOMIAL_SIZE_8 = ((uint8_t)0x02), /*!< 8-bit polynomial for CRC calculation */
  63. CRC_POLYNOMIAL_SIZE_16 = ((uint8_t)0x01), /*!< 16-bit polynomial for CRC calculation */
  64. CRC_POLYNOMIAL_SIZE_32 = ((uint8_t)0x00), /*!< 32-bit polynomial for CRC calculation */
  65. } CRC_POLYNOMIAL_SIZE_T;
  66. /**@} end of group CRC_Enumerations*/
  67. /** @defgroup CRC_Structures Structures
  68. @{
  69. */
  70. /**@} end of group CRC_Structures */
  71. /** @defgroup CRC_Variables Variables
  72. @{
  73. */
  74. /**@} end of group CRC_Variables */
  75. /** @defgroup CRC_Functions Functions
  76. @{
  77. */
  78. /* Reset CRC */
  79. void CRC_Reset(void);
  80. /* Reset DATA */
  81. void CRC_ResetDATA(void);
  82. /* CRC Polynomial Size */
  83. void CRC_SetPolynomialSize(CRC_POLYNOMIAL_SIZE_T polynomialSize); /*!< Only for APM32F072 and APM32F091 devices */
  84. void CRC_SetPolynomialValue(uint32_t polynomialValue); /*!< Only for APM32F072 and APM32F091 devices */
  85. /* Performed on input data */
  86. void CRC_SelectReverseInputData(CRC_REVERSE_INPUT_DATA_T revInData);
  87. /* Enable and Disable Reverse Output Data */
  88. void CRC_EnableReverseOutputData(void);
  89. void CRC_DisableReverseOutputData(void);
  90. /* Write INITVAL register */
  91. void CRC_WriteInitRegister(uint32_t initValue);
  92. /* Calculate CRC */
  93. uint32_t CRC_CalculateCRC(uint32_t data);
  94. uint32_t CRC_CalculateCRC8bits(uint8_t data); /*!< Only for APM32F072 and APM32F091 devices */
  95. uint32_t CRC_CalculateCRC16bits(uint16_t data); /*!< Only for APM32F072 and APM32F091 devices */
  96. uint32_t CRC_CalculateBlockCRC(uint32_t pBuffer[], uint32_t bufferLength);
  97. /* Read CRC */
  98. uint32_t CRC_ReadCRC(void);
  99. /* Independent Data(ID) */
  100. void CRC_WriteIDRegister(uint8_t IDValue);
  101. uint8_t CRC_ReadIDRegister(void);
  102. #ifdef __cplusplus
  103. }
  104. #endif
  105. #endif /* __APM32F0XX_CRC_H */
  106. /**@} end of group CRC_Functions */
  107. /**@} end of group CRC_Driver */
  108. /**@} end of group APM32F0xx_StdPeriphDriver */