STM32L4xx_HAL_Driver  1.14.0
Initialization and de-initialization functions

Initialization and Configuration functions. More...

Functions

HAL_StatusTypeDef HAL_CRC_Init (CRC_HandleTypeDef *hcrc)
 Initialize the CRC according to the specified parameters in the CRC_InitTypeDef and create the associated handle. More...
 
HAL_StatusTypeDef HAL_CRC_DeInit (CRC_HandleTypeDef *hcrc)
 DeInitialize the CRC peripheral. More...
 
void HAL_CRC_MspInit (CRC_HandleTypeDef *hcrc)
 Initializes the CRC MSP. More...
 
void HAL_CRC_MspDeInit (CRC_HandleTypeDef *hcrc)
 DeInitialize the CRC MSP. More...
 

Detailed Description

Initialization and Configuration functions.

 ===============================================================================
            ##### Initialization and de-initialization functions #####
 ===============================================================================
    [..]  This section provides functions allowing to:
      (+) Initialize the CRC according to the specified parameters
          in the CRC_InitTypeDef and create the associated handle
      (+) DeInitialize the CRC peripheral
      (+) Initialize the CRC MSP (MCU Specific Package)
      (+) DeInitialize the CRC MSP

Function Documentation

◆ HAL_CRC_DeInit()

HAL_StatusTypeDef HAL_CRC_DeInit ( CRC_HandleTypeDef hcrc)

DeInitialize the CRC peripheral.

Parameters
hcrcCRC handle
Return values
HALstatus

Definition at line 179 of file stm32l4xx_hal_crc.c.

180 {
181  /* Check the CRC handle allocation */
182  if (hcrc == NULL)
183  {
184  return HAL_ERROR;
185  }
186 
187  /* Check the parameters */
188  assert_param(IS_CRC_ALL_INSTANCE(hcrc->Instance));
189 
190  /* Check the CRC peripheral state */
191  if (hcrc->State == HAL_CRC_STATE_BUSY)
192  {
193  return HAL_BUSY;
194  }
195 
196  /* Change CRC peripheral state */
197  hcrc->State = HAL_CRC_STATE_BUSY;
198 
199  /* Reset CRC calculation unit */
200  __HAL_CRC_DR_RESET(hcrc);
201 
202  /* Reset IDR register content */
203  CLEAR_BIT(hcrc->Instance->IDR, CRC_IDR_IDR);
204 
205  /* DeInit the low level hardware */
206  HAL_CRC_MspDeInit(hcrc);
207 
208  /* Change CRC peripheral state */
209  hcrc->State = HAL_CRC_STATE_RESET;
210 
211  /* Process unlocked */
212  __HAL_UNLOCK(hcrc);
213 
214  /* Return function status */
215  return HAL_OK;
216 }
__IO HAL_CRC_StateTypeDef State
__HAL_UNLOCK(hrtc)
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
return HAL_OK
CRC_TypeDef * Instance
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))
void HAL_CRC_MspDeInit(CRC_HandleTypeDef *hcrc)
DeInitialize the CRC MSP.

◆ HAL_CRC_Init()

HAL_StatusTypeDef HAL_CRC_Init ( CRC_HandleTypeDef hcrc)

Initialize the CRC according to the specified parameters in the CRC_InitTypeDef and create the associated handle.

Parameters
hcrcCRC handle
Return values
HALstatus

Definition at line 103 of file stm32l4xx_hal_crc.c.

104 {
105  /* Check the CRC handle allocation */
106  if (hcrc == NULL)
107  {
108  return HAL_ERROR;
109  }
110 
111  /* Check the parameters */
112  assert_param(IS_CRC_ALL_INSTANCE(hcrc->Instance));
113 
114  if (hcrc->State == HAL_CRC_STATE_RESET)
115  {
116  /* Allocate lock resource and initialize it */
117  hcrc->Lock = HAL_UNLOCKED;
118  /* Init the low level hardware */
119  HAL_CRC_MspInit(hcrc);
120  }
121 
122  hcrc->State = HAL_CRC_STATE_BUSY;
123 
124  /* check whether or not non-default generating polynomial has been
125  * picked up by user */
126  assert_param(IS_DEFAULT_POLYNOMIAL(hcrc->Init.DefaultPolynomialUse));
127  if (hcrc->Init.DefaultPolynomialUse == DEFAULT_POLYNOMIAL_ENABLE)
128  {
129  /* initialize peripheral with default generating polynomial */
130  WRITE_REG(hcrc->Instance->POL, DEFAULT_CRC32_POLY);
131  MODIFY_REG(hcrc->Instance->CR, CRC_CR_POLYSIZE, CRC_POLYLENGTH_32B);
132  }
133  else
134  {
135  /* initialize CRC peripheral with generating polynomial defined by user */
137  {
138  return HAL_ERROR;
139  }
140  }
141 
142  /* check whether or not non-default CRC initial value has been
143  * picked up by user */
144  assert_param(IS_DEFAULT_INIT_VALUE(hcrc->Init.DefaultInitValueUse));
145  if (hcrc->Init.DefaultInitValueUse == DEFAULT_INIT_VALUE_ENABLE)
146  {
147  WRITE_REG(hcrc->Instance->INIT, DEFAULT_CRC_INITVALUE);
148  }
149  else
150  {
151  WRITE_REG(hcrc->Instance->INIT, hcrc->Init.InitValue);
152  }
153 
154 
155  /* set input data inversion mode */
156  assert_param(IS_CRC_INPUTDATA_INVERSION_MODE(hcrc->Init.InputDataInversionMode));
157  MODIFY_REG(hcrc->Instance->CR, CRC_CR_REV_IN, hcrc->Init.InputDataInversionMode);
158 
159  /* set output data inversion mode */
160  assert_param(IS_CRC_OUTPUTDATA_INVERSION_MODE(hcrc->Init.OutputDataInversionMode));
161  MODIFY_REG(hcrc->Instance->CR, CRC_CR_REV_OUT, hcrc->Init.OutputDataInversionMode);
162 
163  /* makes sure the input data format (bytes, halfwords or words stream)
164  * is properly specified by user */
165  assert_param(IS_CRC_INPUTDATA_FORMAT(hcrc->InputDataFormat));
166 
167  /* Change CRC peripheral state */
168  hcrc->State = HAL_CRC_STATE_READY;
169 
170  /* Return function status */
171  return HAL_OK;
172 }
uint32_t OutputDataInversionMode
uint32_t GeneratingPolynomial
__IO HAL_CRC_StateTypeDef State
void HAL_CRC_MspInit(CRC_HandleTypeDef *hcrc)
Initializes the CRC MSP.
return HAL_OK
uint8_t DefaultPolynomialUse
HAL_StatusTypeDef HAL_CRCEx_Polynomial_Set(CRC_HandleTypeDef *hcrc, uint32_t Pol, uint32_t PolyLength)
Initialize the CRC polynomial if different from default one.
CRC_InitTypeDef Init
CRC_TypeDef * Instance
uint32_t InputDataInversionMode
HAL_LockTypeDef Lock
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)
uint8_t DefaultInitValueUse
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_CRC_MspDeInit()

__weak void HAL_CRC_MspDeInit ( CRC_HandleTypeDef hcrc)

DeInitialize the CRC MSP.

Parameters
hcrcCRC handle
Return values
None

Definition at line 238 of file stm32l4xx_hal_crc.c.

239 {
240  /* Prevent unused argument(s) compilation warning */
241  UNUSED(hcrc);
242 
243  /* NOTE : This function should not be modified, when the callback is needed,
244  the HAL_CRC_MspDeInit can be implemented in the user file
245  */
246 }

◆ HAL_CRC_MspInit()

__weak void HAL_CRC_MspInit ( CRC_HandleTypeDef hcrc)

Initializes the CRC MSP.

Parameters
hcrcCRC handle
Return values
None

Definition at line 223 of file stm32l4xx_hal_crc.c.

224 {
225  /* Prevent unused argument(s) compilation warning */
226  UNUSED(hcrc);
227 
228  /* NOTE : This function should not be modified, when the callback is needed,
229  the HAL_CRC_MspInit can be implemented in the user file
230  */
231 }