STM32F4xx HAL Documentation
Hardware Abstraction Layer for STM32F4 familiy
Loading...
Searching...
No Matches
stm32f4xx_hal_crc.c
Go to the documentation of this file.
1
45/* Includes ------------------------------------------------------------------*/
46#include "stm32f4xx_hal.h"
47
57#ifdef HAL_CRC_MODULE_ENABLED
58
59/* Private typedef -----------------------------------------------------------*/
60/* Private define ------------------------------------------------------------*/
61/* Private macro -------------------------------------------------------------*/
62/* Private variables ---------------------------------------------------------*/
63/* Private function prototypes -----------------------------------------------*/
64
65/* Exported functions --------------------------------------------------------*/
66
96{
97 /* Check the CRC handle allocation */
98 if (hcrc == NULL)
99 {
100 return HAL_ERROR;
101 }
102
103 /* Check the parameters */
104 assert_param(IS_CRC_ALL_INSTANCE(hcrc->Instance));
105
106 if (hcrc->State == HAL_CRC_STATE_RESET)
107 {
108 /* Allocate lock resource and initialize it */
109 hcrc->Lock = HAL_UNLOCKED;
110 /* Init the low level hardware */
111 HAL_CRC_MspInit(hcrc);
112 }
113
114 /* Change CRC peripheral state */
116
117 /* Return function status */
118 return HAL_OK;
119}
120
127{
128 /* Check the CRC handle allocation */
129 if (hcrc == NULL)
130 {
131 return HAL_ERROR;
132 }
133
134 /* Check the parameters */
135 assert_param(IS_CRC_ALL_INSTANCE(hcrc->Instance));
136
137 /* Check the CRC peripheral state */
138 if (hcrc->State == HAL_CRC_STATE_BUSY)
139 {
140 return HAL_BUSY;
141 }
142
143 /* Change CRC peripheral state */
145
146 /* Reset CRC calculation unit */
147 __HAL_CRC_DR_RESET(hcrc);
148
149 /* Reset IDR register content */
150 __HAL_CRC_SET_IDR(hcrc, 0);
151
152 /* DeInit the low level hardware */
153 HAL_CRC_MspDeInit(hcrc);
154
155 /* Change CRC peripheral state */
157
158 /* Process unlocked */
159 __HAL_UNLOCK(hcrc);
160
161 /* Return function status */
162 return HAL_OK;
163}
164
171{
172 /* Prevent unused argument(s) compilation warning */
173 UNUSED(hcrc);
174
175 /* NOTE : This function should not be modified, when the callback is needed,
176 the HAL_CRC_MspInit can be implemented in the user file
177 */
178}
179
186{
187 /* Prevent unused argument(s) compilation warning */
188 UNUSED(hcrc);
189
190 /* NOTE : This function should not be modified, when the callback is needed,
191 the HAL_CRC_MspDeInit can be implemented in the user file
192 */
193}
194
227uint32_t HAL_CRC_Accumulate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength)
228{
229 uint32_t index; /* CRC input data buffer index */
230 uint32_t temp = 0U; /* CRC output (read from hcrc->Instance->DR register) */
231
232 /* Change CRC peripheral state */
234
235 /* Enter Data to the CRC calculator */
236 for (index = 0U; index < BufferLength; index++)
237 {
238 hcrc->Instance->DR = pBuffer[index];
239 }
240 temp = hcrc->Instance->DR;
241
242 /* Change CRC peripheral state */
244
245 /* Return the CRC computed value */
246 return temp;
247}
248
257uint32_t HAL_CRC_Calculate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength)
258{
259 uint32_t index; /* CRC input data buffer index */
260 uint32_t temp = 0U; /* CRC output (read from hcrc->Instance->DR register) */
261
262 /* Change CRC peripheral state */
264
265 /* Reset CRC Calculation Unit (hcrc->Instance->INIT is
266 * written in hcrc->Instance->DR) */
267 __HAL_CRC_DR_RESET(hcrc);
268
269 /* Enter 32-bit input data to the CRC calculator */
270 for (index = 0U; index < BufferLength; index++)
271 {
272 hcrc->Instance->DR = pBuffer[index];
273 }
274 temp = hcrc->Instance->DR;
275
276 /* Change CRC peripheral state */
278
279 /* Return the CRC computed value */
280 return temp;
281}
282
307{
308 /* Return CRC handle state */
309 return hcrc->State;
310}
311
321#endif /* HAL_CRC_MODULE_ENABLED */
HAL_StatusTypeDef HAL_CRC_Init(CRC_HandleTypeDef *hcrc)
Initialize the CRC according to the specified parameters in the CRC_InitTypeDef and create the associ...
void HAL_CRC_MspInit(CRC_HandleTypeDef *hcrc)
Initializes the CRC MSP.
void HAL_CRC_MspDeInit(CRC_HandleTypeDef *hcrc)
DeInitialize the CRC MSP.
HAL_StatusTypeDef HAL_CRC_DeInit(CRC_HandleTypeDef *hcrc)
DeInitialize the CRC peripheral.
uint32_t HAL_CRC_Accumulate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength)
Compute the 32-bit CRC value of a 32-bit data buffer starting with the previously computed CRC as ini...
uint32_t HAL_CRC_Calculate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength)
Compute the 32-bit CRC value of a 32-bit data buffer starting with hcrc->Instance->INIT as initializa...
HAL_CRC_StateTypeDef HAL_CRC_GetState(const CRC_HandleTypeDef *hcrc)
Return the CRC handle state.
#define __HAL_CRC_DR_RESET(__HANDLE__)
Reset CRC Data Register.
#define __HAL_CRC_SET_IDR(__HANDLE__, __VALUE__)
Store data in the Independent Data (ID) register.
HAL_CRC_StateTypeDef
CRC HAL State Structure definition.
@ HAL_CRC_STATE_RESET
@ HAL_CRC_STATE_BUSY
@ HAL_CRC_STATE_READY
#define assert_param(expr)
This file contains all the functions prototypes for the HAL module driver.
HAL_StatusTypeDef
HAL Status structures definition
@ HAL_ERROR
@ HAL_OK
@ HAL_BUSY
#define UNUSED(X)
#define __HAL_UNLOCK(__HANDLE__)
@ HAL_UNLOCKED
CRC Handle Structure definition.
__IO HAL_CRC_StateTypeDef State
CRC_TypeDef * Instance
HAL_LockTypeDef Lock