Hal Drivers for L4

Dependents:   BSP OneHopeOnePrayer FINAL_AUDIO_RECORD AudioDemo

Fork of STM32L4xx_HAL_Driver by Senior Design: Sound Monitor

Committer:
EricLew
Date:
Wed Nov 25 17:30:43 2015 +0000
Revision:
2:7aef7655b0a8
Parent:
0:80ee8f3b695e
commit;

Who changed what in which revision?

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