mbed library sources
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_NUCLEO_F030R8/stm32f0xx_crc.c@76:aeb1df146756, 2014-01-27 (annotated)
- Committer:
- mbed_official
- Date:
- Mon Jan 27 14:30:07 2014 +0000
- Revision:
- 76:aeb1df146756
- Child:
- 106:ced8cbb51063
Synchronized with git revision a31ec9c5f7bcb5c8a1b2eced103f6a1dfa921abd
Full URL: https://github.com/mbedmicro/mbed/commit/a31ec9c5f7bcb5c8a1b2eced103f6a1dfa921abd/
Add NUCLEO_L152RE
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 76:aeb1df146756 | 1 | /** |
mbed_official | 76:aeb1df146756 | 2 | ****************************************************************************** |
mbed_official | 76:aeb1df146756 | 3 | * @file stm32f0xx_crc.c |
mbed_official | 76:aeb1df146756 | 4 | * @author MCD Application Team |
mbed_official | 76:aeb1df146756 | 5 | * @version V1.3.0 |
mbed_official | 76:aeb1df146756 | 6 | * @date 16-January-2014 |
mbed_official | 76:aeb1df146756 | 7 | * @brief This file provides firmware functions to manage the following |
mbed_official | 76:aeb1df146756 | 8 | * functionalities of CRC computation unit peripheral: |
mbed_official | 76:aeb1df146756 | 9 | * + Configuration of the CRC computation unit |
mbed_official | 76:aeb1df146756 | 10 | * + CRC computation of one/many 32-bit data |
mbed_official | 76:aeb1df146756 | 11 | * + CRC Independent register (IDR) access |
mbed_official | 76:aeb1df146756 | 12 | * |
mbed_official | 76:aeb1df146756 | 13 | * @verbatim |
mbed_official | 76:aeb1df146756 | 14 | =============================================================================== |
mbed_official | 76:aeb1df146756 | 15 | ##### How to use this driver ##### |
mbed_official | 76:aeb1df146756 | 16 | =============================================================================== |
mbed_official | 76:aeb1df146756 | 17 | [..] |
mbed_official | 76:aeb1df146756 | 18 | |
mbed_official | 76:aeb1df146756 | 19 | (+) Enable CRC AHB clock using RCC_AHBPeriphClockCmd(RCC_AHBPeriph_CRC, ENABLE) |
mbed_official | 76:aeb1df146756 | 20 | function |
mbed_official | 76:aeb1df146756 | 21 | (+) If required, select the reverse operation on input data |
mbed_official | 76:aeb1df146756 | 22 | using CRC_ReverseInputDataSelect() |
mbed_official | 76:aeb1df146756 | 23 | (+) If required, enable the reverse operation on output data |
mbed_official | 76:aeb1df146756 | 24 | using CRC_ReverseOutputDataCmd(Enable) |
mbed_official | 76:aeb1df146756 | 25 | (+) use CRC_CalcCRC() function to compute the CRC of a 32-bit data |
mbed_official | 76:aeb1df146756 | 26 | or use CRC_CalcBlockCRC() function to compute the CRC if a 32-bit |
mbed_official | 76:aeb1df146756 | 27 | data buffer |
mbed_official | 76:aeb1df146756 | 28 | (@) To compute the CRC of a new data use CRC_ResetDR() to reset |
mbed_official | 76:aeb1df146756 | 29 | the CRC computation unit before starting the computation |
mbed_official | 76:aeb1df146756 | 30 | otherwise you can get wrong CRC values. |
mbed_official | 76:aeb1df146756 | 31 | |
mbed_official | 76:aeb1df146756 | 32 | @endverbatim |
mbed_official | 76:aeb1df146756 | 33 | * |
mbed_official | 76:aeb1df146756 | 34 | ****************************************************************************** |
mbed_official | 76:aeb1df146756 | 35 | * @attention |
mbed_official | 76:aeb1df146756 | 36 | * |
mbed_official | 76:aeb1df146756 | 37 | * <h2><center>© COPYRIGHT 2014 STMicroelectronics</center></h2> |
mbed_official | 76:aeb1df146756 | 38 | * |
mbed_official | 76:aeb1df146756 | 39 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); |
mbed_official | 76:aeb1df146756 | 40 | * You may not use this file except in compliance with the License. |
mbed_official | 76:aeb1df146756 | 41 | * You may obtain a copy of the License at: |
mbed_official | 76:aeb1df146756 | 42 | * |
mbed_official | 76:aeb1df146756 | 43 | * http://www.st.com/software_license_agreement_liberty_v2 |
mbed_official | 76:aeb1df146756 | 44 | * |
mbed_official | 76:aeb1df146756 | 45 | * Unless required by applicable law or agreed to in writing, software |
mbed_official | 76:aeb1df146756 | 46 | * distributed under the License is distributed on an "AS IS" BASIS, |
mbed_official | 76:aeb1df146756 | 47 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
mbed_official | 76:aeb1df146756 | 48 | * See the License for the specific language governing permissions and |
mbed_official | 76:aeb1df146756 | 49 | * limitations under the License. |
mbed_official | 76:aeb1df146756 | 50 | * |
mbed_official | 76:aeb1df146756 | 51 | ****************************************************************************** |
mbed_official | 76:aeb1df146756 | 52 | */ |
mbed_official | 76:aeb1df146756 | 53 | |
mbed_official | 76:aeb1df146756 | 54 | /* Includes ------------------------------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 55 | #include "stm32f0xx_crc.h" |
mbed_official | 76:aeb1df146756 | 56 | |
mbed_official | 76:aeb1df146756 | 57 | /** @addtogroup STM32F0xx_StdPeriph_Driver |
mbed_official | 76:aeb1df146756 | 58 | * @{ |
mbed_official | 76:aeb1df146756 | 59 | */ |
mbed_official | 76:aeb1df146756 | 60 | |
mbed_official | 76:aeb1df146756 | 61 | /** @defgroup CRC |
mbed_official | 76:aeb1df146756 | 62 | * @brief CRC driver modules |
mbed_official | 76:aeb1df146756 | 63 | * @{ |
mbed_official | 76:aeb1df146756 | 64 | */ |
mbed_official | 76:aeb1df146756 | 65 | |
mbed_official | 76:aeb1df146756 | 66 | /* Private typedef -----------------------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 67 | /* Private define ------------------------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 68 | /* Private macro -------------------------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 69 | /* Private variables ---------------------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 70 | /* Private function prototypes -----------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 71 | /* Private functions ---------------------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 72 | |
mbed_official | 76:aeb1df146756 | 73 | /** @defgroup CRC_Private_Functions |
mbed_official | 76:aeb1df146756 | 74 | * @{ |
mbed_official | 76:aeb1df146756 | 75 | */ |
mbed_official | 76:aeb1df146756 | 76 | |
mbed_official | 76:aeb1df146756 | 77 | /** @defgroup CRC_Group1 Configuration of the CRC computation unit functions |
mbed_official | 76:aeb1df146756 | 78 | * @brief Configuration of the CRC computation unit functions |
mbed_official | 76:aeb1df146756 | 79 | * |
mbed_official | 76:aeb1df146756 | 80 | @verbatim |
mbed_official | 76:aeb1df146756 | 81 | =============================================================================== |
mbed_official | 76:aeb1df146756 | 82 | ##### CRC configuration functions ##### |
mbed_official | 76:aeb1df146756 | 83 | =============================================================================== |
mbed_official | 76:aeb1df146756 | 84 | |
mbed_official | 76:aeb1df146756 | 85 | @endverbatim |
mbed_official | 76:aeb1df146756 | 86 | * @{ |
mbed_official | 76:aeb1df146756 | 87 | */ |
mbed_official | 76:aeb1df146756 | 88 | |
mbed_official | 76:aeb1df146756 | 89 | /** |
mbed_official | 76:aeb1df146756 | 90 | * @brief Deinitializes CRC peripheral registers to their default reset values. |
mbed_official | 76:aeb1df146756 | 91 | * @param None |
mbed_official | 76:aeb1df146756 | 92 | * @retval None |
mbed_official | 76:aeb1df146756 | 93 | */ |
mbed_official | 76:aeb1df146756 | 94 | void CRC_DeInit(void) |
mbed_official | 76:aeb1df146756 | 95 | { |
mbed_official | 76:aeb1df146756 | 96 | /* Set DR register to reset value */ |
mbed_official | 76:aeb1df146756 | 97 | CRC->DR = 0xFFFFFFFF; |
mbed_official | 76:aeb1df146756 | 98 | |
mbed_official | 76:aeb1df146756 | 99 | /* Set the POL register to the reset value: 0x04C11DB7 */ |
mbed_official | 76:aeb1df146756 | 100 | CRC->POL = 0x04C11DB7; |
mbed_official | 76:aeb1df146756 | 101 | |
mbed_official | 76:aeb1df146756 | 102 | /* Reset IDR register */ |
mbed_official | 76:aeb1df146756 | 103 | CRC->IDR = 0x00; |
mbed_official | 76:aeb1df146756 | 104 | |
mbed_official | 76:aeb1df146756 | 105 | /* Set INIT register to reset value */ |
mbed_official | 76:aeb1df146756 | 106 | CRC->INIT = 0xFFFFFFFF; |
mbed_official | 76:aeb1df146756 | 107 | |
mbed_official | 76:aeb1df146756 | 108 | /* Reset the CRC calculation unit */ |
mbed_official | 76:aeb1df146756 | 109 | CRC->CR = CRC_CR_RESET; |
mbed_official | 76:aeb1df146756 | 110 | } |
mbed_official | 76:aeb1df146756 | 111 | |
mbed_official | 76:aeb1df146756 | 112 | /** |
mbed_official | 76:aeb1df146756 | 113 | * @brief Resets the CRC calculation unit and sets INIT register content in DR register. |
mbed_official | 76:aeb1df146756 | 114 | * @param None |
mbed_official | 76:aeb1df146756 | 115 | * @retval None |
mbed_official | 76:aeb1df146756 | 116 | */ |
mbed_official | 76:aeb1df146756 | 117 | void CRC_ResetDR(void) |
mbed_official | 76:aeb1df146756 | 118 | { |
mbed_official | 76:aeb1df146756 | 119 | /* Reset CRC generator */ |
mbed_official | 76:aeb1df146756 | 120 | CRC->CR |= CRC_CR_RESET; |
mbed_official | 76:aeb1df146756 | 121 | } |
mbed_official | 76:aeb1df146756 | 122 | |
mbed_official | 76:aeb1df146756 | 123 | /** |
mbed_official | 76:aeb1df146756 | 124 | * @brief Selects the polynomial size. This function is only applicable for |
mbed_official | 76:aeb1df146756 | 125 | * STM32F072 devices. |
mbed_official | 76:aeb1df146756 | 126 | * @param CRC_PolSize: Specifies the polynomial size. |
mbed_official | 76:aeb1df146756 | 127 | * This parameter can be: |
mbed_official | 76:aeb1df146756 | 128 | * @arg CRC_PolSize_7: 7-bit polynomial for CRC calculation |
mbed_official | 76:aeb1df146756 | 129 | * @arg CRC_PolSize_8: 8-bit polynomial for CRC calculation |
mbed_official | 76:aeb1df146756 | 130 | * @arg CRC_PolSize_16: 16-bit polynomial for CRC calculation |
mbed_official | 76:aeb1df146756 | 131 | * @arg CRC_PolSize_32: 32-bit polynomial for CRC calculation |
mbed_official | 76:aeb1df146756 | 132 | * @retval None |
mbed_official | 76:aeb1df146756 | 133 | */ |
mbed_official | 76:aeb1df146756 | 134 | void CRC_PolynomialSizeSelect(uint32_t CRC_PolSize) |
mbed_official | 76:aeb1df146756 | 135 | { |
mbed_official | 76:aeb1df146756 | 136 | uint32_t tmpcr = 0; |
mbed_official | 76:aeb1df146756 | 137 | |
mbed_official | 76:aeb1df146756 | 138 | /* Check the parameter */ |
mbed_official | 76:aeb1df146756 | 139 | assert_param(IS_CRC_POL_SIZE(CRC_PolSize)); |
mbed_official | 76:aeb1df146756 | 140 | |
mbed_official | 76:aeb1df146756 | 141 | /* Get CR register value */ |
mbed_official | 76:aeb1df146756 | 142 | tmpcr = CRC->CR; |
mbed_official | 76:aeb1df146756 | 143 | |
mbed_official | 76:aeb1df146756 | 144 | /* Reset POL_SIZE bits */ |
mbed_official | 76:aeb1df146756 | 145 | tmpcr &= (uint32_t)~((uint32_t)CRC_CR_POLSIZE); |
mbed_official | 76:aeb1df146756 | 146 | /* Set the polynomial size */ |
mbed_official | 76:aeb1df146756 | 147 | tmpcr |= (uint32_t)CRC_PolSize; |
mbed_official | 76:aeb1df146756 | 148 | |
mbed_official | 76:aeb1df146756 | 149 | /* Write to CR register */ |
mbed_official | 76:aeb1df146756 | 150 | CRC->CR = (uint32_t)tmpcr; |
mbed_official | 76:aeb1df146756 | 151 | } |
mbed_official | 76:aeb1df146756 | 152 | |
mbed_official | 76:aeb1df146756 | 153 | /** |
mbed_official | 76:aeb1df146756 | 154 | * @brief Selects the reverse operation to be performed on input data. |
mbed_official | 76:aeb1df146756 | 155 | * @param CRC_ReverseInputData: Specifies the reverse operation on input data. |
mbed_official | 76:aeb1df146756 | 156 | * This parameter can be: |
mbed_official | 76:aeb1df146756 | 157 | * @arg CRC_ReverseInputData_No: No reverse operation is performed |
mbed_official | 76:aeb1df146756 | 158 | * @arg CRC_ReverseInputData_8bits: reverse operation performed on 8 bits |
mbed_official | 76:aeb1df146756 | 159 | * @arg CRC_ReverseInputData_16bits: reverse operation performed on 16 bits |
mbed_official | 76:aeb1df146756 | 160 | * @arg CRC_ReverseInputData_32bits: reverse operation performed on 32 bits |
mbed_official | 76:aeb1df146756 | 161 | * @retval None |
mbed_official | 76:aeb1df146756 | 162 | */ |
mbed_official | 76:aeb1df146756 | 163 | void CRC_ReverseInputDataSelect(uint32_t CRC_ReverseInputData) |
mbed_official | 76:aeb1df146756 | 164 | { |
mbed_official | 76:aeb1df146756 | 165 | uint32_t tmpcr = 0; |
mbed_official | 76:aeb1df146756 | 166 | |
mbed_official | 76:aeb1df146756 | 167 | /* Check the parameter */ |
mbed_official | 76:aeb1df146756 | 168 | assert_param(IS_CRC_REVERSE_INPUT_DATA(CRC_ReverseInputData)); |
mbed_official | 76:aeb1df146756 | 169 | |
mbed_official | 76:aeb1df146756 | 170 | /* Get CR register value */ |
mbed_official | 76:aeb1df146756 | 171 | tmpcr = CRC->CR; |
mbed_official | 76:aeb1df146756 | 172 | |
mbed_official | 76:aeb1df146756 | 173 | /* Reset REV_IN bits */ |
mbed_official | 76:aeb1df146756 | 174 | tmpcr &= (uint32_t)~((uint32_t)CRC_CR_REV_IN); |
mbed_official | 76:aeb1df146756 | 175 | /* Set the reverse operation */ |
mbed_official | 76:aeb1df146756 | 176 | tmpcr |= (uint32_t)CRC_ReverseInputData; |
mbed_official | 76:aeb1df146756 | 177 | |
mbed_official | 76:aeb1df146756 | 178 | /* Write to CR register */ |
mbed_official | 76:aeb1df146756 | 179 | CRC->CR = (uint32_t)tmpcr; |
mbed_official | 76:aeb1df146756 | 180 | } |
mbed_official | 76:aeb1df146756 | 181 | |
mbed_official | 76:aeb1df146756 | 182 | /** |
mbed_official | 76:aeb1df146756 | 183 | * @brief Enables or disable the reverse operation on output data. |
mbed_official | 76:aeb1df146756 | 184 | * The reverse operation on output data is performed on 32-bit. |
mbed_official | 76:aeb1df146756 | 185 | * @param NewState: new state of the reverse operation on output data. |
mbed_official | 76:aeb1df146756 | 186 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 76:aeb1df146756 | 187 | * @retval None |
mbed_official | 76:aeb1df146756 | 188 | */ |
mbed_official | 76:aeb1df146756 | 189 | void CRC_ReverseOutputDataCmd(FunctionalState NewState) |
mbed_official | 76:aeb1df146756 | 190 | { |
mbed_official | 76:aeb1df146756 | 191 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 192 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 76:aeb1df146756 | 193 | |
mbed_official | 76:aeb1df146756 | 194 | if (NewState != DISABLE) |
mbed_official | 76:aeb1df146756 | 195 | { |
mbed_official | 76:aeb1df146756 | 196 | /* Enable reverse operation on output data */ |
mbed_official | 76:aeb1df146756 | 197 | CRC->CR |= CRC_CR_REV_OUT; |
mbed_official | 76:aeb1df146756 | 198 | } |
mbed_official | 76:aeb1df146756 | 199 | else |
mbed_official | 76:aeb1df146756 | 200 | { |
mbed_official | 76:aeb1df146756 | 201 | /* Disable reverse operation on output data */ |
mbed_official | 76:aeb1df146756 | 202 | CRC->CR &= (uint32_t)~((uint32_t)CRC_CR_REV_OUT); |
mbed_official | 76:aeb1df146756 | 203 | } |
mbed_official | 76:aeb1df146756 | 204 | } |
mbed_official | 76:aeb1df146756 | 205 | |
mbed_official | 76:aeb1df146756 | 206 | /** |
mbed_official | 76:aeb1df146756 | 207 | * @brief Initializes the INIT register. |
mbed_official | 76:aeb1df146756 | 208 | * @note After resetting CRC calculation unit, CRC_InitValue is stored in DR register |
mbed_official | 76:aeb1df146756 | 209 | * @param CRC_InitValue: Programmable initial CRC value |
mbed_official | 76:aeb1df146756 | 210 | * @retval None |
mbed_official | 76:aeb1df146756 | 211 | */ |
mbed_official | 76:aeb1df146756 | 212 | void CRC_SetInitRegister(uint32_t CRC_InitValue) |
mbed_official | 76:aeb1df146756 | 213 | { |
mbed_official | 76:aeb1df146756 | 214 | CRC->INIT = CRC_InitValue; |
mbed_official | 76:aeb1df146756 | 215 | } |
mbed_official | 76:aeb1df146756 | 216 | |
mbed_official | 76:aeb1df146756 | 217 | /** |
mbed_official | 76:aeb1df146756 | 218 | * @brief Initializes the polynomail coefficients. This function is only |
mbed_official | 76:aeb1df146756 | 219 | * applicable for STM32F072 devices. |
mbed_official | 76:aeb1df146756 | 220 | * @param CRC_Pol: Polynomial to be used for CRC calculation. |
mbed_official | 76:aeb1df146756 | 221 | * @retval None |
mbed_official | 76:aeb1df146756 | 222 | */ |
mbed_official | 76:aeb1df146756 | 223 | void CRC_SetPolynomial(uint32_t CRC_Pol) |
mbed_official | 76:aeb1df146756 | 224 | { |
mbed_official | 76:aeb1df146756 | 225 | CRC->POL = CRC_Pol; |
mbed_official | 76:aeb1df146756 | 226 | } |
mbed_official | 76:aeb1df146756 | 227 | |
mbed_official | 76:aeb1df146756 | 228 | /** |
mbed_official | 76:aeb1df146756 | 229 | * @} |
mbed_official | 76:aeb1df146756 | 230 | */ |
mbed_official | 76:aeb1df146756 | 231 | |
mbed_official | 76:aeb1df146756 | 232 | /** @defgroup CRC_Group2 CRC computation of one/many 32-bit data functions |
mbed_official | 76:aeb1df146756 | 233 | * @brief CRC computation of one/many 32-bit data functions |
mbed_official | 76:aeb1df146756 | 234 | * |
mbed_official | 76:aeb1df146756 | 235 | @verbatim |
mbed_official | 76:aeb1df146756 | 236 | =============================================================================== |
mbed_official | 76:aeb1df146756 | 237 | ##### CRC computation functions ##### |
mbed_official | 76:aeb1df146756 | 238 | =============================================================================== |
mbed_official | 76:aeb1df146756 | 239 | |
mbed_official | 76:aeb1df146756 | 240 | @endverbatim |
mbed_official | 76:aeb1df146756 | 241 | * @{ |
mbed_official | 76:aeb1df146756 | 242 | */ |
mbed_official | 76:aeb1df146756 | 243 | |
mbed_official | 76:aeb1df146756 | 244 | /** |
mbed_official | 76:aeb1df146756 | 245 | * @brief Computes the 32-bit CRC of a given data word(32-bit). |
mbed_official | 76:aeb1df146756 | 246 | * @param CRC_Data: data word(32-bit) to compute its CRC |
mbed_official | 76:aeb1df146756 | 247 | * @retval 32-bit CRC |
mbed_official | 76:aeb1df146756 | 248 | */ |
mbed_official | 76:aeb1df146756 | 249 | uint32_t CRC_CalcCRC(uint32_t CRC_Data) |
mbed_official | 76:aeb1df146756 | 250 | { |
mbed_official | 76:aeb1df146756 | 251 | CRC->DR = CRC_Data; |
mbed_official | 76:aeb1df146756 | 252 | |
mbed_official | 76:aeb1df146756 | 253 | return (CRC->DR); |
mbed_official | 76:aeb1df146756 | 254 | } |
mbed_official | 76:aeb1df146756 | 255 | |
mbed_official | 76:aeb1df146756 | 256 | /** |
mbed_official | 76:aeb1df146756 | 257 | * @brief Computes the 16-bit CRC of a given 16-bit data. This function is only |
mbed_official | 76:aeb1df146756 | 258 | * applicable for STM32F072 devices. |
mbed_official | 76:aeb1df146756 | 259 | * @param CRC_Data: data half-word(16-bit) to compute its CRC |
mbed_official | 76:aeb1df146756 | 260 | * @retval 16-bit CRC |
mbed_official | 76:aeb1df146756 | 261 | */ |
mbed_official | 76:aeb1df146756 | 262 | uint32_t CRC_CalcCRC16bits(uint16_t CRC_Data) |
mbed_official | 76:aeb1df146756 | 263 | { |
mbed_official | 76:aeb1df146756 | 264 | *(uint16_t*)(CRC_BASE) = (uint16_t) CRC_Data; |
mbed_official | 76:aeb1df146756 | 265 | |
mbed_official | 76:aeb1df146756 | 266 | return (CRC->DR); |
mbed_official | 76:aeb1df146756 | 267 | } |
mbed_official | 76:aeb1df146756 | 268 | |
mbed_official | 76:aeb1df146756 | 269 | /** |
mbed_official | 76:aeb1df146756 | 270 | * @brief Computes the 8-bit CRC of a given 8-bit data. This function is only |
mbed_official | 76:aeb1df146756 | 271 | * applicable for STM32F072 devices. |
mbed_official | 76:aeb1df146756 | 272 | * @param CRC_Data: 8-bit data to compute its CRC |
mbed_official | 76:aeb1df146756 | 273 | * @retval 8-bit CRC |
mbed_official | 76:aeb1df146756 | 274 | */ |
mbed_official | 76:aeb1df146756 | 275 | uint32_t CRC_CalcCRC8bits(uint8_t CRC_Data) |
mbed_official | 76:aeb1df146756 | 276 | { |
mbed_official | 76:aeb1df146756 | 277 | *(uint8_t*)(CRC_BASE) = (uint8_t) CRC_Data; |
mbed_official | 76:aeb1df146756 | 278 | |
mbed_official | 76:aeb1df146756 | 279 | return (CRC->DR); |
mbed_official | 76:aeb1df146756 | 280 | } |
mbed_official | 76:aeb1df146756 | 281 | |
mbed_official | 76:aeb1df146756 | 282 | /** |
mbed_official | 76:aeb1df146756 | 283 | * @brief Computes the 32-bit CRC of a given buffer of data word(32-bit). |
mbed_official | 76:aeb1df146756 | 284 | * @param pBuffer: pointer to the buffer containing the data to be computed |
mbed_official | 76:aeb1df146756 | 285 | * @param BufferLength: length of the buffer to be computed |
mbed_official | 76:aeb1df146756 | 286 | * @retval 32-bit CRC |
mbed_official | 76:aeb1df146756 | 287 | */ |
mbed_official | 76:aeb1df146756 | 288 | uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength) |
mbed_official | 76:aeb1df146756 | 289 | { |
mbed_official | 76:aeb1df146756 | 290 | uint32_t index = 0; |
mbed_official | 76:aeb1df146756 | 291 | |
mbed_official | 76:aeb1df146756 | 292 | for(index = 0; index < BufferLength; index++) |
mbed_official | 76:aeb1df146756 | 293 | { |
mbed_official | 76:aeb1df146756 | 294 | CRC->DR = pBuffer[index]; |
mbed_official | 76:aeb1df146756 | 295 | } |
mbed_official | 76:aeb1df146756 | 296 | return (CRC->DR); |
mbed_official | 76:aeb1df146756 | 297 | } |
mbed_official | 76:aeb1df146756 | 298 | |
mbed_official | 76:aeb1df146756 | 299 | /** |
mbed_official | 76:aeb1df146756 | 300 | * @brief Returns the current CRC value. |
mbed_official | 76:aeb1df146756 | 301 | * @param None |
mbed_official | 76:aeb1df146756 | 302 | * @retval 32-bit CRC |
mbed_official | 76:aeb1df146756 | 303 | */ |
mbed_official | 76:aeb1df146756 | 304 | uint32_t CRC_GetCRC(void) |
mbed_official | 76:aeb1df146756 | 305 | { |
mbed_official | 76:aeb1df146756 | 306 | return (CRC->DR); |
mbed_official | 76:aeb1df146756 | 307 | } |
mbed_official | 76:aeb1df146756 | 308 | |
mbed_official | 76:aeb1df146756 | 309 | /** |
mbed_official | 76:aeb1df146756 | 310 | * @} |
mbed_official | 76:aeb1df146756 | 311 | */ |
mbed_official | 76:aeb1df146756 | 312 | |
mbed_official | 76:aeb1df146756 | 313 | /** @defgroup CRC_Group3 CRC Independent Register (IDR) access functions |
mbed_official | 76:aeb1df146756 | 314 | * @brief CRC Independent Register (IDR) access (write/read) functions |
mbed_official | 76:aeb1df146756 | 315 | * |
mbed_official | 76:aeb1df146756 | 316 | @verbatim |
mbed_official | 76:aeb1df146756 | 317 | =============================================================================== |
mbed_official | 76:aeb1df146756 | 318 | ##### CRC Independent Register (IDR) access functions ##### |
mbed_official | 76:aeb1df146756 | 319 | =============================================================================== |
mbed_official | 76:aeb1df146756 | 320 | |
mbed_official | 76:aeb1df146756 | 321 | @endverbatim |
mbed_official | 76:aeb1df146756 | 322 | * @{ |
mbed_official | 76:aeb1df146756 | 323 | */ |
mbed_official | 76:aeb1df146756 | 324 | |
mbed_official | 76:aeb1df146756 | 325 | /** |
mbed_official | 76:aeb1df146756 | 326 | * @brief Stores an 8-bit data in the Independent Data(ID) register. |
mbed_official | 76:aeb1df146756 | 327 | * @param CRC_IDValue: 8-bit value to be stored in the ID register |
mbed_official | 76:aeb1df146756 | 328 | * @retval None |
mbed_official | 76:aeb1df146756 | 329 | */ |
mbed_official | 76:aeb1df146756 | 330 | void CRC_SetIDRegister(uint8_t CRC_IDValue) |
mbed_official | 76:aeb1df146756 | 331 | { |
mbed_official | 76:aeb1df146756 | 332 | CRC->IDR = CRC_IDValue; |
mbed_official | 76:aeb1df146756 | 333 | } |
mbed_official | 76:aeb1df146756 | 334 | |
mbed_official | 76:aeb1df146756 | 335 | /** |
mbed_official | 76:aeb1df146756 | 336 | * @brief Returns the 8-bit data stored in the Independent Data(ID) register |
mbed_official | 76:aeb1df146756 | 337 | * @param None |
mbed_official | 76:aeb1df146756 | 338 | * @retval 8-bit value of the ID register |
mbed_official | 76:aeb1df146756 | 339 | */ |
mbed_official | 76:aeb1df146756 | 340 | uint8_t CRC_GetIDRegister(void) |
mbed_official | 76:aeb1df146756 | 341 | { |
mbed_official | 76:aeb1df146756 | 342 | return (CRC->IDR); |
mbed_official | 76:aeb1df146756 | 343 | } |
mbed_official | 76:aeb1df146756 | 344 | |
mbed_official | 76:aeb1df146756 | 345 | /** |
mbed_official | 76:aeb1df146756 | 346 | * @} |
mbed_official | 76:aeb1df146756 | 347 | */ |
mbed_official | 76:aeb1df146756 | 348 | |
mbed_official | 76:aeb1df146756 | 349 | /** |
mbed_official | 76:aeb1df146756 | 350 | * @} |
mbed_official | 76:aeb1df146756 | 351 | */ |
mbed_official | 76:aeb1df146756 | 352 | |
mbed_official | 76:aeb1df146756 | 353 | /** |
mbed_official | 76:aeb1df146756 | 354 | * @} |
mbed_official | 76:aeb1df146756 | 355 | */ |
mbed_official | 76:aeb1df146756 | 356 | |
mbed_official | 76:aeb1df146756 | 357 | /** |
mbed_official | 76:aeb1df146756 | 358 | * @} |
mbed_official | 76:aeb1df146756 | 359 | */ |
mbed_official | 76:aeb1df146756 | 360 | |
mbed_official | 76:aeb1df146756 | 361 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |