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