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