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