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