-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
stm32f30x_opamp.h
277 lines (218 loc) · 10.7 KB
/
stm32f30x_opamp.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
/**
******************************************************************************
* @file stm32f30x_opamp.h
* @author MCD Application Team
* @version V1.1.1
* @date 04-April-2014
* @brief This file contains all the functions prototypes for the operational
* amplifiers (OPAMP) firmware library.
******************************************************************************
* @attention
*
* <h2><center>© COPYRIGHT 2014 STMicroelectronics</center></h2>
*
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.st.com/software_license_agreement_liberty_v2
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32F30x_OPAMP_H
#define __STM32F30x_OPAMP_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32f30x.h"
/** @addtogroup STM32F30x_StdPeriph_Driver
* @{
*/
/** @addtogroup OPAMP
* @{
*/
/* Exported types ------------------------------------------------------------*/
/**
* @brief OPAMP Init structure definition
*/
typedef struct
{
uint32_t OPAMP_InvertingInput; /*!< Selects the inverting input of the operational amplifier.
This parameter can be a value of @ref OPAMP_InvertingInput */
uint32_t OPAMP_NonInvertingInput; /*!< Selects the non inverting input of the operational amplifier.
This parameter can be a value of @ref OPAMP_NonInvertingInput */
}OPAMP_InitTypeDef;
/* Exported constants --------------------------------------------------------*/
/** @defgroup OPAMP_Exported_Constants
* @{
*/
/** @defgroup OPAMP_Selection
* @{
*/
#define OPAMP_Selection_OPAMP1 ((uint32_t)0x00000000) /*!< OPAMP1 Selection */
#define OPAMP_Selection_OPAMP2 ((uint32_t)0x00000004) /*!< OPAMP2 Selection */
#define OPAMP_Selection_OPAMP3 ((uint32_t)0x00000008) /*!< OPAMP3 Selection */
#define OPAMP_Selection_OPAMP4 ((uint32_t)0x0000000C) /*!< OPAMP4 Selection */
#define IS_OPAMP_ALL_PERIPH(PERIPH) (((PERIPH) == OPAMP_Selection_OPAMP1) || \
((PERIPH) == OPAMP_Selection_OPAMP2) || \
((PERIPH) == OPAMP_Selection_OPAMP3) || \
((PERIPH) == OPAMP_Selection_OPAMP4))
/**
* @}
*/
/** @defgroup OPAMP_InvertingInput
* @{
*/
#define OPAMP_InvertingInput_IO1 ((uint32_t)0x00000000) /*!< IO1 (PC5 for OPAMP1 and OPAMP2, PB10 for OPAMP3 and OPAMP4)
connected to OPAMPx inverting input */
#define OPAMP_InvertingInput_IO2 OPAMP_CSR_VMSEL_0 /*!< IO2 (PA3 for OPAMP1, PA5 for OPAMP2, PB2 for OPAMP3, PD8 for OPAMP4)
connected to OPAMPx inverting input */
#define OPAMP_InvertingInput_PGA OPAMP_CSR_VMSEL_1 /*!< Resistor feedback output connected to OPAMPx inverting input (PGA mode) */
#define OPAMP_InvertingInput_Vout OPAMP_CSR_VMSEL /*!< Vout connected to OPAMPx inverting input (follower mode) */
#define IS_OPAMP_INVERTING_INPUT(INPUT) (((INPUT) == OPAMP_InvertingInput_IO1) || \
((INPUT) == OPAMP_InvertingInput_IO2) || \
((INPUT) == OPAMP_InvertingInput_PGA) || \
((INPUT) == OPAMP_InvertingInput_Vout))
/**
* @}
*/
/** @defgroup OPAMP_NonInvertingInput
* @{
*/
#define OPAMP_NonInvertingInput_IO1 ((uint32_t)0x00000000) /*!< IO1 (PA7 for OPAMP1, PD14 for OPAMP2, PB13 for OPAMP3, PD11 for OPAMP4)
connected to OPAMPx non inverting input */
#define OPAMP_NonInvertingInput_IO2 OPAMP_CSR_VPSEL_0 /*!< IO2 (PA5 for OPAMP1, PB14 for OPAMP2, PA5 for OPAMP3, PB11 for OPAMP4)
connected to OPAMPx non inverting input */
#define OPAMP_NonInvertingInput_IO3 OPAMP_CSR_VPSEL_1 /*!< IO3 (PA3 for OPAMP1, PB0 for OPAMP2, PA1 for OPAMP3, PA4 for OPAMP4)
connected to OPAMPx non inverting input */
#define OPAMP_NonInvertingInput_IO4 OPAMP_CSR_VPSEL /*!< IO4 (PA1 for OPAMP1, PA7 for OPAMP2, PB0 for OPAMP3, PB13 for OPAMP4)
connected to OPAMPx non inverting input */
#define IS_OPAMP_NONINVERTING_INPUT(INPUT) (((INPUT) == OPAMP_NonInvertingInput_IO1) || \
((INPUT) == OPAMP_NonInvertingInput_IO2) || \
((INPUT) == OPAMP_NonInvertingInput_IO3) || \
((INPUT) == OPAMP_NonInvertingInput_IO4))
/**
* @}
*/
/** @defgroup OPAMP_PGAGain_Config
* @{
*/
#define OPAMP_OPAMP_PGAGain_2 ((uint32_t)0x00000000)
#define OPAMP_OPAMP_PGAGain_4 OPAMP_CSR_PGGAIN_0
#define OPAMP_OPAMP_PGAGain_8 OPAMP_CSR_PGGAIN_1
#define OPAMP_OPAMP_PGAGain_16 ((uint32_t)0x0000C000)
#define IS_OPAMP_PGAGAIN(GAIN) (((GAIN) == OPAMP_OPAMP_PGAGain_2) || \
((GAIN) == OPAMP_OPAMP_PGAGain_4) || \
((GAIN) == OPAMP_OPAMP_PGAGain_8) || \
((GAIN) == OPAMP_OPAMP_PGAGain_16))
/**
* @}
*/
/** @defgroup OPAMP_PGAConnect_Config
* @{
*/
#define OPAMP_PGAConnect_No ((uint32_t)0x00000000)
#define OPAMP_PGAConnect_IO1 OPAMP_CSR_PGGAIN_3
#define OPAMP_PGAConnect_IO2 ((uint32_t)0x00030000)
#define IS_OPAMP_PGACONNECT(CONNECT) (((CONNECT) == OPAMP_PGAConnect_No) || \
((CONNECT) == OPAMP_PGAConnect_IO1) || \
((CONNECT) == OPAMP_PGAConnect_IO2))
/**
* @}
*/
/** @defgroup OPAMP_SecondaryInvertingInput
* @{
*/
#define IS_OPAMP_SECONDARY_INVINPUT(INVINPUT) (((INVINPUT) == OPAMP_InvertingInput_IO1) || \
((INVINPUT) == OPAMP_InvertingInput_IO2))
/**
* @}
*/
/** @defgroup OPAMP_Input
* @{
*/
#define OPAMP_Input_Inverting ((uint32_t)0x00000018) /*!< Inverting input */
#define OPAMP_Input_NonInverting ((uint32_t)0x00000013) /*!< Non inverting input */
#define IS_OPAMP_INPUT(INPUT) (((INPUT) == OPAMP_Input_Inverting) || \
((INPUT) == OPAMP_Input_NonInverting))
/**
* @}
*/
/** @defgroup OPAMP_Vref
* @{
*/
#define OPAMP_Vref_3VDDA ((uint32_t)0x00000000) /*!< OPMAP Vref = 3.3% VDDA */
#define OPAMP_Vref_10VDDA OPAMP_CSR_CALSEL_0 /*!< OPMAP Vref = 10% VDDA */
#define OPAMP_Vref_50VDDA OPAMP_CSR_CALSEL_1 /*!< OPMAP Vref = 50% VDDA */
#define OPAMP_Vref_90VDDA OPAMP_CSR_CALSEL /*!< OPMAP Vref = 90% VDDA */
#define IS_OPAMP_VREF(VREF) (((VREF) == OPAMP_Vref_3VDDA) || \
((VREF) == OPAMP_Vref_10VDDA) || \
((VREF) == OPAMP_Vref_50VDDA) || \
((VREF) == OPAMP_Vref_90VDDA))
/**
* @}
*/
/** @defgroup OPAMP_Trimming
*/
#define OPAMP_Trimming_Factory ((uint32_t)0x00000000) /*!< Factory trimming */
#define OPAMP_Trimming_User OPAMP_CSR_USERTRIM /*!< User trimming */
#define IS_OPAMP_TRIMMING(TRIMMING) (((TRIMMING) == OPAMP_Trimming_Factory) || \
((TRIMMING) == OPAMP_Trimming_User))
/**
* @}
*/
/** @defgroup OPAMP_TrimValue
* @{
*/
#define IS_OPAMP_TRIMMINGVALUE(VALUE) ((VALUE) <= 0x0000001F) /*!< Trimming value */
/**
* @}
*/
/** @defgroup OPAMP_OutputLevel
* @{
*/
#define OPAMP_OutputLevel_High OPAMP_CSR_OUTCAL
#define OPAMP_OutputLevel_Low ((uint32_t)0x00000000)
/**
* @}
*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
/* Function used to set the OPAMP configuration to the default reset state ***/
void OPAMP_DeInit(uint32_t OPAMP_Selection);
/* Initialization and Configuration functions *********************************/
void OPAMP_Init(uint32_t OPAMP_Selection, OPAMP_InitTypeDef* OPAMP_InitStruct);
void OPAMP_StructInit(OPAMP_InitTypeDef* OPAMP_InitStruct);
void OPAMP_PGAConfig(uint32_t OPAMP_Selection, uint32_t OPAMP_PGAGain, uint32_t OPAMP_PGAConnect);
void OPAMP_VrefConfig(uint32_t OPAMP_Selection, uint32_t OPAMP_Vref);
void OPAMP_VrefConnectADCCmd(uint32_t OPAMP_Selection, FunctionalState NewState);
void OPAMP_TimerControlledMuxConfig(uint32_t OPAMP_Selection, OPAMP_InitTypeDef* OPAMP_InitStruct);
void OPAMP_TimerControlledMuxCmd(uint32_t OPAMP_Selection, FunctionalState NewState);
void OPAMP_Cmd(uint32_t OPAMP_Selection, FunctionalState NewState);
uint32_t OPAMP_GetOutputLevel(uint32_t OPAMP_Selection);
/* Calibration functions ******************************************************/
void OPAMP_VrefConnectNonInvertingInput(uint32_t OPAMP_Selection, FunctionalState NewState);
void OPAMP_OffsetTrimModeSelect(uint32_t OPAMP_Selection, uint32_t OPAMP_Trimming);
void OPAMP_OffsetTrimConfig(uint32_t OPAMP_Selection, uint32_t OPAMP_Input, uint32_t OPAMP_TrimValue);
void OPAMP_StartCalibration(uint32_t OPAMP_Selection, FunctionalState NewState);
/* OPAMP configuration locking function ***************************************/
void OPAMP_LockConfig(uint32_t OPAMP_Selection);
#ifdef __cplusplus
}
#endif
#endif /*__STM32F30x_OPAMP_H */
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/