mbed library sources. Supersedes mbed-src.
Dependents: Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more
targets/TARGET_STM/TARGET_STM32L0/device/stm32l0xx_ll_crc.h@158:b23ee177fd68, 2017-02-14 (annotated)
- Committer:
- Kojto
- Date:
- Tue Feb 14 14:44:10 2017 +0000
- Revision:
- 158:b23ee177fd68
- Child:
- 186:707f6e361f3e
This updates the lib to the mbed lib v136
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Kojto | 158:b23ee177fd68 | 1 | /** |
Kojto | 158:b23ee177fd68 | 2 | ****************************************************************************** |
Kojto | 158:b23ee177fd68 | 3 | * @file stm32l0xx_ll_crc.h |
Kojto | 158:b23ee177fd68 | 4 | * @author MCD Application Team |
Kojto | 158:b23ee177fd68 | 5 | * @version V1.7.0 |
Kojto | 158:b23ee177fd68 | 6 | * @date 31-May-2016 |
Kojto | 158:b23ee177fd68 | 7 | * @brief Header file of CRC LL module. |
Kojto | 158:b23ee177fd68 | 8 | ****************************************************************************** |
Kojto | 158:b23ee177fd68 | 9 | * @attention |
Kojto | 158:b23ee177fd68 | 10 | * |
Kojto | 158:b23ee177fd68 | 11 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
Kojto | 158:b23ee177fd68 | 12 | * |
Kojto | 158:b23ee177fd68 | 13 | * Redistribution and use in source and binary forms, with or without modification, |
Kojto | 158:b23ee177fd68 | 14 | * are permitted provided that the following conditions are met: |
Kojto | 158:b23ee177fd68 | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
Kojto | 158:b23ee177fd68 | 16 | * this list of conditions and the following disclaimer. |
Kojto | 158:b23ee177fd68 | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
Kojto | 158:b23ee177fd68 | 18 | * this list of conditions and the following disclaimer in the documentation |
Kojto | 158:b23ee177fd68 | 19 | * and/or other materials provided with the distribution. |
Kojto | 158:b23ee177fd68 | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
Kojto | 158:b23ee177fd68 | 21 | * may be used to endorse or promote products derived from this software |
Kojto | 158:b23ee177fd68 | 22 | * without specific prior written permission. |
Kojto | 158:b23ee177fd68 | 23 | * |
Kojto | 158:b23ee177fd68 | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
Kojto | 158:b23ee177fd68 | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
Kojto | 158:b23ee177fd68 | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
Kojto | 158:b23ee177fd68 | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
Kojto | 158:b23ee177fd68 | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
Kojto | 158:b23ee177fd68 | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
Kojto | 158:b23ee177fd68 | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
Kojto | 158:b23ee177fd68 | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
Kojto | 158:b23ee177fd68 | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
Kojto | 158:b23ee177fd68 | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Kojto | 158:b23ee177fd68 | 34 | * |
Kojto | 158:b23ee177fd68 | 35 | ****************************************************************************** |
Kojto | 158:b23ee177fd68 | 36 | */ |
Kojto | 158:b23ee177fd68 | 37 | |
Kojto | 158:b23ee177fd68 | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ |
Kojto | 158:b23ee177fd68 | 39 | #ifndef __STM32L0xx_LL_CRC_H |
Kojto | 158:b23ee177fd68 | 40 | #define __STM32L0xx_LL_CRC_H |
Kojto | 158:b23ee177fd68 | 41 | |
Kojto | 158:b23ee177fd68 | 42 | #ifdef __cplusplus |
Kojto | 158:b23ee177fd68 | 43 | extern "C" { |
Kojto | 158:b23ee177fd68 | 44 | #endif |
Kojto | 158:b23ee177fd68 | 45 | |
Kojto | 158:b23ee177fd68 | 46 | /* Includes ------------------------------------------------------------------*/ |
Kojto | 158:b23ee177fd68 | 47 | #include "stm32l0xx.h" |
Kojto | 158:b23ee177fd68 | 48 | |
Kojto | 158:b23ee177fd68 | 49 | /** @addtogroup STM32L0xx_LL_Driver |
Kojto | 158:b23ee177fd68 | 50 | * @{ |
Kojto | 158:b23ee177fd68 | 51 | */ |
Kojto | 158:b23ee177fd68 | 52 | |
Kojto | 158:b23ee177fd68 | 53 | #if defined(CRC) |
Kojto | 158:b23ee177fd68 | 54 | |
Kojto | 158:b23ee177fd68 | 55 | /** @defgroup CRC_LL CRC |
Kojto | 158:b23ee177fd68 | 56 | * @{ |
Kojto | 158:b23ee177fd68 | 57 | */ |
Kojto | 158:b23ee177fd68 | 58 | |
Kojto | 158:b23ee177fd68 | 59 | /* Private types -------------------------------------------------------------*/ |
Kojto | 158:b23ee177fd68 | 60 | /* Private variables ---------------------------------------------------------*/ |
Kojto | 158:b23ee177fd68 | 61 | /* Private constants ---------------------------------------------------------*/ |
Kojto | 158:b23ee177fd68 | 62 | /* Private macros ------------------------------------------------------------*/ |
Kojto | 158:b23ee177fd68 | 63 | |
Kojto | 158:b23ee177fd68 | 64 | /* Exported types ------------------------------------------------------------*/ |
Kojto | 158:b23ee177fd68 | 65 | /* Exported constants --------------------------------------------------------*/ |
Kojto | 158:b23ee177fd68 | 66 | /** @defgroup CRC_LL_Exported_Constants CRC Exported Constants |
Kojto | 158:b23ee177fd68 | 67 | * @{ |
Kojto | 158:b23ee177fd68 | 68 | */ |
Kojto | 158:b23ee177fd68 | 69 | |
Kojto | 158:b23ee177fd68 | 70 | /** @defgroup CRC_LL_EC_POLYLENGTH Polynomial length |
Kojto | 158:b23ee177fd68 | 71 | * @{ |
Kojto | 158:b23ee177fd68 | 72 | */ |
Kojto | 158:b23ee177fd68 | 73 | #define LL_CRC_POLYLENGTH_32B (uint32_t)0x00000000U /*!< 32 bits Polynomial size */ |
Kojto | 158:b23ee177fd68 | 74 | #define LL_CRC_POLYLENGTH_16B CRC_CR_POLYSIZE_0 /*!< 16 bits Polynomial size */ |
Kojto | 158:b23ee177fd68 | 75 | #define LL_CRC_POLYLENGTH_8B CRC_CR_POLYSIZE_1 /*!< 8 bits Polynomial size */ |
Kojto | 158:b23ee177fd68 | 76 | #define LL_CRC_POLYLENGTH_7B (CRC_CR_POLYSIZE_1 | CRC_CR_POLYSIZE_0) /*!< 7 bits Polynomial size */ |
Kojto | 158:b23ee177fd68 | 77 | /** |
Kojto | 158:b23ee177fd68 | 78 | * @} |
Kojto | 158:b23ee177fd68 | 79 | */ |
Kojto | 158:b23ee177fd68 | 80 | |
Kojto | 158:b23ee177fd68 | 81 | /** @defgroup CRC_LL_EC_INDATA_REVERSE Input Data Reverse |
Kojto | 158:b23ee177fd68 | 82 | * @{ |
Kojto | 158:b23ee177fd68 | 83 | */ |
Kojto | 158:b23ee177fd68 | 84 | #define LL_CRC_INDATA_REVERSE_NONE (uint32_t)0x00000000U /*!< Input Data bit order not affected */ |
Kojto | 158:b23ee177fd68 | 85 | #define LL_CRC_INDATA_REVERSE_BYTE CRC_CR_REV_IN_0 /*!< Input Data bit reversal done by byte */ |
Kojto | 158:b23ee177fd68 | 86 | #define LL_CRC_INDATA_REVERSE_HALFWORD CRC_CR_REV_IN_1 /*!< Input Data bit reversal done by half-word */ |
Kojto | 158:b23ee177fd68 | 87 | #define LL_CRC_INDATA_REVERSE_WORD (CRC_CR_REV_IN_1 | CRC_CR_REV_IN_0) /*!< Input Data bit reversal done by word */ |
Kojto | 158:b23ee177fd68 | 88 | /** |
Kojto | 158:b23ee177fd68 | 89 | * @} |
Kojto | 158:b23ee177fd68 | 90 | */ |
Kojto | 158:b23ee177fd68 | 91 | |
Kojto | 158:b23ee177fd68 | 92 | /** @defgroup CRC_LL_EC_OUTDATA_REVERSE Output Data Reverse |
Kojto | 158:b23ee177fd68 | 93 | * @{ |
Kojto | 158:b23ee177fd68 | 94 | */ |
Kojto | 158:b23ee177fd68 | 95 | #define LL_CRC_OUTDATA_REVERSE_NONE (uint32_t)0x00000000U /*!< Output Data bit order not affected */ |
Kojto | 158:b23ee177fd68 | 96 | #define LL_CRC_OUTDATA_REVERSE_BIT CRC_CR_REV_OUT /*!< Output Data bit reversal done by bit */ |
Kojto | 158:b23ee177fd68 | 97 | /** |
Kojto | 158:b23ee177fd68 | 98 | * @} |
Kojto | 158:b23ee177fd68 | 99 | */ |
Kojto | 158:b23ee177fd68 | 100 | |
Kojto | 158:b23ee177fd68 | 101 | /** @defgroup CRC_LL_EC_Default_Polynomial_Value Default CRC generating polynomial value |
Kojto | 158:b23ee177fd68 | 102 | * @brief Normal representation of this polynomial value is |
Kojto | 158:b23ee177fd68 | 103 | * X^32 + X^26 + X^23 + X^22 + X^16 + X^12 + X^11 + X^10 +X^8 + X^7 + X^5 + X^4 + X^2 + X + 1 . |
Kojto | 158:b23ee177fd68 | 104 | * @{ |
Kojto | 158:b23ee177fd68 | 105 | */ |
Kojto | 158:b23ee177fd68 | 106 | #define LL_CRC_DEFAULT_CRC32_POLY (uint32_t)0x04C11DB7U /*!< Default CRC generating polynomial value */ |
Kojto | 158:b23ee177fd68 | 107 | /** |
Kojto | 158:b23ee177fd68 | 108 | * @} |
Kojto | 158:b23ee177fd68 | 109 | */ |
Kojto | 158:b23ee177fd68 | 110 | |
Kojto | 158:b23ee177fd68 | 111 | /** @defgroup CRC_LL_EC_Default_InitValue Default CRC computation initialization value |
Kojto | 158:b23ee177fd68 | 112 | * @{ |
Kojto | 158:b23ee177fd68 | 113 | */ |
Kojto | 158:b23ee177fd68 | 114 | #define LL_CRC_DEFAULT_CRC_INITVALUE (uint32_t)0xFFFFFFFFU /*!< Default CRC computation initialization value */ |
Kojto | 158:b23ee177fd68 | 115 | /** |
Kojto | 158:b23ee177fd68 | 116 | * @} |
Kojto | 158:b23ee177fd68 | 117 | */ |
Kojto | 158:b23ee177fd68 | 118 | |
Kojto | 158:b23ee177fd68 | 119 | /** |
Kojto | 158:b23ee177fd68 | 120 | * @} |
Kojto | 158:b23ee177fd68 | 121 | */ |
Kojto | 158:b23ee177fd68 | 122 | |
Kojto | 158:b23ee177fd68 | 123 | /* Exported macro ------------------------------------------------------------*/ |
Kojto | 158:b23ee177fd68 | 124 | /** @defgroup CRC_LL_Exported_Macros CRC Exported Macros |
Kojto | 158:b23ee177fd68 | 125 | * @{ |
Kojto | 158:b23ee177fd68 | 126 | */ |
Kojto | 158:b23ee177fd68 | 127 | |
Kojto | 158:b23ee177fd68 | 128 | /** @defgroup CRC_LL_EM_WRITE_READ Common Write and read registers Macros |
Kojto | 158:b23ee177fd68 | 129 | * @{ |
Kojto | 158:b23ee177fd68 | 130 | */ |
Kojto | 158:b23ee177fd68 | 131 | |
Kojto | 158:b23ee177fd68 | 132 | /** |
Kojto | 158:b23ee177fd68 | 133 | * @brief Write a value in CRC register |
Kojto | 158:b23ee177fd68 | 134 | * @param __INSTANCE__ CRC Instance |
Kojto | 158:b23ee177fd68 | 135 | * @param __REG__ Register to be written |
Kojto | 158:b23ee177fd68 | 136 | * @param __VALUE__ Value to be written in the register |
Kojto | 158:b23ee177fd68 | 137 | * @retval None |
Kojto | 158:b23ee177fd68 | 138 | */ |
Kojto | 158:b23ee177fd68 | 139 | #define LL_CRC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__)) |
Kojto | 158:b23ee177fd68 | 140 | |
Kojto | 158:b23ee177fd68 | 141 | /** |
Kojto | 158:b23ee177fd68 | 142 | * @brief Read a value in CRC register |
Kojto | 158:b23ee177fd68 | 143 | * @param __INSTANCE__ CRC Instance |
Kojto | 158:b23ee177fd68 | 144 | * @param __REG__ Register to be read |
Kojto | 158:b23ee177fd68 | 145 | * @retval Register value |
Kojto | 158:b23ee177fd68 | 146 | */ |
Kojto | 158:b23ee177fd68 | 147 | #define LL_CRC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__) |
Kojto | 158:b23ee177fd68 | 148 | /** |
Kojto | 158:b23ee177fd68 | 149 | * @} |
Kojto | 158:b23ee177fd68 | 150 | */ |
Kojto | 158:b23ee177fd68 | 151 | |
Kojto | 158:b23ee177fd68 | 152 | /** |
Kojto | 158:b23ee177fd68 | 153 | * @} |
Kojto | 158:b23ee177fd68 | 154 | */ |
Kojto | 158:b23ee177fd68 | 155 | |
Kojto | 158:b23ee177fd68 | 156 | |
Kojto | 158:b23ee177fd68 | 157 | /* Exported functions --------------------------------------------------------*/ |
Kojto | 158:b23ee177fd68 | 158 | /** @defgroup CRC_LL_Exported_Functions CRC Exported Functions |
Kojto | 158:b23ee177fd68 | 159 | * @{ |
Kojto | 158:b23ee177fd68 | 160 | */ |
Kojto | 158:b23ee177fd68 | 161 | |
Kojto | 158:b23ee177fd68 | 162 | /** @defgroup CRC_LL_EF_Configuration CRC Configuration functions |
Kojto | 158:b23ee177fd68 | 163 | * @{ |
Kojto | 158:b23ee177fd68 | 164 | */ |
Kojto | 158:b23ee177fd68 | 165 | |
Kojto | 158:b23ee177fd68 | 166 | /** |
Kojto | 158:b23ee177fd68 | 167 | * @brief Reset the CRC calculation unit. |
Kojto | 158:b23ee177fd68 | 168 | * @note If Programmable Initial CRC value feature |
Kojto | 158:b23ee177fd68 | 169 | * is available, also set the Data Register to the value stored in the |
Kojto | 158:b23ee177fd68 | 170 | * CRC_INIT register, otherwise, reset Data Register to its default value. |
Kojto | 158:b23ee177fd68 | 171 | * @rmtoll CR RESET LL_CRC_ResetCRCCalculationUnit |
Kojto | 158:b23ee177fd68 | 172 | * @param CRCx CRC Instance |
Kojto | 158:b23ee177fd68 | 173 | * @retval None |
Kojto | 158:b23ee177fd68 | 174 | */ |
Kojto | 158:b23ee177fd68 | 175 | __STATIC_INLINE void LL_CRC_ResetCRCCalculationUnit(CRC_TypeDef *CRCx) |
Kojto | 158:b23ee177fd68 | 176 | { |
Kojto | 158:b23ee177fd68 | 177 | SET_BIT(CRCx->CR, CRC_CR_RESET); |
Kojto | 158:b23ee177fd68 | 178 | } |
Kojto | 158:b23ee177fd68 | 179 | |
Kojto | 158:b23ee177fd68 | 180 | /** |
Kojto | 158:b23ee177fd68 | 181 | * @brief Configure size of the polynomial. |
Kojto | 158:b23ee177fd68 | 182 | * @rmtoll CR POLYSIZE LL_CRC_SetPolynomialSize |
Kojto | 158:b23ee177fd68 | 183 | * @param CRCx CRC Instance |
Kojto | 158:b23ee177fd68 | 184 | * @param PolySize This parameter can be one of the following values: |
Kojto | 158:b23ee177fd68 | 185 | * @arg @ref LL_CRC_POLYLENGTH_32B |
Kojto | 158:b23ee177fd68 | 186 | * @arg @ref LL_CRC_POLYLENGTH_16B |
Kojto | 158:b23ee177fd68 | 187 | * @arg @ref LL_CRC_POLYLENGTH_8B |
Kojto | 158:b23ee177fd68 | 188 | * @arg @ref LL_CRC_POLYLENGTH_7B |
Kojto | 158:b23ee177fd68 | 189 | * @retval None |
Kojto | 158:b23ee177fd68 | 190 | */ |
Kojto | 158:b23ee177fd68 | 191 | __STATIC_INLINE void LL_CRC_SetPolynomialSize(CRC_TypeDef *CRCx, uint32_t PolySize) |
Kojto | 158:b23ee177fd68 | 192 | { |
Kojto | 158:b23ee177fd68 | 193 | MODIFY_REG(CRCx->CR, CRC_CR_POLYSIZE, PolySize); |
Kojto | 158:b23ee177fd68 | 194 | } |
Kojto | 158:b23ee177fd68 | 195 | |
Kojto | 158:b23ee177fd68 | 196 | /** |
Kojto | 158:b23ee177fd68 | 197 | * @brief Return size of the polynomial. |
Kojto | 158:b23ee177fd68 | 198 | * @rmtoll CR POLYSIZE LL_CRC_GetPolynomialSize |
Kojto | 158:b23ee177fd68 | 199 | * @param CRCx CRC Instance |
Kojto | 158:b23ee177fd68 | 200 | * @retval Returned value can be one of the following values: |
Kojto | 158:b23ee177fd68 | 201 | * @arg @ref LL_CRC_POLYLENGTH_32B |
Kojto | 158:b23ee177fd68 | 202 | * @arg @ref LL_CRC_POLYLENGTH_16B |
Kojto | 158:b23ee177fd68 | 203 | * @arg @ref LL_CRC_POLYLENGTH_8B |
Kojto | 158:b23ee177fd68 | 204 | * @arg @ref LL_CRC_POLYLENGTH_7B |
Kojto | 158:b23ee177fd68 | 205 | */ |
Kojto | 158:b23ee177fd68 | 206 | __STATIC_INLINE uint32_t LL_CRC_GetPolynomialSize(CRC_TypeDef *CRCx) |
Kojto | 158:b23ee177fd68 | 207 | { |
Kojto | 158:b23ee177fd68 | 208 | return (uint32_t)(READ_BIT(CRCx->CR, CRC_CR_POLYSIZE)); |
Kojto | 158:b23ee177fd68 | 209 | } |
Kojto | 158:b23ee177fd68 | 210 | |
Kojto | 158:b23ee177fd68 | 211 | /** |
Kojto | 158:b23ee177fd68 | 212 | * @brief Configure the reversal of the bit order of the input data |
Kojto | 158:b23ee177fd68 | 213 | * @rmtoll CR REV_IN LL_CRC_SetInputDataReverseMode |
Kojto | 158:b23ee177fd68 | 214 | * @param CRCx CRC Instance |
Kojto | 158:b23ee177fd68 | 215 | * @param ReverseMode This parameter can be one of the following values: |
Kojto | 158:b23ee177fd68 | 216 | * @arg @ref LL_CRC_INDATA_REVERSE_NONE |
Kojto | 158:b23ee177fd68 | 217 | * @arg @ref LL_CRC_INDATA_REVERSE_BYTE |
Kojto | 158:b23ee177fd68 | 218 | * @arg @ref LL_CRC_INDATA_REVERSE_HALFWORD |
Kojto | 158:b23ee177fd68 | 219 | * @arg @ref LL_CRC_INDATA_REVERSE_WORD |
Kojto | 158:b23ee177fd68 | 220 | * @retval None |
Kojto | 158:b23ee177fd68 | 221 | */ |
Kojto | 158:b23ee177fd68 | 222 | __STATIC_INLINE void LL_CRC_SetInputDataReverseMode(CRC_TypeDef *CRCx, uint32_t ReverseMode) |
Kojto | 158:b23ee177fd68 | 223 | { |
Kojto | 158:b23ee177fd68 | 224 | MODIFY_REG(CRCx->CR, CRC_CR_REV_IN, ReverseMode); |
Kojto | 158:b23ee177fd68 | 225 | } |
Kojto | 158:b23ee177fd68 | 226 | |
Kojto | 158:b23ee177fd68 | 227 | /** |
Kojto | 158:b23ee177fd68 | 228 | * @brief Return type of reversal for input data bit order |
Kojto | 158:b23ee177fd68 | 229 | * @rmtoll CR REV_IN LL_CRC_GetInputDataReverseMode |
Kojto | 158:b23ee177fd68 | 230 | * @param CRCx CRC Instance |
Kojto | 158:b23ee177fd68 | 231 | * @retval Returned value can be one of the following values: |
Kojto | 158:b23ee177fd68 | 232 | * @arg @ref LL_CRC_INDATA_REVERSE_NONE |
Kojto | 158:b23ee177fd68 | 233 | * @arg @ref LL_CRC_INDATA_REVERSE_BYTE |
Kojto | 158:b23ee177fd68 | 234 | * @arg @ref LL_CRC_INDATA_REVERSE_HALFWORD |
Kojto | 158:b23ee177fd68 | 235 | * @arg @ref LL_CRC_INDATA_REVERSE_WORD |
Kojto | 158:b23ee177fd68 | 236 | */ |
Kojto | 158:b23ee177fd68 | 237 | __STATIC_INLINE uint32_t LL_CRC_GetInputDataReverseMode(CRC_TypeDef *CRCx) |
Kojto | 158:b23ee177fd68 | 238 | { |
Kojto | 158:b23ee177fd68 | 239 | return (uint32_t)(READ_BIT(CRCx->CR, CRC_CR_REV_IN)); |
Kojto | 158:b23ee177fd68 | 240 | } |
Kojto | 158:b23ee177fd68 | 241 | |
Kojto | 158:b23ee177fd68 | 242 | /** |
Kojto | 158:b23ee177fd68 | 243 | * @brief Configure the reversal of the bit order of the Output data |
Kojto | 158:b23ee177fd68 | 244 | * @rmtoll CR REV_OUT LL_CRC_SetOutputDataReverseMode |
Kojto | 158:b23ee177fd68 | 245 | * @param CRCx CRC Instance |
Kojto | 158:b23ee177fd68 | 246 | * @param ReverseMode This parameter can be one of the following values: |
Kojto | 158:b23ee177fd68 | 247 | * @arg @ref LL_CRC_OUTDATA_REVERSE_NONE |
Kojto | 158:b23ee177fd68 | 248 | * @arg @ref LL_CRC_OUTDATA_REVERSE_BIT |
Kojto | 158:b23ee177fd68 | 249 | * @retval None |
Kojto | 158:b23ee177fd68 | 250 | */ |
Kojto | 158:b23ee177fd68 | 251 | __STATIC_INLINE void LL_CRC_SetOutputDataReverseMode(CRC_TypeDef *CRCx, uint32_t ReverseMode) |
Kojto | 158:b23ee177fd68 | 252 | { |
Kojto | 158:b23ee177fd68 | 253 | MODIFY_REG(CRCx->CR, CRC_CR_REV_OUT, ReverseMode); |
Kojto | 158:b23ee177fd68 | 254 | } |
Kojto | 158:b23ee177fd68 | 255 | |
Kojto | 158:b23ee177fd68 | 256 | /** |
Kojto | 158:b23ee177fd68 | 257 | * @brief Configure the reversal of the bit order of the Output data |
Kojto | 158:b23ee177fd68 | 258 | * @rmtoll CR REV_OUT LL_CRC_GetOutputDataReverseMode |
Kojto | 158:b23ee177fd68 | 259 | * @param CRCx CRC Instance |
Kojto | 158:b23ee177fd68 | 260 | * @retval Returned value can be one of the following values: |
Kojto | 158:b23ee177fd68 | 261 | * @arg @ref LL_CRC_OUTDATA_REVERSE_NONE |
Kojto | 158:b23ee177fd68 | 262 | * @arg @ref LL_CRC_OUTDATA_REVERSE_BIT |
Kojto | 158:b23ee177fd68 | 263 | */ |
Kojto | 158:b23ee177fd68 | 264 | __STATIC_INLINE uint32_t LL_CRC_GetOutputDataReverseMode(CRC_TypeDef *CRCx) |
Kojto | 158:b23ee177fd68 | 265 | { |
Kojto | 158:b23ee177fd68 | 266 | return (uint32_t)(READ_BIT(CRCx->CR, CRC_CR_REV_OUT)); |
Kojto | 158:b23ee177fd68 | 267 | } |
Kojto | 158:b23ee177fd68 | 268 | |
Kojto | 158:b23ee177fd68 | 269 | /** |
Kojto | 158:b23ee177fd68 | 270 | * @brief Initialize the Programmable initial CRC value. |
Kojto | 158:b23ee177fd68 | 271 | * @note If the CRC size is less than 32 bits, the least significant bits |
Kojto | 158:b23ee177fd68 | 272 | * are used to write the correct value |
Kojto | 158:b23ee177fd68 | 273 | * @note LL_CRC_DEFAULT_CRC_INITVALUE could be used as value for InitCrc parameter. |
Kojto | 158:b23ee177fd68 | 274 | * @rmtoll INIT INIT LL_CRC_SetInitialData |
Kojto | 158:b23ee177fd68 | 275 | * @param CRCx CRC Instance |
Kojto | 158:b23ee177fd68 | 276 | * @param InitCrc Value to be programmed in Programmable initial CRC value register |
Kojto | 158:b23ee177fd68 | 277 | * @retval None |
Kojto | 158:b23ee177fd68 | 278 | */ |
Kojto | 158:b23ee177fd68 | 279 | __STATIC_INLINE void LL_CRC_SetInitialData(CRC_TypeDef *CRCx, uint32_t InitCrc) |
Kojto | 158:b23ee177fd68 | 280 | { |
Kojto | 158:b23ee177fd68 | 281 | WRITE_REG(CRCx->INIT, InitCrc); |
Kojto | 158:b23ee177fd68 | 282 | } |
Kojto | 158:b23ee177fd68 | 283 | |
Kojto | 158:b23ee177fd68 | 284 | /** |
Kojto | 158:b23ee177fd68 | 285 | * @brief Return current Initial CRC value. |
Kojto | 158:b23ee177fd68 | 286 | * @note If the CRC size is less than 32 bits, the least significant bits |
Kojto | 158:b23ee177fd68 | 287 | * are used to read the correct value |
Kojto | 158:b23ee177fd68 | 288 | * @rmtoll INIT INIT LL_CRC_GetInitialData |
Kojto | 158:b23ee177fd68 | 289 | * @param CRCx CRC Instance |
Kojto | 158:b23ee177fd68 | 290 | * @retval Value programmed in Programmable initial CRC value register |
Kojto | 158:b23ee177fd68 | 291 | */ |
Kojto | 158:b23ee177fd68 | 292 | __STATIC_INLINE uint32_t LL_CRC_GetInitialData(CRC_TypeDef *CRCx) |
Kojto | 158:b23ee177fd68 | 293 | { |
Kojto | 158:b23ee177fd68 | 294 | return (uint32_t)(READ_REG(CRCx->INIT)); |
Kojto | 158:b23ee177fd68 | 295 | } |
Kojto | 158:b23ee177fd68 | 296 | |
Kojto | 158:b23ee177fd68 | 297 | /** |
Kojto | 158:b23ee177fd68 | 298 | * @brief Initialize the Programmable polynomial value |
Kojto | 158:b23ee177fd68 | 299 | * (coefficients of the polynomial to be used for CRC calculation). |
Kojto | 158:b23ee177fd68 | 300 | * @note LL_CRC_DEFAULT_CRC32_POLY could be used as value for PolynomCoef parameter. |
Kojto | 158:b23ee177fd68 | 301 | * @note Please check Reference Manual and existing Errata Sheets, |
Kojto | 158:b23ee177fd68 | 302 | * regarding possible limitations for Polynomial values usage. |
Kojto | 158:b23ee177fd68 | 303 | * For example, for a polynomial of degree 7, X^7 + X^6 + X^5 + X^2 + 1 is written 0x65 |
Kojto | 158:b23ee177fd68 | 304 | * @rmtoll POL POL LL_CRC_SetPolynomialCoef |
Kojto | 158:b23ee177fd68 | 305 | * @param CRCx CRC Instance |
Kojto | 158:b23ee177fd68 | 306 | * @param PolynomCoef Value to be programmed in Programmable Polynomial value register |
Kojto | 158:b23ee177fd68 | 307 | * @retval None |
Kojto | 158:b23ee177fd68 | 308 | */ |
Kojto | 158:b23ee177fd68 | 309 | __STATIC_INLINE void LL_CRC_SetPolynomialCoef(CRC_TypeDef *CRCx, uint32_t PolynomCoef) |
Kojto | 158:b23ee177fd68 | 310 | { |
Kojto | 158:b23ee177fd68 | 311 | WRITE_REG(CRCx->POL, PolynomCoef); |
Kojto | 158:b23ee177fd68 | 312 | } |
Kojto | 158:b23ee177fd68 | 313 | |
Kojto | 158:b23ee177fd68 | 314 | /** |
Kojto | 158:b23ee177fd68 | 315 | * @brief Return current Programmable polynomial value |
Kojto | 158:b23ee177fd68 | 316 | * @note Please check Reference Manual and existing Errata Sheets, |
Kojto | 158:b23ee177fd68 | 317 | * regarding possible limitations for Polynomial values usage. |
Kojto | 158:b23ee177fd68 | 318 | * For example, for a polynomial of degree 7, X^7 + X^6 + X^5 + X^2 + 1 is written 0x65 |
Kojto | 158:b23ee177fd68 | 319 | * @rmtoll POL POL LL_CRC_GetPolynomialCoef |
Kojto | 158:b23ee177fd68 | 320 | * @param CRCx CRC Instance |
Kojto | 158:b23ee177fd68 | 321 | * @retval Value programmed in Programmable Polynomial value register |
Kojto | 158:b23ee177fd68 | 322 | */ |
Kojto | 158:b23ee177fd68 | 323 | __STATIC_INLINE uint32_t LL_CRC_GetPolynomialCoef(CRC_TypeDef *CRCx) |
Kojto | 158:b23ee177fd68 | 324 | { |
Kojto | 158:b23ee177fd68 | 325 | return (uint32_t)(READ_REG(CRCx->POL)); |
Kojto | 158:b23ee177fd68 | 326 | } |
Kojto | 158:b23ee177fd68 | 327 | |
Kojto | 158:b23ee177fd68 | 328 | /** |
Kojto | 158:b23ee177fd68 | 329 | * @} |
Kojto | 158:b23ee177fd68 | 330 | */ |
Kojto | 158:b23ee177fd68 | 331 | |
Kojto | 158:b23ee177fd68 | 332 | /** @defgroup CRC_LL_EF_Data_Management Data_Management |
Kojto | 158:b23ee177fd68 | 333 | * @{ |
Kojto | 158:b23ee177fd68 | 334 | */ |
Kojto | 158:b23ee177fd68 | 335 | |
Kojto | 158:b23ee177fd68 | 336 | /** |
Kojto | 158:b23ee177fd68 | 337 | * @brief Write given 32-bit data to the CRC calculator |
Kojto | 158:b23ee177fd68 | 338 | * @rmtoll DR DR LL_CRC_FeedData32 |
Kojto | 158:b23ee177fd68 | 339 | * @param CRCx CRC Instance |
Kojto | 158:b23ee177fd68 | 340 | * @param InData value to be provided to CRC calculator between between Min_Data=0 and Max_Data=0xFFFFFFFF |
Kojto | 158:b23ee177fd68 | 341 | * @retval None |
Kojto | 158:b23ee177fd68 | 342 | */ |
Kojto | 158:b23ee177fd68 | 343 | __STATIC_INLINE void LL_CRC_FeedData32(CRC_TypeDef *CRCx, uint32_t InData) |
Kojto | 158:b23ee177fd68 | 344 | { |
Kojto | 158:b23ee177fd68 | 345 | WRITE_REG(CRCx->DR, InData); |
Kojto | 158:b23ee177fd68 | 346 | } |
Kojto | 158:b23ee177fd68 | 347 | |
Kojto | 158:b23ee177fd68 | 348 | /** |
Kojto | 158:b23ee177fd68 | 349 | * @brief Write given 16-bit data to the CRC calculator |
Kojto | 158:b23ee177fd68 | 350 | * @rmtoll DR DR LL_CRC_FeedData16 |
Kojto | 158:b23ee177fd68 | 351 | * @param CRCx CRC Instance |
Kojto | 158:b23ee177fd68 | 352 | * @param InData 16 bit value to be provided to CRC calculator between between Min_Data=0 and Max_Data=0xFFFF |
Kojto | 158:b23ee177fd68 | 353 | * @retval None |
Kojto | 158:b23ee177fd68 | 354 | */ |
Kojto | 158:b23ee177fd68 | 355 | __STATIC_INLINE void LL_CRC_FeedData16(CRC_TypeDef *CRCx, uint16_t InData) |
Kojto | 158:b23ee177fd68 | 356 | { |
Kojto | 158:b23ee177fd68 | 357 | *(uint16_t __IO *)(&CRCx->DR) = (uint16_t) InData; |
Kojto | 158:b23ee177fd68 | 358 | } |
Kojto | 158:b23ee177fd68 | 359 | |
Kojto | 158:b23ee177fd68 | 360 | /** |
Kojto | 158:b23ee177fd68 | 361 | * @brief Write given 8-bit data to the CRC calculator |
Kojto | 158:b23ee177fd68 | 362 | * @rmtoll DR DR LL_CRC_FeedData8 |
Kojto | 158:b23ee177fd68 | 363 | * @param CRCx CRC Instance |
Kojto | 158:b23ee177fd68 | 364 | * @param InData 8 bit value to be provided to CRC calculator between between Min_Data=0 and Max_Data=0xFF |
Kojto | 158:b23ee177fd68 | 365 | * @retval None |
Kojto | 158:b23ee177fd68 | 366 | */ |
Kojto | 158:b23ee177fd68 | 367 | __STATIC_INLINE void LL_CRC_FeedData8(CRC_TypeDef *CRCx, uint8_t InData) |
Kojto | 158:b23ee177fd68 | 368 | { |
Kojto | 158:b23ee177fd68 | 369 | *(uint8_t __IO *)(&CRCx->DR) = (uint8_t) InData; |
Kojto | 158:b23ee177fd68 | 370 | } |
Kojto | 158:b23ee177fd68 | 371 | |
Kojto | 158:b23ee177fd68 | 372 | /** |
Kojto | 158:b23ee177fd68 | 373 | * @brief Return current CRC calculation result. 32 bits value is returned. |
Kojto | 158:b23ee177fd68 | 374 | * @rmtoll DR DR LL_CRC_ReadData32 |
Kojto | 158:b23ee177fd68 | 375 | * @param CRCx CRC Instance |
Kojto | 158:b23ee177fd68 | 376 | * @retval Current CRC calculation result as stored in CRC_DR register (32 bits). |
Kojto | 158:b23ee177fd68 | 377 | */ |
Kojto | 158:b23ee177fd68 | 378 | __STATIC_INLINE uint32_t LL_CRC_ReadData32(CRC_TypeDef *CRCx) |
Kojto | 158:b23ee177fd68 | 379 | { |
Kojto | 158:b23ee177fd68 | 380 | return (uint32_t)(READ_REG(CRCx->DR)); |
Kojto | 158:b23ee177fd68 | 381 | } |
Kojto | 158:b23ee177fd68 | 382 | |
Kojto | 158:b23ee177fd68 | 383 | /** |
Kojto | 158:b23ee177fd68 | 384 | * @brief Return current CRC calculation result. 16 bits value is returned. |
Kojto | 158:b23ee177fd68 | 385 | * @note This function is expected to be used in a 16 bits CRC polynomial size context. |
Kojto | 158:b23ee177fd68 | 386 | * @rmtoll DR DR LL_CRC_ReadData16 |
Kojto | 158:b23ee177fd68 | 387 | * @param CRCx CRC Instance |
Kojto | 158:b23ee177fd68 | 388 | * @retval Current CRC calculation result as stored in CRC_DR register (16 bits). |
Kojto | 158:b23ee177fd68 | 389 | */ |
Kojto | 158:b23ee177fd68 | 390 | __STATIC_INLINE uint16_t LL_CRC_ReadData16(CRC_TypeDef *CRCx) |
Kojto | 158:b23ee177fd68 | 391 | { |
Kojto | 158:b23ee177fd68 | 392 | return (uint16_t)READ_REG(CRCx->DR); |
Kojto | 158:b23ee177fd68 | 393 | } |
Kojto | 158:b23ee177fd68 | 394 | |
Kojto | 158:b23ee177fd68 | 395 | /** |
Kojto | 158:b23ee177fd68 | 396 | * @brief Return current CRC calculation result. 8 bits value is returned. |
Kojto | 158:b23ee177fd68 | 397 | * @note This function is expected to be used in a 8 bits CRC polynomial size context. |
Kojto | 158:b23ee177fd68 | 398 | * @rmtoll DR DR LL_CRC_ReadData8 |
Kojto | 158:b23ee177fd68 | 399 | * @param CRCx CRC Instance |
Kojto | 158:b23ee177fd68 | 400 | * @retval Current CRC calculation result as stored in CRC_DR register (8 bits). |
Kojto | 158:b23ee177fd68 | 401 | */ |
Kojto | 158:b23ee177fd68 | 402 | __STATIC_INLINE uint8_t LL_CRC_ReadData8(CRC_TypeDef *CRCx) |
Kojto | 158:b23ee177fd68 | 403 | { |
Kojto | 158:b23ee177fd68 | 404 | return (uint8_t)READ_REG(CRCx->DR); |
Kojto | 158:b23ee177fd68 | 405 | } |
Kojto | 158:b23ee177fd68 | 406 | |
Kojto | 158:b23ee177fd68 | 407 | /** |
Kojto | 158:b23ee177fd68 | 408 | * @brief Return current CRC calculation result. 7 bits value is returned. |
Kojto | 158:b23ee177fd68 | 409 | * @note This function is expected to be used in a 7 bits CRC polynomial size context. |
Kojto | 158:b23ee177fd68 | 410 | * @rmtoll DR DR LL_CRC_ReadData7 |
Kojto | 158:b23ee177fd68 | 411 | * @param CRCx CRC Instance |
Kojto | 158:b23ee177fd68 | 412 | * @retval Current CRC calculation result as stored in CRC_DR register (7 bits). |
Kojto | 158:b23ee177fd68 | 413 | */ |
Kojto | 158:b23ee177fd68 | 414 | __STATIC_INLINE uint8_t LL_CRC_ReadData7(CRC_TypeDef *CRCx) |
Kojto | 158:b23ee177fd68 | 415 | { |
Kojto | 158:b23ee177fd68 | 416 | return (uint8_t)(READ_REG(CRCx->DR) & 0x7FU); |
Kojto | 158:b23ee177fd68 | 417 | } |
Kojto | 158:b23ee177fd68 | 418 | |
Kojto | 158:b23ee177fd68 | 419 | /** |
Kojto | 158:b23ee177fd68 | 420 | * @brief Return data stored in the Independent Data(IDR) register. |
Kojto | 158:b23ee177fd68 | 421 | * @note This register can be used as a temporary storage location for one byte. |
Kojto | 158:b23ee177fd68 | 422 | * @rmtoll IDR IDR LL_CRC_Read_IDR |
Kojto | 158:b23ee177fd68 | 423 | * @param CRCx CRC Instance |
Kojto | 158:b23ee177fd68 | 424 | * @retval Value stored in CRC_IDR register (General-purpose 8-bit data register). |
Kojto | 158:b23ee177fd68 | 425 | */ |
Kojto | 158:b23ee177fd68 | 426 | __STATIC_INLINE uint32_t LL_CRC_Read_IDR(CRC_TypeDef *CRCx) |
Kojto | 158:b23ee177fd68 | 427 | { |
Kojto | 158:b23ee177fd68 | 428 | return (uint32_t)(READ_REG(CRCx->IDR)); |
Kojto | 158:b23ee177fd68 | 429 | } |
Kojto | 158:b23ee177fd68 | 430 | |
Kojto | 158:b23ee177fd68 | 431 | /** |
Kojto | 158:b23ee177fd68 | 432 | * @brief Store data in the Independent Data(IDR) register. |
Kojto | 158:b23ee177fd68 | 433 | * @note This register can be used as a temporary storage location for one byte. |
Kojto | 158:b23ee177fd68 | 434 | * @rmtoll IDR IDR LL_CRC_Write_IDR |
Kojto | 158:b23ee177fd68 | 435 | * @param CRCx CRC Instance |
Kojto | 158:b23ee177fd68 | 436 | * @param InData value to be stored in CRC_IDR register (8-bit) between between Min_Data=0 and Max_Data=0xFF |
Kojto | 158:b23ee177fd68 | 437 | * @retval None |
Kojto | 158:b23ee177fd68 | 438 | */ |
Kojto | 158:b23ee177fd68 | 439 | __STATIC_INLINE void LL_CRC_Write_IDR(CRC_TypeDef *CRCx, uint32_t InData) |
Kojto | 158:b23ee177fd68 | 440 | { |
Kojto | 158:b23ee177fd68 | 441 | *((uint8_t __IO *)(&CRCx->IDR)) = (uint8_t) InData; |
Kojto | 158:b23ee177fd68 | 442 | } |
Kojto | 158:b23ee177fd68 | 443 | /** |
Kojto | 158:b23ee177fd68 | 444 | * @} |
Kojto | 158:b23ee177fd68 | 445 | */ |
Kojto | 158:b23ee177fd68 | 446 | |
Kojto | 158:b23ee177fd68 | 447 | #if defined(USE_FULL_LL_DRIVER) |
Kojto | 158:b23ee177fd68 | 448 | /** @defgroup CRC_LL_EF_Init Initialization and de-initialization functions |
Kojto | 158:b23ee177fd68 | 449 | * @{ |
Kojto | 158:b23ee177fd68 | 450 | */ |
Kojto | 158:b23ee177fd68 | 451 | |
Kojto | 158:b23ee177fd68 | 452 | ErrorStatus LL_CRC_DeInit(CRC_TypeDef *CRCx); |
Kojto | 158:b23ee177fd68 | 453 | |
Kojto | 158:b23ee177fd68 | 454 | /** |
Kojto | 158:b23ee177fd68 | 455 | * @} |
Kojto | 158:b23ee177fd68 | 456 | */ |
Kojto | 158:b23ee177fd68 | 457 | #endif /* USE_FULL_LL_DRIVER */ |
Kojto | 158:b23ee177fd68 | 458 | |
Kojto | 158:b23ee177fd68 | 459 | /** |
Kojto | 158:b23ee177fd68 | 460 | * @} |
Kojto | 158:b23ee177fd68 | 461 | */ |
Kojto | 158:b23ee177fd68 | 462 | |
Kojto | 158:b23ee177fd68 | 463 | /** |
Kojto | 158:b23ee177fd68 | 464 | * @} |
Kojto | 158:b23ee177fd68 | 465 | */ |
Kojto | 158:b23ee177fd68 | 466 | |
Kojto | 158:b23ee177fd68 | 467 | #endif /* defined(CRC) */ |
Kojto | 158:b23ee177fd68 | 468 | |
Kojto | 158:b23ee177fd68 | 469 | /** |
Kojto | 158:b23ee177fd68 | 470 | * @} |
Kojto | 158:b23ee177fd68 | 471 | */ |
Kojto | 158:b23ee177fd68 | 472 | |
Kojto | 158:b23ee177fd68 | 473 | #ifdef __cplusplus |
Kojto | 158:b23ee177fd68 | 474 | } |
Kojto | 158:b23ee177fd68 | 475 | #endif |
Kojto | 158:b23ee177fd68 | 476 | |
Kojto | 158:b23ee177fd68 | 477 | #endif /* __STM32L0xx_LL_CRC_H */ |
Kojto | 158:b23ee177fd68 | 478 | |
Kojto | 158:b23ee177fd68 | 479 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |