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