Merge pull request #11198 from SteveCEvans/sce_rc2
[betaflight.git] / lib / main / STM32F1 / Drivers / STM32F10x_StdPeriph_Driver / src / stm32f10x_crc.c
blob65017281205ab8d6bef728b116284d9239d3971f
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
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.
18 * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
19 ******************************************************************************
22 /* Includes ------------------------------------------------------------------*/
23 #include "stm32f10x_crc.h"
25 /** @addtogroup STM32F10x_StdPeriph_Driver
26 * @{
29 /** @defgroup CRC
30 * @brief CRC driver modules
31 * @{
34 /** @defgroup CRC_Private_TypesDefinitions
35 * @{
38 /**
39 * @}
42 /** @defgroup CRC_Private_Defines
43 * @{
46 /**
47 * @}
50 /** @defgroup CRC_Private_Macros
51 * @{
54 /**
55 * @}
58 /** @defgroup CRC_Private_Variables
59 * @{
62 /**
63 * @}
66 /** @defgroup CRC_Private_FunctionPrototypes
67 * @{
70 /**
71 * @}
74 /** @defgroup CRC_Private_Functions
75 * @{
78 /**
79 * @brief Resets the CRC Data register (DR).
80 * @param None
81 * @retval None
83 void CRC_ResetDR(void)
85 /* Reset CRC generator */
86 CRC->CR = CRC_CR_RESET;
89 /**
90 * @brief Computes the 32-bit CRC of a given data word(32-bit).
91 * @param Data: data word(32-bit) to compute its CRC
92 * @retval 32-bit CRC
94 uint32_t CRC_CalcCRC(uint32_t Data)
96 CRC->DR = Data;
98 return (CRC->DR);
102 * @brief Computes the 32-bit CRC of a given buffer of data word(32-bit).
103 * @param pBuffer: pointer to the buffer containing the data to be computed
104 * @param BufferLength: length of the buffer to be computed
105 * @retval 32-bit CRC
107 uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength)
109 uint32_t index = 0;
111 for(index = 0; index < BufferLength; index++)
113 CRC->DR = pBuffer[index];
115 return (CRC->DR);
119 * @brief Returns the current CRC value.
120 * @param None
121 * @retval 32-bit CRC
123 uint32_t CRC_GetCRC(void)
125 return (CRC->DR);
129 * @brief Stores a 8-bit data in the Independent Data(ID) register.
130 * @param IDValue: 8-bit value to be stored in the ID register
131 * @retval None
133 void CRC_SetIDRegister(uint8_t IDValue)
135 CRC->IDR = IDValue;
139 * @brief Returns the 8-bit data stored in the Independent Data(ID) register
140 * @param None
141 * @retval 8-bit value of the ID register
143 uint8_t CRC_GetIDRegister(void)
145 return (CRC->IDR);
149 * @}
153 * @}
157 * @}
160 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/