2 ******************************************************************************
3 * @file stm32f30x_opamp.h
4 * @author MCD Application Team
6 * @date 27-February-2014
7 * @brief This file contains all the functions prototypes for the operational
8 * amplifiers (OPAMP) firmware library.
9 ******************************************************************************
12 * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
14 * Redistribution and use in source and binary forms, with or without modification,
15 * are permitted provided that the following conditions are met:
16 * 1. Redistributions of source code must retain the above copyright notice,
17 * this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright notice,
19 * this list of conditions and the following disclaimer in the documentation
20 * and/or other materials provided with the distribution.
21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 ******************************************************************************
39 /* Define to prevent recursive inclusion -------------------------------------*/
40 #ifndef __STM32F30x_OPAMP_H
41 #define __STM32F30x_OPAMP_H
47 /* Includes ------------------------------------------------------------------*/
48 #include "stm32f30x.h"
50 /** @addtogroup STM32F30x_StdPeriph_Driver
58 /* Exported types ------------------------------------------------------------*/
61 * @brief OPAMP Init structure definition
67 uint32_t OPAMP_InvertingInput; /*!< Selects the inverting input of the operational amplifier.
68 This parameter can be a value of @ref OPAMP_InvertingInput */
70 uint32_t OPAMP_NonInvertingInput; /*!< Selects the non inverting input of the operational amplifier.
71 This parameter can be a value of @ref OPAMP_NonInvertingInput */
75 /* Exported constants --------------------------------------------------------*/
77 /** @defgroup OPAMP_Exported_Constants
81 /** @defgroup OPAMP_Selection
85 #define OPAMP_Selection_OPAMP1 ((uint32_t)0x00000000) /*!< OPAMP1 Selection */
86 #define OPAMP_Selection_OPAMP2 ((uint32_t)0x00000004) /*!< OPAMP2 Selection */
87 #define OPAMP_Selection_OPAMP3 ((uint32_t)0x00000008) /*!< OPAMP3 Selection */
88 #define OPAMP_Selection_OPAMP4 ((uint32_t)0x0000000C) /*!< OPAMP4 Selection */
90 #define IS_OPAMP_ALL_PERIPH(PERIPH) (((PERIPH) == OPAMP_Selection_OPAMP1) || \
91 ((PERIPH) == OPAMP_Selection_OPAMP2) || \
92 ((PERIPH) == OPAMP_Selection_OPAMP3) || \
93 ((PERIPH) == OPAMP_Selection_OPAMP4))
99 /** @defgroup OPAMP_InvertingInput
103 #define OPAMP_InvertingInput_IO1 ((uint32_t)0x00000000) /*!< IO1 (PC5 for OPAMP1 and OPAMP2, PB10 for OPAMP3 and OPAMP4)
104 connected to OPAMPx inverting input */
105 #define OPAMP_InvertingInput_IO2 OPAMP_CSR_VMSEL_0 /*!< IO2 (PA3 for OPAMP1, PA5 for OPAMP2, PB2 for OPAMP3, PD8 for OPAMP4)
106 connected to OPAMPx inverting input */
107 #define OPAMP_InvertingInput_PGA OPAMP_CSR_VMSEL_1 /*!< Resistor feedback output connected to OPAMPx inverting input (PGA mode) */
108 #define OPAMP_InvertingInput_Vout OPAMP_CSR_VMSEL /*!< Vout connected to OPAMPx inverting input (follower mode) */
110 #define IS_OPAMP_INVERTING_INPUT(INPUT) (((INPUT) == OPAMP_InvertingInput_IO1) || \
111 ((INPUT) == OPAMP_InvertingInput_IO2) || \
112 ((INPUT) == OPAMP_InvertingInput_PGA) || \
113 ((INPUT) == OPAMP_InvertingInput_Vout))
118 /** @defgroup OPAMP_NonInvertingInput
122 #define OPAMP_NonInvertingInput_IO1 ((uint32_t)0x00000000) /*!< IO1 (PA7 for OPAMP1, PD14 for OPAMP2, PB13 for OPAMP3, PD11 for OPAMP4)
123 connected to OPAMPx non inverting input */
124 #define OPAMP_NonInvertingInput_IO2 OPAMP_CSR_VPSEL_0 /*!< IO2 (PA5 for OPAMP1, PB14 for OPAMP2, PA5 for OPAMP3, PB11 for OPAMP4)
125 connected to OPAMPx non inverting input */
126 #define OPAMP_NonInvertingInput_IO3 OPAMP_CSR_VPSEL_1 /*!< IO3 (PA3 for OPAMP1, PB0 for OPAMP2, PA1 for OPAMP3, PA4 for OPAMP4)
127 connected to OPAMPx non inverting input */
128 #define OPAMP_NonInvertingInput_IO4 OPAMP_CSR_VPSEL /*!< IO4 (PA1 for OPAMP1, PA7 for OPAMP2, PB0 for OPAMP3, PB13 for OPAMP4)
129 connected to OPAMPx non inverting input */
131 #define IS_OPAMP_NONINVERTING_INPUT(INPUT) (((INPUT) == OPAMP_NonInvertingInput_IO1) || \
132 ((INPUT) == OPAMP_NonInvertingInput_IO2) || \
133 ((INPUT) == OPAMP_NonInvertingInput_IO3) || \
134 ((INPUT) == OPAMP_NonInvertingInput_IO4))
139 /** @defgroup OPAMP_PGAGain_Config
143 #define OPAMP_OPAMP_PGAGain_2 ((uint32_t)0x00000000)
144 #define OPAMP_OPAMP_PGAGain_4 OPAMP_CSR_PGGAIN_0
145 #define OPAMP_OPAMP_PGAGain_8 OPAMP_CSR_PGGAIN_1
146 #define OPAMP_OPAMP_PGAGain_16 ((uint32_t)0x0000C000)
148 #define IS_OPAMP_PGAGAIN(GAIN) (((GAIN) == OPAMP_OPAMP_PGAGain_2) || \
149 ((GAIN) == OPAMP_OPAMP_PGAGain_4) || \
150 ((GAIN) == OPAMP_OPAMP_PGAGain_8) || \
151 ((GAIN) == OPAMP_OPAMP_PGAGain_16))
156 /** @defgroup OPAMP_PGAConnect_Config
160 #define OPAMP_PGAConnect_No ((uint32_t)0x00000000)
161 #define OPAMP_PGAConnect_IO1 OPAMP_CSR_PGGAIN_3
162 #define OPAMP_PGAConnect_IO2 ((uint32_t)0x00030000)
164 #define IS_OPAMP_PGACONNECT(CONNECT) (((CONNECT) == OPAMP_PGAConnect_No) || \
165 ((CONNECT) == OPAMP_PGAConnect_IO1) || \
166 ((CONNECT) == OPAMP_PGAConnect_IO2))
171 /** @defgroup OPAMP_SecondaryInvertingInput
175 #define IS_OPAMP_SECONDARY_INVINPUT(INVINPUT) (((INVINPUT) == OPAMP_InvertingInput_IO1) || \
176 ((INVINPUT) == OPAMP_InvertingInput_IO2))
181 /** @defgroup OPAMP_Input
185 #define OPAMP_Input_Inverting ((uint32_t)0x00000018) /*!< Inverting input */
186 #define OPAMP_Input_NonInverting ((uint32_t)0x00000013) /*!< Non inverting input */
188 #define IS_OPAMP_INPUT(INPUT) (((INPUT) == OPAMP_Input_Inverting) || \
189 ((INPUT) == OPAMP_Input_NonInverting))
195 /** @defgroup OPAMP_Vref
199 #define OPAMP_Vref_3VDDA ((uint32_t)0x00000000) /*!< OPMAP Vref = 3.3% VDDA */
200 #define OPAMP_Vref_10VDDA OPAMP_CSR_CALSEL_0 /*!< OPMAP Vref = 10% VDDA */
201 #define OPAMP_Vref_50VDDA OPAMP_CSR_CALSEL_1 /*!< OPMAP Vref = 50% VDDA */
202 #define OPAMP_Vref_90VDDA OPAMP_CSR_CALSEL /*!< OPMAP Vref = 90% VDDA */
204 #define IS_OPAMP_VREF(VREF) (((VREF) == OPAMP_Vref_3VDDA) || \
205 ((VREF) == OPAMP_Vref_10VDDA) || \
206 ((VREF) == OPAMP_Vref_50VDDA) || \
207 ((VREF) == OPAMP_Vref_90VDDA))
213 /** @defgroup OPAMP_Trimming
216 #define OPAMP_Trimming_Factory ((uint32_t)0x00000000) /*!< Factory trimming */
217 #define OPAMP_Trimming_User OPAMP_CSR_USERTRIM /*!< User trimming */
219 #define IS_OPAMP_TRIMMING(TRIMMING) (((TRIMMING) == OPAMP_Trimming_Factory) || \
220 ((TRIMMING) == OPAMP_Trimming_User))
226 /** @defgroup OPAMP_TrimValue
230 #define IS_OPAMP_TRIMMINGVALUE(VALUE) ((VALUE) <= 0x0000001F) /*!< Trimming value */
236 /** @defgroup OPAMP_OutputLevel
240 #define OPAMP_OutputLevel_High OPAMP_CSR_OUTCAL
241 #define OPAMP_OutputLevel_Low ((uint32_t)0x00000000)
247 /* Exported macro ------------------------------------------------------------*/
248 /* Exported functions ------------------------------------------------------- */
250 /* Function used to set the OPAMP configuration to the default reset state ***/
251 void OPAMP_DeInit(uint32_t OPAMP_Selection);
253 /* Initialization and Configuration functions *********************************/
254 void OPAMP_Init(uint32_t OPAMP_Selection, OPAMP_InitTypeDef* OPAMP_InitStruct);
255 void OPAMP_StructInit(OPAMP_InitTypeDef* OPAMP_InitStruct);
256 void OPAMP_PGAConfig(uint32_t OPAMP_Selection, uint32_t OPAMP_PGAGain, uint32_t OPAMP_PGAConnect);
257 void OPAMP_VrefConfig(uint32_t OPAMP_Selection, uint32_t OPAMP_Vref);
258 void OPAMP_VrefConnectADCCmd(uint32_t OPAMP_Selection, FunctionalState NewState);
259 void OPAMP_TimerControlledMuxConfig(uint32_t OPAMP_Selection, OPAMP_InitTypeDef* OPAMP_InitStruct);
260 void OPAMP_TimerControlledMuxCmd(uint32_t OPAMP_Selection, FunctionalState NewState);
261 void OPAMP_Cmd(uint32_t OPAMP_Selection, FunctionalState NewState);
262 uint32_t OPAMP_GetOutputLevel(uint32_t OPAMP_Selection);
264 /* Calibration functions ******************************************************/
265 void OPAMP_VrefConnectNonInvertingInput(uint32_t OPAMP_Selection, FunctionalState NewState);
266 void OPAMP_OffsetTrimModeSelect(uint32_t OPAMP_Selection, uint32_t OPAMP_Trimming);
267 void OPAMP_OffsetTrimConfig(uint32_t OPAMP_Selection, uint32_t OPAMP_Input, uint32_t OPAMP_TrimValue);
268 void OPAMP_StartCalibration(uint32_t OPAMP_Selection, FunctionalState NewState);
270 /* OPAMP configuration locking function ***************************************/
271 void OPAMP_LockConfig(uint32_t OPAMP_Selection);
277 #endif /*__STM32F30x_OPAMP_H */
287 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/