mbed library sources
Dependents: frdm_kl05z_gpio_test
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_NUCLEO_F072RB/stm32f0xx_hal_crc_ex.c@205:c41fc65bcfb4, 2014-05-22 (annotated)
- Committer:
- mbed_official
- Date:
- Thu May 22 20:00:09 2014 +0100
- Revision:
- 205:c41fc65bcfb4
- Child:
- 218:44081b78fdc2
Synchronized with git revision ea4b6f76efab17a3f7d7777b0cc1ef05fec6d1cb
Full URL: https://github.com/mbedmicro/mbed/commit/ea4b6f76efab17a3f7d7777b0cc1ef05fec6d1cb/
[NUCLEO_F072RB] cmsis files
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 205:c41fc65bcfb4 | 1 | /** |
mbed_official | 205:c41fc65bcfb4 | 2 | ****************************************************************************** |
mbed_official | 205:c41fc65bcfb4 | 3 | * @file stm32f0xx_hal_crc_ex.c |
mbed_official | 205:c41fc65bcfb4 | 4 | * @author MCD Application Team |
mbed_official | 205:c41fc65bcfb4 | 5 | * @version V1.0.0 |
mbed_official | 205:c41fc65bcfb4 | 6 | * @date 20-May-2014 |
mbed_official | 205:c41fc65bcfb4 | 7 | * @brief Extended CRC HAL module driver. |
mbed_official | 205:c41fc65bcfb4 | 8 | * |
mbed_official | 205:c41fc65bcfb4 | 9 | * This file provides firmware functions to manage the following |
mbed_official | 205:c41fc65bcfb4 | 10 | * functionalities of the CRC peripheral: |
mbed_official | 205:c41fc65bcfb4 | 11 | * + Extended initialization functions |
mbed_official | 205:c41fc65bcfb4 | 12 | * |
mbed_official | 205:c41fc65bcfb4 | 13 | @verbatim |
mbed_official | 205:c41fc65bcfb4 | 14 | ================================================================================ |
mbed_official | 205:c41fc65bcfb4 | 15 | ##### <Product specific features/integration> ##### |
mbed_official | 205:c41fc65bcfb4 | 16 | ================================================================================ |
mbed_official | 205:c41fc65bcfb4 | 17 | |
mbed_official | 205:c41fc65bcfb4 | 18 | |
mbed_official | 205:c41fc65bcfb4 | 19 | ##### How to use this driver ##### |
mbed_official | 205:c41fc65bcfb4 | 20 | ================================================================================ |
mbed_official | 205:c41fc65bcfb4 | 21 | [..] |
mbed_official | 205:c41fc65bcfb4 | 22 | (+) Extended initialization |
mbed_official | 205:c41fc65bcfb4 | 23 | (+) Set or not user-defined generating |
mbed_official | 205:c41fc65bcfb4 | 24 | polynomial other than default one |
mbed_official | 205:c41fc65bcfb4 | 25 | |
mbed_official | 205:c41fc65bcfb4 | 26 | @endverbatim |
mbed_official | 205:c41fc65bcfb4 | 27 | ****************************************************************************** |
mbed_official | 205:c41fc65bcfb4 | 28 | * @attention |
mbed_official | 205:c41fc65bcfb4 | 29 | * |
mbed_official | 205:c41fc65bcfb4 | 30 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
mbed_official | 205:c41fc65bcfb4 | 31 | * |
mbed_official | 205:c41fc65bcfb4 | 32 | * Redistribution and use in source and binary forms, with or without modification, |
mbed_official | 205:c41fc65bcfb4 | 33 | * are permitted provided that the following conditions are met: |
mbed_official | 205:c41fc65bcfb4 | 34 | * 1. Redistributions of source code must retain the above copyright notice, |
mbed_official | 205:c41fc65bcfb4 | 35 | * this list of conditions and the following disclaimer. |
mbed_official | 205:c41fc65bcfb4 | 36 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mbed_official | 205:c41fc65bcfb4 | 37 | * this list of conditions and the following disclaimer in the documentation |
mbed_official | 205:c41fc65bcfb4 | 38 | * and/or other materials provided with the distribution. |
mbed_official | 205:c41fc65bcfb4 | 39 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
mbed_official | 205:c41fc65bcfb4 | 40 | * may be used to endorse or promote products derived from this software |
mbed_official | 205:c41fc65bcfb4 | 41 | * without specific prior written permission. |
mbed_official | 205:c41fc65bcfb4 | 42 | * |
mbed_official | 205:c41fc65bcfb4 | 43 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 205:c41fc65bcfb4 | 44 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 205:c41fc65bcfb4 | 45 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
mbed_official | 205:c41fc65bcfb4 | 46 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
mbed_official | 205:c41fc65bcfb4 | 47 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mbed_official | 205:c41fc65bcfb4 | 48 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
mbed_official | 205:c41fc65bcfb4 | 49 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mbed_official | 205:c41fc65bcfb4 | 50 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
mbed_official | 205:c41fc65bcfb4 | 51 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
mbed_official | 205:c41fc65bcfb4 | 52 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 205:c41fc65bcfb4 | 53 | * |
mbed_official | 205:c41fc65bcfb4 | 54 | ****************************************************************************** |
mbed_official | 205:c41fc65bcfb4 | 55 | */ |
mbed_official | 205:c41fc65bcfb4 | 56 | |
mbed_official | 205:c41fc65bcfb4 | 57 | /* Includes ------------------------------------------------------------------*/ |
mbed_official | 205:c41fc65bcfb4 | 58 | #include "stm32f0xx_hal.h" |
mbed_official | 205:c41fc65bcfb4 | 59 | |
mbed_official | 205:c41fc65bcfb4 | 60 | /** @addtogroup STM32F0xx_HAL_Driver |
mbed_official | 205:c41fc65bcfb4 | 61 | * @{ |
mbed_official | 205:c41fc65bcfb4 | 62 | */ |
mbed_official | 205:c41fc65bcfb4 | 63 | |
mbed_official | 205:c41fc65bcfb4 | 64 | /** @defgroup CRCEx |
mbed_official | 205:c41fc65bcfb4 | 65 | * @brief CRC Extended HAL module driver |
mbed_official | 205:c41fc65bcfb4 | 66 | * @{ |
mbed_official | 205:c41fc65bcfb4 | 67 | */ |
mbed_official | 205:c41fc65bcfb4 | 68 | |
mbed_official | 205:c41fc65bcfb4 | 69 | #ifdef HAL_CRC_MODULE_ENABLED |
mbed_official | 205:c41fc65bcfb4 | 70 | |
mbed_official | 205:c41fc65bcfb4 | 71 | /* Private typedef -----------------------------------------------------------*/ |
mbed_official | 205:c41fc65bcfb4 | 72 | /* Private define ------------------------------------------------------------*/ |
mbed_official | 205:c41fc65bcfb4 | 73 | /* Private macro -------------------------------------------------------------*/ |
mbed_official | 205:c41fc65bcfb4 | 74 | /* Private variables ---------------------------------------------------------*/ |
mbed_official | 205:c41fc65bcfb4 | 75 | /* Private function prototypes -----------------------------------------------*/ |
mbed_official | 205:c41fc65bcfb4 | 76 | /* Private functions ---------------------------------------------------------*/ |
mbed_official | 205:c41fc65bcfb4 | 77 | |
mbed_official | 205:c41fc65bcfb4 | 78 | /** @defgroup CRCEx_Private_Functions |
mbed_official | 205:c41fc65bcfb4 | 79 | * @{ |
mbed_official | 205:c41fc65bcfb4 | 80 | */ |
mbed_official | 205:c41fc65bcfb4 | 81 | |
mbed_official | 205:c41fc65bcfb4 | 82 | /** @defgroup CRCEx_Group1 Extended Initialization/de-initialization functions |
mbed_official | 205:c41fc65bcfb4 | 83 | * @brief Extended Initialization and Configuration functions. |
mbed_official | 205:c41fc65bcfb4 | 84 | * |
mbed_official | 205:c41fc65bcfb4 | 85 | @verbatim |
mbed_official | 205:c41fc65bcfb4 | 86 | =============================================================================== |
mbed_official | 205:c41fc65bcfb4 | 87 | ##### Initialization/de-initialization function ##### |
mbed_official | 205:c41fc65bcfb4 | 88 | =============================================================================== |
mbed_official | 205:c41fc65bcfb4 | 89 | [..] This section provides functions allowing to: |
mbed_official | 205:c41fc65bcfb4 | 90 | (+) Initialize the CRC generating polynomial: if programmable polynomial |
mbed_official | 205:c41fc65bcfb4 | 91 | feature is applicable to device, set default or non-default generating |
mbed_official | 205:c41fc65bcfb4 | 92 | polynomial according to hcrc->Init.DefaultPolynomialUse parameter. |
mbed_official | 205:c41fc65bcfb4 | 93 | If feature is non-applicable to device in use, HAL_CRCEx_Init straight |
mbed_official | 205:c41fc65bcfb4 | 94 | away reports HAL_OK. |
mbed_official | 205:c41fc65bcfb4 | 95 | (+) Set the generating polynomial |
mbed_official | 205:c41fc65bcfb4 | 96 | |
mbed_official | 205:c41fc65bcfb4 | 97 | @endverbatim |
mbed_official | 205:c41fc65bcfb4 | 98 | * @{ |
mbed_official | 205:c41fc65bcfb4 | 99 | */ |
mbed_official | 205:c41fc65bcfb4 | 100 | |
mbed_official | 205:c41fc65bcfb4 | 101 | |
mbed_official | 205:c41fc65bcfb4 | 102 | /** |
mbed_official | 205:c41fc65bcfb4 | 103 | * @brief Extended initialization to set generating polynomial |
mbed_official | 205:c41fc65bcfb4 | 104 | * @param hcrc: CRC handle |
mbed_official | 205:c41fc65bcfb4 | 105 | * @retval HAL status |
mbed_official | 205:c41fc65bcfb4 | 106 | */ |
mbed_official | 205:c41fc65bcfb4 | 107 | HAL_StatusTypeDef HAL_CRCEx_Init(CRC_HandleTypeDef *hcrc) |
mbed_official | 205:c41fc65bcfb4 | 108 | { |
mbed_official | 205:c41fc65bcfb4 | 109 | #if defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) |
mbed_official | 205:c41fc65bcfb4 | 110 | /* check whether or not non-default generating polynomial has been |
mbed_official | 205:c41fc65bcfb4 | 111 | * picked up by user */ |
mbed_official | 205:c41fc65bcfb4 | 112 | assert_param(IS_DEFAULT_POLYNOMIAL(hcrc->Init.DefaultPolynomialUse)); |
mbed_official | 205:c41fc65bcfb4 | 113 | if (hcrc->Init.DefaultPolynomialUse == DEFAULT_POLYNOMIAL_ENABLE) |
mbed_official | 205:c41fc65bcfb4 | 114 | { |
mbed_official | 205:c41fc65bcfb4 | 115 | /* initialize IP with default generating polynomial */ |
mbed_official | 205:c41fc65bcfb4 | 116 | WRITE_REG(hcrc->Instance->POL, DEFAULT_CRC32_POLY); |
mbed_official | 205:c41fc65bcfb4 | 117 | MODIFY_REG(hcrc->Instance->CR, CRC_CR_POLYSIZE, CRC_POLYLENGTH_32B); |
mbed_official | 205:c41fc65bcfb4 | 118 | } |
mbed_official | 205:c41fc65bcfb4 | 119 | else |
mbed_official | 205:c41fc65bcfb4 | 120 | { |
mbed_official | 205:c41fc65bcfb4 | 121 | /* initialize CRC IP with generating polynomial defined by user */ |
mbed_official | 205:c41fc65bcfb4 | 122 | if (HAL_CRCEx_Polynomial_Set(hcrc, hcrc->Init.GeneratingPolynomial, hcrc->Init.CRCLength) != HAL_OK) |
mbed_official | 205:c41fc65bcfb4 | 123 | { |
mbed_official | 205:c41fc65bcfb4 | 124 | return HAL_ERROR; |
mbed_official | 205:c41fc65bcfb4 | 125 | } |
mbed_official | 205:c41fc65bcfb4 | 126 | } |
mbed_official | 205:c41fc65bcfb4 | 127 | #endif /* defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) */ |
mbed_official | 205:c41fc65bcfb4 | 128 | |
mbed_official | 205:c41fc65bcfb4 | 129 | return HAL_OK; |
mbed_official | 205:c41fc65bcfb4 | 130 | } |
mbed_official | 205:c41fc65bcfb4 | 131 | |
mbed_official | 205:c41fc65bcfb4 | 132 | /** |
mbed_official | 205:c41fc65bcfb4 | 133 | * @brief Set the Reverse Input data mode. |
mbed_official | 205:c41fc65bcfb4 | 134 | * @param hcrc: CRC handle |
mbed_official | 205:c41fc65bcfb4 | 135 | * @param InputReverseMode: Input Data inversion mode |
mbed_official | 205:c41fc65bcfb4 | 136 | * This parameter can be one of the following values: |
mbed_official | 205:c41fc65bcfb4 | 137 | * @arg CRC_INPUTDATA_NOINVERSION: no change in bit order (default value) |
mbed_official | 205:c41fc65bcfb4 | 138 | * @arg CRC_INPUTDATA_INVERSION_BYTE: Byte-wise bit reversal |
mbed_official | 205:c41fc65bcfb4 | 139 | * @arg CRC_INPUTDATA_INVERSION_HALFWORD: HalfWord-wise bit reversal |
mbed_official | 205:c41fc65bcfb4 | 140 | * @arg CRC_INPUTDATA_INVERSION_WORD: Word-wise bit reversal |
mbed_official | 205:c41fc65bcfb4 | 141 | * @retval HAL status |
mbed_official | 205:c41fc65bcfb4 | 142 | */ |
mbed_official | 205:c41fc65bcfb4 | 143 | HAL_StatusTypeDef HAL_CRCEx_Input_Data_Reverse(CRC_HandleTypeDef *hcrc, uint32_t InputReverseMode) |
mbed_official | 205:c41fc65bcfb4 | 144 | { |
mbed_official | 205:c41fc65bcfb4 | 145 | /* Check the parameters */ |
mbed_official | 205:c41fc65bcfb4 | 146 | assert_param(IS_CRC_INPUTDATA_INVERSION_MODE(InputReverseMode)); |
mbed_official | 205:c41fc65bcfb4 | 147 | |
mbed_official | 205:c41fc65bcfb4 | 148 | /* Change CRC peripheral state */ |
mbed_official | 205:c41fc65bcfb4 | 149 | hcrc->State = HAL_CRC_STATE_BUSY; |
mbed_official | 205:c41fc65bcfb4 | 150 | |
mbed_official | 205:c41fc65bcfb4 | 151 | /* set input data inversion mode */ |
mbed_official | 205:c41fc65bcfb4 | 152 | MODIFY_REG(hcrc->Instance->CR, CRC_CR_REV_IN, InputReverseMode); |
mbed_official | 205:c41fc65bcfb4 | 153 | /* Change CRC peripheral state */ |
mbed_official | 205:c41fc65bcfb4 | 154 | hcrc->State = HAL_CRC_STATE_READY; |
mbed_official | 205:c41fc65bcfb4 | 155 | |
mbed_official | 205:c41fc65bcfb4 | 156 | /* Return function status */ |
mbed_official | 205:c41fc65bcfb4 | 157 | return HAL_OK; |
mbed_official | 205:c41fc65bcfb4 | 158 | } |
mbed_official | 205:c41fc65bcfb4 | 159 | |
mbed_official | 205:c41fc65bcfb4 | 160 | /** |
mbed_official | 205:c41fc65bcfb4 | 161 | * @brief Set the Reverse Output data mode. |
mbed_official | 205:c41fc65bcfb4 | 162 | * @param hcrc: CRC handle |
mbed_official | 205:c41fc65bcfb4 | 163 | * @param OutputReverseMode: Output Data inversion mode |
mbed_official | 205:c41fc65bcfb4 | 164 | * This parameter can be one of the following values: |
mbed_official | 205:c41fc65bcfb4 | 165 | * @arg CRC_OUTPUTDATA_INVERSION_DISABLED: no CRC inversion (default value) |
mbed_official | 205:c41fc65bcfb4 | 166 | * @arg CRC_OUTPUTDATA_INVERSION_ENABLED: bit-level inversion (e.g for a 8-bit CRC: 0xB5 becomes 0xAD) |
mbed_official | 205:c41fc65bcfb4 | 167 | * @retval HAL status |
mbed_official | 205:c41fc65bcfb4 | 168 | */ |
mbed_official | 205:c41fc65bcfb4 | 169 | HAL_StatusTypeDef HAL_CRCEx_Output_Data_Reverse(CRC_HandleTypeDef *hcrc, uint32_t OutputReverseMode) |
mbed_official | 205:c41fc65bcfb4 | 170 | { |
mbed_official | 205:c41fc65bcfb4 | 171 | /* Check the parameters */ |
mbed_official | 205:c41fc65bcfb4 | 172 | assert_param(IS_CRC_OUTPUTDATA_INVERSION_MODE(OutputReverseMode)); |
mbed_official | 205:c41fc65bcfb4 | 173 | |
mbed_official | 205:c41fc65bcfb4 | 174 | /* Change CRC peripheral state */ |
mbed_official | 205:c41fc65bcfb4 | 175 | hcrc->State = HAL_CRC_STATE_BUSY; |
mbed_official | 205:c41fc65bcfb4 | 176 | |
mbed_official | 205:c41fc65bcfb4 | 177 | /* set output data inversion mode */ |
mbed_official | 205:c41fc65bcfb4 | 178 | MODIFY_REG(hcrc->Instance->CR, CRC_CR_REV_OUT, OutputReverseMode); |
mbed_official | 205:c41fc65bcfb4 | 179 | |
mbed_official | 205:c41fc65bcfb4 | 180 | /* Change CRC peripheral state */ |
mbed_official | 205:c41fc65bcfb4 | 181 | hcrc->State = HAL_CRC_STATE_READY; |
mbed_official | 205:c41fc65bcfb4 | 182 | |
mbed_official | 205:c41fc65bcfb4 | 183 | /* Return function status */ |
mbed_official | 205:c41fc65bcfb4 | 184 | return HAL_OK; |
mbed_official | 205:c41fc65bcfb4 | 185 | } |
mbed_official | 205:c41fc65bcfb4 | 186 | |
mbed_official | 205:c41fc65bcfb4 | 187 | #if defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) |
mbed_official | 205:c41fc65bcfb4 | 188 | /** |
mbed_official | 205:c41fc65bcfb4 | 189 | * @brief Initializes the CRC polynomial if different from default one. |
mbed_official | 205:c41fc65bcfb4 | 190 | * @param hcrc: CRC handle |
mbed_official | 205:c41fc65bcfb4 | 191 | * @param Pol: CRC generating polynomial (7, 8, 16 or 32-bit long) |
mbed_official | 205:c41fc65bcfb4 | 192 | * This parameter is written in normal representation, e.g. |
mbed_official | 205:c41fc65bcfb4 | 193 | * for a polynomial of degree 7, X^7 + X^6 + X^5 + X^2 + 1 is written 0x65 |
mbed_official | 205:c41fc65bcfb4 | 194 | * for a polynomial of degree 16, X^16 + X^12 + X^5 + 1 is written 0x1021 |
mbed_official | 205:c41fc65bcfb4 | 195 | * @param PolyLength: CRC polynomial length |
mbed_official | 205:c41fc65bcfb4 | 196 | * This parameter can be one of the following values: |
mbed_official | 205:c41fc65bcfb4 | 197 | * @arg CRC_POLYLENGTH_7B: 7-bit long CRC (generating polynomial of degree 7) |
mbed_official | 205:c41fc65bcfb4 | 198 | * @arg CRC_POLYLENGTH_8B: 8-bit long CRC (generating polynomial of degree 8) |
mbed_official | 205:c41fc65bcfb4 | 199 | * @arg CRC_POLYLENGTH_16B: 16-bit long CRC (generating polynomial of degree 16) |
mbed_official | 205:c41fc65bcfb4 | 200 | * @arg CRC_POLYLENGTH_32B: 32-bit long CRC (generating polynomial of degree 32) |
mbed_official | 205:c41fc65bcfb4 | 201 | * @retval HAL status |
mbed_official | 205:c41fc65bcfb4 | 202 | */ |
mbed_official | 205:c41fc65bcfb4 | 203 | HAL_StatusTypeDef HAL_CRCEx_Polynomial_Set(CRC_HandleTypeDef *hcrc, uint32_t Pol, uint32_t PolyLength) |
mbed_official | 205:c41fc65bcfb4 | 204 | { |
mbed_official | 205:c41fc65bcfb4 | 205 | uint32_t msb = 31; /* polynomial degree is 32 at most, so msb is initialized to max value */ |
mbed_official | 205:c41fc65bcfb4 | 206 | |
mbed_official | 205:c41fc65bcfb4 | 207 | /* Check the parameters */ |
mbed_official | 205:c41fc65bcfb4 | 208 | assert_param(IS_CRC_POL_LENGTH(PolyLength)); |
mbed_official | 205:c41fc65bcfb4 | 209 | |
mbed_official | 205:c41fc65bcfb4 | 210 | /* check polynomial definition vs polynomial size: |
mbed_official | 205:c41fc65bcfb4 | 211 | * polynomial length must be aligned with polynomial |
mbed_official | 205:c41fc65bcfb4 | 212 | * definition. HAL_ERROR is reported if Pol degree is |
mbed_official | 205:c41fc65bcfb4 | 213 | * larger than that indicated by PolyLength. |
mbed_official | 205:c41fc65bcfb4 | 214 | * Look for MSB position: msb will contain the degree of |
mbed_official | 205:c41fc65bcfb4 | 215 | * the second to the largest polynomial member. E.g., for |
mbed_official | 205:c41fc65bcfb4 | 216 | * X^7 + X^6 + X^5 + X^2 + 1, msb = 6. */ |
mbed_official | 205:c41fc65bcfb4 | 217 | while (((Pol & (0x1 << msb)) == 0) && (msb-- > 0)); |
mbed_official | 205:c41fc65bcfb4 | 218 | |
mbed_official | 205:c41fc65bcfb4 | 219 | switch (PolyLength) |
mbed_official | 205:c41fc65bcfb4 | 220 | { |
mbed_official | 205:c41fc65bcfb4 | 221 | case CRC_POLYLENGTH_7B: |
mbed_official | 205:c41fc65bcfb4 | 222 | if (msb >= HAL_CRC_LENGTH_7B) |
mbed_official | 205:c41fc65bcfb4 | 223 | { |
mbed_official | 205:c41fc65bcfb4 | 224 | return HAL_ERROR; |
mbed_official | 205:c41fc65bcfb4 | 225 | } |
mbed_official | 205:c41fc65bcfb4 | 226 | break; |
mbed_official | 205:c41fc65bcfb4 | 227 | case CRC_POLYLENGTH_8B: |
mbed_official | 205:c41fc65bcfb4 | 228 | if (msb >= HAL_CRC_LENGTH_8B) |
mbed_official | 205:c41fc65bcfb4 | 229 | { |
mbed_official | 205:c41fc65bcfb4 | 230 | return HAL_ERROR; |
mbed_official | 205:c41fc65bcfb4 | 231 | } |
mbed_official | 205:c41fc65bcfb4 | 232 | break; |
mbed_official | 205:c41fc65bcfb4 | 233 | case CRC_POLYLENGTH_16B: |
mbed_official | 205:c41fc65bcfb4 | 234 | if (msb >= HAL_CRC_LENGTH_16B) |
mbed_official | 205:c41fc65bcfb4 | 235 | { |
mbed_official | 205:c41fc65bcfb4 | 236 | return HAL_ERROR; |
mbed_official | 205:c41fc65bcfb4 | 237 | } |
mbed_official | 205:c41fc65bcfb4 | 238 | break; |
mbed_official | 205:c41fc65bcfb4 | 239 | case CRC_POLYLENGTH_32B: |
mbed_official | 205:c41fc65bcfb4 | 240 | /* no polynomial definition vs. polynomial length issue possible */ |
mbed_official | 205:c41fc65bcfb4 | 241 | break; |
mbed_official | 205:c41fc65bcfb4 | 242 | default: |
mbed_official | 205:c41fc65bcfb4 | 243 | break; |
mbed_official | 205:c41fc65bcfb4 | 244 | } |
mbed_official | 205:c41fc65bcfb4 | 245 | |
mbed_official | 205:c41fc65bcfb4 | 246 | /* set generating polynomial */ |
mbed_official | 205:c41fc65bcfb4 | 247 | WRITE_REG(hcrc->Instance->POL, Pol); |
mbed_official | 205:c41fc65bcfb4 | 248 | |
mbed_official | 205:c41fc65bcfb4 | 249 | /* set generating polynomial size */ |
mbed_official | 205:c41fc65bcfb4 | 250 | MODIFY_REG(hcrc->Instance->CR, CRC_CR_POLYSIZE, PolyLength); |
mbed_official | 205:c41fc65bcfb4 | 251 | |
mbed_official | 205:c41fc65bcfb4 | 252 | /* Return function status */ |
mbed_official | 205:c41fc65bcfb4 | 253 | return HAL_OK; |
mbed_official | 205:c41fc65bcfb4 | 254 | } |
mbed_official | 205:c41fc65bcfb4 | 255 | #endif /* #if defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) */ |
mbed_official | 205:c41fc65bcfb4 | 256 | |
mbed_official | 205:c41fc65bcfb4 | 257 | /** |
mbed_official | 205:c41fc65bcfb4 | 258 | * @} |
mbed_official | 205:c41fc65bcfb4 | 259 | */ |
mbed_official | 205:c41fc65bcfb4 | 260 | |
mbed_official | 205:c41fc65bcfb4 | 261 | |
mbed_official | 205:c41fc65bcfb4 | 262 | /** |
mbed_official | 205:c41fc65bcfb4 | 263 | * @} |
mbed_official | 205:c41fc65bcfb4 | 264 | */ |
mbed_official | 205:c41fc65bcfb4 | 265 | |
mbed_official | 205:c41fc65bcfb4 | 266 | |
mbed_official | 205:c41fc65bcfb4 | 267 | #endif /* HAL_CRC_MODULE_ENABLED */ |
mbed_official | 205:c41fc65bcfb4 | 268 | /** |
mbed_official | 205:c41fc65bcfb4 | 269 | * @} |
mbed_official | 205:c41fc65bcfb4 | 270 | */ |
mbed_official | 205:c41fc65bcfb4 | 271 | |
mbed_official | 205:c41fc65bcfb4 | 272 | /** |
mbed_official | 205:c41fc65bcfb4 | 273 | * @} |
mbed_official | 205:c41fc65bcfb4 | 274 | */ |
mbed_official | 205:c41fc65bcfb4 | 275 | |
mbed_official | 205:c41fc65bcfb4 | 276 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |