Rev 56 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 56 | Rev 77 | ||
|---|---|---|---|
| Line 1... | Line 1... | ||
| 1 | /** |
1 | /** |
| 2 | ****************************************************************************** |
2 | ****************************************************************************** |
| 3 | * @file stm32l1xx_ll_comp.c |
3 | * @file stm32l1xx_ll_comp.c |
| 4 | * @author MCD Application Team |
4 | * @author MCD Application Team |
| 5 | * @brief COMP LL module driver |
5 | * @brief COMP LL module driver |
| 6 | ****************************************************************************** |
6 | ****************************************************************************** |
| 7 | * @attention |
7 | * @attention |
| 8 | * |
8 | * |
| 9 | * <h2><center>© Copyright (c) 2017 STMicroelectronics. |
9 | * Copyright (c) 2017 STMicroelectronics. |
| 10 | * All rights reserved.</center></h2> |
10 | * All rights reserved. |
| 11 | * |
11 | * |
| 12 | * This software component is licensed by ST under BSD 3-Clause license, |
12 | * This software is licensed under terms that can be found in the LICENSE file |
| 13 | * the "License"; You may not use this file except in compliance with the |
13 | * in the root directory of this software component. |
| 14 | * License. You may obtain a copy of the License at: |
14 | * If no LICENSE file comes with this software, it is provided AS-IS. |
| 15 | * opensource.org/licenses/BSD-3-Clause |
15 | * |
| 16 | * |
16 | ****************************************************************************** |
| 17 | ****************************************************************************** |
17 | */ |
| 18 | */ |
18 | #if defined(USE_FULL_LL_DRIVER) |
| 19 | #if defined(USE_FULL_LL_DRIVER) |
19 | |
| 20 | 20 | /* Includes ------------------------------------------------------------------*/ |
|
| 21 | /* Includes ------------------------------------------------------------------*/ |
21 | #include "stm32l1xx_ll_comp.h" |
| 22 | #include "stm32l1xx_ll_comp.h" |
22 | |
| 23 | 23 | #ifdef USE_FULL_ASSERT |
|
| 24 | #ifdef USE_FULL_ASSERT |
24 | #include "stm32_assert.h" |
| 25 | #include "stm32_assert.h" |
25 | #else |
| 26 | #else |
26 | #define assert_param(expr) ((void)0U) |
| 27 | #define assert_param(expr) ((void)0U) |
27 | #endif |
| 28 | #endif |
28 | |
| 29 | 29 | /** @addtogroup STM32L1xx_LL_Driver |
|
| 30 | /** @addtogroup STM32L1xx_LL_Driver |
30 | * @{ |
| 31 | * @{ |
31 | */ |
| 32 | */ |
32 | |
| 33 | 33 | #if defined (COMP1) || defined (COMP2) |
|
| 34 | #if defined (COMP1) || defined (COMP2) |
34 | |
| 35 | 35 | /** @addtogroup COMP_LL COMP |
|
| 36 | /** @addtogroup COMP_LL COMP |
36 | * @{ |
| 37 | * @{ |
37 | */ |
| 38 | */ |
38 | |
| 39 | 39 | /* Private types -------------------------------------------------------------*/ |
|
| 40 | /* Private types -------------------------------------------------------------*/ |
40 | /* Private variables ---------------------------------------------------------*/ |
| 41 | /* Private variables ---------------------------------------------------------*/ |
41 | /* Private constants ---------------------------------------------------------*/ |
| 42 | /* Private constants ---------------------------------------------------------*/ |
42 | /* Private macros ------------------------------------------------------------*/ |
| 43 | /* Private macros ------------------------------------------------------------*/ |
43 | |
| 44 | 44 | /** @addtogroup COMP_LL_Private_Macros |
|
| 45 | /** @addtogroup COMP_LL_Private_Macros |
45 | * @{ |
| 46 | * @{ |
46 | */ |
| 47 | */ |
47 | |
| 48 | 48 | /* Check of parameters for configuration of COMP hierarchical scope: */ |
|
| 49 | /* Check of parameters for configuration of COMP hierarchical scope: */ |
49 | /* COMP instance. */ |
| 50 | /* COMP instance. */ |
50 | |
| 51 | 51 | #define IS_LL_COMP_POWER_MODE(__POWER_MODE__) \ |
|
| 52 | #define IS_LL_COMP_POWER_MODE(__POWER_MODE__) \ |
52 | ( ((__POWER_MODE__) == LL_COMP_POWERMODE_MEDIUMSPEED) \ |
| 53 | ( ((__POWER_MODE__) == LL_COMP_POWERMODE_MEDIUMSPEED) \ |
53 | || ((__POWER_MODE__) == LL_COMP_POWERMODE_ULTRALOWPOWER) \ |
| 54 | || ((__POWER_MODE__) == LL_COMP_POWERMODE_ULTRALOWPOWER) \ |
54 | ) |
| 55 | ) |
55 | |
| 56 | 56 | /* Note: On this STM32 series, comparator input plus parameters are */ |
|
| 57 | /* Note: On this STM32 serie, comparator input plus parameters are */ |
57 | /* the different depending on COMP instances. */ |
| 58 | /* the different depending on COMP instances. */ |
58 | #if defined(RI_ASCR1_CH_31) |
| 59 | #if defined(RI_ASCR1_CH_31) |
59 | #define IS_LL_COMP_INPUT_PLUS(__COMP_INSTANCE__, __INPUT_PLUS__) \ |
| 60 | #define IS_LL_COMP_INPUT_PLUS(__COMP_INSTANCE__, __INPUT_PLUS__) \ |
60 | (((__COMP_INSTANCE__) == COMP1) \ |
| 61 | (((__COMP_INSTANCE__) == COMP1) \ |
61 | ? ( \ |
| 62 | ? ( \ |
62 | ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO5) \ |
| 63 | ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO5) \ |
63 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO6) \ |
| 64 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO6) \ |
64 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO7) \ |
| 65 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO7) \ |
65 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO8) \ |
| 66 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO8) \ |
66 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO9) \ |
| 67 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO9) \ |
67 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO10) \ |
| 68 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO10) \ |
68 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO11) \ |
| 69 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO11) \ |
69 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO12) \ |
| 70 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO12) \ |
70 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO13) \ |
| 71 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO13) \ |
71 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO14) \ |
| 72 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO14) \ |
72 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO15) \ |
| 73 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO15) \ |
73 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO16) \ |
| 74 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO16) \ |
74 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO17) \ |
| 75 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO17) \ |
75 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO18) \ |
| 76 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO18) \ |
76 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO19) \ |
| 77 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO19) \ |
77 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO20) \ |
| 78 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO20) \ |
78 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO21) \ |
| 79 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO21) \ |
79 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO22) \ |
| 80 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO22) \ |
80 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO23) \ |
| 81 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO23) \ |
81 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO24) \ |
| 82 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO24) \ |
82 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO25) \ |
| 83 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO25) \ |
83 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO26) \ |
| 84 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO26) \ |
84 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO27) \ |
| 85 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO27) \ |
85 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO28) \ |
| 86 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO28) \ |
86 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO29) \ |
| 87 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO29) \ |
87 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO30) \ |
| 88 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO30) \ |
88 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO31) \ |
| 89 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO31) \ |
89 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO32) \ |
| 90 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO32) \ |
90 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO33) \ |
| 91 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO33) \ |
91 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_NONE) \ |
| 92 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_NONE) \ |
92 | ) \ |
| 93 | ) \ |
93 | : \ |
| 94 | : \ |
94 | ( \ |
| 95 | ( \ |
95 | ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO1) \ |
| 96 | ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO1) \ |
96 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO2) \ |
| 97 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO2) \ |
97 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO3) \ |
| 98 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO3) \ |
98 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO4) \ |
| 99 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO4) \ |
99 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_NONE) \ |
| 100 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_NONE) \ |
100 | ) \ |
| 101 | ) \ |
101 | ) |
| 102 | ) |
102 | #else |
| 103 | #else |
103 | #define IS_LL_COMP_INPUT_PLUS(__COMP_INSTANCE__, __INPUT_PLUS__) \ |
| 104 | #define IS_LL_COMP_INPUT_PLUS(__COMP_INSTANCE__, __INPUT_PLUS__) \ |
104 | (((__COMP_INSTANCE__) == COMP1) \ |
| 105 | (((__COMP_INSTANCE__) == COMP1) \ |
105 | ? ( \ |
| 106 | ? ( \ |
106 | ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO5) \ |
| 107 | ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO5) \ |
107 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO6) \ |
| 108 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO6) \ |
108 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO7) \ |
| 109 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO7) \ |
109 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO8) \ |
| 110 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO8) \ |
110 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO9) \ |
| 111 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO9) \ |
111 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO10) \ |
| 112 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO10) \ |
112 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO11) \ |
| 113 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO11) \ |
113 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO12) \ |
| 114 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO12) \ |
114 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO13) \ |
| 115 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO13) \ |
115 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO14) \ |
| 116 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO14) \ |
116 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO15) \ |
| 117 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO15) \ |
117 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO16) \ |
| 118 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO16) \ |
118 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO17) \ |
| 119 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO17) \ |
119 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO18) \ |
| 120 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO18) \ |
120 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO19) \ |
| 121 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO19) \ |
121 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO20) \ |
| 122 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO20) \ |
122 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO21) \ |
| 123 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO21) \ |
123 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO22) \ |
| 124 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO22) \ |
124 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO23) \ |
| 125 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO23) \ |
125 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO24) \ |
| 126 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO24) \ |
126 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO25) \ |
| 127 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO25) \ |
127 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO26) \ |
| 128 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO26) \ |
128 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO27) \ |
| 129 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO27) \ |
129 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO28) \ |
| 130 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO28) \ |
130 | ) \ |
| 131 | ) \ |
131 | : \ |
| 132 | : \ |
132 | ( \ |
| 133 | ( \ |
133 | ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO1) \ |
| 134 | ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO1) \ |
134 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO2) \ |
| 135 | || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO2) \ |
135 | ) \ |
| 136 | ) \ |
136 | ) |
| 137 | ) |
137 | #endif |
| 138 | #endif |
138 | |
| 139 | 139 | /* Note: On this STM32 series, comparator input minus parameters are */ |
|
| 140 | /* Note: On this STM32 serie, comparator input minus parameters are */ |
140 | /* the different depending on COMP instances. */ |
| 141 | /* the different depending on COMP instances. */ |
141 | #define IS_LL_COMP_INPUT_MINUS(__COMP_INSTANCE__, __INPUT_MINUS__) \ |
| 142 | #define IS_LL_COMP_INPUT_MINUS(__COMP_INSTANCE__, __INPUT_MINUS__) \ |
142 | (((__COMP_INSTANCE__) == COMP1) \ |
| 143 | (((__COMP_INSTANCE__) == COMP1) \ |
143 | ? ( \ |
| 144 | ? ( \ |
144 | ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_VREFINT) \ |
| 145 | ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_VREFINT) \ |
145 | ) \ |
| 146 | ) \ |
146 | : \ |
| 147 | : \ |
147 | ( \ |
| 148 | ( \ |
148 | ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_1_4VREFINT) \ |
| 149 | ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_1_4VREFINT) \ |
149 | || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_1_2VREFINT) \ |
| 150 | || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_1_2VREFINT) \ |
150 | || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_3_4VREFINT) \ |
| 151 | || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_3_4VREFINT) \ |
151 | || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_VREFINT) \ |
| 152 | || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_VREFINT) \ |
152 | || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_DAC1_CH1) \ |
| 153 | || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_DAC1_CH1) \ |
153 | || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_DAC1_CH2) \ |
| 154 | || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_DAC1_CH2) \ |
154 | || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_IO1) \ |
| 155 | || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_IO1) \ |
155 | ) \ |
| 156 | ) \ |
156 | ) |
| 157 | ) |
157 | |
| 158 | 158 | #define IS_LL_COMP_OUTPUT_SELECTION(__OUTPUT_SELECTION__) \ |
|
| 159 | #define IS_LL_COMP_OUTPUT_SELECTION(__OUTPUT_SELECTION__) \ |
159 | ( ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_NONE) \ |
| 160 | ( ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_NONE) \ |
160 | || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM2_IC4) \ |
| 161 | || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM2_IC4) \ |
161 | || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM2_OCREFCLR) \ |
| 162 | || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM2_OCREFCLR) \ |
162 | || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM3_IC4) \ |
| 163 | || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM3_IC4) \ |
163 | || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM3_OCREFCLR) \ |
| 164 | || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM3_OCREFCLR) \ |
164 | || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM4_IC4) \ |
| 165 | || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM4_IC4) \ |
165 | || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM4_OCREFCLR) \ |
| 166 | || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM4_OCREFCLR) \ |
166 | || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM10_IC1) \ |
| 167 | || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM10_IC1) \ |
167 | ) |
| 168 | ) |
168 | |
| 169 | 169 | /** |
|
| 170 | /** |
170 | * @} |
| 171 | * @} |
171 | */ |
| 172 | */ |
172 | |
| 173 | 173 | ||
| 174 | 174 | /* Private function prototypes -----------------------------------------------*/ |
|
| 175 | /* Private function prototypes -----------------------------------------------*/ |
175 | |
| 176 | 176 | /* Exported functions --------------------------------------------------------*/ |
|
| 177 | /* Exported functions --------------------------------------------------------*/ |
177 | /** @addtogroup COMP_LL_Exported_Functions |
| 178 | /** @addtogroup COMP_LL_Exported_Functions |
178 | * @{ |
| 179 | * @{ |
179 | */ |
| 180 | */ |
180 | |
| 181 | 181 | /** @addtogroup COMP_LL_EF_Init |
|
| 182 | /** @addtogroup COMP_LL_EF_Init |
182 | * @{ |
| 183 | * @{ |
183 | */ |
| 184 | */ |
184 | |
| 185 | 185 | /** |
|
| 186 | /** |
186 | * @brief De-initialize registers of the selected COMP instance |
| 187 | * @brief De-initialize registers of the selected COMP instance |
187 | * to their default reset values. |
| 188 | * to their default reset values. |
188 | * @note If comparator is locked, de-initialization by software is |
| 189 | * @note If comparator is locked, de-initialization by software is |
189 | * not possible. |
| 190 | * not possible. |
190 | * The only way to unlock the comparator is a device hardware reset. |
| 191 | * The only way to unlock the comparator is a device hardware reset. |
191 | * @param COMPx COMP instance |
| 192 | * @param COMPx COMP instance |
192 | * @retval An ErrorStatus enumeration value: |
| 193 | * @retval An ErrorStatus enumeration value: |
193 | * - SUCCESS: COMP registers are de-initialized |
| 194 | * - SUCCESS: COMP registers are de-initialized |
194 | * - ERROR: COMP registers are not de-initialized |
| 195 | * - ERROR: COMP registers are not de-initialized |
195 | */ |
| 196 | */ |
196 | ErrorStatus LL_COMP_DeInit(COMP_TypeDef *COMPx) |
| 197 | ErrorStatus LL_COMP_DeInit(COMP_TypeDef *COMPx) |
197 | { |
| 198 | { |
198 | ErrorStatus status = SUCCESS; |
| 199 | ErrorStatus status = SUCCESS; |
199 | |
| 200 | 200 | /* Check the parameters */ |
|
| 201 | /* Check the parameters */ |
201 | assert_param(IS_COMP_ALL_INSTANCE(COMPx)); |
| 202 | assert_param(IS_COMP_ALL_INSTANCE(COMPx)); |
202 | |
| 203 | 203 | /* Note: On this STM32 series, only COMP instance COMP2 has */ |
|
| 204 | /* Note: On this STM32 serie, only COMP instance COMP2 has */ |
204 | /* features settables: power mode, input minus selection */ |
| 205 | /* features settables: power mode, input minus selection */ |
205 | /* and output selection. */ |
| 206 | /* and output selection. */ |
206 | /* Note: On this STM32 series, setting COMP instance COMP2 input minus */ |
| 207 | /* Note: On this STM32 serie, setting COMP instance COMP2 input minus */ |
207 | /* is enabling the comparator. */ |
| 208 | /* is enabling the comparator. */ |
208 | /* Reset COMP2 input minus also disable the comparator. */ |
| 209 | /* Reset COMP2 input minus also disable the comparator. */ |
209 | /* Note: In case of de-initialization of COMP instance COMP1: */ |
| 210 | /* Note: In case of de-initialization of COMP instance COMP1: */ |
210 | /* Switch COMP_CSR_SW1 is not modified because can be used */ |
| 211 | /* Switch COMP_CSR_SW1 is not modified because can be used */ |
211 | /* to connect OPAMP3 to ADC. */ |
| 212 | /* to connect OPAMP3 to ADC. */ |
212 | /* Switches RI_ASCR1_VCOMP, RI_ASCR1_SCM are reset: let routing */ |
| 213 | /* Switches RI_ASCR1_VCOMP, RI_ASCR1_SCM are reset: let routing */ |
213 | /* interface under control of ADC. */ |
| 214 | /* interface under control of ADC. */ |
214 | if(COMPx == COMP1) |
| 215 | if(COMPx == COMP1) |
215 | { |
| 216 | { |
216 | CLEAR_BIT(COMP->CSR, |
| 217 | CLEAR_BIT(COMP->CSR, |
217 | ( COMP_CSR_CMP1EN |
| 218 | ( COMP_CSR_CMP1EN |
218 | | COMP_CSR_10KPU |
| 219 | | COMP_CSR_10KPU |
219 | | COMP_CSR_400KPU |
| 220 | | COMP_CSR_400KPU |
220 | | COMP_CSR_10KPD |
| 221 | | COMP_CSR_10KPD |
221 | | COMP_CSR_400KPD |
| 222 | | COMP_CSR_400KPD |
222 | ) |
| 223 | ) |
223 | ); |
| 224 | ); |
224 | } |
| 225 | } |
225 | else |
| 226 | else |
226 | { |
| 227 | { |
227 | CLEAR_BIT(COMP->CSR, |
| 228 | CLEAR_BIT(COMP->CSR, |
228 | ( COMP_CSR_SPEED |
| 229 | ( COMP_CSR_SPEED |
229 | | COMP_CSR_INSEL |
| 230 | | COMP_CSR_INSEL |
230 | | COMP_CSR_OUTSEL |
| 231 | | COMP_CSR_OUTSEL |
231 | ) |
| 232 | ) |
232 | ); |
| 233 | ); |
233 | } |
| 234 | } |
234 | |
| 235 | 235 | /* Set comparator input plus */ |
|
| 236 | /* Set comparator input plus */ |
236 | LL_COMP_SetInputPlus(COMPx, LL_COMP_INPUT_PLUS_NONE); |
| 237 | LL_COMP_SetInputPlus(COMPx, LL_COMP_INPUT_PLUS_NONE); |
237 | |
| 238 | 238 | return status; |
|
| 239 | return status; |
239 | } |
| 240 | } |
240 | |
| 241 | 241 | /** |
|
| 242 | /** |
242 | * @brief Initialize some features of COMP instance. |
| 243 | * @brief Initialize some features of COMP instance. |
243 | * @note This function configures features of the selected COMP instance. |
| 244 | * @note This function configures features of the selected COMP instance. |
244 | * Some features are also available at scope COMP common instance |
| 245 | * Some features are also available at scope COMP common instance |
245 | * (common to several COMP instances). |
| 246 | * (common to several COMP instances). |
246 | * Refer to functions having argument "COMPxy_COMMON" as parameter. |
| 247 | * Refer to functions having argument "COMPxy_COMMON" as parameter. |
247 | * @param COMPx COMP instance |
| 248 | * @param COMPx COMP instance |
248 | * @param COMP_InitStruct Pointer to a @ref LL_COMP_InitTypeDef structure |
| 249 | * @param COMP_InitStruct Pointer to a @ref LL_COMP_InitTypeDef structure |
249 | * @retval An ErrorStatus enumeration value: |
| 250 | * @retval An ErrorStatus enumeration value: |
250 | * - SUCCESS: COMP registers are initialized |
| 251 | * - SUCCESS: COMP registers are initialized |
251 | * - ERROR: COMP registers are not initialized |
| 252 | * - ERROR: COMP registers are not initialized |
252 | */ |
| 253 | */ |
253 | ErrorStatus LL_COMP_Init(COMP_TypeDef *COMPx, LL_COMP_InitTypeDef *COMP_InitStruct) |
| 254 | ErrorStatus LL_COMP_Init(COMP_TypeDef *COMPx, LL_COMP_InitTypeDef *COMP_InitStruct) |
254 | { |
| 255 | { |
255 | ErrorStatus status = SUCCESS; |
| 256 | ErrorStatus status = SUCCESS; |
256 | |
| 257 | 257 | /* Check the parameters */ |
|
| 258 | /* Check the parameters */ |
258 | assert_param(IS_COMP_ALL_INSTANCE(COMPx)); |
| 259 | assert_param(IS_COMP_ALL_INSTANCE(COMPx)); |
259 | if(COMPx == COMP2) |
| 260 | if(COMPx == COMP2) |
260 | { |
| 261 | { |
261 | assert_param(IS_LL_COMP_POWER_MODE(COMP_InitStruct->PowerMode)); |
| 262 | assert_param(IS_LL_COMP_POWER_MODE(COMP_InitStruct->PowerMode)); |
262 | assert_param(IS_LL_COMP_INPUT_MINUS(COMPx, COMP_InitStruct->InputMinus)); |
| 263 | assert_param(IS_LL_COMP_INPUT_MINUS(COMPx, COMP_InitStruct->InputMinus)); |
263 | assert_param(IS_LL_COMP_OUTPUT_SELECTION(COMP_InitStruct->OutputSelection)); |
| 264 | assert_param(IS_LL_COMP_OUTPUT_SELECTION(COMP_InitStruct->OutputSelection)); |
264 | } |
| 265 | } |
265 | assert_param(IS_LL_COMP_INPUT_PLUS(COMPx, COMP_InitStruct->InputPlus)); |
| 266 | assert_param(IS_LL_COMP_INPUT_PLUS(COMPx, COMP_InitStruct->InputPlus)); |
266 | |
| 267 | 267 | /* Configuration of comparator instance : */ |
|
| 268 | /* Configuration of comparator instance : */ |
268 | /* - PowerMode */ |
| 269 | /* - PowerMode */ |
269 | /* - InputPlus */ |
| 270 | /* - InputPlus */ |
270 | /* - InputMinus */ |
| 271 | /* - InputMinus */ |
271 | /* - OutputSelection */ |
| 272 | /* - OutputSelection */ |
272 | /* Note: On this STM32 series, only COMP instance COMP2 has */ |
| 273 | /* Note: On this STM32 serie, only COMP instance COMP2 has */ |
273 | /* features settables: power mode, input minus selection */ |
| 274 | /* features settables: power mode, input minus selection */ |
274 | /* and output selection. */ |
| 275 | /* and output selection. */ |
275 | /* Note: On this STM32 series, setting COMP instance COMP2 input minus */ |
| 276 | /* Note: On this STM32 serie, setting COMP instance COMP2 input minus */ |
276 | /* is enabling the comparator. */ |
| 277 | /* is enabling the comparator. */ |
277 | if(COMPx == COMP2) |
| 278 | if(COMPx == COMP2) |
278 | { |
| 279 | { |
279 | MODIFY_REG(COMP->CSR, |
| 280 | MODIFY_REG(COMP->CSR, |
280 | COMP_CSR_SPEED |
| 281 | COMP_CSR_SPEED |
281 | | COMP_CSR_INSEL |
| 282 | | COMP_CSR_INSEL |
282 | | COMP_CSR_OUTSEL |
| 283 | | COMP_CSR_OUTSEL |
283 | , |
| 284 | , |
284 | COMP_InitStruct->PowerMode |
| 285 | COMP_InitStruct->PowerMode |
285 | | COMP_InitStruct->InputMinus |
| 286 | | COMP_InitStruct->InputMinus |
286 | | COMP_InitStruct->OutputSelection |
| 287 | | COMP_InitStruct->OutputSelection |
287 | ); |
| 288 | ); |
288 | |
| 289 | 289 | /* Set comparator input plus */ |
|
| 290 | /* Set comparator input plus */ |
290 | LL_COMP_SetInputPlus(COMPx, COMP_InitStruct->InputPlus); |
| 291 | LL_COMP_SetInputPlus(COMPx, COMP_InitStruct->InputPlus); |
291 | } |
| 292 | } |
292 | else /* COMPx == COMP1 */ |
| 293 | else /* COMPx == COMP1 */ |
293 | { |
| 294 | { |
294 | /* If window mode is enabled, COMP1 input plus is not used and therefore |
| 295 | /* If window mode is enabled, COMP1 input plus is not used and therefore |
295 | not modified */ |
| 296 | not modified */ |
296 | if(READ_BIT(COMP12_COMMON->CSR, COMP_CSR_WNDWE) == COMP_CSR_WNDWE) |
| 297 | if(READ_BIT(COMP12_COMMON->CSR, COMP_CSR_WNDWE) == COMP_CSR_WNDWE) |
297 | { |
| 298 | { |
298 | /* Set comparator input plus */ |
| 299 | /* Set comparator input plus */ |
299 | LL_COMP_SetInputPlus(COMPx, COMP_InitStruct->InputPlus); |
| 300 | LL_COMP_SetInputPlus(COMPx, COMP_InitStruct->InputPlus); |
300 | } |
| 301 | } |
301 | } |
| 302 | } |
302 | |
| 303 | 303 | return status; |
|
| 304 | return status; |
304 | } |
| 305 | } |
305 | |
| 306 | 306 | /** |
|
| 307 | /** |
307 | * @brief Set each @ref LL_COMP_InitTypeDef field to default value. |
| 308 | * @brief Set each @ref LL_COMP_InitTypeDef field to default value. |
308 | * @param COMP_InitStruct: pointer to a @ref LL_COMP_InitTypeDef structure |
| 309 | * @param COMP_InitStruct: pointer to a @ref LL_COMP_InitTypeDef structure |
309 | * whose fields will be set to default values. |
| 310 | * whose fields will be set to default values. |
310 | * @retval None |
| 311 | * @retval None |
311 | */ |
| 312 | */ |
312 | void LL_COMP_StructInit(LL_COMP_InitTypeDef *COMP_InitStruct) |
| 313 | void LL_COMP_StructInit(LL_COMP_InitTypeDef *COMP_InitStruct) |
313 | { |
| 314 | { |
314 | /* Set COMP_InitStruct fields to default values */ |
| 315 | /* Set COMP_InitStruct fields to default values */ |
315 | COMP_InitStruct->PowerMode = LL_COMP_POWERMODE_ULTRALOWPOWER; |
| 316 | COMP_InitStruct->PowerMode = LL_COMP_POWERMODE_ULTRALOWPOWER; |
316 | COMP_InitStruct->InputPlus = LL_COMP_INPUT_PLUS_IO1; |
| 317 | COMP_InitStruct->InputPlus = LL_COMP_INPUT_PLUS_IO1; |
317 | COMP_InitStruct->InputMinus = LL_COMP_INPUT_MINUS_VREFINT; |
| 318 | COMP_InitStruct->InputMinus = LL_COMP_INPUT_MINUS_VREFINT; |
318 | COMP_InitStruct->OutputSelection = LL_COMP_OUTPUT_NONE; |
| 319 | COMP_InitStruct->OutputSelection = LL_COMP_OUTPUT_NONE; |
319 | } |
| 320 | } |
320 | |
| 321 | 321 | /** |
|
| 322 | /** |
322 | * @} |
| 323 | * @} |
323 | */ |
| 324 | */ |
324 | |
| 325 | 325 | /** |
|
| 326 | /** |
326 | * @} |
| 327 | * @} |
327 | */ |
| 328 | */ |
328 | |
| 329 | 329 | /** |
|
| 330 | /** |
330 | * @} |
| 331 | * @} |
331 | */ |
| 332 | */ |
332 | |
| 333 | 333 | #endif /* COMP1 || COMP2 */ |
|
| 334 | #endif /* COMP1 || COMP2 */ |
334 | |
| 335 | 335 | /** |
|
| 336 | /** |
336 | * @} |
| 337 | * @} |
337 | */ |
| 338 | */ |
338 | |
| 339 | 339 | #endif /* USE_FULL_LL_DRIVER */ |
|
| 340 | #endif /* USE_FULL_LL_DRIVER */ |
340 | |
| 341 | - | ||
| 342 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
- | |