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