stm32f0xx_crc.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /**
  2. ******************************************************************************
  3. * @file stm32f0xx_crc.h
  4. * @author MCD Application Team
  5. * @version V1.5.0
  6. * @date 05-December-2014
  7. * @brief This file contains all the functions prototypes for the CRC firmware
  8. * library.
  9. ******************************************************************************
  10. * @attention
  11. *
  12. * <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
  13. *
  14. * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  15. * You may not use this file except in compliance with the License.
  16. * You may obtain a copy of the License at:
  17. *
  18. * http://www.st.com/software_license_agreement_liberty_v2
  19. *
  20. * Unless required by applicable law or agreed to in writing, software
  21. * distributed under the License is distributed on an "AS IS" BASIS,
  22. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  23. * See the License for the specific language governing permissions and
  24. * limitations under the License.
  25. *
  26. ******************************************************************************
  27. */
  28. /* Define to prevent recursive inclusion -------------------------------------*/
  29. #ifndef __STM32F0XX_CRC_H
  30. #define __STM32F0XX_CRC_H
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. /*!< Includes ----------------------------------------------------------------*/
  35. #include "stm32f0xx.h"
  36. /** @addtogroup STM32F0xx_StdPeriph_Driver
  37. * @{
  38. */
  39. /** @addtogroup CRC
  40. * @{
  41. */
  42. /* Exported types ------------------------------------------------------------*/
  43. /* Exported constants --------------------------------------------------------*/
  44. /** @defgroup CRC_ReverseInputData
  45. * @{
  46. */
  47. #define CRC_ReverseInputData_No ((uint32_t)0x00000000) /*!< No reverse operation of Input Data */
  48. #define CRC_ReverseInputData_8bits CRC_CR_REV_IN_0 /*!< Reverse operation of Input Data on 8 bits */
  49. #define CRC_ReverseInputData_16bits CRC_CR_REV_IN_1 /*!< Reverse operation of Input Data on 16 bits */
  50. #define CRC_ReverseInputData_32bits CRC_CR_REV_IN /*!< Reverse operation of Input Data on 32 bits */
  51. #define IS_CRC_REVERSE_INPUT_DATA(DATA) (((DATA) == CRC_ReverseInputData_No) || \
  52. ((DATA) == CRC_ReverseInputData_8bits) || \
  53. ((DATA) == CRC_ReverseInputData_16bits) || \
  54. ((DATA) == CRC_ReverseInputData_32bits))
  55. /**
  56. * @}
  57. */
  58. /** @defgroup CRC_PolynomialSize
  59. * @brief Only applicable for STM32F042 and STM32F072 devices
  60. * @{
  61. */
  62. #define CRC_PolSize_7 CRC_CR_POLSIZE /*!< 7-bit polynomial for CRC calculation */
  63. #define CRC_PolSize_8 CRC_CR_POLSIZE_1 /*!< 8-bit polynomial for CRC calculation */
  64. #define CRC_PolSize_16 CRC_CR_POLSIZE_0 /*!< 16-bit polynomial for CRC calculation */
  65. #define CRC_PolSize_32 ((uint32_t)0x00000000)/*!< 32-bit polynomial for CRC calculation */
  66. #define IS_CRC_POL_SIZE(SIZE) (((SIZE) == CRC_PolSize_7) || \
  67. ((SIZE) == CRC_PolSize_8) || \
  68. ((SIZE) == CRC_PolSize_16) || \
  69. ((SIZE) == CRC_PolSize_32))
  70. /**
  71. * @}
  72. */
  73. /* Exported macro ------------------------------------------------------------*/
  74. /* Exported functions ------------------------------------------------------- */
  75. /* Configuration of the CRC computation unit **********************************/
  76. void CRC_DeInit(void);
  77. void CRC_ResetDR(void);
  78. void CRC_PolynomialSizeSelect(uint32_t CRC_PolSize); /*!< Only applicable for STM32F042 and STM32F072 devices */
  79. void CRC_ReverseInputDataSelect(uint32_t CRC_ReverseInputData);
  80. void CRC_ReverseOutputDataCmd(FunctionalState NewState);
  81. void CRC_SetInitRegister(uint32_t CRC_InitValue);
  82. void CRC_SetPolynomial(uint32_t CRC_Pol); /*!< Only applicable for STM32F042 and STM32F072 devices */
  83. /* CRC computation ************************************************************/
  84. uint32_t CRC_CalcCRC(uint32_t CRC_Data);
  85. uint32_t CRC_CalcCRC16bits(uint16_t CRC_Data); /*!< Only applicable for STM32F042 and STM32F072 devices */
  86. uint32_t CRC_CalcCRC8bits(uint8_t CRC_Data); /*!< Only applicable for STM32F042 and STM32F072 devices */
  87. uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength);
  88. uint32_t CRC_GetCRC(void);
  89. /* Independent register (IDR) access (write/read) *****************************/
  90. void CRC_SetIDRegister(uint8_t CRC_IDValue);
  91. uint8_t CRC_GetIDRegister(void);
  92. #ifdef __cplusplus
  93. }
  94. #endif
  95. #endif /* __STM32F0XX_CRC_H */
  96. /**
  97. * @}
  98. */
  99. /**
  100. * @}
  101. */
  102. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/