1 /**
2   ******************************************************************************
3   * @file    stm32f0xx_ll_crc.c
4   * @author  MCD Application Team
5   * @brief   CRC LL module driver.
6   ******************************************************************************
7   * @attention
8   *
9   * Copyright (c) 2016 STMicroelectronics.
10   * All rights reserved.
11   *
12   * This software is licensed under terms that can be found in the LICENSE file
13   * in the root directory of this software component.
14   * If no LICENSE file comes with this software, it is provided AS-IS.
15   *
16   ******************************************************************************
17   */
18 #if defined(USE_FULL_LL_DRIVER)
19 
20 /* Includes ------------------------------------------------------------------*/
21 #include "stm32f0xx_ll_crc.h"
22 #include "stm32f0xx_ll_bus.h"
23 
24 #ifdef  USE_FULL_ASSERT
25 #include "stm32_assert.h"
26 #else
27 #define assert_param(expr) ((void)0U)
28 #endif /* USE_FULL_ASSERT */
29 
30 /** @addtogroup STM32F0xx_LL_Driver
31   * @{
32   */
33 
34 #if defined (CRC)
35 
36 /** @addtogroup CRC_LL
37   * @{
38   */
39 
40 /* Private types -------------------------------------------------------------*/
41 /* Private variables ---------------------------------------------------------*/
42 /* Private constants ---------------------------------------------------------*/
43 /* Private macros ------------------------------------------------------------*/
44 /* Private function prototypes -----------------------------------------------*/
45 
46 /* Exported functions --------------------------------------------------------*/
47 /** @addtogroup CRC_LL_Exported_Functions
48   * @{
49   */
50 
51 /** @addtogroup CRC_LL_EF_Init
52   * @{
53   */
54 
55 /**
56   * @brief  De-initialize CRC registers (Registers restored to their default values).
57   * @param  CRCx CRC Instance
58   * @retval An ErrorStatus enumeration value:
59   *          - SUCCESS: CRC registers are de-initialized
60   *          - ERROR: CRC registers are not de-initialized
61   */
LL_CRC_DeInit(CRC_TypeDef * CRCx)62 ErrorStatus LL_CRC_DeInit(CRC_TypeDef *CRCx)
63 {
64   ErrorStatus status = SUCCESS;
65 
66   /* Check the parameters */
67   assert_param(IS_CRC_ALL_INSTANCE(CRCx));
68 
69   if (CRCx == CRC)
70   {
71 #if defined(CRC_POL_POL)
72     /* Set programmable polynomial size in CR register to reset value (32 bits)*/
73     LL_CRC_SetPolynomialSize(CRCx, LL_CRC_POLYLENGTH_32B);
74 
75     /* Set programmable polynomial in POL register to reset value */
76     LL_CRC_SetPolynomialCoef(CRCx, LL_CRC_DEFAULT_CRC32_POLY);
77 #endif /* CRC_POL_POL */
78 
79     /* Set INIT register to reset value */
80     LL_CRC_SetInitialData(CRCx, LL_CRC_DEFAULT_CRC_INITVALUE);
81 
82     /* Set Reversibility options on I/O data values in CR register to reset value */
83     LL_CRC_SetInputDataReverseMode(CRCx, LL_CRC_INDATA_REVERSE_NONE);
84     LL_CRC_SetOutputDataReverseMode(CRCx, LL_CRC_OUTDATA_REVERSE_NONE);
85 
86     /* Reset the CRC calculation unit */
87     LL_CRC_ResetCRCCalculationUnit(CRCx);
88 
89     /* Reset IDR register */
90     LL_CRC_Write_IDR(CRCx, 0x00U);
91   }
92   else
93   {
94     status = ERROR;
95   }
96 
97   return (status);
98 }
99 
100 /**
101   * @}
102   */
103 
104 /**
105   * @}
106   */
107 
108 /**
109   * @}
110   */
111 
112 #endif /* defined (CRC) */
113 
114 /**
115   * @}
116   */
117 
118 #endif /* USE_FULL_LL_DRIVER */
119