2 ******************************************************************************
3 * @file stm32f30x_opamp.c
4 * @author MCD Application Team
6 * @date 27-February-2014
7 * @brief This file provides firmware functions to manage the following
8 * functionalities of the operational amplifiers (OPAMP1,...OPAMP4) peripheral:
9 * + OPAMP Configuration
14 ==============================================================================
15 ##### OPAMP Peripheral Features #####
16 ==============================================================================
19 The device integrates 4 operational amplifiers OPAMP1, OPAMP2, OPAMP3 and OPAMP4:
21 (+) The OPAMPs non inverting input can be selected among the list shown by
24 (+) The OPAMPs inverting input can be selected among the list shown by
27 (+) The OPAMPs outputs can be internally connected to the inverting input
29 (+) The OPAMPs outputs can be internally connected to resistor feedback
30 output (Programmable Gain Amplifier mode)
32 (+) The OPAMPs outputs can be internally connected to ADC
34 (+) The OPAMPs can be calibrated to compensate the offset compensation
36 (+) Timer-controlled Mux for automatic switch of inverting and
39 OPAMPs inverting/non-inverting inputs:
40 +--------------------------------------------------------------+
41 | | | OPAMP1 | OPAMP2 | OPAMP3 | OPAMP4 |
42 |-----------------|--------|--------|--------|--------|--------|
43 | | PGA | OK | OK | OK | OK |
44 | Inverting Input | Vout | OK | OK | OK | OK |
45 | | IO1 | PC5 | PC5 | PB10 | PB10 |
46 | | IO2 | PA3 | PA5 | PB2 | PD8 |
47 |-----------------|--------|--------|--------|--------|--------|
48 | | IO1 | PA7 | PD14 | PB13 | PD11 |
49 | Non Inverting | IO2 | PA5 | PB14 | PA5 | PB11 |
50 | Input | IO3 | PA3 | PB0 | PA1 | PA4 |
51 | | IO4 | PA1 | PA7 | PB0 | PB13 |
52 +--------------------------------------------------------------+
54 ##### How to use this driver #####
55 ==============================================================================
57 This driver provides functions to configure and program the OPAMP
58 of all STM32F30x devices.
60 To use the OPAMP, perform the following steps:
62 (#) Enable the SYSCFG APB clock to get write access to OPAMP
63 register using RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
65 (#) Configure the OPAMP input in analog mode using GPIO_Init()
67 (#) Configure the OPAMP using OPAMP_Init() function:
68 (++) Select the inverting input
69 (++) Select the non-inverting inverting input
71 (#) Enable the OPAMP using OPAMP_Cmd() function
75 ******************************************************************************
78 * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
80 * Redistribution and use in source and binary forms, with or without modification,
81 * are permitted provided that the following conditions are met:
82 * 1. Redistributions of source code must retain the above copyright notice,
83 * this list of conditions and the following disclaimer.
84 * 2. Redistributions in binary form must reproduce the above copyright notice,
85 * this list of conditions and the following disclaimer in the documentation
86 * and/or other materials provided with the distribution.
87 * 3. Neither the name of STMicroelectronics nor the names of its contributors
88 * may be used to endorse or promote products derived from this software
89 * without specific prior written permission.
91 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
92 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
93 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
94 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
95 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
96 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
97 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
98 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
99 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
100 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
102 ******************************************************************************
105 /* Includes ------------------------------------------------------------------*/
106 #include "stm32f30x_opamp.h"
108 /** @addtogroup STM32F30x_StdPeriph_Driver
113 * @brief OPAMP driver modules
117 /* Private typedef -----------------------------------------------------------*/
118 /* Private define ------------------------------------------------------------*/
119 #define OPAMP_CSR_DEFAULT_MASK ((uint32_t)0xFFFFFF93)
120 #define OPAMP_CSR_TIMERMUX_MASK ((uint32_t)0xFFFFF8FF)
121 #define OPAMP_CSR_TRIMMING_MASK ((uint32_t)0x0000001F)
123 /* Private macro -------------------------------------------------------------*/
124 /* Private variables ---------------------------------------------------------*/
125 /* Private function prototypes -----------------------------------------------*/
126 /* Private functions ---------------------------------------------------------*/
128 /** @defgroup OPAMP_Private_Functions
132 /** @defgroup OPAMP_Group1 Initialization and Configuration functions
133 * @brief Initialization and Configuration functions
136 ===============================================================================
137 ##### Initialization and Configuration functions #####
138 ===============================================================================
145 * @brief Deinitializes OPAMP peripheral registers to their default reset values.
146 * @note Deinitialization can't be performed if the OPAMP configuration is locked.
147 * To unlock the configuration, perform a system reset.
148 * @param OPAMP_Selection: the selected OPAMP.
149 * This parameter can be OPAMP_Selection_OPAMPx where x can be 1 to 4
150 * to select the OPAMP peripheral.
154 void OPAMP_DeInit(uint32_t OPAMP_Selection
)
156 /*!< Set OPAMP_CSR register to reset value */
157 *(__IO
uint32_t *) (OPAMP_BASE
+ OPAMP_Selection
) = ((uint32_t)0x00000000);
161 * @brief Initializes the OPAMP peripheral according to the specified parameters
162 * in OPAMP_InitStruct
163 * @note If the selected OPAMP is locked, initialization can't be performed.
164 * To unlock the configuration, perform a system reset.
165 * @param OPAMP_Selection: the selected OPAMP.
166 * This parameter can be OPAMP_Selection_OPAMPx where x can be 1 to 4
167 * to select the OPAMP peripheral.
168 * @param OPAMP_InitStruct: pointer to an OPAMP_InitTypeDef structure that contains
169 * the configuration information for the specified OPAMP peripheral.
170 * - OPAMP_InvertingInput specifies the inverting input of OPAMP
171 * - OPAMP_NonInvertingInput specifies the non inverting input of OPAMP
174 void OPAMP_Init(uint32_t OPAMP_Selection
, OPAMP_InitTypeDef
* OPAMP_InitStruct
)
178 /* Check the parameters */
179 assert_param(IS_OPAMP_ALL_PERIPH(OPAMP_Selection
));
180 assert_param(IS_OPAMP_INVERTING_INPUT(OPAMP_InitStruct
->OPAMP_InvertingInput
));
181 assert_param(IS_OPAMP_NONINVERTING_INPUT(OPAMP_InitStruct
->OPAMP_NonInvertingInput
));
183 /*!< Get the OPAMPx_CSR register value */
184 tmpreg
= *(__IO
uint32_t *) (OPAMP_BASE
+ OPAMP_Selection
);
186 /*!< Clear the inverting and non inverting bits selection bits */
187 tmpreg
&= (uint32_t) (OPAMP_CSR_DEFAULT_MASK
);
189 /*!< Configure OPAMP: inverting and non inverting inputs */
190 tmpreg
|= (uint32_t)(OPAMP_InitStruct
->OPAMP_InvertingInput
| OPAMP_InitStruct
->OPAMP_NonInvertingInput
);
192 /*!< Write to OPAMPx_CSR register */
193 *(__IO
uint32_t *) (OPAMP_BASE
+ OPAMP_Selection
) = tmpreg
;
197 * @brief Fills each OPAMP_InitStruct member with its default value.
198 * @param OPAMP_InitStruct: pointer to an OPAMP_InitTypeDef structure which will
202 void OPAMP_StructInit(OPAMP_InitTypeDef
* OPAMP_InitStruct
)
204 OPAMP_InitStruct
->OPAMP_NonInvertingInput
= OPAMP_NonInvertingInput_IO1
;
205 OPAMP_InitStruct
->OPAMP_InvertingInput
= OPAMP_InvertingInput_IO1
;
209 * @brief Configure the feedback resistor gain.
210 * @note If the selected OPAMP is locked, gain configuration can't be performed.
211 * To unlock the configuration, perform a system reset.
212 * @param OPAMP_Selection: the selected OPAMP.
213 * This parameter can be OPAMP_Selection_OPAMPx where x can be 1 to 4
214 * to select the OPAMP peripheral.
215 * @param NewState: new state of the OPAMP peripheral.
216 * This parameter can be: ENABLE or DISABLE.
219 void OPAMP_PGAConfig(uint32_t OPAMP_Selection
, uint32_t OPAMP_PGAGain
, uint32_t OPAMP_PGAConnect
)
221 /* Check the parameters */
222 assert_param(IS_OPAMP_ALL_PERIPH(OPAMP_Selection
));
223 assert_param(IS_OPAMP_PGAGAIN(OPAMP_PGAGain
));
224 assert_param(IS_OPAMP_PGACONNECT(OPAMP_PGAConnect
));
226 /* Reset the configuration bits */
227 *(__IO
uint32_t *) (OPAMP_BASE
+ OPAMP_Selection
) &= (uint32_t)(~OPAMP_CSR_PGGAIN
);
229 /* Set the new configuration */
230 *(__IO
uint32_t *) (OPAMP_BASE
+ OPAMP_Selection
) |= (uint32_t) (OPAMP_PGAGain
| OPAMP_PGAConnect
);
234 * @brief Configure the OPAMP's internal reference.
235 * @note This feature is used when calibration enabled or OPAMP's reference
236 * connected to the non inverting input.
237 * @note If the selected OPAMP is locked, Vref configuration can't be performed.
238 * To unlock the configuration, perform a system reset.
239 * @param OPAMP_Selection: the selected OPAMP.
240 * This parameter can be OPAMP_Selection_OPAMPx where x can be 1 to 4
241 * to select the OPAMP peripheral.
242 * @param OPAMP_Vref: This parameter can be:
243 * OPAMP_Vref_3VDDA: OPMAP Vref = 3.3% VDDA
244 * OPAMP_Vref_10VDDA: OPMAP Vref = 10% VDDA
245 * OPAMP_Vref_50VDDA: OPMAP Vref = 50% VDDA
246 * OPAMP_Vref_90VDDA: OPMAP Vref = 90% VDDA
249 void OPAMP_VrefConfig(uint32_t OPAMP_Selection
, uint32_t OPAMP_Vref
)
253 /* Check the parameters */
254 assert_param(IS_OPAMP_ALL_PERIPH(OPAMP_Selection
));
255 assert_param(IS_OPAMP_VREF(OPAMP_Vref
));
257 /*!< Get the OPAMPx_CSR register value */
258 tmpreg
= *(__IO
uint32_t *) (OPAMP_BASE
+ OPAMP_Selection
);
260 /*!< Clear the CALSEL bits */
261 tmpreg
&= (uint32_t) (~OPAMP_CSR_CALSEL
);
263 /*!< Configure OPAMP reference */
264 tmpreg
|= (uint32_t)(OPAMP_Vref
);
266 /*!< Write to OPAMPx_CSR register */
267 *(__IO
uint32_t *) (OPAMP_BASE
+ OPAMP_Selection
) = tmpreg
;
271 * @brief Connnect the internal reference to the OPAMP's non inverting input.
272 * @note If the selected OPAMP is locked, Vref configuration can't be performed.
273 * To unlock the configuration, perform a system reset.
274 * @param OPAMP_Selection: the selected OPAMP.
275 * This parameter can be OPAMP_Selection_OPAMPx where x can be 1 to 4
276 * to select the OPAMP peripheral.
277 * @param NewState: new state of the OPAMP peripheral.
278 * This parameter can be: ENABLE or DISABLE.
281 void OPAMP_VrefConnectNonInvertingInput(uint32_t OPAMP_Selection
, FunctionalState NewState
)
283 /* Check the parameters */
284 assert_param(IS_OPAMP_ALL_PERIPH(OPAMP_Selection
));
285 assert_param(IS_FUNCTIONAL_STATE(NewState
));
287 if (NewState
!= DISABLE
)
289 /* Connnect the internal reference to the OPAMP's non inverting input */
290 *(__IO
uint32_t *) (OPAMP_BASE
+ OPAMP_Selection
) |= (uint32_t) (OPAMP_CSR_FORCEVP
);
294 /* Disconnnect the internal reference to the OPAMP's non inverting input */
295 *(__IO
uint32_t *) (OPAMP_BASE
+ OPAMP_Selection
) &= (uint32_t)(~OPAMP_CSR_FORCEVP
);
300 * @brief Enables or disables connecting the OPAMP's internal reference to ADC.
301 * @note If the selected OPAMP is locked, Vref connection can't be performed.
302 * To unlock the configuration, perform a system reset.
303 * @param NewState: new state of the Vrefint output.
304 * This parameter can be: ENABLE or DISABLE.
307 void OPAMP_VrefConnectADCCmd(uint32_t OPAMP_Selection
, FunctionalState NewState
)
309 /* Check the parameters */
310 assert_param(IS_OPAMP_ALL_PERIPH(OPAMP_Selection
));
311 assert_param(IS_FUNCTIONAL_STATE(NewState
));
313 if (NewState
!= DISABLE
)
315 /* Enable output internal reference */
316 *(__IO
uint32_t *) (OPAMP_BASE
+ OPAMP_Selection
) |= (uint32_t) (OPAMP_CSR_TSTREF
);
320 /* Disable output internal reference */
321 *(__IO
uint32_t *) (OPAMP_BASE
+ OPAMP_Selection
) &= (uint32_t)(~OPAMP_CSR_TSTREF
);
326 * @brief Configure the OPAMP peripheral (secondary inputs) for timer-controlled
327 * mux mode according to the specified parameters in OPAMP_InitStruct.
328 * @note If the selected OPAMP is locked, timer-controlled mux configuration
329 * can't be performed.
330 * To unlock the configuration, perform a system reset.
331 * @param OPAMP_Selection: the selected OPAMP.
332 * This parameter can be OPAMP_Selection_OPAMPx where x can be 1 to 4
333 * to select the OPAMP peripheral.
334 * @param OPAMP_InitStruct: pointer to an OPAMP_InitTypeDef structure that contains
335 * the configuration information for the specified OPAMP peripheral.
336 * - OPAMP_InvertingInput specifies the inverting input of OPAMP
337 * - OPAMP_NonInvertingInput specifies the non inverting input of OPAMP
338 * @note PGA and Vout can't be selected as seconadry inverting input.
341 void OPAMP_TimerControlledMuxConfig(uint32_t OPAMP_Selection
, OPAMP_InitTypeDef
* OPAMP_InitStruct
)
345 /* Check the parameters */
346 assert_param(IS_OPAMP_ALL_PERIPH(OPAMP_Selection
));
347 assert_param(IS_OPAMP_SECONDARY_INVINPUT(OPAMP_InitStruct
->OPAMP_InvertingInput
));
348 assert_param(IS_OPAMP_NONINVERTING_INPUT(OPAMP_InitStruct
->OPAMP_NonInvertingInput
));
350 /*!< Get the OPAMPx_CSR register value */
351 tmpreg
= *(__IO
uint32_t *) (OPAMP_BASE
+ OPAMP_Selection
);
353 /*!< Clear the secondary inverting bit, secondary non inverting bit and TCMEN bits */
354 tmpreg
&= (uint32_t) (OPAMP_CSR_TIMERMUX_MASK
);
356 /*!< Configure OPAMP: secondary inverting and non inverting inputs */
357 tmpreg
|= (uint32_t)((uint32_t)(OPAMP_InitStruct
->OPAMP_InvertingInput
<<3) | (uint32_t)(OPAMP_InitStruct
->OPAMP_NonInvertingInput
<<7));
359 /*!< Write to OPAMPx_CSR register */
360 *(__IO
uint32_t *) (OPAMP_BASE
+ OPAMP_Selection
) = tmpreg
;
364 * @brief Enable or disable the timer-controlled mux mode.
365 * @note If the selected OPAMP is locked, enable/disable can't be performed.
366 * To unlock the configuration, perform a system reset.
367 * @param OPAMP_Selection: the selected OPAMP.
368 * This parameter can be OPAMP_Selection_OPAMPx where x can be 1 to 4
369 * to select the OPAMP peripheral.
370 * @param NewState: new state of the OPAMP peripheral.
371 * This parameter can be: ENABLE or DISABLE.
374 void OPAMP_TimerControlledMuxCmd(uint32_t OPAMP_Selection
, FunctionalState NewState
)
376 /* Check the parameters */
377 assert_param(IS_OPAMP_ALL_PERIPH(OPAMP_Selection
));
378 assert_param(IS_FUNCTIONAL_STATE(NewState
));
380 if (NewState
!= DISABLE
)
382 /* Enable the timer-controlled Mux mode */
383 *(__IO
uint32_t *) (OPAMP_BASE
+ OPAMP_Selection
) |= (uint32_t) (OPAMP_CSR_TCMEN
);
387 /* Disable the timer-controlled Mux mode */
388 *(__IO
uint32_t *) (OPAMP_BASE
+ OPAMP_Selection
) &= (uint32_t)(~OPAMP_CSR_TCMEN
);
393 * @brief Enable or disable the OPAMP peripheral.
394 * @note If the selected OPAMP is locked, enable/disable can't be performed.
395 * To unlock the configuration, perform a system reset.
396 * @param OPAMP_Selection: the selected OPAMP.
397 * This parameter can be OPAMP_Selection_OPAMPx where x can be 1 to 4
398 * to select the OPAMP peripheral.
399 * @param NewState: new state of the OPAMP peripheral.
400 * This parameter can be: ENABLE or DISABLE.
403 void OPAMP_Cmd(uint32_t OPAMP_Selection
, FunctionalState NewState
)
405 /* Check the parameters */
406 assert_param(IS_OPAMP_ALL_PERIPH(OPAMP_Selection
));
407 assert_param(IS_FUNCTIONAL_STATE(NewState
));
409 if (NewState
!= DISABLE
)
411 /* Enable the selected OPAMPx peripheral */
412 *(__IO
uint32_t *) (OPAMP_BASE
+ OPAMP_Selection
) |= (uint32_t) (OPAMP_CSR_OPAMPxEN
);
416 /* Disable the selected OPAMPx peripheral */
417 *(__IO
uint32_t *) (OPAMP_BASE
+ OPAMP_Selection
) &= (uint32_t)(~OPAMP_CSR_OPAMPxEN
);
422 * @brief Return the output level (high or low) during calibration of the selected OPAMP.
423 * @param OPAMP_Selection: the selected OPAMP.
424 * This parameter can be OPAMP_Selection_OPAMPx where x can be 1 to 4
425 * to select the OPAMP peripheral.
426 * - OPAMP output is low when the non-inverting input is at a lower
427 * voltage than the inverting input
428 * - OPAMP output is high when the non-inverting input is at a higher
429 * voltage than the inverting input
430 * @note OPAMP ouput level is provided only during calibration phase.
431 * @retval Returns the selected OPAMP output level: low or high.
434 uint32_t OPAMP_GetOutputLevel(uint32_t OPAMP_Selection
)
436 uint32_t opampout
= 0x0;
438 /* Check the parameters */
439 assert_param(IS_OPAMP_ALL_PERIPH(OPAMP_Selection
));
441 /* Check if selected OPAMP output is high */
442 if ((*(__IO
uint32_t *) (OPAMP_BASE
+ OPAMP_Selection
) & (OPAMP_CSR_OUTCAL
)) != 0)
444 opampout
= OPAMP_OutputLevel_High
;
448 opampout
= OPAMP_OutputLevel_Low
;
451 /* Return the OPAMP output level */
452 return (uint32_t)(opampout
);
456 * @brief Select the trimming mode.
457 * @param OffsetTrimming: the selected offset trimming mode.
458 * This parameter can be one of the following values:
459 * @arg OPAMP_Trimming_Factory: factory trimming values are used for offset
461 * @arg OPAMP_Trimming_User: user trimming values are used for offset
463 * @note When OffsetTrimming_User is selected, use OPAMP_OffsetTrimConfig()
464 * function or OPAMP_OffsetTrimLowPowerConfig() function to adjust
468 void OPAMP_OffsetTrimModeSelect(uint32_t OPAMP_Selection
, uint32_t OPAMP_Trimming
)
470 /* Check the parameters */
471 assert_param(IS_OPAMP_ALL_PERIPH(OPAMP_Selection
));
472 assert_param(IS_OPAMP_TRIMMING(OPAMP_Trimming
));
474 /* Reset USERTRIM bit */
475 *(__IO
uint32_t *) (OPAMP_BASE
+ OPAMP_Selection
) &= (~(uint32_t) (OPAMP_CSR_USERTRIM
));
477 /* Select trimming mode */
478 *(__IO
uint32_t *) (OPAMP_BASE
+ OPAMP_Selection
) |= OPAMP_Trimming
;
482 * @brief Configure the trimming value of the OPAMP.
483 * @param OPAMP_Selection: the selected OPAMP.
484 * This parameter can be OPAMP_Selection_OPAMPx where x can be 1 to 4
485 * to select the OPAMP peripheral.
486 * @param OPAMP_Input: the selected OPAMP input.
487 * This parameter can be one of the following values:
488 * @arg OPAMP_Input_Inverting: Inverting input is selected to configure the trimming value
489 * @arg OPAMP_Input_NonInverting: Non inverting input is selected to configure the trimming value
490 * @param OPAMP_TrimValue: the trimming value. This parameter can be any value lower
491 * or equal to 0x0000001F.
494 void OPAMP_OffsetTrimConfig(uint32_t OPAMP_Selection
, uint32_t OPAMP_Input
, uint32_t OPAMP_TrimValue
)
498 /* Check the parameters */
499 assert_param(IS_OPAMP_ALL_PERIPH(OPAMP_Selection
));
500 assert_param(IS_OPAMP_INPUT(OPAMP_Input
));
501 assert_param(IS_OPAMP_TRIMMINGVALUE(OPAMP_TrimValue
));
503 /*!< Get the OPAMPx_CSR register value */
504 tmpreg
= *(__IO
uint32_t *) (OPAMP_BASE
+ OPAMP_Selection
);
506 /*!< Clear the trimming bits */
507 tmpreg
&= ((uint32_t)~(OPAMP_CSR_TRIMMING_MASK
<<OPAMP_Input
));
509 /*!< Configure the new trimming value */
510 tmpreg
|= (uint32_t)(OPAMP_TrimValue
<<OPAMP_Input
);
512 /*!< Write to OPAMPx_CSR register */
513 *(__IO
uint32_t *) (OPAMP_BASE
+ OPAMP_Selection
) = tmpreg
;
517 * @brief Start or stop the calibration of selected OPAMP peripheral.
518 * @note If the selected OPAMP is locked, start/stop can't be performed.
519 * To unlock the configuration, perform a system reset.
520 * @param OPAMP_Selection: the selected OPAMP.
521 * This parameter can be OPAMP_Selection_OPAMPx where x can be 1 to 4
522 * to select the OPAMP peripheral.
523 * @param NewState: new state of the OPAMP peripheral.
524 * This parameter can be: ENABLE or DISABLE.
527 void OPAMP_StartCalibration(uint32_t OPAMP_Selection
, FunctionalState NewState
)
529 /* Check the parameters */
530 assert_param(IS_OPAMP_ALL_PERIPH(OPAMP_Selection
));
531 assert_param(IS_FUNCTIONAL_STATE(NewState
));
533 if (NewState
!= DISABLE
)
535 /* Start the OPAMPx calibration */
536 *(__IO
uint32_t *) (OPAMP_BASE
+ OPAMP_Selection
) |= (uint32_t) (OPAMP_CSR_CALON
);
540 /* Stop the OPAMPx calibration */
541 *(__IO
uint32_t *) (OPAMP_BASE
+ OPAMP_Selection
) &= (uint32_t)(~OPAMP_CSR_CALON
);
549 /** @defgroup OPAMP_Group2 OPAMP configuration locking function
550 * @brief OPAMP1,...OPAMP4 configuration locking function
551 * OPAMP1,...OPAMP4 configuration can be locked each separately.
552 * Unlocking is performed by system reset.
555 ===============================================================================
556 ##### Configuration Lock function #####
557 ===============================================================================
564 * @brief Lock the selected OPAMP configuration.
565 * @note Locking the configuration means that all control bits are read-only.
566 * To unlock the OPAMP configuration, perform a system reset.
567 * @param OPAMP_Selection: the selected OPAMP.
568 * This parameter can be OPAMP_Selection_OPAMPx where x can be 1 to 4
569 * to select the OPAMP peripheral.
572 void OPAMP_LockConfig(uint32_t OPAMP_Selection
)
574 /* Check the parameter */
575 assert_param(IS_OPAMP_ALL_PERIPH(OPAMP_Selection
));
577 /* Set the lock bit corresponding to selected OPAMP */
578 *(__IO
uint32_t *) (OPAMP_BASE
+ OPAMP_Selection
) |= (uint32_t) (OPAMP_CSR_LOCK
);
585 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/