mbed library sources

Dependents:   bare

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Wed Mar 19 10:15:22 2014 +0000
Revision:
125:23cc3068a9e4
Synchronized with git revision ace35dfba3748c7cdc102eb38ec6b9e1067c3252

Full URL: https://github.com/mbedmicro/mbed/commit/ace35dfba3748c7cdc102eb38ec6b9e1067c3252/

[NUCLEO_F302R8] Add cmsis and hal files + change F401RE clock to 84MHz

Who changed what in which revision?

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