mbed library sources
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_STM32F3XX/stm32f30x_crc.c@637:ed69428d4850, 2015-12-22 (annotated)
- Committer:
- jaerts
- Date:
- Tue Dec 22 13:22:16 2015 +0000
- Revision:
- 637:ed69428d4850
- Parent:
- 155:8435094ec241
Add very shady LPC1768 CAN Filter implementation
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 155:8435094ec241 | 1 | /** |
mbed_official | 155:8435094ec241 | 2 | ****************************************************************************** |
mbed_official | 155:8435094ec241 | 3 | * @file stm32f30x_crc.c |
mbed_official | 155:8435094ec241 | 4 | * @author MCD Application Team |
mbed_official | 155:8435094ec241 | 5 | * @version V1.1.0 |
mbed_official | 155:8435094ec241 | 6 | * @date 27-February-2014 |
mbed_official | 155:8435094ec241 | 7 | * @brief This file provides firmware functions to manage the following |
mbed_official | 155:8435094ec241 | 8 | * functionalities of CRC computation unit peripheral: |
mbed_official | 155:8435094ec241 | 9 | * + Configuration of the CRC computation unit |
mbed_official | 155:8435094ec241 | 10 | * + CRC computation of one/many 32-bit data |
mbed_official | 155:8435094ec241 | 11 | * + CRC Independent register (IDR) access |
mbed_official | 155:8435094ec241 | 12 | * |
mbed_official | 155:8435094ec241 | 13 | @verbatim |
mbed_official | 155:8435094ec241 | 14 | |
mbed_official | 155:8435094ec241 | 15 | =============================================================================== |
mbed_official | 155:8435094ec241 | 16 | ##### How to use this driver ##### |
mbed_official | 155:8435094ec241 | 17 | =============================================================================== |
mbed_official | 155:8435094ec241 | 18 | [..] |
mbed_official | 155:8435094ec241 | 19 | (#) Enable CRC AHB clock using RCC_AHBPeriphClockCmd(RCC_AHBPeriph_CRC, ENABLE) |
mbed_official | 155:8435094ec241 | 20 | function. |
mbed_official | 155:8435094ec241 | 21 | (#) Select the polynomial size: 7-bit, 8-bit, 16-bit or 32-bit. |
mbed_official | 155:8435094ec241 | 22 | (#) Set the polynomial coefficients using CRC_SetPolynomial(); |
mbed_official | 155:8435094ec241 | 23 | (#) If required, select the reverse operation on input data |
mbed_official | 155:8435094ec241 | 24 | using CRC_ReverseInputDataSelect(); |
mbed_official | 155:8435094ec241 | 25 | (#) If required, enable the reverse operation on output data |
mbed_official | 155:8435094ec241 | 26 | using CRC_ReverseOutputDataCmd(Enable); |
mbed_official | 155:8435094ec241 | 27 | (#) If required, set the initialization remainder value using |
mbed_official | 155:8435094ec241 | 28 | CRC_SetInitRegister(); |
mbed_official | 155:8435094ec241 | 29 | (#) use CRC_CalcCRC() function to compute the CRC of a 32-bit data |
mbed_official | 155:8435094ec241 | 30 | or use CRC_CalcBlockCRC() function to compute the CRC if a 32-bit |
mbed_official | 155:8435094ec241 | 31 | data buffer. |
mbed_official | 155:8435094ec241 | 32 | |
mbed_official | 155:8435094ec241 | 33 | @endverbatim |
mbed_official | 155:8435094ec241 | 34 | |
mbed_official | 155:8435094ec241 | 35 | ****************************************************************************** |
mbed_official | 155:8435094ec241 | 36 | * @attention |
mbed_official | 155:8435094ec241 | 37 | * |
mbed_official | 155:8435094ec241 | 38 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
mbed_official | 155:8435094ec241 | 39 | * |
mbed_official | 155:8435094ec241 | 40 | * Redistribution and use in source and binary forms, with or without modification, |
mbed_official | 155:8435094ec241 | 41 | * are permitted provided that the following conditions are met: |
mbed_official | 155:8435094ec241 | 42 | * 1. Redistributions of source code must retain the above copyright notice, |
mbed_official | 155:8435094ec241 | 43 | * this list of conditions and the following disclaimer. |
mbed_official | 155:8435094ec241 | 44 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mbed_official | 155:8435094ec241 | 45 | * this list of conditions and the following disclaimer in the documentation |
mbed_official | 155:8435094ec241 | 46 | * and/or other materials provided with the distribution. |
mbed_official | 155:8435094ec241 | 47 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
mbed_official | 155:8435094ec241 | 48 | * may be used to endorse or promote products derived from this software |
mbed_official | 155:8435094ec241 | 49 | * without specific prior written permission. |
mbed_official | 155:8435094ec241 | 50 | * |
mbed_official | 155:8435094ec241 | 51 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 155:8435094ec241 | 52 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 155:8435094ec241 | 53 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
mbed_official | 155:8435094ec241 | 54 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
mbed_official | 155:8435094ec241 | 55 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mbed_official | 155:8435094ec241 | 56 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
mbed_official | 155:8435094ec241 | 57 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mbed_official | 155:8435094ec241 | 58 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
mbed_official | 155:8435094ec241 | 59 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
mbed_official | 155:8435094ec241 | 60 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 155:8435094ec241 | 61 | * |
mbed_official | 155:8435094ec241 | 62 | ****************************************************************************** |
mbed_official | 155:8435094ec241 | 63 | */ |
mbed_official | 155:8435094ec241 | 64 | |
mbed_official | 155:8435094ec241 | 65 | /* Includes ------------------------------------------------------------------*/ |
mbed_official | 155:8435094ec241 | 66 | #include "stm32f30x_crc.h" |
mbed_official | 155:8435094ec241 | 67 | |
mbed_official | 155:8435094ec241 | 68 | /** @addtogroup STM32F30x_StdPeriph_Driver |
mbed_official | 155:8435094ec241 | 69 | * @{ |
mbed_official | 155:8435094ec241 | 70 | */ |
mbed_official | 155:8435094ec241 | 71 | |
mbed_official | 155:8435094ec241 | 72 | /** @defgroup CRC |
mbed_official | 155:8435094ec241 | 73 | * @brief CRC driver modules |
mbed_official | 155:8435094ec241 | 74 | * @{ |
mbed_official | 155:8435094ec241 | 75 | */ |
mbed_official | 155:8435094ec241 | 76 | |
mbed_official | 155:8435094ec241 | 77 | /* Private typedef -----------------------------------------------------------*/ |
mbed_official | 155:8435094ec241 | 78 | /* Private define ------------------------------------------------------------*/ |
mbed_official | 155:8435094ec241 | 79 | /* Private macro -------------------------------------------------------------*/ |
mbed_official | 155:8435094ec241 | 80 | /* Private variables ---------------------------------------------------------*/ |
mbed_official | 155:8435094ec241 | 81 | /* Private function prototypes -----------------------------------------------*/ |
mbed_official | 155:8435094ec241 | 82 | /* Private functions ---------------------------------------------------------*/ |
mbed_official | 155:8435094ec241 | 83 | |
mbed_official | 155:8435094ec241 | 84 | /** @defgroup CRC_Private_Functions |
mbed_official | 155:8435094ec241 | 85 | * @{ |
mbed_official | 155:8435094ec241 | 86 | */ |
mbed_official | 155:8435094ec241 | 87 | |
mbed_official | 155:8435094ec241 | 88 | /** @defgroup CRC_Group1 Configuration of the CRC computation unit functions |
mbed_official | 155:8435094ec241 | 89 | * @brief Configuration of the CRC computation unit functions |
mbed_official | 155:8435094ec241 | 90 | * |
mbed_official | 155:8435094ec241 | 91 | @verbatim |
mbed_official | 155:8435094ec241 | 92 | =============================================================================== |
mbed_official | 155:8435094ec241 | 93 | ##### CRC configuration functions ##### |
mbed_official | 155:8435094ec241 | 94 | =============================================================================== |
mbed_official | 155:8435094ec241 | 95 | |
mbed_official | 155:8435094ec241 | 96 | @endverbatim |
mbed_official | 155:8435094ec241 | 97 | * @{ |
mbed_official | 155:8435094ec241 | 98 | */ |
mbed_official | 155:8435094ec241 | 99 | |
mbed_official | 155:8435094ec241 | 100 | /** |
mbed_official | 155:8435094ec241 | 101 | * @brief Deinitializes CRC peripheral registers to their default reset values. |
mbed_official | 155:8435094ec241 | 102 | * @param None |
mbed_official | 155:8435094ec241 | 103 | * @retval None |
mbed_official | 155:8435094ec241 | 104 | */ |
mbed_official | 155:8435094ec241 | 105 | void CRC_DeInit(void) |
mbed_official | 155:8435094ec241 | 106 | { |
mbed_official | 155:8435094ec241 | 107 | /* Set DR register to reset value */ |
mbed_official | 155:8435094ec241 | 108 | CRC->DR = 0xFFFFFFFF; |
mbed_official | 155:8435094ec241 | 109 | /* Set the POL register to the reset value: 0x04C11DB7 */ |
mbed_official | 155:8435094ec241 | 110 | CRC->POL = 0x04C11DB7; |
mbed_official | 155:8435094ec241 | 111 | /* Reset IDR register */ |
mbed_official | 155:8435094ec241 | 112 | CRC->IDR = 0x00; |
mbed_official | 155:8435094ec241 | 113 | /* Set INIT register to reset value */ |
mbed_official | 155:8435094ec241 | 114 | CRC->INIT = 0xFFFFFFFF; |
mbed_official | 155:8435094ec241 | 115 | /* Reset the CRC calculation unit */ |
mbed_official | 155:8435094ec241 | 116 | CRC->CR = CRC_CR_RESET; |
mbed_official | 155:8435094ec241 | 117 | } |
mbed_official | 155:8435094ec241 | 118 | |
mbed_official | 155:8435094ec241 | 119 | /** |
mbed_official | 155:8435094ec241 | 120 | * @brief Resets the CRC calculation unit and sets INIT register content in DR register. |
mbed_official | 155:8435094ec241 | 121 | * @param None |
mbed_official | 155:8435094ec241 | 122 | * @retval None |
mbed_official | 155:8435094ec241 | 123 | */ |
mbed_official | 155:8435094ec241 | 124 | void CRC_ResetDR(void) |
mbed_official | 155:8435094ec241 | 125 | { |
mbed_official | 155:8435094ec241 | 126 | /* Reset CRC generator */ |
mbed_official | 155:8435094ec241 | 127 | CRC->CR |= CRC_CR_RESET; |
mbed_official | 155:8435094ec241 | 128 | } |
mbed_official | 155:8435094ec241 | 129 | |
mbed_official | 155:8435094ec241 | 130 | /** |
mbed_official | 155:8435094ec241 | 131 | * @brief Selects the polynomial size. |
mbed_official | 155:8435094ec241 | 132 | * @param CRC_PolSize: Specifies the polynomial size. |
mbed_official | 155:8435094ec241 | 133 | * This parameter can be: |
mbed_official | 155:8435094ec241 | 134 | * @arg CRC_PolSize_7: 7-bit polynomial for CRC calculation |
mbed_official | 155:8435094ec241 | 135 | * @arg CRC_PolSize_8: 8-bit polynomial for CRC calculation |
mbed_official | 155:8435094ec241 | 136 | * @arg CRC_PolSize_16: 16-bit polynomial for CRC calculation |
mbed_official | 155:8435094ec241 | 137 | * @arg CRC_PolSize_32: 32-bit polynomial for CRC calculation |
mbed_official | 155:8435094ec241 | 138 | * @retval None |
mbed_official | 155:8435094ec241 | 139 | */ |
mbed_official | 155:8435094ec241 | 140 | void CRC_PolynomialSizeSelect(uint32_t CRC_PolSize) |
mbed_official | 155:8435094ec241 | 141 | { |
mbed_official | 155:8435094ec241 | 142 | uint32_t tmpcr = 0; |
mbed_official | 155:8435094ec241 | 143 | |
mbed_official | 155:8435094ec241 | 144 | /* Check the parameter */ |
mbed_official | 155:8435094ec241 | 145 | assert_param(IS_CRC_POL_SIZE(CRC_PolSize)); |
mbed_official | 155:8435094ec241 | 146 | |
mbed_official | 155:8435094ec241 | 147 | /* Get CR register value */ |
mbed_official | 155:8435094ec241 | 148 | tmpcr = CRC->CR; |
mbed_official | 155:8435094ec241 | 149 | |
mbed_official | 155:8435094ec241 | 150 | /* Reset POL_SIZE bits */ |
mbed_official | 155:8435094ec241 | 151 | tmpcr &= (uint32_t)~((uint32_t)CRC_CR_POLSIZE); |
mbed_official | 155:8435094ec241 | 152 | /* Set the polynomial size */ |
mbed_official | 155:8435094ec241 | 153 | tmpcr |= (uint32_t)CRC_PolSize; |
mbed_official | 155:8435094ec241 | 154 | |
mbed_official | 155:8435094ec241 | 155 | /* Write to CR register */ |
mbed_official | 155:8435094ec241 | 156 | CRC->CR = (uint32_t)tmpcr; |
mbed_official | 155:8435094ec241 | 157 | } |
mbed_official | 155:8435094ec241 | 158 | |
mbed_official | 155:8435094ec241 | 159 | /** |
mbed_official | 155:8435094ec241 | 160 | * @brief Selects the reverse operation to be performed on input data. |
mbed_official | 155:8435094ec241 | 161 | * @param CRC_ReverseInputData: Specifies the reverse operation on input data. |
mbed_official | 155:8435094ec241 | 162 | * This parameter can be: |
mbed_official | 155:8435094ec241 | 163 | * @arg CRC_ReverseInputData_No: No reverse operation is performed |
mbed_official | 155:8435094ec241 | 164 | * @arg CRC_ReverseInputData_8bits: reverse operation performed on 8 bits |
mbed_official | 155:8435094ec241 | 165 | * @arg CRC_ReverseInputData_16bits: reverse operation performed on 16 bits |
mbed_official | 155:8435094ec241 | 166 | * @arg CRC_ReverseInputData_32bits: reverse operation performed on 32 bits |
mbed_official | 155:8435094ec241 | 167 | * @retval None |
mbed_official | 155:8435094ec241 | 168 | */ |
mbed_official | 155:8435094ec241 | 169 | void CRC_ReverseInputDataSelect(uint32_t CRC_ReverseInputData) |
mbed_official | 155:8435094ec241 | 170 | { |
mbed_official | 155:8435094ec241 | 171 | uint32_t tmpcr = 0; |
mbed_official | 155:8435094ec241 | 172 | |
mbed_official | 155:8435094ec241 | 173 | /* Check the parameter */ |
mbed_official | 155:8435094ec241 | 174 | assert_param(IS_CRC_REVERSE_INPUT_DATA(CRC_ReverseInputData)); |
mbed_official | 155:8435094ec241 | 175 | |
mbed_official | 155:8435094ec241 | 176 | /* Get CR register value */ |
mbed_official | 155:8435094ec241 | 177 | tmpcr = CRC->CR; |
mbed_official | 155:8435094ec241 | 178 | |
mbed_official | 155:8435094ec241 | 179 | /* Reset REV_IN bits */ |
mbed_official | 155:8435094ec241 | 180 | tmpcr &= (uint32_t)~((uint32_t)CRC_CR_REV_IN); |
mbed_official | 155:8435094ec241 | 181 | /* Set the reverse operation */ |
mbed_official | 155:8435094ec241 | 182 | tmpcr |= (uint32_t)CRC_ReverseInputData; |
mbed_official | 155:8435094ec241 | 183 | |
mbed_official | 155:8435094ec241 | 184 | /* Write to CR register */ |
mbed_official | 155:8435094ec241 | 185 | CRC->CR = (uint32_t)tmpcr; |
mbed_official | 155:8435094ec241 | 186 | } |
mbed_official | 155:8435094ec241 | 187 | |
mbed_official | 155:8435094ec241 | 188 | /** |
mbed_official | 155:8435094ec241 | 189 | * @brief Enables or disable the reverse operation on output data. |
mbed_official | 155:8435094ec241 | 190 | * The reverse operation on output data is performed on 32-bit. |
mbed_official | 155:8435094ec241 | 191 | * @param NewState: new state of the reverse operation on output data. |
mbed_official | 155:8435094ec241 | 192 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 193 | * @retval None |
mbed_official | 155:8435094ec241 | 194 | */ |
mbed_official | 155:8435094ec241 | 195 | void CRC_ReverseOutputDataCmd(FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 196 | { |
mbed_official | 155:8435094ec241 | 197 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 198 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 199 | |
mbed_official | 155:8435094ec241 | 200 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 201 | { |
mbed_official | 155:8435094ec241 | 202 | /* Enable reverse operation on output data */ |
mbed_official | 155:8435094ec241 | 203 | CRC->CR |= CRC_CR_REV_OUT; |
mbed_official | 155:8435094ec241 | 204 | } |
mbed_official | 155:8435094ec241 | 205 | else |
mbed_official | 155:8435094ec241 | 206 | { |
mbed_official | 155:8435094ec241 | 207 | /* Disable reverse operation on output data */ |
mbed_official | 155:8435094ec241 | 208 | CRC->CR &= (uint32_t)~((uint32_t)CRC_CR_REV_OUT); |
mbed_official | 155:8435094ec241 | 209 | } |
mbed_official | 155:8435094ec241 | 210 | } |
mbed_official | 155:8435094ec241 | 211 | |
mbed_official | 155:8435094ec241 | 212 | /** |
mbed_official | 155:8435094ec241 | 213 | * @brief Initializes the INIT register. |
mbed_official | 155:8435094ec241 | 214 | * @note After resetting CRC calculation unit, CRC_InitValue is stored in DR register |
mbed_official | 155:8435094ec241 | 215 | * @param CRC_InitValue: Programmable initial CRC value |
mbed_official | 155:8435094ec241 | 216 | * @retval None |
mbed_official | 155:8435094ec241 | 217 | */ |
mbed_official | 155:8435094ec241 | 218 | void CRC_SetInitRegister(uint32_t CRC_InitValue) |
mbed_official | 155:8435094ec241 | 219 | { |
mbed_official | 155:8435094ec241 | 220 | CRC->INIT = CRC_InitValue; |
mbed_official | 155:8435094ec241 | 221 | } |
mbed_official | 155:8435094ec241 | 222 | |
mbed_official | 155:8435094ec241 | 223 | /** |
mbed_official | 155:8435094ec241 | 224 | * @brief Initializes the polynomail coefficients. |
mbed_official | 155:8435094ec241 | 225 | * @param CRC_Pol: Polynomial to be used for CRC calculation. |
mbed_official | 155:8435094ec241 | 226 | * @retval None |
mbed_official | 155:8435094ec241 | 227 | */ |
mbed_official | 155:8435094ec241 | 228 | void CRC_SetPolynomial(uint32_t CRC_Pol) |
mbed_official | 155:8435094ec241 | 229 | { |
mbed_official | 155:8435094ec241 | 230 | CRC->POL = CRC_Pol; |
mbed_official | 155:8435094ec241 | 231 | } |
mbed_official | 155:8435094ec241 | 232 | |
mbed_official | 155:8435094ec241 | 233 | /** |
mbed_official | 155:8435094ec241 | 234 | * @} |
mbed_official | 155:8435094ec241 | 235 | */ |
mbed_official | 155:8435094ec241 | 236 | |
mbed_official | 155:8435094ec241 | 237 | /** @defgroup CRC_Group2 CRC computation of one/many 32-bit data functions |
mbed_official | 155:8435094ec241 | 238 | * @brief CRC computation of one/many 32-bit data functions |
mbed_official | 155:8435094ec241 | 239 | * |
mbed_official | 155:8435094ec241 | 240 | @verbatim |
mbed_official | 155:8435094ec241 | 241 | =============================================================================== |
mbed_official | 155:8435094ec241 | 242 | ##### CRC computation functions ##### |
mbed_official | 155:8435094ec241 | 243 | =============================================================================== |
mbed_official | 155:8435094ec241 | 244 | |
mbed_official | 155:8435094ec241 | 245 | @endverbatim |
mbed_official | 155:8435094ec241 | 246 | * @{ |
mbed_official | 155:8435094ec241 | 247 | */ |
mbed_official | 155:8435094ec241 | 248 | |
mbed_official | 155:8435094ec241 | 249 | /** |
mbed_official | 155:8435094ec241 | 250 | * @brief Computes the 32-bit CRC of a given data word(32-bit). |
mbed_official | 155:8435094ec241 | 251 | * @param CRC_Data: data word(32-bit) to compute its CRC |
mbed_official | 155:8435094ec241 | 252 | * @retval 32-bit CRC |
mbed_official | 155:8435094ec241 | 253 | */ |
mbed_official | 155:8435094ec241 | 254 | uint32_t CRC_CalcCRC(uint32_t CRC_Data) |
mbed_official | 155:8435094ec241 | 255 | { |
mbed_official | 155:8435094ec241 | 256 | CRC->DR = CRC_Data; |
mbed_official | 155:8435094ec241 | 257 | |
mbed_official | 155:8435094ec241 | 258 | return (CRC->DR); |
mbed_official | 155:8435094ec241 | 259 | } |
mbed_official | 155:8435094ec241 | 260 | |
mbed_official | 155:8435094ec241 | 261 | /** |
mbed_official | 155:8435094ec241 | 262 | * @brief Computes the 16-bit CRC of a given 16-bit data. |
mbed_official | 155:8435094ec241 | 263 | * @param CRC_Data: data half-word(16-bit) to compute its CRC |
mbed_official | 155:8435094ec241 | 264 | * @retval 16-bit CRC |
mbed_official | 155:8435094ec241 | 265 | */ |
mbed_official | 155:8435094ec241 | 266 | uint32_t CRC_CalcCRC16bits(uint16_t CRC_Data) |
mbed_official | 155:8435094ec241 | 267 | { |
mbed_official | 155:8435094ec241 | 268 | *(uint16_t*)(CRC_BASE) = (uint16_t) CRC_Data; |
mbed_official | 155:8435094ec241 | 269 | |
mbed_official | 155:8435094ec241 | 270 | return (CRC->DR); |
mbed_official | 155:8435094ec241 | 271 | } |
mbed_official | 155:8435094ec241 | 272 | |
mbed_official | 155:8435094ec241 | 273 | /** |
mbed_official | 155:8435094ec241 | 274 | * @brief Computes the 8-bit CRC of a given 8-bit data. |
mbed_official | 155:8435094ec241 | 275 | * @param CRC_Data: 8-bit data to compute its CRC |
mbed_official | 155:8435094ec241 | 276 | * @retval 8-bit CRC |
mbed_official | 155:8435094ec241 | 277 | */ |
mbed_official | 155:8435094ec241 | 278 | uint32_t CRC_CalcCRC8bits(uint8_t CRC_Data) |
mbed_official | 155:8435094ec241 | 279 | { |
mbed_official | 155:8435094ec241 | 280 | *(uint8_t*)(CRC_BASE) = (uint8_t) CRC_Data; |
mbed_official | 155:8435094ec241 | 281 | |
mbed_official | 155:8435094ec241 | 282 | return (CRC->DR); |
mbed_official | 155:8435094ec241 | 283 | } |
mbed_official | 155:8435094ec241 | 284 | |
mbed_official | 155:8435094ec241 | 285 | /** |
mbed_official | 155:8435094ec241 | 286 | * @brief Computes the 32-bit CRC of a given buffer of data word(32-bit). |
mbed_official | 155:8435094ec241 | 287 | * @param pBuffer: pointer to the buffer containing the data to be computed |
mbed_official | 155:8435094ec241 | 288 | * @param BufferLength: length of the buffer to be computed |
mbed_official | 155:8435094ec241 | 289 | * @retval 32-bit CRC |
mbed_official | 155:8435094ec241 | 290 | */ |
mbed_official | 155:8435094ec241 | 291 | uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength) |
mbed_official | 155:8435094ec241 | 292 | { |
mbed_official | 155:8435094ec241 | 293 | uint32_t index = 0; |
mbed_official | 155:8435094ec241 | 294 | |
mbed_official | 155:8435094ec241 | 295 | for(index = 0; index < BufferLength; index++) |
mbed_official | 155:8435094ec241 | 296 | { |
mbed_official | 155:8435094ec241 | 297 | CRC->DR = pBuffer[index]; |
mbed_official | 155:8435094ec241 | 298 | } |
mbed_official | 155:8435094ec241 | 299 | return (CRC->DR); |
mbed_official | 155:8435094ec241 | 300 | } |
mbed_official | 155:8435094ec241 | 301 | |
mbed_official | 155:8435094ec241 | 302 | /** |
mbed_official | 155:8435094ec241 | 303 | * @brief Returns the current CRC value. |
mbed_official | 155:8435094ec241 | 304 | * @param None |
mbed_official | 155:8435094ec241 | 305 | * @retval 32-bit CRC |
mbed_official | 155:8435094ec241 | 306 | */ |
mbed_official | 155:8435094ec241 | 307 | uint32_t CRC_GetCRC(void) |
mbed_official | 155:8435094ec241 | 308 | { |
mbed_official | 155:8435094ec241 | 309 | return (CRC->DR); |
mbed_official | 155:8435094ec241 | 310 | } |
mbed_official | 155:8435094ec241 | 311 | |
mbed_official | 155:8435094ec241 | 312 | /** |
mbed_official | 155:8435094ec241 | 313 | * @} |
mbed_official | 155:8435094ec241 | 314 | */ |
mbed_official | 155:8435094ec241 | 315 | |
mbed_official | 155:8435094ec241 | 316 | /** @defgroup CRC_Group3 CRC Independent Register (IDR) access functions |
mbed_official | 155:8435094ec241 | 317 | * @brief CRC Independent Register (IDR) access (write/read) functions |
mbed_official | 155:8435094ec241 | 318 | * |
mbed_official | 155:8435094ec241 | 319 | @verbatim |
mbed_official | 155:8435094ec241 | 320 | =============================================================================== |
mbed_official | 155:8435094ec241 | 321 | ##### CRC Independent Register (IDR) access functions ##### |
mbed_official | 155:8435094ec241 | 322 | =============================================================================== |
mbed_official | 155:8435094ec241 | 323 | |
mbed_official | 155:8435094ec241 | 324 | @endverbatim |
mbed_official | 155:8435094ec241 | 325 | * @{ |
mbed_official | 155:8435094ec241 | 326 | */ |
mbed_official | 155:8435094ec241 | 327 | |
mbed_official | 155:8435094ec241 | 328 | /** |
mbed_official | 155:8435094ec241 | 329 | * @brief Stores an 8-bit data in the Independent Data(ID) register. |
mbed_official | 155:8435094ec241 | 330 | * @param CRC_IDValue: 8-bit value to be stored in the ID register |
mbed_official | 155:8435094ec241 | 331 | * @retval None |
mbed_official | 155:8435094ec241 | 332 | */ |
mbed_official | 155:8435094ec241 | 333 | void CRC_SetIDRegister(uint8_t CRC_IDValue) |
mbed_official | 155:8435094ec241 | 334 | { |
mbed_official | 155:8435094ec241 | 335 | CRC->IDR = CRC_IDValue; |
mbed_official | 155:8435094ec241 | 336 | } |
mbed_official | 155:8435094ec241 | 337 | |
mbed_official | 155:8435094ec241 | 338 | /** |
mbed_official | 155:8435094ec241 | 339 | * @brief Returns the 8-bit data stored in the Independent Data(ID) register |
mbed_official | 155:8435094ec241 | 340 | * @param None |
mbed_official | 155:8435094ec241 | 341 | * @retval 8-bit value of the ID register |
mbed_official | 155:8435094ec241 | 342 | */ |
mbed_official | 155:8435094ec241 | 343 | uint8_t CRC_GetIDRegister(void) |
mbed_official | 155:8435094ec241 | 344 | { |
mbed_official | 155:8435094ec241 | 345 | return (CRC->IDR); |
mbed_official | 155:8435094ec241 | 346 | } |
mbed_official | 155:8435094ec241 | 347 | |
mbed_official | 155:8435094ec241 | 348 | /** |
mbed_official | 155:8435094ec241 | 349 | * @} |
mbed_official | 155:8435094ec241 | 350 | */ |
mbed_official | 155:8435094ec241 | 351 | |
mbed_official | 155:8435094ec241 | 352 | /** |
mbed_official | 155:8435094ec241 | 353 | * @} |
mbed_official | 155:8435094ec241 | 354 | */ |
mbed_official | 155:8435094ec241 | 355 | |
mbed_official | 155:8435094ec241 | 356 | /** |
mbed_official | 155:8435094ec241 | 357 | * @} |
mbed_official | 155:8435094ec241 | 358 | */ |
mbed_official | 155:8435094ec241 | 359 | |
mbed_official | 155:8435094ec241 | 360 | /** |
mbed_official | 155:8435094ec241 | 361 | * @} |
mbed_official | 155:8435094ec241 | 362 | */ |
mbed_official | 155:8435094ec241 | 363 | |
mbed_official | 155:8435094ec241 | 364 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |