stm32f10x_crc.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /**
  2. ******************************************************************************
  3. * @file stm32f10x_crc.c
  4. * @author MCD Application Team
  5. * @version V3.5.0
  6. * @date 11-March-2011
  7. * @brief This file provides all the CRC firmware functions.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  12. * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
  13. * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
  14. * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
  15. * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
  16. * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  17. *
  18. * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
  19. ******************************************************************************
  20. */
  21. /* Includes ------------------------------------------------------------------*/
  22. #include "stm32f10x_crc.h"
  23. /** @addtogroup STM32F10x_StdPeriph_Driver
  24. * @{
  25. */
  26. /** @defgroup CRC
  27. * @brief CRC driver modules
  28. * @{
  29. */
  30. /** @defgroup CRC_Private_TypesDefinitions
  31. * @{
  32. */
  33. /**
  34. * @}
  35. */
  36. /** @defgroup CRC_Private_Defines
  37. * @{
  38. */
  39. /**
  40. * @}
  41. */
  42. /** @defgroup CRC_Private_Macros
  43. * @{
  44. */
  45. /**
  46. * @}
  47. */
  48. /** @defgroup CRC_Private_Variables
  49. * @{
  50. */
  51. /**
  52. * @}
  53. */
  54. /** @defgroup CRC_Private_FunctionPrototypes
  55. * @{
  56. */
  57. /**
  58. * @}
  59. */
  60. /** @defgroup CRC_Private_Functions
  61. * @{
  62. */
  63. /**
  64. * @brief Resets the CRC Data register (DR).
  65. * @param None
  66. * @retval None
  67. */
  68. void CRC_ResetDR(void)
  69. {
  70. /* Reset CRC generator */
  71. CRC->CR = CRC_CR_RESET;
  72. }
  73. /**
  74. * @brief Computes the 32-bit CRC of a given data word(32-bit).
  75. * @param Data: data word(32-bit) to compute its CRC
  76. * @retval 32-bit CRC
  77. */
  78. uint32_t CRC_CalcCRC(uint32_t Data)
  79. {
  80. CRC->DR = Data;
  81. return (CRC->DR);
  82. }
  83. /**
  84. * @brief Computes the 32-bit CRC of a given buffer of data word(32-bit).
  85. * @param pBuffer: pointer to the buffer containing the data to be computed
  86. * @param BufferLength: length of the buffer to be computed
  87. * @retval 32-bit CRC
  88. */
  89. uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength)
  90. {
  91. uint32_t index = 0;
  92. for(index = 0; index < BufferLength; index++)
  93. {
  94. CRC->DR = pBuffer[index];
  95. }
  96. return (CRC->DR);
  97. }
  98. /**
  99. * @brief Returns the current CRC value.
  100. * @param None
  101. * @retval 32-bit CRC
  102. */
  103. uint32_t CRC_GetCRC(void)
  104. {
  105. return (CRC->DR);
  106. }
  107. /**
  108. * @brief Stores a 8-bit data in the Independent Data(ID) register.
  109. * @param IDValue: 8-bit value to be stored in the ID register
  110. * @retval None
  111. */
  112. void CRC_SetIDRegister(uint8_t IDValue)
  113. {
  114. CRC->IDR = IDValue;
  115. }
  116. /**
  117. * @brief Returns the 8-bit data stored in the Independent Data(ID) register
  118. * @param None
  119. * @retval 8-bit value of the ID register
  120. */
  121. uint8_t CRC_GetIDRegister(void)
  122. {
  123. return (CRC->IDR);
  124. }
  125. /**
  126. * @}
  127. */
  128. /**
  129. * @}
  130. */
  131. /**
  132. * @}
  133. */
  134. /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/