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_opamp.c |
3 | * @file stm32l1xx_ll_opamp.c |
4 | * @author MCD Application Team |
4 | * @author MCD Application Team |
5 | * @brief OPAMP LL module driver |
5 | * @brief OPAMP 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_opamp.h" |
22 | #include "stm32l1xx_ll_opamp.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 (OPAMP1) || defined (OPAMP2) || defined (OPAMP3) |
|
34 | #if defined (OPAMP1) || defined (OPAMP2) || defined (OPAMP3) |
34 | |
35 | 35 | /** @addtogroup OPAMP_LL OPAMP |
|
36 | /** @addtogroup OPAMP_LL OPAMP |
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 OPAMP_LL_Private_Macros |
|
45 | /** @addtogroup OPAMP_LL_Private_Macros |
45 | * @{ |
46 | * @{ |
46 | */ |
47 | */ |
47 | |
48 | 48 | /* Check of parameters for configuration of OPAMP hierarchical scope: */ |
|
49 | /* Check of parameters for configuration of OPAMP hierarchical scope: */ |
49 | /* OPAMP instance. */ |
50 | /* OPAMP instance. */ |
50 | |
51 | 51 | #define IS_LL_OPAMP_POWER_MODE(__POWER_MODE__) \ |
|
52 | #define IS_LL_OPAMP_POWER_MODE(__POWER_MODE__) \ |
52 | ( ((__POWER_MODE__) == LL_OPAMP_POWERMODE_NORMAL) \ |
53 | ( ((__POWER_MODE__) == LL_OPAMP_POWERMODE_NORMAL) \ |
53 | || ((__POWER_MODE__) == LL_OPAMP_POWERMODE_LOWPOWER)) |
54 | || ((__POWER_MODE__) == LL_OPAMP_POWERMODE_LOWPOWER)) |
54 | |
55 | 55 | #define IS_LL_OPAMP_FUNCTIONAL_MODE(__FUNCTIONAL_MODE__) \ |
|
56 | #define IS_LL_OPAMP_FUNCTIONAL_MODE(__FUNCTIONAL_MODE__) \ |
56 | ( ((__FUNCTIONAL_MODE__) == LL_OPAMP_MODE_STANDALONE) \ |
57 | ( ((__FUNCTIONAL_MODE__) == LL_OPAMP_MODE_STANDALONE) \ |
57 | || ((__FUNCTIONAL_MODE__) == LL_OPAMP_MODE_FOLLOWER) \ |
58 | || ((__FUNCTIONAL_MODE__) == LL_OPAMP_MODE_FOLLOWER) \ |
58 | ) |
59 | ) |
59 | |
60 | 60 | /* Note: Comparator non-inverting inputs parameters are different */ |
|
61 | /* Note: Comparator non-inverting inputs parameters are different */ |
61 | /* depending on OPAMP instance. */ |
62 | /* depending on OPAMP instance. */ |
62 | #if defined(OPAMP3) |
63 | #if defined(OPAMP3) |
63 | #define IS_LL_OPAMP_INPUT_NONINVERTING(__OPAMPX__, __INPUT_NONINVERTING__) \ |
64 | #define IS_LL_OPAMP_INPUT_NONINVERTING(__OPAMPX__, __INPUT_NONINVERTING__) \ |
64 | (((__OPAMPX__) == OPAMP1) \ |
65 | (((__OPAMPX__) == OPAMP1) \ |
65 | ? ( \ |
66 | ? ( \ |
66 | ((__INPUT_NONINVERTING__) == LL_OPAMP_INPUT_NONINVERT_IO0) \ |
67 | ((__INPUT_NONINVERTING__) == LL_OPAMP_INPUT_NONINVERT_IO0) \ |
67 | || ((__INPUT_NONINVERTING__) == LL_OPAMP_INPUT_NONINV_DAC1_CH1) \ |
68 | || ((__INPUT_NONINVERTING__) == LL_OPAMP_INPUT_NONINV_DAC1_CH1) \ |
68 | ) \ |
69 | ) \ |
69 | : \ |
70 | : \ |
70 | (((__OPAMPX__) == OPAMP2) \ |
71 | (((__OPAMPX__) == OPAMP2) \ |
71 | ? ( \ |
72 | ? ( \ |
72 | ((__INPUT_NONINVERTING__) == LL_OPAMP_INPUT_NONINVERT_IO0) \ |
73 | ((__INPUT_NONINVERTING__) == LL_OPAMP_INPUT_NONINVERT_IO0) \ |
73 | || ((__INPUT_NONINVERTING__) == LL_OPAMP_INPUT_NONINV_DAC1_CH1) \ |
74 | || ((__INPUT_NONINVERTING__) == LL_OPAMP_INPUT_NONINV_DAC1_CH1) \ |
74 | || ((__INPUT_NONINVERTING__) == LL_OPAMP_INPUT_NONINV_DAC1_CH2) \ |
75 | || ((__INPUT_NONINVERTING__) == LL_OPAMP_INPUT_NONINV_DAC1_CH2) \ |
75 | ) \ |
76 | ) \ |
76 | : \ |
77 | : \ |
77 | ( \ |
78 | ( \ |
78 | ((__INPUT_NONINVERTING__) == LL_OPAMP_INPUT_NONINVERT_IO0) \ |
79 | ((__INPUT_NONINVERTING__) == LL_OPAMP_INPUT_NONINVERT_IO0) \ |
79 | || ((__INPUT_NONINVERTING__) == LL_OPAMP_INPUT_NONINV_DAC1_CH2_OPAMP3) \ |
80 | || ((__INPUT_NONINVERTING__) == LL_OPAMP_INPUT_NONINV_DAC1_CH2_OPAMP3) \ |
80 | ) \ |
81 | ) \ |
81 | ) \ |
82 | ) \ |
82 | ) |
83 | ) |
83 | #else |
84 | #else |
84 | #define IS_LL_OPAMP_INPUT_NONINVERTING(__OPAMPX__, __INPUT_NONINVERTING__) \ |
85 | #define IS_LL_OPAMP_INPUT_NONINVERTING(__OPAMPX__, __INPUT_NONINVERTING__) \ |
85 | (((__OPAMPX__) == OPAMP1) \ |
86 | (((__OPAMPX__) == OPAMP1) \ |
86 | ? ( \ |
87 | ? ( \ |
87 | ((__INPUT_NONINVERTING__) == LL_OPAMP_INPUT_NONINVERT_IO0) \ |
88 | ((__INPUT_NONINVERTING__) == LL_OPAMP_INPUT_NONINVERT_IO0) \ |
88 | || ((__INPUT_NONINVERTING__) == LL_OPAMP_INPUT_NONINV_DAC1_CH1) \ |
89 | || ((__INPUT_NONINVERTING__) == LL_OPAMP_INPUT_NONINV_DAC1_CH1) \ |
89 | ) \ |
90 | ) \ |
90 | : \ |
91 | : \ |
91 | ( \ |
92 | ( \ |
92 | ((__INPUT_NONINVERTING__) == LL_OPAMP_INPUT_NONINVERT_IO0) \ |
93 | ((__INPUT_NONINVERTING__) == LL_OPAMP_INPUT_NONINVERT_IO0) \ |
93 | || ((__INPUT_NONINVERTING__) == LL_OPAMP_INPUT_NONINV_DAC1_CH1) \ |
94 | || ((__INPUT_NONINVERTING__) == LL_OPAMP_INPUT_NONINV_DAC1_CH1) \ |
94 | || ((__INPUT_NONINVERTING__) == LL_OPAMP_INPUT_NONINV_DAC1_CH2) \ |
95 | || ((__INPUT_NONINVERTING__) == LL_OPAMP_INPUT_NONINV_DAC1_CH2) \ |
95 | ) \ |
96 | ) \ |
96 | ) |
97 | ) |
97 | #endif |
98 | #endif |
98 | |
99 | 99 | /* Note: Comparator non-inverting inputs parameters are the same on all */ |
|
100 | /* Note: Comparator non-inverting inputs parameters are the same on all */ |
100 | /* OPAMP instances. */ |
101 | /* OPAMP instances. */ |
101 | /* However, comparator instance kept as macro parameter for */ |
102 | /* However, comparator instance kept as macro parameter for */ |
102 | /* compatibility with other STM32 families. */ |
103 | /* compatibility with other STM32 families. */ |
103 | #define IS_LL_OPAMP_INPUT_INVERTING(__OPAMPX__, __INPUT_INVERTING__) \ |
104 | #define IS_LL_OPAMP_INPUT_INVERTING(__OPAMPX__, __INPUT_INVERTING__) \ |
104 | ( ((__INPUT_INVERTING__) == LL_OPAMP_INPUT_INVERT_IO0) \ |
105 | ( ((__INPUT_INVERTING__) == LL_OPAMP_INPUT_INVERT_IO0) \ |
105 | || ((__INPUT_INVERTING__) == LL_OPAMP_INPUT_INVERT_IO1) \ |
106 | || ((__INPUT_INVERTING__) == LL_OPAMP_INPUT_INVERT_IO1) \ |
106 | || ((__INPUT_INVERTING__) == LL_OPAMP_INPUT_INVERT_CONNECT_NO) \ |
107 | || ((__INPUT_INVERTING__) == LL_OPAMP_INPUT_INVERT_CONNECT_NO) \ |
107 | ) |
108 | ) |
108 | |
109 | 109 | /** |
|
110 | /** |
110 | * @} |
111 | * @} |
111 | */ |
112 | */ |
112 | |
113 | 113 | ||
114 | 114 | /* Private function prototypes -----------------------------------------------*/ |
|
115 | /* Private function prototypes -----------------------------------------------*/ |
115 | |
116 | 116 | /* Exported functions --------------------------------------------------------*/ |
|
117 | /* Exported functions --------------------------------------------------------*/ |
117 | /** @addtogroup OPAMP_LL_Exported_Functions |
118 | /** @addtogroup OPAMP_LL_Exported_Functions |
118 | * @{ |
119 | * @{ |
119 | */ |
120 | */ |
120 | |
121 | 121 | /** @addtogroup OPAMP_LL_EF_Init |
|
122 | /** @addtogroup OPAMP_LL_EF_Init |
122 | * @{ |
123 | * @{ |
123 | */ |
124 | */ |
124 | |
125 | 125 | /** |
|
126 | /** |
126 | * @brief De-initialize registers of the selected OPAMP instance |
127 | * @brief De-initialize registers of the selected OPAMP instance |
127 | * to their default reset values. |
128 | * to their default reset values. |
128 | * @param OPAMPx OPAMP instance |
129 | * @param OPAMPx OPAMP instance |
129 | * @retval An ErrorStatus enumeration value: |
130 | * @retval An ErrorStatus enumeration value: |
130 | * - SUCCESS: OPAMP registers are de-initialized |
131 | * - SUCCESS: OPAMP registers are de-initialized |
131 | * - ERROR: OPAMP registers are not de-initialized |
132 | * - ERROR: OPAMP registers are not de-initialized |
132 | */ |
133 | */ |
133 | ErrorStatus LL_OPAMP_DeInit(OPAMP_TypeDef* OPAMPx) |
134 | ErrorStatus LL_OPAMP_DeInit(OPAMP_TypeDef* OPAMPx) |
134 | { |
135 | { |
135 | ErrorStatus status = SUCCESS; |
136 | ErrorStatus status = SUCCESS; |
136 | |
137 | 137 | /* Check the parameters */ |
|
138 | /* Check the parameters */ |
138 | assert_param(IS_OPAMP_ALL_INSTANCE(OPAMPx)); |
139 | assert_param(IS_OPAMP_ALL_INSTANCE(OPAMPx)); |
139 | |
140 | 140 | MODIFY_REG(OPAMP->CSR, |
|
141 | MODIFY_REG(OPAMP->CSR, |
141 | (OPAMP_CSR_S3SEL1 | OPAMP_CSR_S4SEL1 | OPAMP_CSR_S5SEL1 | OPAMP_CSR_S6SEL1 | OPAMP_CSR_OPA1CAL_L | OPAMP_CSR_OPA1CAL_H | OPAMP_CSR_OPA1LPM) << __OPAMP_INSTANCE_BITOFFSET(OPAMPx) |
142 | (OPAMP_CSR_S3SEL1 | OPAMP_CSR_S4SEL1 | OPAMP_CSR_S5SEL1 | OPAMP_CSR_S6SEL1 | OPAMP_CSR_OPA1CAL_L | OPAMP_CSR_OPA1CAL_H | OPAMP_CSR_OPA1LPM) << __OPAMP_INSTANCE_BITOFFSET(OPAMPx) |
142 | | (OPAMP_CSR_ANAWSEL1) << __OPAMP_INSTANCE_DECIMAL(OPAMPx) |
143 | | (OPAMP_CSR_ANAWSEL1) << __OPAMP_INSTANCE_DECIMAL(OPAMPx) |
143 | | (OPAMP_CSR_S7SEL2 * __OPAMP_IS_INSTANCE_OPAMP2(OPAMPx)) , |
144 | | (OPAMP_CSR_S7SEL2 * __OPAMP_IS_INSTANCE_OPAMP2(OPAMPx)) , |
144 | (OPAMP_CSR_OPA1PD) << __OPAMP_INSTANCE_BITOFFSET(OPAMPx) |
145 | (OPAMP_CSR_OPA1PD) << __OPAMP_INSTANCE_BITOFFSET(OPAMPx) |
145 | ); |
146 | ); |
146 | return status; |
147 | return status; |
147 | } |
148 | } |
148 | |
149 | 149 | /** |
|
150 | /** |
150 | * @brief Initialize some features of OPAMP instance. |
151 | * @brief Initialize some features of OPAMP instance. |
151 | * @note This function reset bit of calibration mode to ensure |
152 | * @note This function reset bit of calibration mode to ensure |
152 | * to be in functional mode, in order to have OPAMP parameters |
153 | * to be in functional mode, in order to have OPAMP parameters |
153 | * (inputs selection, ...) set with the corresponding OPAMP mode |
154 | * (inputs selection, ...) set with the corresponding OPAMP mode |
154 | * to be effective. |
155 | * to be effective. |
155 | * @note This function configures features of the selected OPAMP instance. |
156 | * @note This function configures features of the selected OPAMP instance. |
156 | * Some features are also available at scope OPAMP common instance |
157 | * Some features are also available at scope OPAMP common instance |
157 | * (common to several OPAMP instances). |
158 | * (common to several OPAMP instances). |
158 | * Refer to functions having argument "OPAMPxy_COMMON" as parameter. |
159 | * Refer to functions having argument "OPAMPxy_COMMON" as parameter. |
159 | * @param OPAMPx OPAMP instance |
160 | * @param OPAMPx OPAMP instance |
160 | * @param OPAMP_InitStruct Pointer to a @ref LL_OPAMP_InitTypeDef structure |
161 | * @param OPAMP_InitStruct Pointer to a @ref LL_OPAMP_InitTypeDef structure |
161 | * @retval An ErrorStatus enumeration value: |
162 | * @retval An ErrorStatus enumeration value: |
162 | * - SUCCESS: OPAMP registers are initialized |
163 | * - SUCCESS: OPAMP registers are initialized |
163 | * - ERROR: OPAMP registers are not initialized |
164 | * - ERROR: OPAMP registers are not initialized |
164 | */ |
165 | */ |
165 | ErrorStatus LL_OPAMP_Init(OPAMP_TypeDef *OPAMPx, LL_OPAMP_InitTypeDef *OPAMP_InitStruct) |
166 | ErrorStatus LL_OPAMP_Init(OPAMP_TypeDef *OPAMPx, LL_OPAMP_InitTypeDef *OPAMP_InitStruct) |
166 | { |
167 | { |
167 | /* Check the parameters */ |
168 | /* Check the parameters */ |
168 | assert_param(IS_OPAMP_ALL_INSTANCE(OPAMPx)); |
169 | assert_param(IS_OPAMP_ALL_INSTANCE(OPAMPx)); |
169 | assert_param(IS_LL_OPAMP_POWER_MODE(OPAMP_InitStruct->PowerMode)); |
170 | assert_param(IS_LL_OPAMP_POWER_MODE(OPAMP_InitStruct->PowerMode)); |
170 | assert_param(IS_LL_OPAMP_FUNCTIONAL_MODE(OPAMP_InitStruct->FunctionalMode)); |
171 | assert_param(IS_LL_OPAMP_FUNCTIONAL_MODE(OPAMP_InitStruct->FunctionalMode)); |
171 | assert_param(IS_LL_OPAMP_INPUT_NONINVERTING(OPAMPx, OPAMP_InitStruct->InputNonInverting)); |
172 | assert_param(IS_LL_OPAMP_INPUT_NONINVERTING(OPAMPx, OPAMP_InitStruct->InputNonInverting)); |
172 | |
173 | 173 | /* Note: OPAMP inverting input can be used with OPAMP in mode standalone. */ |
|
174 | /* Note: OPAMP inverting input can be used with OPAMP in mode standalone. */ |
174 | /* Otherwise (OPAMP in mode follower), OPAMP inverting input is */ |
175 | /* Otherwise (OPAMP in mode follower), OPAMP inverting input is */ |
175 | /* not used (not connected to GPIO pin). */ |
176 | /* not used (not connected to GPIO pin). */ |
176 | if(OPAMP_InitStruct->FunctionalMode != LL_OPAMP_MODE_FOLLOWER) |
177 | if(OPAMP_InitStruct->FunctionalMode != LL_OPAMP_MODE_FOLLOWER) |
177 | { |
178 | { |
178 | assert_param(IS_LL_OPAMP_INPUT_INVERTING(OPAMPx, OPAMP_InitStruct->InputInverting)); |
179 | assert_param(IS_LL_OPAMP_INPUT_INVERTING(OPAMPx, OPAMP_InitStruct->InputInverting)); |
179 | } |
180 | } |
180 | |
181 | 181 | /* Configuration of OPAMP instance : */ |
|
182 | /* Configuration of OPAMP instance : */ |
182 | /* - PowerMode */ |
183 | /* - PowerMode */ |
183 | /* - Functional mode */ |
184 | /* - Functional mode */ |
184 | /* - Input non-inverting */ |
185 | /* - Input non-inverting */ |
185 | /* - Input inverting */ |
186 | /* - Input inverting */ |
186 | /* Note: Bits OPAMP_CSR_OPAxCAL_y reset to ensure to be in functional mode */ |
187 | /* Note: Bits OPAMP_CSR_OPAxCAL_y reset to ensure to be in functional mode */ |
187 | if(OPAMP_InitStruct->FunctionalMode != LL_OPAMP_MODE_FOLLOWER) |
188 | if(OPAMP_InitStruct->FunctionalMode != LL_OPAMP_MODE_FOLLOWER) |
188 | { |
189 | { |
189 | MODIFY_REG(OPAMP->CSR, |
190 | MODIFY_REG(OPAMP->CSR, |
190 | (( |
191 | (( |
191 | OPAMP_CSR_OPA1LPM |
192 | OPAMP_CSR_OPA1LPM |
192 | | OPAMP_CSR_S3SEL1 |
193 | | OPAMP_CSR_S3SEL1 |
193 | | OPAMP_CSR_OPA1CAL_H |
194 | | OPAMP_CSR_OPA1CAL_H |
194 | | OPAMP_CSR_OPA1CAL_L |
195 | | OPAMP_CSR_OPA1CAL_L |
195 | | OPAMP_CSR_S5SEL1 |
196 | | OPAMP_CSR_S5SEL1 |
196 | | OPAMP_CSR_S6SEL1 |
197 | | OPAMP_CSR_S6SEL1 |
197 | | OPAMP_CSR_S4SEL1 |
198 | | OPAMP_CSR_S4SEL1 |
198 | ) << __OPAMP_INSTANCE_BITOFFSET(OPAMPx) |
199 | ) << __OPAMP_INSTANCE_BITOFFSET(OPAMPx) |
199 | ) |
200 | ) |
200 | | ((OPAMP_CSR_ANAWSEL1) << __OPAMP_INSTANCE_DECIMAL(OPAMPx)) |
201 | | ((OPAMP_CSR_ANAWSEL1) << __OPAMP_INSTANCE_DECIMAL(OPAMPx)) |
201 | | (OPAMP_CSR_S7SEL2 * __OPAMP_IS_INSTANCE_OPAMP2(OPAMPx)) |
202 | | (OPAMP_CSR_S7SEL2 * __OPAMP_IS_INSTANCE_OPAMP2(OPAMPx)) |
202 | , |
203 | , |
203 | (( |
204 | (( |
204 | (OPAMP_InitStruct->PowerMode & OPAMP_POWERMODE_CSR_BIT_MASK) |
205 | (OPAMP_InitStruct->PowerMode & OPAMP_POWERMODE_CSR_BIT_MASK) |
205 | | OPAMP_InitStruct->FunctionalMode |
206 | | OPAMP_InitStruct->FunctionalMode |
206 | | OPAMP_InitStruct->InputNonInverting |
207 | | OPAMP_InitStruct->InputNonInverting |
207 | | (OPAMP_InitStruct->InputInverting & OPAMP_CSR_S4SEL1) |
208 | | (OPAMP_InitStruct->InputInverting & OPAMP_CSR_S4SEL1) |
208 | ) << __OPAMP_INSTANCE_BITOFFSET(OPAMPx) |
209 | ) << __OPAMP_INSTANCE_BITOFFSET(OPAMPx) |
209 | ) |
210 | ) |
210 | | ((OPAMP_InitStruct->InputInverting & OPAMP_CSR_ANAWSEL1) << __OPAMP_INSTANCE_DECIMAL(OPAMPx)) |
211 | | ((OPAMP_InitStruct->InputInverting & OPAMP_CSR_ANAWSEL1) << __OPAMP_INSTANCE_DECIMAL(OPAMPx)) |
211 | | ((OPAMP_InitStruct->InputNonInverting & OPAMP_CSR_S7SEL2) * __OPAMP_IS_INSTANCE_OPAMP2(OPAMPx)) |
212 | | ((OPAMP_InitStruct->InputNonInverting & OPAMP_CSR_S7SEL2) * __OPAMP_IS_INSTANCE_OPAMP2(OPAMPx)) |
212 | ); |
213 | ); |
213 | } |
214 | } |
214 | else |
215 | else |
215 | { |
216 | { |
216 | MODIFY_REG(OPAMP->CSR, |
217 | MODIFY_REG(OPAMP->CSR, |
217 | (( |
218 | (( |
218 | OPAMP_CSR_OPA1LPM |
219 | OPAMP_CSR_OPA1LPM |
219 | | OPAMP_CSR_OPA1CAL_H |
220 | | OPAMP_CSR_OPA1CAL_H |
220 | | OPAMP_CSR_OPA1CAL_L |
221 | | OPAMP_CSR_OPA1CAL_L |
221 | | OPAMP_CSR_S5SEL1 |
222 | | OPAMP_CSR_S5SEL1 |
222 | | OPAMP_CSR_S6SEL1 |
223 | | OPAMP_CSR_S6SEL1 |
223 | | OPAMP_CSR_S4SEL1 |
224 | | OPAMP_CSR_S4SEL1 |
224 | ) << __OPAMP_INSTANCE_BITOFFSET(OPAMPx) |
225 | ) << __OPAMP_INSTANCE_BITOFFSET(OPAMPx) |
225 | ) |
226 | ) |
226 | | ((OPAMP_CSR_ANAWSEL1) << __OPAMP_INSTANCE_DECIMAL(OPAMPx)) |
227 | | ((OPAMP_CSR_ANAWSEL1) << __OPAMP_INSTANCE_DECIMAL(OPAMPx)) |
227 | | (OPAMP_CSR_S7SEL2 * __OPAMP_IS_INSTANCE_OPAMP2(OPAMPx)) |
228 | | (OPAMP_CSR_S7SEL2 * __OPAMP_IS_INSTANCE_OPAMP2(OPAMPx)) |
228 | , |
229 | , |
229 | (( |
230 | (( |
230 | (OPAMP_InitStruct->PowerMode & OPAMP_POWERMODE_CSR_BIT_MASK) |
231 | (OPAMP_InitStruct->PowerMode & OPAMP_POWERMODE_CSR_BIT_MASK) |
231 | | OPAMP_InitStruct->FunctionalMode |
232 | | OPAMP_InitStruct->FunctionalMode |
232 | | OPAMP_InitStruct->InputNonInverting |
233 | | OPAMP_InitStruct->InputNonInverting |
233 | | OPAMP_CSR_S3SEL1 |
234 | | OPAMP_CSR_S3SEL1 |
234 | ) << __OPAMP_INSTANCE_BITOFFSET(OPAMPx) |
235 | ) << __OPAMP_INSTANCE_BITOFFSET(OPAMPx) |
235 | ) |
236 | ) |
236 | | ((OPAMP_InitStruct->InputNonInverting & OPAMP_CSR_S7SEL2) * __OPAMP_IS_INSTANCE_OPAMP2(OPAMPx)) |
237 | | ((OPAMP_InitStruct->InputNonInverting & OPAMP_CSR_S7SEL2) * __OPAMP_IS_INSTANCE_OPAMP2(OPAMPx)) |
237 | ); |
238 | ); |
238 | } |
239 | } |
239 | return SUCCESS; |
240 | return SUCCESS; |
240 | } |
241 | } |
241 | |
242 | 242 | /** |
|
243 | /** |
243 | * @brief Set each @ref LL_OPAMP_InitTypeDef field to default value. |
244 | * @brief Set each @ref LL_OPAMP_InitTypeDef field to default value. |
244 | * @param OPAMP_InitStruct pointer to a @ref LL_OPAMP_InitTypeDef structure |
245 | * @param OPAMP_InitStruct pointer to a @ref LL_OPAMP_InitTypeDef structure |
245 | * whose fields will be set to default values. |
246 | * whose fields will be set to default values. |
246 | * @retval None |
247 | * @retval None |
247 | */ |
248 | */ |
248 | void LL_OPAMP_StructInit(LL_OPAMP_InitTypeDef *OPAMP_InitStruct) |
249 | void LL_OPAMP_StructInit(LL_OPAMP_InitTypeDef *OPAMP_InitStruct) |
249 | { |
250 | { |
250 | /* Set OPAMP_InitStruct fields to default values */ |
251 | /* Set OPAMP_InitStruct fields to default values */ |
251 | OPAMP_InitStruct->PowerMode = LL_OPAMP_POWERMODE_NORMAL; |
252 | OPAMP_InitStruct->PowerMode = LL_OPAMP_POWERMODE_NORMAL; |
252 | OPAMP_InitStruct->FunctionalMode = LL_OPAMP_MODE_FOLLOWER; |
253 | OPAMP_InitStruct->FunctionalMode = LL_OPAMP_MODE_FOLLOWER; |
253 | OPAMP_InitStruct->InputNonInverting = LL_OPAMP_INPUT_NONINVERT_IO0; |
254 | OPAMP_InitStruct->InputNonInverting = LL_OPAMP_INPUT_NONINVERT_IO0; |
254 | /* Note: Parameter discarded if OPAMP in functional mode follower, */ |
255 | /* Note: Parameter discarded if OPAMP in functional mode follower, */ |
255 | /* set anyway to its default value. */ |
256 | /* set anyway to its default value. */ |
256 | OPAMP_InitStruct->InputInverting = LL_OPAMP_INPUT_INVERT_CONNECT_NO; |
257 | OPAMP_InitStruct->InputInverting = LL_OPAMP_INPUT_INVERT_CONNECT_NO; |
257 | } |
258 | } |
258 | |
259 | 259 | /** |
|
260 | /** |
260 | * @} |
261 | * @} |
261 | */ |
262 | */ |
262 | |
263 | 263 | /** |
|
264 | /** |
264 | * @} |
265 | * @} |
265 | */ |
266 | */ |
266 | |
267 | 267 | /** |
|
268 | /** |
268 | * @} |
269 | * @} |
269 | */ |
270 | */ |
270 | |
271 | 271 | #endif /* OPAMP1 || OPAMP2 || OPAMP3 */ |
|
272 | #endif /* OPAMP1 || OPAMP2 || OPAMP3 */ |
272 | |
273 | 273 | /** |
|
274 | /** |
274 | * @} |
275 | * @} |
275 | */ |
276 | */ |
276 | |
277 | 277 | #endif /* USE_FULL_LL_DRIVER */ |
|
278 | #endif /* USE_FULL_LL_DRIVER */ |
278 | |
279 | - | ||
280 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
- |