annotate Common/Drivers/STM32F4xx_HAL_DRIVER_v120/Src/stm32f4xx_hal_crc.c @ 101:83feba2ad1c3 kittz

globals
author Dmitry Romanov <kitt@bk.ru>
date Tue, 27 Nov 2018 13:18:59 +0300
parents 5f11787b4f42
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3 * @file stm32f4xx_hal_crc.c
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4 * @author MCD Application Team
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5 * @version V1.2.0
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
6 * @date 26-December-2014
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
7 * @brief CRC HAL module driver.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
8 * This file provides firmware functions to manage the following
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
9 * functionalities of the Cyclic Redundancy Check (CRC) peripheral:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
10 * + Initialization and de-initialization functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
11 * + Peripheral Control functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
12 * + Peripheral State functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
13 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
14 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
15 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
16 ##### How to use this driver #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
17 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
18 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
19 The CRC HAL driver can be used as follows:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
20
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
21 (#) Enable CRC AHB clock using __HAL_RCC_CRC_CLK_ENABLE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
22
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
23 (#) Use HAL_CRC_Accumulate() function to compute the CRC value of
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
24 a 32-bit data buffer using combination of the previous CRC value
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
25 and the new one.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
26
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
27 (#) Use HAL_CRC_Calculate() function to compute the CRC Value of
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
28 a new 32-bit data buffer. This function resets the CRC computation
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
29 unit before starting the computation to avoid getting wrong CRC values.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
30
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
33 * @attention
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
34 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
35 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
36 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37 * Redistribution and use in source and binary forms, with or without modification,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38 * are permitted provided that the following conditions are met:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
39 * 1. Redistributions of source code must retain the above copyright notice,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
40 * this list of conditions and the following disclaimer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
41 * 2. Redistributions in binary form must reproduce the above copyright notice,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
42 * this list of conditions and the following disclaimer in the documentation
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
43 * and/or other materials provided with the distribution.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
44 * 3. Neither the name of STMicroelectronics nor the names of its contributors
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
45 * may be used to endorse or promote products derived from this software
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
46 * without specific prior written permission.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
47 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
48 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
49 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
50 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
51 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
54 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
55 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
56 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
57 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
58 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
59 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
60 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62 /* Includes ------------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
63 #include "stm32f4xx_hal.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
64
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
65 /** @addtogroup STM32F4xx_HAL_Driver
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
66 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69 /** @addtogroup CRC
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
71 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
72
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
73 #ifdef HAL_CRC_MODULE_ENABLED
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
74
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
75 /* Private typedef -----------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76 /* Private define ------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77 /* Private macro -------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78 /* Private variables ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79 /* Private function prototypes -----------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80 /* Private functions ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81 /* Exported functions --------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83 /** @addtogroup CRC_Exported_Functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
84 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
86
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87 /** @addtogroup CRC_Exported_Functions_Group1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88 * @brief Initialization and de-initialization functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92 ##### Initialization and de-initialization functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94 [..] This section provides functions allowing to:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
95 (+) Initialize the CRC according to the specified parameters
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
96 in the CRC_InitTypeDef and create the associated handle
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97 (+) DeInitialize the CRC peripheral
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98 (+) Initialize the CRC MSP
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
99 (+) DeInitialize CRC MSP
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
100
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
101 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
103 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106 * @brief Initializes the CRC according to the specified
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107 * parameters in the CRC_InitTypeDef and creates the associated handle.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108 * @param hcrc: pointer to a CRC_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109 * the configuration information for CRC
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
110 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
111 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
112 HAL_StatusTypeDef HAL_CRC_Init(CRC_HandleTypeDef *hcrc)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
113 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
114 /* Check the CRC handle allocation */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115 if(hcrc == NULL)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
116 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
117 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
118 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
119
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
120 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
121 assert_param(IS_CRC_ALL_INSTANCE(hcrc->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
122
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
123 if(hcrc->State == HAL_CRC_STATE_RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
124 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
125 /* Init the low level hardware */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
126 HAL_CRC_MspInit(hcrc);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
127 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
128
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
129 /* Change CRC peripheral state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
130 hcrc->State = HAL_CRC_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
131
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132 /* Change CRC peripheral state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
133 hcrc->State = HAL_CRC_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
134
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
135 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
136 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
137 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
138
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
139 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140 * @brief DeInitializes the CRC peripheral.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141 * @param hcrc: pointer to a CRC_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142 * the configuration information for CRC
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
144 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145 HAL_StatusTypeDef HAL_CRC_DeInit(CRC_HandleTypeDef *hcrc)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
146 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147 /* Check the CRC handle allocation */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
148 if(hcrc == NULL)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
152
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154 assert_param(IS_CRC_ALL_INSTANCE(hcrc->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156 /* Change CRC peripheral state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
157 hcrc->State = HAL_CRC_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
158
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
159 /* DeInit the low level hardware */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
160 HAL_CRC_MspDeInit(hcrc);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
161
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
162 /* Change CRC peripheral state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
163 hcrc->State = HAL_CRC_STATE_RESET;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
164
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
165 /* Release Lock */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
166 __HAL_UNLOCK(hcrc);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
167
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
168 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
169 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
170 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
171
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
172 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
173 * @brief Initializes the CRC MSP.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
174 * @param hcrc: pointer to a CRC_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
175 * the configuration information for CRC
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
176 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
177 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
178 __weak void HAL_CRC_MspInit(CRC_HandleTypeDef *hcrc)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
179 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
180 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
181 the HAL_CRC_MspInit could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
182 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
183 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
184
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
185 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
186 * @brief DeInitializes the CRC MSP.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
187 * @param hcrc: pointer to a CRC_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
188 * the configuration information for CRC
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
189 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
190 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
191 __weak void HAL_CRC_MspDeInit(CRC_HandleTypeDef *hcrc)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
192 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
193 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
194 the HAL_CRC_MspDeInit could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
195 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
196 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
197
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
198 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
199 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
200 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
201
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
202 /** @addtogroup CRC_Exported_Functions_Group2
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
203 * @brief Peripheral Control functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
204 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
205 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
206 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
207 ##### Peripheral Control functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
208 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
209 [..] This section provides functions allowing to:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
210 (+) Compute the 32-bit CRC value of 32-bit data buffer,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
211 using combination of the previous CRC value and the new one.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
212 (+) Compute the 32-bit CRC value of 32-bit data buffer,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
213 independently of the previous CRC value.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
214
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
215 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
216 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
217 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
218
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
219 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
220 * @brief Computes the 32-bit CRC of 32-bit data buffer using combination
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
221 * of the previous CRC value and the new one.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
222 * @param hcrc: pointer to a CRC_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
223 * the configuration information for CRC
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
224 * @param pBuffer: pointer to the buffer containing the data to be computed
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
225 * @param BufferLength: length of the buffer to be computed
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
226 * @retval 32-bit CRC
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
227 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
228 uint32_t HAL_CRC_Accumulate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
229 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
230 uint32_t index = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
231
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
232 /* Process Locked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
233 __HAL_LOCK(hcrc);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
234
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
235 /* Change CRC peripheral state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
236 hcrc->State = HAL_CRC_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
237
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
238 /* Enter Data to the CRC calculator */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
239 for(index = 0; index < BufferLength; index++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
240 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
241 hcrc->Instance->DR = pBuffer[index];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
242 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
243
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
244 /* Change CRC peripheral state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
245 hcrc->State = HAL_CRC_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
246
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
247 /* Process Unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
248 __HAL_UNLOCK(hcrc);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
249
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
250 /* Return the CRC computed value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
251 return hcrc->Instance->DR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
252 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
253
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
254 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
255 * @brief Computes the 32-bit CRC of 32-bit data buffer independently
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
256 * of the previous CRC value.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
257 * @param hcrc: pointer to a CRC_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
258 * the configuration information for CRC
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
259 * @param pBuffer: Pointer to the buffer containing the data to be computed
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
260 * @param BufferLength: Length of the buffer to be computed
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
261 * @retval 32-bit CRC
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
262 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
263 uint32_t HAL_CRC_Calculate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
264 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
265 uint32_t index = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
266
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
267 /* Process Locked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
268 __HAL_LOCK(hcrc);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
269
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
270 /* Change CRC peripheral state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
271 hcrc->State = HAL_CRC_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
272
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
273 /* Reset CRC Calculation Unit */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
274 __HAL_CRC_DR_RESET(hcrc);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
275
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
276 /* Enter Data to the CRC calculator */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
277 for(index = 0; index < BufferLength; index++)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
278 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
279 hcrc->Instance->DR = pBuffer[index];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
280 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
281
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
282 /* Change CRC peripheral state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
283 hcrc->State = HAL_CRC_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
284
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
285 /* Process Unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
286 __HAL_UNLOCK(hcrc);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
287
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
288 /* Return the CRC computed value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
289 return hcrc->Instance->DR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
290 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
291
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
292 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
293 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
294 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
295
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
296
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
297 /** @addtogroup CRC_Exported_Functions_Group3
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
298 * @brief Peripheral State functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
299 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
300 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
301 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
302 ##### Peripheral State functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
303 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
304 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
305 This subsection permits to get in run-time the status of the peripheral
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
306 and the data flow.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
307
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
308 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
309 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
310 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
311
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
312 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
313 * @brief Returns the CRC state.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
314 * @param hcrc: pointer to a CRC_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
315 * the configuration information for CRC
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
316 * @retval HAL state
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
317 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
318 HAL_CRC_StateTypeDef HAL_CRC_GetState(CRC_HandleTypeDef *hcrc)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
319 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
320 return hcrc->State;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
321 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
322
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
323 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
324 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
325 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
326
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
327 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
328 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
329 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
330
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
331 #endif /* HAL_CRC_MODULE_ENABLED */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
332 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
333 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
334 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
335
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
336 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
337 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
338 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
339
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
340 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/