]> git.donarmstrong.com Git - qmk_firmware.git/blob - tool/mbed/mbed-sdk/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F3XX/stm32f30x_opamp.h
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[qmk_firmware.git] / tool / mbed / mbed-sdk / libraries / mbed / targets / cmsis / TARGET_STM / TARGET_STM32F3XX / stm32f30x_opamp.h
1 /**
2   ******************************************************************************
3   * @file    stm32f30x_opamp.h
4   * @author  MCD Application Team
5   * @version V1.1.0
6   * @date    27-February-2014
7   * @brief   This file contains all the functions prototypes for the operational
8   *          amplifiers (OPAMP) firmware library.         
9   ******************************************************************************
10   * @attention
11   *
12   * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
13   *
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.
24   *
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.
35   *
36   ******************************************************************************
37   */ 
38
39 /* Define to prevent recursive inclusion -------------------------------------*/
40 #ifndef __STM32F30x_OPAMP_H
41 #define __STM32F30x_OPAMP_H
42
43 #ifdef __cplusplus
44  extern "C" {
45 #endif
46
47 /* Includes ------------------------------------------------------------------*/
48 #include "stm32f30x.h"
49
50 /** @addtogroup STM32F30x_StdPeriph_Driver
51   * @{
52   */
53
54 /** @addtogroup OPAMP
55   * @{
56   */
57
58 /* Exported types ------------------------------------------------------------*/
59
60 /** 
61   * @brief  OPAMP Init structure definition  
62   */
63   
64 typedef struct
65 {
66
67   uint32_t OPAMP_InvertingInput;     /*!< Selects the inverting input of the operational amplifier.
68                                           This parameter can be a value of @ref OPAMP_InvertingInput */
69
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 */
72
73 }OPAMP_InitTypeDef;
74
75 /* Exported constants --------------------------------------------------------*/
76
77 /** @defgroup OPAMP_Exported_Constants
78   * @{
79   */ 
80
81 /** @defgroup OPAMP_Selection
82   * @{
83   */
84
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 */
89
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))
94  
95 /**
96   * @}
97   */
98
99 /** @defgroup OPAMP_InvertingInput
100   * @{
101   */
102
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) */
109
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))
114 /**
115   * @}
116   */
117
118 /** @defgroup OPAMP_NonInvertingInput
119   * @{
120   */
121
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 */
130
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))
135 /**
136   * @}
137   */
138
139 /** @defgroup OPAMP_PGAGain_Config
140   * @{
141   */
142
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)
147
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))
152 /**
153   * @}
154   */
155
156 /** @defgroup OPAMP_PGAConnect_Config
157   * @{
158   */
159
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)
163
164 #define IS_OPAMP_PGACONNECT(CONNECT) (((CONNECT) == OPAMP_PGAConnect_No)  || \
165                                       ((CONNECT) == OPAMP_PGAConnect_IO1) || \
166                                       ((CONNECT) == OPAMP_PGAConnect_IO2))
167 /**
168   * @}
169   */
170
171 /** @defgroup OPAMP_SecondaryInvertingInput
172   * @{
173   */
174
175 #define IS_OPAMP_SECONDARY_INVINPUT(INVINPUT) (((INVINPUT) == OPAMP_InvertingInput_IO1) || \
176                                                ((INVINPUT) == OPAMP_InvertingInput_IO2))
177 /**
178   * @}
179   */
180
181 /** @defgroup OPAMP_Input
182   * @{
183   */
184
185 #define OPAMP_Input_Inverting                 ((uint32_t)0x00000018) /*!< Inverting input */
186 #define OPAMP_Input_NonInverting              ((uint32_t)0x00000013) /*!< Non inverting input */
187
188 #define IS_OPAMP_INPUT(INPUT) (((INPUT) == OPAMP_Input_Inverting) || \
189                                ((INPUT) == OPAMP_Input_NonInverting))
190
191 /**
192   * @}
193   */ 
194
195 /** @defgroup OPAMP_Vref
196   * @{
197   */
198
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  */
203
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))
208
209 /**
210   * @}
211   */
212
213 /** @defgroup OPAMP_Trimming
214   */
215
216 #define OPAMP_Trimming_Factory        ((uint32_t)0x00000000) /*!< Factory trimming */
217 #define OPAMP_Trimming_User           OPAMP_CSR_USERTRIM     /*!< User trimming */
218
219 #define IS_OPAMP_TRIMMING(TRIMMING) (((TRIMMING) == OPAMP_Trimming_Factory) || \
220                                      ((TRIMMING) == OPAMP_Trimming_User))
221
222 /**
223   * @}
224   */ 
225
226 /** @defgroup OPAMP_TrimValue
227   * @{
228   */
229
230 #define IS_OPAMP_TRIMMINGVALUE(VALUE) ((VALUE) <= 0x0000001F) /*!< Trimming value */
231
232 /**
233   * @}
234   */
235
236 /** @defgroup OPAMP_OutputLevel
237   * @{
238   */
239
240 #define OPAMP_OutputLevel_High                   OPAMP_CSR_OUTCAL
241 #define OPAMP_OutputLevel_Low                    ((uint32_t)0x00000000)
242
243 /**
244   * @}
245   */
246
247 /* Exported macro ------------------------------------------------------------*/
248 /* Exported functions ------------------------------------------------------- */
249
250 /*  Function used to set the OPAMP configuration to the default reset state ***/
251 void OPAMP_DeInit(uint32_t OPAMP_Selection);
252
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);
263
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);
269
270 /* OPAMP configuration locking function ***************************************/
271 void OPAMP_LockConfig(uint32_t OPAMP_Selection);
272
273 #ifdef __cplusplus
274 }
275 #endif
276
277 #endif /*__STM32F30x_OPAMP_H */
278
279 /**
280   * @}
281   */ 
282
283 /**
284   * @}
285   */
286
287 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/