提交 | 用户 | age
|
483170
|
1 |
/** |
Q |
2 |
****************************************************************************** |
|
3 |
* @file stm32f0xx_ll_crc.c |
|
4 |
* @author MCD Application Team |
|
5 |
* @brief CRC LL module driver. |
|
6 |
****************************************************************************** |
|
7 |
* @attention |
|
8 |
* |
|
9 |
* <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
|
10 |
* |
|
11 |
* Redistribution and use in source and binary forms, with or without modification, |
|
12 |
* are permitted provided that the following conditions are met: |
|
13 |
* 1. Redistributions of source code must retain the above copyright notice, |
|
14 |
* this list of conditions and the following disclaimer. |
|
15 |
* 2. Redistributions in binary form must reproduce the above copyright notice, |
|
16 |
* this list of conditions and the following disclaimer in the documentation |
|
17 |
* and/or other materials provided with the distribution. |
|
18 |
* 3. Neither the name of STMicroelectronics nor the names of its contributors |
|
19 |
* may be used to endorse or promote products derived from this software |
|
20 |
* without specific prior written permission. |
|
21 |
* |
|
22 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|
23 |
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
24 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
|
25 |
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
|
26 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|
27 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
|
28 |
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
|
29 |
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
|
30 |
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
31 |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
32 |
* |
|
33 |
****************************************************************************** |
|
34 |
*/ |
|
35 |
#if defined(USE_FULL_LL_DRIVER) |
|
36 |
|
|
37 |
/* Includes ------------------------------------------------------------------*/ |
|
38 |
#include "stm32f0xx_ll_crc.h" |
|
39 |
|
|
40 |
#ifdef USE_FULL_ASSERT |
|
41 |
#include "stm32_assert.h" |
|
42 |
#else |
|
43 |
#define assert_param(expr) ((void)0U) |
|
44 |
#endif |
|
45 |
|
|
46 |
/** @addtogroup STM32F0xx_LL_Driver |
|
47 |
* @{ |
|
48 |
*/ |
|
49 |
|
|
50 |
#if defined (CRC) |
|
51 |
|
|
52 |
/** @addtogroup CRC_LL |
|
53 |
* @{ |
|
54 |
*/ |
|
55 |
|
|
56 |
/* Private types -------------------------------------------------------------*/ |
|
57 |
/* Private variables ---------------------------------------------------------*/ |
|
58 |
/* Private constants ---------------------------------------------------------*/ |
|
59 |
/* Private macros ------------------------------------------------------------*/ |
|
60 |
/* Private function prototypes -----------------------------------------------*/ |
|
61 |
|
|
62 |
/* Exported functions --------------------------------------------------------*/ |
|
63 |
/** @addtogroup CRC_LL_Exported_Functions |
|
64 |
* @{ |
|
65 |
*/ |
|
66 |
|
|
67 |
/** @addtogroup CRC_LL_EF_Init |
|
68 |
* @{ |
|
69 |
*/ |
|
70 |
|
|
71 |
/** |
|
72 |
* @brief De-initialize CRC registers (Registers restored to their default values). |
|
73 |
* @param CRCx CRC Instance |
|
74 |
* @retval An ErrorStatus enumeration value: |
|
75 |
* - SUCCESS: CRC registers are de-initialized |
|
76 |
* - ERROR: CRC registers are not de-initialized |
|
77 |
*/ |
|
78 |
ErrorStatus LL_CRC_DeInit(CRC_TypeDef *CRCx) |
|
79 |
{ |
|
80 |
ErrorStatus status = SUCCESS; |
|
81 |
|
|
82 |
/* Check the parameters */ |
|
83 |
assert_param(IS_CRC_ALL_INSTANCE(CRCx)); |
|
84 |
|
|
85 |
if (CRCx == CRC) |
|
86 |
{ |
|
87 |
#if defined(CRC_PROG_POLYNOMIAL_SUPPORT) |
|
88 |
/* Set programmable polynomial size in CR register to reset value (32 bits)*/ |
|
89 |
LL_CRC_SetPolynomialSize(CRCx, LL_CRC_POLYLENGTH_32B); |
|
90 |
|
|
91 |
/* Set programmable polynomial in POL register to reset value */ |
|
92 |
LL_CRC_SetPolynomialCoef(CRCx, LL_CRC_DEFAULT_CRC32_POLY); |
|
93 |
#endif |
|
94 |
|
|
95 |
/* Set INIT register to reset value */ |
|
96 |
LL_CRC_SetInitialData(CRCx, LL_CRC_DEFAULT_CRC_INITVALUE); |
|
97 |
|
|
98 |
/* Set Reversibility options on I/O data values in CR register to reset value */ |
|
99 |
LL_CRC_SetInputDataReverseMode(CRCx, LL_CRC_INDATA_REVERSE_NONE); |
|
100 |
LL_CRC_SetOutputDataReverseMode(CRCx, LL_CRC_OUTDATA_REVERSE_NONE); |
|
101 |
|
|
102 |
/* Reset the CRC calculation unit */ |
|
103 |
LL_CRC_ResetCRCCalculationUnit(CRCx); |
|
104 |
|
|
105 |
/* Reset IDR register */ |
|
106 |
LL_CRC_Write_IDR(CRCx, 0x00U); |
|
107 |
} |
|
108 |
else |
|
109 |
{ |
|
110 |
status = ERROR; |
|
111 |
} |
|
112 |
|
|
113 |
return (status); |
|
114 |
} |
|
115 |
|
|
116 |
/** |
|
117 |
* @} |
|
118 |
*/ |
|
119 |
|
|
120 |
/** |
|
121 |
* @} |
|
122 |
*/ |
|
123 |
|
|
124 |
/** |
|
125 |
* @} |
|
126 |
*/ |
|
127 |
|
|
128 |
#endif /* defined (CRC) */ |
|
129 |
|
|
130 |
/** |
|
131 |
* @} |
|
132 |
*/ |
|
133 |
|
|
134 |
#endif /* USE_FULL_LL_DRIVER */ |
|
135 |
|
|
136 |
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
|
137 |
|