mbed library sources modified for open wear
Dependents: openwear-lifelogger-example
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_DISCO_F407VG/stm32f4xx_hal_crc.c@133:d4dda5c437f0, 2014-03-24 (annotated)
- Committer:
- mbed_official
- Date:
- Mon Mar 24 17:45:07 2014 +0000
- Revision:
- 133:d4dda5c437f0
- Child:
- 242:7074e42da0b2
Synchronized with git revision 47b961246bed973fe4cb8932781ffc8025b78a61
Full URL: https://github.com/mbedmicro/mbed/commit/47b961246bed973fe4cb8932781ffc8025b78a61/
[STM32F4-Discovery (STM32F407VG)] initial port
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 | 133:d4dda5c437f0 | 5 | * @version V1.0.0 |
mbed_official | 133:d4dda5c437f0 | 6 | * @date 18-February-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 | 133:d4dda5c437f0 | 108 | * @param hcrc: CRC handle |
mbed_official | 133:d4dda5c437f0 | 109 | * @retval HAL status |
mbed_official | 133:d4dda5c437f0 | 110 | */ |
mbed_official | 133:d4dda5c437f0 | 111 | HAL_StatusTypeDef HAL_CRC_Init(CRC_HandleTypeDef *hcrc) |
mbed_official | 133:d4dda5c437f0 | 112 | { |
mbed_official | 133:d4dda5c437f0 | 113 | /* Check the CRC handle allocation */ |
mbed_official | 133:d4dda5c437f0 | 114 | if(hcrc == NULL) |
mbed_official | 133:d4dda5c437f0 | 115 | { |
mbed_official | 133:d4dda5c437f0 | 116 | return HAL_ERROR; |
mbed_official | 133:d4dda5c437f0 | 117 | } |
mbed_official | 133:d4dda5c437f0 | 118 | |
mbed_official | 133:d4dda5c437f0 | 119 | /* Check the parameters */ |
mbed_official | 133:d4dda5c437f0 | 120 | assert_param(IS_CRC_ALL_INSTANCE(hcrc->Instance)); |
mbed_official | 133:d4dda5c437f0 | 121 | |
mbed_official | 133:d4dda5c437f0 | 122 | if(hcrc->State == HAL_CRC_STATE_RESET) |
mbed_official | 133:d4dda5c437f0 | 123 | { |
mbed_official | 133:d4dda5c437f0 | 124 | /* Init the low level hardware */ |
mbed_official | 133:d4dda5c437f0 | 125 | HAL_CRC_MspInit(hcrc); |
mbed_official | 133:d4dda5c437f0 | 126 | } |
mbed_official | 133:d4dda5c437f0 | 127 | |
mbed_official | 133:d4dda5c437f0 | 128 | /* Change CRC peripheral state */ |
mbed_official | 133:d4dda5c437f0 | 129 | hcrc->State = HAL_CRC_STATE_BUSY; |
mbed_official | 133:d4dda5c437f0 | 130 | |
mbed_official | 133:d4dda5c437f0 | 131 | /* Change CRC peripheral state */ |
mbed_official | 133:d4dda5c437f0 | 132 | hcrc->State = HAL_CRC_STATE_READY; |
mbed_official | 133:d4dda5c437f0 | 133 | |
mbed_official | 133:d4dda5c437f0 | 134 | /* Return function status */ |
mbed_official | 133:d4dda5c437f0 | 135 | return HAL_OK; |
mbed_official | 133:d4dda5c437f0 | 136 | } |
mbed_official | 133:d4dda5c437f0 | 137 | |
mbed_official | 133:d4dda5c437f0 | 138 | /** |
mbed_official | 133:d4dda5c437f0 | 139 | * @brief DeInitializes the CRC peripheral. |
mbed_official | 133:d4dda5c437f0 | 140 | * @param hcrc: CRC handle |
mbed_official | 133:d4dda5c437f0 | 141 | * @retval HAL status |
mbed_official | 133:d4dda5c437f0 | 142 | */ |
mbed_official | 133:d4dda5c437f0 | 143 | HAL_StatusTypeDef HAL_CRC_DeInit(CRC_HandleTypeDef *hcrc) |
mbed_official | 133:d4dda5c437f0 | 144 | { |
mbed_official | 133:d4dda5c437f0 | 145 | /* Check the CRC handle allocation */ |
mbed_official | 133:d4dda5c437f0 | 146 | if(hcrc == NULL) |
mbed_official | 133:d4dda5c437f0 | 147 | { |
mbed_official | 133:d4dda5c437f0 | 148 | return HAL_ERROR; |
mbed_official | 133:d4dda5c437f0 | 149 | } |
mbed_official | 133:d4dda5c437f0 | 150 | |
mbed_official | 133:d4dda5c437f0 | 151 | /* Check the parameters */ |
mbed_official | 133:d4dda5c437f0 | 152 | assert_param(IS_CRC_ALL_INSTANCE(hcrc->Instance)); |
mbed_official | 133:d4dda5c437f0 | 153 | |
mbed_official | 133:d4dda5c437f0 | 154 | /* Change CRC peripheral state */ |
mbed_official | 133:d4dda5c437f0 | 155 | hcrc->State = HAL_CRC_STATE_BUSY; |
mbed_official | 133:d4dda5c437f0 | 156 | |
mbed_official | 133:d4dda5c437f0 | 157 | /* DeInit the low level hardware */ |
mbed_official | 133:d4dda5c437f0 | 158 | HAL_CRC_MspDeInit(hcrc); |
mbed_official | 133:d4dda5c437f0 | 159 | |
mbed_official | 133:d4dda5c437f0 | 160 | /* Change CRC peripheral state */ |
mbed_official | 133:d4dda5c437f0 | 161 | hcrc->State = HAL_CRC_STATE_RESET; |
mbed_official | 133:d4dda5c437f0 | 162 | |
mbed_official | 133:d4dda5c437f0 | 163 | /* Release Lock */ |
mbed_official | 133:d4dda5c437f0 | 164 | __HAL_UNLOCK(hcrc); |
mbed_official | 133:d4dda5c437f0 | 165 | |
mbed_official | 133:d4dda5c437f0 | 166 | /* Return function status */ |
mbed_official | 133:d4dda5c437f0 | 167 | return HAL_OK; |
mbed_official | 133:d4dda5c437f0 | 168 | } |
mbed_official | 133:d4dda5c437f0 | 169 | |
mbed_official | 133:d4dda5c437f0 | 170 | /** |
mbed_official | 133:d4dda5c437f0 | 171 | * @brief Initializes the CRC MSP. |
mbed_official | 133:d4dda5c437f0 | 172 | * @param hcrc: CRC handle |
mbed_official | 133:d4dda5c437f0 | 173 | * @retval None |
mbed_official | 133:d4dda5c437f0 | 174 | */ |
mbed_official | 133:d4dda5c437f0 | 175 | __weak void HAL_CRC_MspInit(CRC_HandleTypeDef *hcrc) |
mbed_official | 133:d4dda5c437f0 | 176 | { |
mbed_official | 133:d4dda5c437f0 | 177 | /* NOTE : This function Should not be modified, when the callback is needed, |
mbed_official | 133:d4dda5c437f0 | 178 | the HAL_CRC_MspInit could be implemented in the user file |
mbed_official | 133:d4dda5c437f0 | 179 | */ |
mbed_official | 133:d4dda5c437f0 | 180 | } |
mbed_official | 133:d4dda5c437f0 | 181 | |
mbed_official | 133:d4dda5c437f0 | 182 | /** |
mbed_official | 133:d4dda5c437f0 | 183 | * @brief DeInitializes the CRC MSP. |
mbed_official | 133:d4dda5c437f0 | 184 | * @param hcrc: CRC handle |
mbed_official | 133:d4dda5c437f0 | 185 | * @retval None |
mbed_official | 133:d4dda5c437f0 | 186 | */ |
mbed_official | 133:d4dda5c437f0 | 187 | __weak void HAL_CRC_MspDeInit(CRC_HandleTypeDef *hcrc) |
mbed_official | 133:d4dda5c437f0 | 188 | { |
mbed_official | 133:d4dda5c437f0 | 189 | /* NOTE : This function Should not be modified, when the callback is needed, |
mbed_official | 133:d4dda5c437f0 | 190 | the HAL_CRC_MspDeInit could be implemented in the user file |
mbed_official | 133:d4dda5c437f0 | 191 | */ |
mbed_official | 133:d4dda5c437f0 | 192 | } |
mbed_official | 133:d4dda5c437f0 | 193 | |
mbed_official | 133:d4dda5c437f0 | 194 | /** |
mbed_official | 133:d4dda5c437f0 | 195 | * @} |
mbed_official | 133:d4dda5c437f0 | 196 | */ |
mbed_official | 133:d4dda5c437f0 | 197 | |
mbed_official | 133:d4dda5c437f0 | 198 | /** @defgroup CRC_Group2 Peripheral Control functions |
mbed_official | 133:d4dda5c437f0 | 199 | * @brief management functions. |
mbed_official | 133:d4dda5c437f0 | 200 | * |
mbed_official | 133:d4dda5c437f0 | 201 | @verbatim |
mbed_official | 133:d4dda5c437f0 | 202 | ============================================================================== |
mbed_official | 133:d4dda5c437f0 | 203 | ##### Peripheral Control functions ##### |
mbed_official | 133:d4dda5c437f0 | 204 | ============================================================================== |
mbed_official | 133:d4dda5c437f0 | 205 | [..] This section provides functions allowing to: |
mbed_official | 133:d4dda5c437f0 | 206 | (+) Compute the 32-bit CRC value of 32-bit data buffer, |
mbed_official | 133:d4dda5c437f0 | 207 | using combination of the previous CRC value and the new one. |
mbed_official | 133:d4dda5c437f0 | 208 | (+) Compute the 32-bit CRC value of 32-bit data buffer, |
mbed_official | 133:d4dda5c437f0 | 209 | independently of the previous CRC value. |
mbed_official | 133:d4dda5c437f0 | 210 | |
mbed_official | 133:d4dda5c437f0 | 211 | @endverbatim |
mbed_official | 133:d4dda5c437f0 | 212 | * @{ |
mbed_official | 133:d4dda5c437f0 | 213 | */ |
mbed_official | 133:d4dda5c437f0 | 214 | |
mbed_official | 133:d4dda5c437f0 | 215 | /** |
mbed_official | 133:d4dda5c437f0 | 216 | * @brief Computes the 32-bit CRC of 32-bit data buffer using combination |
mbed_official | 133:d4dda5c437f0 | 217 | * of the previous CRC value and the new one. |
mbed_official | 133:d4dda5c437f0 | 218 | * @param hcrc: CRC handle |
mbed_official | 133:d4dda5c437f0 | 219 | * @param pBuffer: pointer to the buffer containing the data to be computed |
mbed_official | 133:d4dda5c437f0 | 220 | * @param BufferLength: length of the buffer to be computed |
mbed_official | 133:d4dda5c437f0 | 221 | * @retval 32-bit CRC |
mbed_official | 133:d4dda5c437f0 | 222 | */ |
mbed_official | 133:d4dda5c437f0 | 223 | uint32_t HAL_CRC_Accumulate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength) |
mbed_official | 133:d4dda5c437f0 | 224 | { |
mbed_official | 133:d4dda5c437f0 | 225 | uint32_t index = 0; |
mbed_official | 133:d4dda5c437f0 | 226 | |
mbed_official | 133:d4dda5c437f0 | 227 | /* Process Locked */ |
mbed_official | 133:d4dda5c437f0 | 228 | __HAL_LOCK(hcrc); |
mbed_official | 133:d4dda5c437f0 | 229 | |
mbed_official | 133:d4dda5c437f0 | 230 | /* Change CRC peripheral state */ |
mbed_official | 133:d4dda5c437f0 | 231 | hcrc->State = HAL_CRC_STATE_BUSY; |
mbed_official | 133:d4dda5c437f0 | 232 | |
mbed_official | 133:d4dda5c437f0 | 233 | /* Enter Data to the CRC calculator */ |
mbed_official | 133:d4dda5c437f0 | 234 | for(index = 0; index < BufferLength; index++) |
mbed_official | 133:d4dda5c437f0 | 235 | { |
mbed_official | 133:d4dda5c437f0 | 236 | hcrc->Instance->DR = pBuffer[index]; |
mbed_official | 133:d4dda5c437f0 | 237 | } |
mbed_official | 133:d4dda5c437f0 | 238 | |
mbed_official | 133:d4dda5c437f0 | 239 | /* Change CRC peripheral state */ |
mbed_official | 133:d4dda5c437f0 | 240 | hcrc->State = HAL_CRC_STATE_READY; |
mbed_official | 133:d4dda5c437f0 | 241 | |
mbed_official | 133:d4dda5c437f0 | 242 | /* Process Unlocked */ |
mbed_official | 133:d4dda5c437f0 | 243 | __HAL_UNLOCK(hcrc); |
mbed_official | 133:d4dda5c437f0 | 244 | |
mbed_official | 133:d4dda5c437f0 | 245 | /* Return the CRC computed value */ |
mbed_official | 133:d4dda5c437f0 | 246 | return hcrc->Instance->DR; |
mbed_official | 133:d4dda5c437f0 | 247 | } |
mbed_official | 133:d4dda5c437f0 | 248 | |
mbed_official | 133:d4dda5c437f0 | 249 | /** |
mbed_official | 133:d4dda5c437f0 | 250 | * @brief Computes the 32-bit CRC of 32-bit data buffer independently |
mbed_official | 133:d4dda5c437f0 | 251 | * of the previous CRC value. |
mbed_official | 133:d4dda5c437f0 | 252 | * @param hcrc: CRC handle |
mbed_official | 133:d4dda5c437f0 | 253 | * @param pBuffer: Pointer to the buffer containing the data to be computed |
mbed_official | 133:d4dda5c437f0 | 254 | * @param BufferLength: Length of the buffer to be computed |
mbed_official | 133:d4dda5c437f0 | 255 | * @retval 32-bit CRC |
mbed_official | 133:d4dda5c437f0 | 256 | */ |
mbed_official | 133:d4dda5c437f0 | 257 | uint32_t HAL_CRC_Calculate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength) |
mbed_official | 133:d4dda5c437f0 | 258 | { |
mbed_official | 133:d4dda5c437f0 | 259 | uint32_t index = 0; |
mbed_official | 133:d4dda5c437f0 | 260 | |
mbed_official | 133:d4dda5c437f0 | 261 | /* Process Locked */ |
mbed_official | 133:d4dda5c437f0 | 262 | __HAL_LOCK(hcrc); |
mbed_official | 133:d4dda5c437f0 | 263 | |
mbed_official | 133:d4dda5c437f0 | 264 | /* Change CRC peripheral state */ |
mbed_official | 133:d4dda5c437f0 | 265 | hcrc->State = HAL_CRC_STATE_BUSY; |
mbed_official | 133:d4dda5c437f0 | 266 | |
mbed_official | 133:d4dda5c437f0 | 267 | /* Reset CRC Calculation Unit */ |
mbed_official | 133:d4dda5c437f0 | 268 | __HAL_CRC_DR_RESET(hcrc); |
mbed_official | 133:d4dda5c437f0 | 269 | |
mbed_official | 133:d4dda5c437f0 | 270 | /* Enter Data to the CRC calculator */ |
mbed_official | 133:d4dda5c437f0 | 271 | for(index = 0; index < BufferLength; index++) |
mbed_official | 133:d4dda5c437f0 | 272 | { |
mbed_official | 133:d4dda5c437f0 | 273 | hcrc->Instance->DR = pBuffer[index]; |
mbed_official | 133:d4dda5c437f0 | 274 | } |
mbed_official | 133:d4dda5c437f0 | 275 | |
mbed_official | 133:d4dda5c437f0 | 276 | /* Change CRC peripheral state */ |
mbed_official | 133:d4dda5c437f0 | 277 | hcrc->State = HAL_CRC_STATE_READY; |
mbed_official | 133:d4dda5c437f0 | 278 | |
mbed_official | 133:d4dda5c437f0 | 279 | /* Process Unlocked */ |
mbed_official | 133:d4dda5c437f0 | 280 | __HAL_UNLOCK(hcrc); |
mbed_official | 133:d4dda5c437f0 | 281 | |
mbed_official | 133:d4dda5c437f0 | 282 | /* Return the CRC computed value */ |
mbed_official | 133:d4dda5c437f0 | 283 | return hcrc->Instance->DR; |
mbed_official | 133:d4dda5c437f0 | 284 | } |
mbed_official | 133:d4dda5c437f0 | 285 | |
mbed_official | 133:d4dda5c437f0 | 286 | /** |
mbed_official | 133:d4dda5c437f0 | 287 | * @} |
mbed_official | 133:d4dda5c437f0 | 288 | */ |
mbed_official | 133:d4dda5c437f0 | 289 | |
mbed_official | 133:d4dda5c437f0 | 290 | /** @defgroup CRC_Group3 Peripheral State functions |
mbed_official | 133:d4dda5c437f0 | 291 | * @brief Peripheral State functions. |
mbed_official | 133:d4dda5c437f0 | 292 | * |
mbed_official | 133:d4dda5c437f0 | 293 | @verbatim |
mbed_official | 133:d4dda5c437f0 | 294 | ============================================================================== |
mbed_official | 133:d4dda5c437f0 | 295 | ##### Peripheral State functions ##### |
mbed_official | 133:d4dda5c437f0 | 296 | ============================================================================== |
mbed_official | 133:d4dda5c437f0 | 297 | [..] |
mbed_official | 133:d4dda5c437f0 | 298 | This subsection permits to get in run-time the status of the peripheral |
mbed_official | 133:d4dda5c437f0 | 299 | and the data flow. |
mbed_official | 133:d4dda5c437f0 | 300 | |
mbed_official | 133:d4dda5c437f0 | 301 | @endverbatim |
mbed_official | 133:d4dda5c437f0 | 302 | * @{ |
mbed_official | 133:d4dda5c437f0 | 303 | */ |
mbed_official | 133:d4dda5c437f0 | 304 | |
mbed_official | 133:d4dda5c437f0 | 305 | /** |
mbed_official | 133:d4dda5c437f0 | 306 | * @brief Returns the CRC state. |
mbed_official | 133:d4dda5c437f0 | 307 | * @param hcrc: CRC handle |
mbed_official | 133:d4dda5c437f0 | 308 | * @retval HAL state |
mbed_official | 133:d4dda5c437f0 | 309 | */ |
mbed_official | 133:d4dda5c437f0 | 310 | HAL_CRC_StateTypeDef HAL_CRC_GetState(CRC_HandleTypeDef *hcrc) |
mbed_official | 133:d4dda5c437f0 | 311 | { |
mbed_official | 133:d4dda5c437f0 | 312 | return hcrc->State; |
mbed_official | 133:d4dda5c437f0 | 313 | } |
mbed_official | 133:d4dda5c437f0 | 314 | |
mbed_official | 133:d4dda5c437f0 | 315 | /** |
mbed_official | 133:d4dda5c437f0 | 316 | * @} |
mbed_official | 133:d4dda5c437f0 | 317 | */ |
mbed_official | 133:d4dda5c437f0 | 318 | |
mbed_official | 133:d4dda5c437f0 | 319 | /** |
mbed_official | 133:d4dda5c437f0 | 320 | * @} |
mbed_official | 133:d4dda5c437f0 | 321 | */ |
mbed_official | 133:d4dda5c437f0 | 322 | |
mbed_official | 133:d4dda5c437f0 | 323 | #endif /* HAL_CRC_MODULE_ENABLED */ |
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 | */ |
mbed_official | 133:d4dda5c437f0 | 331 | |
mbed_official | 133:d4dda5c437f0 | 332 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |