mbed library sources

Dependents:   frdm_kl05z_gpio_test

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Fri Apr 11 17:15:06 2014 +0100
Revision:
157:90e3acc479a2
Synchronized with git revision 6e20ca17847dceb62132bf3d8519876411e175bf

Full URL: https://github.com/mbedmicro/mbed/commit/6e20ca17847dceb62132bf3d8519876411e175bf/

[STM32F3-Discovery][DISCO_F303VC] initial port.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 157:90e3acc479a2 1 /**
mbed_official 157:90e3acc479a2 2 ******************************************************************************
mbed_official 157:90e3acc479a2 3 * @file stm32f30x_opamp.c
mbed_official 157:90e3acc479a2 4 * @author MCD Application Team
mbed_official 157:90e3acc479a2 5 * @version V1.1.0
mbed_official 157:90e3acc479a2 6 * @date 27-February-2014
mbed_official 157:90e3acc479a2 7 * @brief This file provides firmware functions to manage the following
mbed_official 157:90e3acc479a2 8 * functionalities of the operational amplifiers (OPAMP1,...OPAMP4) peripheral:
mbed_official 157:90e3acc479a2 9 * + OPAMP Configuration
mbed_official 157:90e3acc479a2 10 * + OPAMP calibration
mbed_official 157:90e3acc479a2 11 *
mbed_official 157:90e3acc479a2 12 @verbatim
mbed_official 157:90e3acc479a2 13
mbed_official 157:90e3acc479a2 14 ==============================================================================
mbed_official 157:90e3acc479a2 15 ##### OPAMP Peripheral Features #####
mbed_official 157:90e3acc479a2 16 ==============================================================================
mbed_official 157:90e3acc479a2 17
mbed_official 157:90e3acc479a2 18 [..]
mbed_official 157:90e3acc479a2 19 The device integrates 4 operational amplifiers OPAMP1, OPAMP2, OPAMP3 and OPAMP4:
mbed_official 157:90e3acc479a2 20
mbed_official 157:90e3acc479a2 21 (+) The OPAMPs non inverting input can be selected among the list shown by
mbed_official 157:90e3acc479a2 22 table below.
mbed_official 157:90e3acc479a2 23
mbed_official 157:90e3acc479a2 24 (+) The OPAMPs inverting input can be selected among the list shown by
mbed_official 157:90e3acc479a2 25 table below.
mbed_official 157:90e3acc479a2 26
mbed_official 157:90e3acc479a2 27 (+) The OPAMPs outputs can be internally connected to the inverting input
mbed_official 157:90e3acc479a2 28 (follower mode)
mbed_official 157:90e3acc479a2 29 (+) The OPAMPs outputs can be internally connected to resistor feedback
mbed_official 157:90e3acc479a2 30 output (Programmable Gain Amplifier mode)
mbed_official 157:90e3acc479a2 31
mbed_official 157:90e3acc479a2 32 (+) The OPAMPs outputs can be internally connected to ADC
mbed_official 157:90e3acc479a2 33
mbed_official 157:90e3acc479a2 34 (+) The OPAMPs can be calibrated to compensate the offset compensation
mbed_official 157:90e3acc479a2 35
mbed_official 157:90e3acc479a2 36 (+) Timer-controlled Mux for automatic switch of inverting and
mbed_official 157:90e3acc479a2 37 non-inverting input
mbed_official 157:90e3acc479a2 38
mbed_official 157:90e3acc479a2 39 OPAMPs inverting/non-inverting inputs:
mbed_official 157:90e3acc479a2 40 +--------------------------------------------------------------+
mbed_official 157:90e3acc479a2 41 | | | OPAMP1 | OPAMP2 | OPAMP3 | OPAMP4 |
mbed_official 157:90e3acc479a2 42 |-----------------|--------|--------|--------|--------|--------|
mbed_official 157:90e3acc479a2 43 | | PGA | OK | OK | OK | OK |
mbed_official 157:90e3acc479a2 44 | Inverting Input | Vout | OK | OK | OK | OK |
mbed_official 157:90e3acc479a2 45 | | IO1 | PC5 | PC5 | PB10 | PB10 |
mbed_official 157:90e3acc479a2 46 | | IO2 | PA3 | PA5 | PB2 | PD8 |
mbed_official 157:90e3acc479a2 47 |-----------------|--------|--------|--------|--------|--------|
mbed_official 157:90e3acc479a2 48 | | IO1 | PA7 | PD14 | PB13 | PD11 |
mbed_official 157:90e3acc479a2 49 | Non Inverting | IO2 | PA5 | PB14 | PA5 | PB11 |
mbed_official 157:90e3acc479a2 50 | Input | IO3 | PA3 | PB0 | PA1 | PA4 |
mbed_official 157:90e3acc479a2 51 | | IO4 | PA1 | PA7 | PB0 | PB13 |
mbed_official 157:90e3acc479a2 52 +--------------------------------------------------------------+
mbed_official 157:90e3acc479a2 53
mbed_official 157:90e3acc479a2 54 ##### How to use this driver #####
mbed_official 157:90e3acc479a2 55 ==============================================================================
mbed_official 157:90e3acc479a2 56 [..]
mbed_official 157:90e3acc479a2 57 This driver provides functions to configure and program the OPAMP
mbed_official 157:90e3acc479a2 58 of all STM32F30x devices.
mbed_official 157:90e3acc479a2 59
mbed_official 157:90e3acc479a2 60 To use the OPAMP, perform the following steps:
mbed_official 157:90e3acc479a2 61
mbed_official 157:90e3acc479a2 62 (#) Enable the SYSCFG APB clock to get write access to OPAMP
mbed_official 157:90e3acc479a2 63 register using RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
mbed_official 157:90e3acc479a2 64
mbed_official 157:90e3acc479a2 65 (#) Configure the OPAMP input in analog mode using GPIO_Init()
mbed_official 157:90e3acc479a2 66
mbed_official 157:90e3acc479a2 67 (#) Configure the OPAMP using OPAMP_Init() function:
mbed_official 157:90e3acc479a2 68 (++) Select the inverting input
mbed_official 157:90e3acc479a2 69 (++) Select the non-inverting inverting input
mbed_official 157:90e3acc479a2 70
mbed_official 157:90e3acc479a2 71 (#) Enable the OPAMP using OPAMP_Cmd() function
mbed_official 157:90e3acc479a2 72
mbed_official 157:90e3acc479a2 73 @endverbatim
mbed_official 157:90e3acc479a2 74
mbed_official 157:90e3acc479a2 75 ******************************************************************************
mbed_official 157:90e3acc479a2 76 * @attention
mbed_official 157:90e3acc479a2 77 *
mbed_official 157:90e3acc479a2 78 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
mbed_official 157:90e3acc479a2 79 *
mbed_official 157:90e3acc479a2 80 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 157:90e3acc479a2 81 * are permitted provided that the following conditions are met:
mbed_official 157:90e3acc479a2 82 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 157:90e3acc479a2 83 * this list of conditions and the following disclaimer.
mbed_official 157:90e3acc479a2 84 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 157:90e3acc479a2 85 * this list of conditions and the following disclaimer in the documentation
mbed_official 157:90e3acc479a2 86 * and/or other materials provided with the distribution.
mbed_official 157:90e3acc479a2 87 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 157:90e3acc479a2 88 * may be used to endorse or promote products derived from this software
mbed_official 157:90e3acc479a2 89 * without specific prior written permission.
mbed_official 157:90e3acc479a2 90 *
mbed_official 157:90e3acc479a2 91 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 157:90e3acc479a2 92 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 157:90e3acc479a2 93 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 157:90e3acc479a2 94 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 157:90e3acc479a2 95 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 157:90e3acc479a2 96 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 157:90e3acc479a2 97 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 157:90e3acc479a2 98 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 157:90e3acc479a2 99 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 157:90e3acc479a2 100 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 157:90e3acc479a2 101 *
mbed_official 157:90e3acc479a2 102 ******************************************************************************
mbed_official 157:90e3acc479a2 103 */
mbed_official 157:90e3acc479a2 104
mbed_official 157:90e3acc479a2 105 /* Includes ------------------------------------------------------------------*/
mbed_official 157:90e3acc479a2 106 #include "stm32f30x_opamp.h"
mbed_official 157:90e3acc479a2 107
mbed_official 157:90e3acc479a2 108 /** @addtogroup STM32F30x_StdPeriph_Driver
mbed_official 157:90e3acc479a2 109 * @{
mbed_official 157:90e3acc479a2 110 */
mbed_official 157:90e3acc479a2 111
mbed_official 157:90e3acc479a2 112 /** @defgroup OPAMP
mbed_official 157:90e3acc479a2 113 * @brief OPAMP driver modules
mbed_official 157:90e3acc479a2 114 * @{
mbed_official 157:90e3acc479a2 115 */
mbed_official 157:90e3acc479a2 116
mbed_official 157:90e3acc479a2 117 /* Private typedef -----------------------------------------------------------*/
mbed_official 157:90e3acc479a2 118 /* Private define ------------------------------------------------------------*/
mbed_official 157:90e3acc479a2 119 #define OPAMP_CSR_DEFAULT_MASK ((uint32_t)0xFFFFFF93)
mbed_official 157:90e3acc479a2 120 #define OPAMP_CSR_TIMERMUX_MASK ((uint32_t)0xFFFFF8FF)
mbed_official 157:90e3acc479a2 121 #define OPAMP_CSR_TRIMMING_MASK ((uint32_t)0x0000001F)
mbed_official 157:90e3acc479a2 122
mbed_official 157:90e3acc479a2 123 /* Private macro -------------------------------------------------------------*/
mbed_official 157:90e3acc479a2 124 /* Private variables ---------------------------------------------------------*/
mbed_official 157:90e3acc479a2 125 /* Private function prototypes -----------------------------------------------*/
mbed_official 157:90e3acc479a2 126 /* Private functions ---------------------------------------------------------*/
mbed_official 157:90e3acc479a2 127
mbed_official 157:90e3acc479a2 128 /** @defgroup OPAMP_Private_Functions
mbed_official 157:90e3acc479a2 129 * @{
mbed_official 157:90e3acc479a2 130 */
mbed_official 157:90e3acc479a2 131
mbed_official 157:90e3acc479a2 132 /** @defgroup OPAMP_Group1 Initialization and Configuration functions
mbed_official 157:90e3acc479a2 133 * @brief Initialization and Configuration functions
mbed_official 157:90e3acc479a2 134 *
mbed_official 157:90e3acc479a2 135 @verbatim
mbed_official 157:90e3acc479a2 136 ===============================================================================
mbed_official 157:90e3acc479a2 137 ##### Initialization and Configuration functions #####
mbed_official 157:90e3acc479a2 138 ===============================================================================
mbed_official 157:90e3acc479a2 139
mbed_official 157:90e3acc479a2 140 @endverbatim
mbed_official 157:90e3acc479a2 141 * @{
mbed_official 157:90e3acc479a2 142 */
mbed_official 157:90e3acc479a2 143
mbed_official 157:90e3acc479a2 144 /**
mbed_official 157:90e3acc479a2 145 * @brief Deinitializes OPAMP peripheral registers to their default reset values.
mbed_official 157:90e3acc479a2 146 * @note Deinitialization can't be performed if the OPAMP configuration is locked.
mbed_official 157:90e3acc479a2 147 * To unlock the configuration, perform a system reset.
mbed_official 157:90e3acc479a2 148 * @param OPAMP_Selection: the selected OPAMP.
mbed_official 157:90e3acc479a2 149 * This parameter can be OPAMP_Selection_OPAMPx where x can be 1 to 4
mbed_official 157:90e3acc479a2 150 * to select the OPAMP peripheral.
mbed_official 157:90e3acc479a2 151 * @param None
mbed_official 157:90e3acc479a2 152 * @retval None
mbed_official 157:90e3acc479a2 153 */
mbed_official 157:90e3acc479a2 154 void OPAMP_DeInit(uint32_t OPAMP_Selection)
mbed_official 157:90e3acc479a2 155 {
mbed_official 157:90e3acc479a2 156 /*!< Set OPAMP_CSR register to reset value */
mbed_official 157:90e3acc479a2 157 *(__IO uint32_t *) (OPAMP_BASE + OPAMP_Selection) = ((uint32_t)0x00000000);
mbed_official 157:90e3acc479a2 158 }
mbed_official 157:90e3acc479a2 159
mbed_official 157:90e3acc479a2 160 /**
mbed_official 157:90e3acc479a2 161 * @brief Initializes the OPAMP peripheral according to the specified parameters
mbed_official 157:90e3acc479a2 162 * in OPAMP_InitStruct
mbed_official 157:90e3acc479a2 163 * @note If the selected OPAMP is locked, initialization can't be performed.
mbed_official 157:90e3acc479a2 164 * To unlock the configuration, perform a system reset.
mbed_official 157:90e3acc479a2 165 * @param OPAMP_Selection: the selected OPAMP.
mbed_official 157:90e3acc479a2 166 * This parameter can be OPAMP_Selection_OPAMPx where x can be 1 to 4
mbed_official 157:90e3acc479a2 167 * to select the OPAMP peripheral.
mbed_official 157:90e3acc479a2 168 * @param OPAMP_InitStruct: pointer to an OPAMP_InitTypeDef structure that contains
mbed_official 157:90e3acc479a2 169 * the configuration information for the specified OPAMP peripheral.
mbed_official 157:90e3acc479a2 170 * - OPAMP_InvertingInput specifies the inverting input of OPAMP
mbed_official 157:90e3acc479a2 171 * - OPAMP_NonInvertingInput specifies the non inverting input of OPAMP
mbed_official 157:90e3acc479a2 172 * @retval None
mbed_official 157:90e3acc479a2 173 */
mbed_official 157:90e3acc479a2 174 void OPAMP_Init(uint32_t OPAMP_Selection, OPAMP_InitTypeDef* OPAMP_InitStruct)
mbed_official 157:90e3acc479a2 175 {
mbed_official 157:90e3acc479a2 176 uint32_t tmpreg = 0;
mbed_official 157:90e3acc479a2 177
mbed_official 157:90e3acc479a2 178 /* Check the parameters */
mbed_official 157:90e3acc479a2 179 assert_param(IS_OPAMP_ALL_PERIPH(OPAMP_Selection));
mbed_official 157:90e3acc479a2 180 assert_param(IS_OPAMP_INVERTING_INPUT(OPAMP_InitStruct->OPAMP_InvertingInput));
mbed_official 157:90e3acc479a2 181 assert_param(IS_OPAMP_NONINVERTING_INPUT(OPAMP_InitStruct->OPAMP_NonInvertingInput));
mbed_official 157:90e3acc479a2 182
mbed_official 157:90e3acc479a2 183 /*!< Get the OPAMPx_CSR register value */
mbed_official 157:90e3acc479a2 184 tmpreg = *(__IO uint32_t *) (OPAMP_BASE + OPAMP_Selection);
mbed_official 157:90e3acc479a2 185
mbed_official 157:90e3acc479a2 186 /*!< Clear the inverting and non inverting bits selection bits */
mbed_official 157:90e3acc479a2 187 tmpreg &= (uint32_t) (OPAMP_CSR_DEFAULT_MASK);
mbed_official 157:90e3acc479a2 188
mbed_official 157:90e3acc479a2 189 /*!< Configure OPAMP: inverting and non inverting inputs */
mbed_official 157:90e3acc479a2 190 tmpreg |= (uint32_t)(OPAMP_InitStruct->OPAMP_InvertingInput | OPAMP_InitStruct->OPAMP_NonInvertingInput);
mbed_official 157:90e3acc479a2 191
mbed_official 157:90e3acc479a2 192 /*!< Write to OPAMPx_CSR register */
mbed_official 157:90e3acc479a2 193 *(__IO uint32_t *) (OPAMP_BASE + OPAMP_Selection) = tmpreg;
mbed_official 157:90e3acc479a2 194 }
mbed_official 157:90e3acc479a2 195
mbed_official 157:90e3acc479a2 196 /**
mbed_official 157:90e3acc479a2 197 * @brief Fills each OPAMP_InitStruct member with its default value.
mbed_official 157:90e3acc479a2 198 * @param OPAMP_InitStruct: pointer to an OPAMP_InitTypeDef structure which will
mbed_official 157:90e3acc479a2 199 * be initialized.
mbed_official 157:90e3acc479a2 200 * @retval None
mbed_official 157:90e3acc479a2 201 */
mbed_official 157:90e3acc479a2 202 void OPAMP_StructInit(OPAMP_InitTypeDef* OPAMP_InitStruct)
mbed_official 157:90e3acc479a2 203 {
mbed_official 157:90e3acc479a2 204 OPAMP_InitStruct->OPAMP_NonInvertingInput = OPAMP_NonInvertingInput_IO1;
mbed_official 157:90e3acc479a2 205 OPAMP_InitStruct->OPAMP_InvertingInput = OPAMP_InvertingInput_IO1;
mbed_official 157:90e3acc479a2 206 }
mbed_official 157:90e3acc479a2 207
mbed_official 157:90e3acc479a2 208 /**
mbed_official 157:90e3acc479a2 209 * @brief Configure the feedback resistor gain.
mbed_official 157:90e3acc479a2 210 * @note If the selected OPAMP is locked, gain configuration can't be performed.
mbed_official 157:90e3acc479a2 211 * To unlock the configuration, perform a system reset.
mbed_official 157:90e3acc479a2 212 * @param OPAMP_Selection: the selected OPAMP.
mbed_official 157:90e3acc479a2 213 * This parameter can be OPAMP_Selection_OPAMPx where x can be 1 to 4
mbed_official 157:90e3acc479a2 214 * to select the OPAMP peripheral.
mbed_official 157:90e3acc479a2 215 * @param NewState: new state of the OPAMP peripheral.
mbed_official 157:90e3acc479a2 216 * This parameter can be: ENABLE or DISABLE.
mbed_official 157:90e3acc479a2 217 * @retval None
mbed_official 157:90e3acc479a2 218 */
mbed_official 157:90e3acc479a2 219 void OPAMP_PGAConfig(uint32_t OPAMP_Selection, uint32_t OPAMP_PGAGain, uint32_t OPAMP_PGAConnect)
mbed_official 157:90e3acc479a2 220 {
mbed_official 157:90e3acc479a2 221 /* Check the parameters */
mbed_official 157:90e3acc479a2 222 assert_param(IS_OPAMP_ALL_PERIPH(OPAMP_Selection));
mbed_official 157:90e3acc479a2 223 assert_param(IS_OPAMP_PGAGAIN(OPAMP_PGAGain));
mbed_official 157:90e3acc479a2 224 assert_param(IS_OPAMP_PGACONNECT(OPAMP_PGAConnect));
mbed_official 157:90e3acc479a2 225
mbed_official 157:90e3acc479a2 226 /* Reset the configuration bits */
mbed_official 157:90e3acc479a2 227 *(__IO uint32_t *) (OPAMP_BASE + OPAMP_Selection) &= (uint32_t)(~OPAMP_CSR_PGGAIN);
mbed_official 157:90e3acc479a2 228
mbed_official 157:90e3acc479a2 229 /* Set the new configuration */
mbed_official 157:90e3acc479a2 230 *(__IO uint32_t *) (OPAMP_BASE + OPAMP_Selection) |= (uint32_t) (OPAMP_PGAGain | OPAMP_PGAConnect);
mbed_official 157:90e3acc479a2 231 }
mbed_official 157:90e3acc479a2 232
mbed_official 157:90e3acc479a2 233 /**
mbed_official 157:90e3acc479a2 234 * @brief Configure the OPAMP's internal reference.
mbed_official 157:90e3acc479a2 235 * @note This feature is used when calibration enabled or OPAMP's reference
mbed_official 157:90e3acc479a2 236 * connected to the non inverting input.
mbed_official 157:90e3acc479a2 237 * @note If the selected OPAMP is locked, Vref configuration can't be performed.
mbed_official 157:90e3acc479a2 238 * To unlock the configuration, perform a system reset.
mbed_official 157:90e3acc479a2 239 * @param OPAMP_Selection: the selected OPAMP.
mbed_official 157:90e3acc479a2 240 * This parameter can be OPAMP_Selection_OPAMPx where x can be 1 to 4
mbed_official 157:90e3acc479a2 241 * to select the OPAMP peripheral.
mbed_official 157:90e3acc479a2 242 * @param OPAMP_Vref: This parameter can be:
mbed_official 157:90e3acc479a2 243 * OPAMP_Vref_3VDDA: OPMAP Vref = 3.3% VDDA
mbed_official 157:90e3acc479a2 244 * OPAMP_Vref_10VDDA: OPMAP Vref = 10% VDDA
mbed_official 157:90e3acc479a2 245 * OPAMP_Vref_50VDDA: OPMAP Vref = 50% VDDA
mbed_official 157:90e3acc479a2 246 * OPAMP_Vref_90VDDA: OPMAP Vref = 90% VDDA
mbed_official 157:90e3acc479a2 247 * @retval None
mbed_official 157:90e3acc479a2 248 */
mbed_official 157:90e3acc479a2 249 void OPAMP_VrefConfig(uint32_t OPAMP_Selection, uint32_t OPAMP_Vref)
mbed_official 157:90e3acc479a2 250 {
mbed_official 157:90e3acc479a2 251 uint32_t tmpreg = 0;
mbed_official 157:90e3acc479a2 252
mbed_official 157:90e3acc479a2 253 /* Check the parameters */
mbed_official 157:90e3acc479a2 254 assert_param(IS_OPAMP_ALL_PERIPH(OPAMP_Selection));
mbed_official 157:90e3acc479a2 255 assert_param(IS_OPAMP_VREF(OPAMP_Vref));
mbed_official 157:90e3acc479a2 256
mbed_official 157:90e3acc479a2 257 /*!< Get the OPAMPx_CSR register value */
mbed_official 157:90e3acc479a2 258 tmpreg = *(__IO uint32_t *) (OPAMP_BASE + OPAMP_Selection);
mbed_official 157:90e3acc479a2 259
mbed_official 157:90e3acc479a2 260 /*!< Clear the CALSEL bits */
mbed_official 157:90e3acc479a2 261 tmpreg &= (uint32_t) (~OPAMP_CSR_CALSEL);
mbed_official 157:90e3acc479a2 262
mbed_official 157:90e3acc479a2 263 /*!< Configure OPAMP reference */
mbed_official 157:90e3acc479a2 264 tmpreg |= (uint32_t)(OPAMP_Vref);
mbed_official 157:90e3acc479a2 265
mbed_official 157:90e3acc479a2 266 /*!< Write to OPAMPx_CSR register */
mbed_official 157:90e3acc479a2 267 *(__IO uint32_t *) (OPAMP_BASE + OPAMP_Selection) = tmpreg;
mbed_official 157:90e3acc479a2 268 }
mbed_official 157:90e3acc479a2 269
mbed_official 157:90e3acc479a2 270 /**
mbed_official 157:90e3acc479a2 271 * @brief Connnect the internal reference to the OPAMP's non inverting input.
mbed_official 157:90e3acc479a2 272 * @note If the selected OPAMP is locked, Vref configuration can't be performed.
mbed_official 157:90e3acc479a2 273 * To unlock the configuration, perform a system reset.
mbed_official 157:90e3acc479a2 274 * @param OPAMP_Selection: the selected OPAMP.
mbed_official 157:90e3acc479a2 275 * This parameter can be OPAMP_Selection_OPAMPx where x can be 1 to 4
mbed_official 157:90e3acc479a2 276 * to select the OPAMP peripheral.
mbed_official 157:90e3acc479a2 277 * @param NewState: new state of the OPAMP peripheral.
mbed_official 157:90e3acc479a2 278 * This parameter can be: ENABLE or DISABLE.
mbed_official 157:90e3acc479a2 279 * @retval None
mbed_official 157:90e3acc479a2 280 */
mbed_official 157:90e3acc479a2 281 void OPAMP_VrefConnectNonInvertingInput(uint32_t OPAMP_Selection, FunctionalState NewState)
mbed_official 157:90e3acc479a2 282 {
mbed_official 157:90e3acc479a2 283 /* Check the parameters */
mbed_official 157:90e3acc479a2 284 assert_param(IS_OPAMP_ALL_PERIPH(OPAMP_Selection));
mbed_official 157:90e3acc479a2 285 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 157:90e3acc479a2 286
mbed_official 157:90e3acc479a2 287 if (NewState != DISABLE)
mbed_official 157:90e3acc479a2 288 {
mbed_official 157:90e3acc479a2 289 /* Connnect the internal reference to the OPAMP's non inverting input */
mbed_official 157:90e3acc479a2 290 *(__IO uint32_t *) (OPAMP_BASE + OPAMP_Selection) |= (uint32_t) (OPAMP_CSR_FORCEVP);
mbed_official 157:90e3acc479a2 291 }
mbed_official 157:90e3acc479a2 292 else
mbed_official 157:90e3acc479a2 293 {
mbed_official 157:90e3acc479a2 294 /* Disconnnect the internal reference to the OPAMP's non inverting input */
mbed_official 157:90e3acc479a2 295 *(__IO uint32_t *) (OPAMP_BASE + OPAMP_Selection) &= (uint32_t)(~OPAMP_CSR_FORCEVP);
mbed_official 157:90e3acc479a2 296 }
mbed_official 157:90e3acc479a2 297 }
mbed_official 157:90e3acc479a2 298
mbed_official 157:90e3acc479a2 299 /**
mbed_official 157:90e3acc479a2 300 * @brief Enables or disables connecting the OPAMP's internal reference to ADC.
mbed_official 157:90e3acc479a2 301 * @note If the selected OPAMP is locked, Vref connection can't be performed.
mbed_official 157:90e3acc479a2 302 * To unlock the configuration, perform a system reset.
mbed_official 157:90e3acc479a2 303 * @param NewState: new state of the Vrefint output.
mbed_official 157:90e3acc479a2 304 * This parameter can be: ENABLE or DISABLE.
mbed_official 157:90e3acc479a2 305 * @retval None
mbed_official 157:90e3acc479a2 306 */
mbed_official 157:90e3acc479a2 307 void OPAMP_VrefConnectADCCmd(uint32_t OPAMP_Selection, FunctionalState NewState)
mbed_official 157:90e3acc479a2 308 {
mbed_official 157:90e3acc479a2 309 /* Check the parameters */
mbed_official 157:90e3acc479a2 310 assert_param(IS_OPAMP_ALL_PERIPH(OPAMP_Selection));
mbed_official 157:90e3acc479a2 311 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 157:90e3acc479a2 312
mbed_official 157:90e3acc479a2 313 if (NewState != DISABLE)
mbed_official 157:90e3acc479a2 314 {
mbed_official 157:90e3acc479a2 315 /* Enable output internal reference */
mbed_official 157:90e3acc479a2 316 *(__IO uint32_t *) (OPAMP_BASE + OPAMP_Selection) |= (uint32_t) (OPAMP_CSR_TSTREF);
mbed_official 157:90e3acc479a2 317 }
mbed_official 157:90e3acc479a2 318 else
mbed_official 157:90e3acc479a2 319 {
mbed_official 157:90e3acc479a2 320 /* Disable output internal reference */
mbed_official 157:90e3acc479a2 321 *(__IO uint32_t *) (OPAMP_BASE + OPAMP_Selection) &= (uint32_t)(~OPAMP_CSR_TSTREF);
mbed_official 157:90e3acc479a2 322 }
mbed_official 157:90e3acc479a2 323 }
mbed_official 157:90e3acc479a2 324
mbed_official 157:90e3acc479a2 325 /**
mbed_official 157:90e3acc479a2 326 * @brief Configure the OPAMP peripheral (secondary inputs) for timer-controlled
mbed_official 157:90e3acc479a2 327 * mux mode according to the specified parameters in OPAMP_InitStruct.
mbed_official 157:90e3acc479a2 328 * @note If the selected OPAMP is locked, timer-controlled mux configuration
mbed_official 157:90e3acc479a2 329 * can't be performed.
mbed_official 157:90e3acc479a2 330 * To unlock the configuration, perform a system reset.
mbed_official 157:90e3acc479a2 331 * @param OPAMP_Selection: the selected OPAMP.
mbed_official 157:90e3acc479a2 332 * This parameter can be OPAMP_Selection_OPAMPx where x can be 1 to 4
mbed_official 157:90e3acc479a2 333 * to select the OPAMP peripheral.
mbed_official 157:90e3acc479a2 334 * @param OPAMP_InitStruct: pointer to an OPAMP_InitTypeDef structure that contains
mbed_official 157:90e3acc479a2 335 * the configuration information for the specified OPAMP peripheral.
mbed_official 157:90e3acc479a2 336 * - OPAMP_InvertingInput specifies the inverting input of OPAMP
mbed_official 157:90e3acc479a2 337 * - OPAMP_NonInvertingInput specifies the non inverting input of OPAMP
mbed_official 157:90e3acc479a2 338 * @note PGA and Vout can't be selected as seconadry inverting input.
mbed_official 157:90e3acc479a2 339 * @retval None
mbed_official 157:90e3acc479a2 340 */
mbed_official 157:90e3acc479a2 341 void OPAMP_TimerControlledMuxConfig(uint32_t OPAMP_Selection, OPAMP_InitTypeDef* OPAMP_InitStruct)
mbed_official 157:90e3acc479a2 342 {
mbed_official 157:90e3acc479a2 343 uint32_t tmpreg = 0;
mbed_official 157:90e3acc479a2 344
mbed_official 157:90e3acc479a2 345 /* Check the parameters */
mbed_official 157:90e3acc479a2 346 assert_param(IS_OPAMP_ALL_PERIPH(OPAMP_Selection));
mbed_official 157:90e3acc479a2 347 assert_param(IS_OPAMP_SECONDARY_INVINPUT(OPAMP_InitStruct->OPAMP_InvertingInput));
mbed_official 157:90e3acc479a2 348 assert_param(IS_OPAMP_NONINVERTING_INPUT(OPAMP_InitStruct->OPAMP_NonInvertingInput));
mbed_official 157:90e3acc479a2 349
mbed_official 157:90e3acc479a2 350 /*!< Get the OPAMPx_CSR register value */
mbed_official 157:90e3acc479a2 351 tmpreg = *(__IO uint32_t *) (OPAMP_BASE + OPAMP_Selection);
mbed_official 157:90e3acc479a2 352
mbed_official 157:90e3acc479a2 353 /*!< Clear the secondary inverting bit, secondary non inverting bit and TCMEN bits */
mbed_official 157:90e3acc479a2 354 tmpreg &= (uint32_t) (OPAMP_CSR_TIMERMUX_MASK);
mbed_official 157:90e3acc479a2 355
mbed_official 157:90e3acc479a2 356 /*!< Configure OPAMP: secondary inverting and non inverting inputs */
mbed_official 157:90e3acc479a2 357 tmpreg |= (uint32_t)((uint32_t)(OPAMP_InitStruct->OPAMP_InvertingInput<<3) | (uint32_t)(OPAMP_InitStruct->OPAMP_NonInvertingInput<<7));
mbed_official 157:90e3acc479a2 358
mbed_official 157:90e3acc479a2 359 /*!< Write to OPAMPx_CSR register */
mbed_official 157:90e3acc479a2 360 *(__IO uint32_t *) (OPAMP_BASE + OPAMP_Selection) = tmpreg;
mbed_official 157:90e3acc479a2 361 }
mbed_official 157:90e3acc479a2 362
mbed_official 157:90e3acc479a2 363 /**
mbed_official 157:90e3acc479a2 364 * @brief Enable or disable the timer-controlled mux mode.
mbed_official 157:90e3acc479a2 365 * @note If the selected OPAMP is locked, enable/disable can't be performed.
mbed_official 157:90e3acc479a2 366 * To unlock the configuration, perform a system reset.
mbed_official 157:90e3acc479a2 367 * @param OPAMP_Selection: the selected OPAMP.
mbed_official 157:90e3acc479a2 368 * This parameter can be OPAMP_Selection_OPAMPx where x can be 1 to 4
mbed_official 157:90e3acc479a2 369 * to select the OPAMP peripheral.
mbed_official 157:90e3acc479a2 370 * @param NewState: new state of the OPAMP peripheral.
mbed_official 157:90e3acc479a2 371 * This parameter can be: ENABLE or DISABLE.
mbed_official 157:90e3acc479a2 372 * @retval None
mbed_official 157:90e3acc479a2 373 */
mbed_official 157:90e3acc479a2 374 void OPAMP_TimerControlledMuxCmd(uint32_t OPAMP_Selection, FunctionalState NewState)
mbed_official 157:90e3acc479a2 375 {
mbed_official 157:90e3acc479a2 376 /* Check the parameters */
mbed_official 157:90e3acc479a2 377 assert_param(IS_OPAMP_ALL_PERIPH(OPAMP_Selection));
mbed_official 157:90e3acc479a2 378 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 157:90e3acc479a2 379
mbed_official 157:90e3acc479a2 380 if (NewState != DISABLE)
mbed_official 157:90e3acc479a2 381 {
mbed_official 157:90e3acc479a2 382 /* Enable the timer-controlled Mux mode */
mbed_official 157:90e3acc479a2 383 *(__IO uint32_t *) (OPAMP_BASE + OPAMP_Selection) |= (uint32_t) (OPAMP_CSR_TCMEN);
mbed_official 157:90e3acc479a2 384 }
mbed_official 157:90e3acc479a2 385 else
mbed_official 157:90e3acc479a2 386 {
mbed_official 157:90e3acc479a2 387 /* Disable the timer-controlled Mux mode */
mbed_official 157:90e3acc479a2 388 *(__IO uint32_t *) (OPAMP_BASE + OPAMP_Selection) &= (uint32_t)(~OPAMP_CSR_TCMEN);
mbed_official 157:90e3acc479a2 389 }
mbed_official 157:90e3acc479a2 390 }
mbed_official 157:90e3acc479a2 391
mbed_official 157:90e3acc479a2 392 /**
mbed_official 157:90e3acc479a2 393 * @brief Enable or disable the OPAMP peripheral.
mbed_official 157:90e3acc479a2 394 * @note If the selected OPAMP is locked, enable/disable can't be performed.
mbed_official 157:90e3acc479a2 395 * To unlock the configuration, perform a system reset.
mbed_official 157:90e3acc479a2 396 * @param OPAMP_Selection: the selected OPAMP.
mbed_official 157:90e3acc479a2 397 * This parameter can be OPAMP_Selection_OPAMPx where x can be 1 to 4
mbed_official 157:90e3acc479a2 398 * to select the OPAMP peripheral.
mbed_official 157:90e3acc479a2 399 * @param NewState: new state of the OPAMP peripheral.
mbed_official 157:90e3acc479a2 400 * This parameter can be: ENABLE or DISABLE.
mbed_official 157:90e3acc479a2 401 * @retval None
mbed_official 157:90e3acc479a2 402 */
mbed_official 157:90e3acc479a2 403 void OPAMP_Cmd(uint32_t OPAMP_Selection, FunctionalState NewState)
mbed_official 157:90e3acc479a2 404 {
mbed_official 157:90e3acc479a2 405 /* Check the parameters */
mbed_official 157:90e3acc479a2 406 assert_param(IS_OPAMP_ALL_PERIPH(OPAMP_Selection));
mbed_official 157:90e3acc479a2 407 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 157:90e3acc479a2 408
mbed_official 157:90e3acc479a2 409 if (NewState != DISABLE)
mbed_official 157:90e3acc479a2 410 {
mbed_official 157:90e3acc479a2 411 /* Enable the selected OPAMPx peripheral */
mbed_official 157:90e3acc479a2 412 *(__IO uint32_t *) (OPAMP_BASE + OPAMP_Selection) |= (uint32_t) (OPAMP_CSR_OPAMPxEN);
mbed_official 157:90e3acc479a2 413 }
mbed_official 157:90e3acc479a2 414 else
mbed_official 157:90e3acc479a2 415 {
mbed_official 157:90e3acc479a2 416 /* Disable the selected OPAMPx peripheral */
mbed_official 157:90e3acc479a2 417 *(__IO uint32_t *) (OPAMP_BASE + OPAMP_Selection) &= (uint32_t)(~OPAMP_CSR_OPAMPxEN);
mbed_official 157:90e3acc479a2 418 }
mbed_official 157:90e3acc479a2 419 }
mbed_official 157:90e3acc479a2 420
mbed_official 157:90e3acc479a2 421 /**
mbed_official 157:90e3acc479a2 422 * @brief Return the output level (high or low) during calibration of the selected OPAMP.
mbed_official 157:90e3acc479a2 423 * @param OPAMP_Selection: the selected OPAMP.
mbed_official 157:90e3acc479a2 424 * This parameter can be OPAMP_Selection_OPAMPx where x can be 1 to 4
mbed_official 157:90e3acc479a2 425 * to select the OPAMP peripheral.
mbed_official 157:90e3acc479a2 426 * - OPAMP output is low when the non-inverting input is at a lower
mbed_official 157:90e3acc479a2 427 * voltage than the inverting input
mbed_official 157:90e3acc479a2 428 * - OPAMP output is high when the non-inverting input is at a higher
mbed_official 157:90e3acc479a2 429 * voltage than the inverting input
mbed_official 157:90e3acc479a2 430 * @note OPAMP ouput level is provided only during calibration phase.
mbed_official 157:90e3acc479a2 431 * @retval Returns the selected OPAMP output level: low or high.
mbed_official 157:90e3acc479a2 432 *
mbed_official 157:90e3acc479a2 433 */
mbed_official 157:90e3acc479a2 434 uint32_t OPAMP_GetOutputLevel(uint32_t OPAMP_Selection)
mbed_official 157:90e3acc479a2 435 {
mbed_official 157:90e3acc479a2 436 uint32_t opampout = 0x0;
mbed_official 157:90e3acc479a2 437
mbed_official 157:90e3acc479a2 438 /* Check the parameters */
mbed_official 157:90e3acc479a2 439 assert_param(IS_OPAMP_ALL_PERIPH(OPAMP_Selection));
mbed_official 157:90e3acc479a2 440
mbed_official 157:90e3acc479a2 441 /* Check if selected OPAMP output is high */
mbed_official 157:90e3acc479a2 442 if ((*(__IO uint32_t *) (OPAMP_BASE + OPAMP_Selection) & (OPAMP_CSR_OUTCAL)) != 0)
mbed_official 157:90e3acc479a2 443 {
mbed_official 157:90e3acc479a2 444 opampout = OPAMP_OutputLevel_High;
mbed_official 157:90e3acc479a2 445 }
mbed_official 157:90e3acc479a2 446 else
mbed_official 157:90e3acc479a2 447 {
mbed_official 157:90e3acc479a2 448 opampout = OPAMP_OutputLevel_Low;
mbed_official 157:90e3acc479a2 449 }
mbed_official 157:90e3acc479a2 450
mbed_official 157:90e3acc479a2 451 /* Return the OPAMP output level */
mbed_official 157:90e3acc479a2 452 return (uint32_t)(opampout);
mbed_official 157:90e3acc479a2 453 }
mbed_official 157:90e3acc479a2 454
mbed_official 157:90e3acc479a2 455 /**
mbed_official 157:90e3acc479a2 456 * @brief Select the trimming mode.
mbed_official 157:90e3acc479a2 457 * @param OffsetTrimming: the selected offset trimming mode.
mbed_official 157:90e3acc479a2 458 * This parameter can be one of the following values:
mbed_official 157:90e3acc479a2 459 * @arg OPAMP_Trimming_Factory: factory trimming values are used for offset
mbed_official 157:90e3acc479a2 460 * calibration
mbed_official 157:90e3acc479a2 461 * @arg OPAMP_Trimming_User: user trimming values are used for offset
mbed_official 157:90e3acc479a2 462 * calibration
mbed_official 157:90e3acc479a2 463 * @note When OffsetTrimming_User is selected, use OPAMP_OffsetTrimConfig()
mbed_official 157:90e3acc479a2 464 * function or OPAMP_OffsetTrimLowPowerConfig() function to adjust
mbed_official 157:90e3acc479a2 465 * trimming value.
mbed_official 157:90e3acc479a2 466 * @retval None
mbed_official 157:90e3acc479a2 467 */
mbed_official 157:90e3acc479a2 468 void OPAMP_OffsetTrimModeSelect(uint32_t OPAMP_Selection, uint32_t OPAMP_Trimming)
mbed_official 157:90e3acc479a2 469 {
mbed_official 157:90e3acc479a2 470 /* Check the parameters */
mbed_official 157:90e3acc479a2 471 assert_param(IS_OPAMP_ALL_PERIPH(OPAMP_Selection));
mbed_official 157:90e3acc479a2 472 assert_param(IS_OPAMP_TRIMMING(OPAMP_Trimming));
mbed_official 157:90e3acc479a2 473
mbed_official 157:90e3acc479a2 474 /* Reset USERTRIM bit */
mbed_official 157:90e3acc479a2 475 *(__IO uint32_t *) (OPAMP_BASE + OPAMP_Selection) &= (~(uint32_t) (OPAMP_CSR_USERTRIM));
mbed_official 157:90e3acc479a2 476
mbed_official 157:90e3acc479a2 477 /* Select trimming mode */
mbed_official 157:90e3acc479a2 478 *(__IO uint32_t *) (OPAMP_BASE + OPAMP_Selection) |= OPAMP_Trimming;
mbed_official 157:90e3acc479a2 479 }
mbed_official 157:90e3acc479a2 480
mbed_official 157:90e3acc479a2 481 /**
mbed_official 157:90e3acc479a2 482 * @brief Configure the trimming value of the OPAMP.
mbed_official 157:90e3acc479a2 483 * @param OPAMP_Selection: the selected OPAMP.
mbed_official 157:90e3acc479a2 484 * This parameter can be OPAMP_Selection_OPAMPx where x can be 1 to 4
mbed_official 157:90e3acc479a2 485 * to select the OPAMP peripheral.
mbed_official 157:90e3acc479a2 486 * @param OPAMP_Input: the selected OPAMP input.
mbed_official 157:90e3acc479a2 487 * This parameter can be one of the following values:
mbed_official 157:90e3acc479a2 488 * @arg OPAMP_Input_Inverting: Inverting input is selected to configure the trimming value
mbed_official 157:90e3acc479a2 489 * @arg OPAMP_Input_NonInverting: Non inverting input is selected to configure the trimming value
mbed_official 157:90e3acc479a2 490 * @param OPAMP_TrimValue: the trimming value. This parameter can be any value lower
mbed_official 157:90e3acc479a2 491 * or equal to 0x0000001F.
mbed_official 157:90e3acc479a2 492 * @retval None
mbed_official 157:90e3acc479a2 493 */
mbed_official 157:90e3acc479a2 494 void OPAMP_OffsetTrimConfig(uint32_t OPAMP_Selection, uint32_t OPAMP_Input, uint32_t OPAMP_TrimValue)
mbed_official 157:90e3acc479a2 495 {
mbed_official 157:90e3acc479a2 496 uint32_t tmpreg = 0;
mbed_official 157:90e3acc479a2 497
mbed_official 157:90e3acc479a2 498 /* Check the parameters */
mbed_official 157:90e3acc479a2 499 assert_param(IS_OPAMP_ALL_PERIPH(OPAMP_Selection));
mbed_official 157:90e3acc479a2 500 assert_param(IS_OPAMP_INPUT(OPAMP_Input));
mbed_official 157:90e3acc479a2 501 assert_param(IS_OPAMP_TRIMMINGVALUE(OPAMP_TrimValue));
mbed_official 157:90e3acc479a2 502
mbed_official 157:90e3acc479a2 503 /*!< Get the OPAMPx_CSR register value */
mbed_official 157:90e3acc479a2 504 tmpreg = *(__IO uint32_t *) (OPAMP_BASE + OPAMP_Selection);
mbed_official 157:90e3acc479a2 505
mbed_official 157:90e3acc479a2 506 /*!< Clear the trimming bits */
mbed_official 157:90e3acc479a2 507 tmpreg &= ((uint32_t)~(OPAMP_CSR_TRIMMING_MASK<<OPAMP_Input));
mbed_official 157:90e3acc479a2 508
mbed_official 157:90e3acc479a2 509 /*!< Configure the new trimming value */
mbed_official 157:90e3acc479a2 510 tmpreg |= (uint32_t)(OPAMP_TrimValue<<OPAMP_Input);
mbed_official 157:90e3acc479a2 511
mbed_official 157:90e3acc479a2 512 /*!< Write to OPAMPx_CSR register */
mbed_official 157:90e3acc479a2 513 *(__IO uint32_t *) (OPAMP_BASE + OPAMP_Selection) = tmpreg;
mbed_official 157:90e3acc479a2 514 }
mbed_official 157:90e3acc479a2 515
mbed_official 157:90e3acc479a2 516 /**
mbed_official 157:90e3acc479a2 517 * @brief Start or stop the calibration of selected OPAMP peripheral.
mbed_official 157:90e3acc479a2 518 * @note If the selected OPAMP is locked, start/stop can't be performed.
mbed_official 157:90e3acc479a2 519 * To unlock the configuration, perform a system reset.
mbed_official 157:90e3acc479a2 520 * @param OPAMP_Selection: the selected OPAMP.
mbed_official 157:90e3acc479a2 521 * This parameter can be OPAMP_Selection_OPAMPx where x can be 1 to 4
mbed_official 157:90e3acc479a2 522 * to select the OPAMP peripheral.
mbed_official 157:90e3acc479a2 523 * @param NewState: new state of the OPAMP peripheral.
mbed_official 157:90e3acc479a2 524 * This parameter can be: ENABLE or DISABLE.
mbed_official 157:90e3acc479a2 525 * @retval None
mbed_official 157:90e3acc479a2 526 */
mbed_official 157:90e3acc479a2 527 void OPAMP_StartCalibration(uint32_t OPAMP_Selection, FunctionalState NewState)
mbed_official 157:90e3acc479a2 528 {
mbed_official 157:90e3acc479a2 529 /* Check the parameters */
mbed_official 157:90e3acc479a2 530 assert_param(IS_OPAMP_ALL_PERIPH(OPAMP_Selection));
mbed_official 157:90e3acc479a2 531 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 157:90e3acc479a2 532
mbed_official 157:90e3acc479a2 533 if (NewState != DISABLE)
mbed_official 157:90e3acc479a2 534 {
mbed_official 157:90e3acc479a2 535 /* Start the OPAMPx calibration */
mbed_official 157:90e3acc479a2 536 *(__IO uint32_t *) (OPAMP_BASE + OPAMP_Selection) |= (uint32_t) (OPAMP_CSR_CALON);
mbed_official 157:90e3acc479a2 537 }
mbed_official 157:90e3acc479a2 538 else
mbed_official 157:90e3acc479a2 539 {
mbed_official 157:90e3acc479a2 540 /* Stop the OPAMPx calibration */
mbed_official 157:90e3acc479a2 541 *(__IO uint32_t *) (OPAMP_BASE + OPAMP_Selection) &= (uint32_t)(~OPAMP_CSR_CALON);
mbed_official 157:90e3acc479a2 542 }
mbed_official 157:90e3acc479a2 543 }
mbed_official 157:90e3acc479a2 544
mbed_official 157:90e3acc479a2 545 /**
mbed_official 157:90e3acc479a2 546 * @}
mbed_official 157:90e3acc479a2 547 */
mbed_official 157:90e3acc479a2 548
mbed_official 157:90e3acc479a2 549 /** @defgroup OPAMP_Group2 OPAMP configuration locking function
mbed_official 157:90e3acc479a2 550 * @brief OPAMP1,...OPAMP4 configuration locking function
mbed_official 157:90e3acc479a2 551 * OPAMP1,...OPAMP4 configuration can be locked each separately.
mbed_official 157:90e3acc479a2 552 * Unlocking is performed by system reset.
mbed_official 157:90e3acc479a2 553 *
mbed_official 157:90e3acc479a2 554 @verbatim
mbed_official 157:90e3acc479a2 555 ===============================================================================
mbed_official 157:90e3acc479a2 556 ##### Configuration Lock function #####
mbed_official 157:90e3acc479a2 557 ===============================================================================
mbed_official 157:90e3acc479a2 558
mbed_official 157:90e3acc479a2 559 @endverbatim
mbed_official 157:90e3acc479a2 560 * @{
mbed_official 157:90e3acc479a2 561 */
mbed_official 157:90e3acc479a2 562
mbed_official 157:90e3acc479a2 563 /**
mbed_official 157:90e3acc479a2 564 * @brief Lock the selected OPAMP configuration.
mbed_official 157:90e3acc479a2 565 * @note Locking the configuration means that all control bits are read-only.
mbed_official 157:90e3acc479a2 566 * To unlock the OPAMP configuration, perform a system reset.
mbed_official 157:90e3acc479a2 567 * @param OPAMP_Selection: the selected OPAMP.
mbed_official 157:90e3acc479a2 568 * This parameter can be OPAMP_Selection_OPAMPx where x can be 1 to 4
mbed_official 157:90e3acc479a2 569 * to select the OPAMP peripheral.
mbed_official 157:90e3acc479a2 570 * @retval None
mbed_official 157:90e3acc479a2 571 */
mbed_official 157:90e3acc479a2 572 void OPAMP_LockConfig(uint32_t OPAMP_Selection)
mbed_official 157:90e3acc479a2 573 {
mbed_official 157:90e3acc479a2 574 /* Check the parameter */
mbed_official 157:90e3acc479a2 575 assert_param(IS_OPAMP_ALL_PERIPH(OPAMP_Selection));
mbed_official 157:90e3acc479a2 576
mbed_official 157:90e3acc479a2 577 /* Set the lock bit corresponding to selected OPAMP */
mbed_official 157:90e3acc479a2 578 *(__IO uint32_t *) (OPAMP_BASE + OPAMP_Selection) |= (uint32_t) (OPAMP_CSR_LOCK);
mbed_official 157:90e3acc479a2 579 }
mbed_official 157:90e3acc479a2 580
mbed_official 157:90e3acc479a2 581 /**
mbed_official 157:90e3acc479a2 582 * @}
mbed_official 157:90e3acc479a2 583 */
mbed_official 157:90e3acc479a2 584
mbed_official 157:90e3acc479a2 585 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/