TUKS MCU Introductory course / TUKS-COURSE-THERMOMETER

Fork of TUKS-COURSE-TIMER by TUKS MCU Introductory course

Committer:
elmot
Date:
Sat Feb 25 09:03:15 2017 +0000
Revision:
3:b69e098b4613
Parent:
1:d0dfbce63a89
Ready

Who changed what in which revision?

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