mbed library sources
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_opamp.c@106:ced8cbb51063, 2014-02-26 (annotated)
- Committer:
- mbed_official
- Date:
- Wed Feb 26 09:45:12 2014 +0000
- Revision:
- 106:ced8cbb51063
- Parent:
- 80:66393a7b209d
Synchronized with git revision 4222735eff5868389433f0e9271976b39c8115cd
Full URL: https://github.com/mbedmicro/mbed/commit/4222735eff5868389433f0e9271976b39c8115cd/
[NUCLEO_xxx] Update STM32CubeF4 driver V1.0.0 + update license
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 76:aeb1df146756 | 1 | /** |
mbed_official | 76:aeb1df146756 | 2 | ****************************************************************************** |
mbed_official | 76:aeb1df146756 | 3 | * @file stm32l1xx_opamp.c |
mbed_official | 76:aeb1df146756 | 4 | * @author MCD Application Team |
mbed_official | 80:66393a7b209d | 5 | * @version V1.3.0 |
mbed_official | 80:66393a7b209d | 6 | * @date 31-January-2014 |
mbed_official | 76:aeb1df146756 | 7 | * @brief This file provides firmware functions to manage the following |
mbed_official | 76:aeb1df146756 | 8 | * functionalities of the operational amplifiers (opamp) peripheral: |
mbed_official | 76:aeb1df146756 | 9 | * + Initialization and configuration |
mbed_official | 76:aeb1df146756 | 10 | * + Calibration management |
mbed_official | 76:aeb1df146756 | 11 | * |
mbed_official | 76:aeb1df146756 | 12 | * @verbatim |
mbed_official | 76:aeb1df146756 | 13 | ============================================================================== |
mbed_official | 76:aeb1df146756 | 14 | ##### How to use this driver ##### |
mbed_official | 76:aeb1df146756 | 15 | ============================================================================== |
mbed_official | 76:aeb1df146756 | 16 | [..] The device integrates three independent rail-to-rail operational amplifiers |
mbed_official | 76:aeb1df146756 | 17 | OPAMP1, OPAMP2 and OPAMP3: |
mbed_official | 76:aeb1df146756 | 18 | (+) Internal connections to the ADC. |
mbed_official | 76:aeb1df146756 | 19 | (+) Internal connections to the DAC. |
mbed_official | 76:aeb1df146756 | 20 | (+) Internal connection to COMP1 (only OPAMP3). |
mbed_official | 76:aeb1df146756 | 21 | (+) Internal connection for unity gain (voltage follower) configuration. |
mbed_official | 76:aeb1df146756 | 22 | (+) Calibration capability. |
mbed_official | 76:aeb1df146756 | 23 | (+) Selectable gain-bandwidth (2MHz in normal mode, 500KHz in low power mode). |
mbed_official | 76:aeb1df146756 | 24 | [..] |
mbed_official | 76:aeb1df146756 | 25 | (#) COMP AHB clock must be enabled to get write access |
mbed_official | 76:aeb1df146756 | 26 | to OPAMP registers using |
mbed_official | 76:aeb1df146756 | 27 | (#) RCC_APB1PeriphClockCmd(RCC_APB1Periph_COMP, ENABLE) |
mbed_official | 76:aeb1df146756 | 28 | |
mbed_official | 76:aeb1df146756 | 29 | (#) Configure the corresponding GPIO to OPAMPx INP, OPAMPx_INN (if used) |
mbed_official | 76:aeb1df146756 | 30 | and OPAMPx_OUT in analog mode. |
mbed_official | 76:aeb1df146756 | 31 | |
mbed_official | 76:aeb1df146756 | 32 | (#) Configure (close/open) the OPAMP switches using OPAMP_SwitchCmd() |
mbed_official | 76:aeb1df146756 | 33 | |
mbed_official | 76:aeb1df146756 | 34 | (#) Enable the OPAMP peripheral using OPAMP_Cmd() |
mbed_official | 76:aeb1df146756 | 35 | |
mbed_official | 76:aeb1df146756 | 36 | -@- In order to use OPAMP outputs as ADC inputs, the opamps must be enabled |
mbed_official | 76:aeb1df146756 | 37 | and the ADC must use the OPAMP output channel number: |
mbed_official | 76:aeb1df146756 | 38 | (+@) OPAMP1 output is connected to ADC channel 3. |
mbed_official | 76:aeb1df146756 | 39 | (+@) OPAMP2 output is connected to ADC channel 8. |
mbed_official | 76:aeb1df146756 | 40 | (+@) OPAMP3 output is connected to ADC channel 13 (SW1 switch must be closed). |
mbed_official | 76:aeb1df146756 | 41 | |
mbed_official | 76:aeb1df146756 | 42 | * @endverbatim |
mbed_official | 76:aeb1df146756 | 43 | * |
mbed_official | 76:aeb1df146756 | 44 | ****************************************************************************** |
mbed_official | 76:aeb1df146756 | 45 | * @attention |
mbed_official | 76:aeb1df146756 | 46 | * |
mbed_official | 106:ced8cbb51063 | 47 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
mbed_official | 76:aeb1df146756 | 48 | * |
mbed_official | 106:ced8cbb51063 | 49 | * Redistribution and use in source and binary forms, with or without modification, |
mbed_official | 106:ced8cbb51063 | 50 | * are permitted provided that the following conditions are met: |
mbed_official | 106:ced8cbb51063 | 51 | * 1. Redistributions of source code must retain the above copyright notice, |
mbed_official | 106:ced8cbb51063 | 52 | * this list of conditions and the following disclaimer. |
mbed_official | 106:ced8cbb51063 | 53 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mbed_official | 106:ced8cbb51063 | 54 | * this list of conditions and the following disclaimer in the documentation |
mbed_official | 106:ced8cbb51063 | 55 | * and/or other materials provided with the distribution. |
mbed_official | 106:ced8cbb51063 | 56 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
mbed_official | 106:ced8cbb51063 | 57 | * may be used to endorse or promote products derived from this software |
mbed_official | 106:ced8cbb51063 | 58 | * without specific prior written permission. |
mbed_official | 76:aeb1df146756 | 59 | * |
mbed_official | 106:ced8cbb51063 | 60 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 106:ced8cbb51063 | 61 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 106:ced8cbb51063 | 62 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
mbed_official | 106:ced8cbb51063 | 63 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
mbed_official | 106:ced8cbb51063 | 64 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mbed_official | 106:ced8cbb51063 | 65 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
mbed_official | 106:ced8cbb51063 | 66 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mbed_official | 106:ced8cbb51063 | 67 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
mbed_official | 106:ced8cbb51063 | 68 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
mbed_official | 106:ced8cbb51063 | 69 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 76:aeb1df146756 | 70 | * |
mbed_official | 76:aeb1df146756 | 71 | ****************************************************************************** |
mbed_official | 76:aeb1df146756 | 72 | */ |
mbed_official | 76:aeb1df146756 | 73 | |
mbed_official | 76:aeb1df146756 | 74 | /* Includes ------------------------------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 75 | #include "stm32l1xx_opamp.h" |
mbed_official | 76:aeb1df146756 | 76 | |
mbed_official | 76:aeb1df146756 | 77 | |
mbed_official | 76:aeb1df146756 | 78 | /** @addtogroup STM32L1xx_StdPeriph_Driver |
mbed_official | 76:aeb1df146756 | 79 | * @{ |
mbed_official | 76:aeb1df146756 | 80 | */ |
mbed_official | 76:aeb1df146756 | 81 | |
mbed_official | 76:aeb1df146756 | 82 | /** @defgroup OPAMP |
mbed_official | 76:aeb1df146756 | 83 | * @brief OPAMP driver modules |
mbed_official | 76:aeb1df146756 | 84 | * @{ |
mbed_official | 76:aeb1df146756 | 85 | */ |
mbed_official | 76:aeb1df146756 | 86 | |
mbed_official | 76:aeb1df146756 | 87 | /* Private typedef -----------------------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 88 | /* Private define ------------------------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 89 | /* Private macro -------------------------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 90 | /* Private variables ---------------------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 91 | /* Private function prototypes -----------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 92 | /* Private functions ---------------------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 93 | |
mbed_official | 76:aeb1df146756 | 94 | /** @defgroup OPAMP_Private_Functions |
mbed_official | 76:aeb1df146756 | 95 | * @{ |
mbed_official | 76:aeb1df146756 | 96 | */ |
mbed_official | 76:aeb1df146756 | 97 | |
mbed_official | 76:aeb1df146756 | 98 | /** @defgroup OPAMP_Group1 Initialization and configuration |
mbed_official | 76:aeb1df146756 | 99 | * @brief Initialization and configuration |
mbed_official | 76:aeb1df146756 | 100 | * |
mbed_official | 76:aeb1df146756 | 101 | @verbatim |
mbed_official | 76:aeb1df146756 | 102 | =============================================================================== |
mbed_official | 76:aeb1df146756 | 103 | ##### Initialization and configuration ##### |
mbed_official | 76:aeb1df146756 | 104 | =============================================================================== |
mbed_official | 76:aeb1df146756 | 105 | |
mbed_official | 76:aeb1df146756 | 106 | @endverbatim |
mbed_official | 76:aeb1df146756 | 107 | * @{ |
mbed_official | 76:aeb1df146756 | 108 | */ |
mbed_official | 76:aeb1df146756 | 109 | |
mbed_official | 76:aeb1df146756 | 110 | /** |
mbed_official | 76:aeb1df146756 | 111 | * @brief Deinitialize the OPAMPs register to its default reset value. |
mbed_official | 76:aeb1df146756 | 112 | * @note At startup, OTR and LPOTR registers are set to factory programmed values. |
mbed_official | 76:aeb1df146756 | 113 | * @param None. |
mbed_official | 76:aeb1df146756 | 114 | * @retval None. |
mbed_official | 76:aeb1df146756 | 115 | */ |
mbed_official | 76:aeb1df146756 | 116 | void OPAMP_DeInit(void) |
mbed_official | 76:aeb1df146756 | 117 | { |
mbed_official | 76:aeb1df146756 | 118 | /*!< Set OPAMP_CSR register to reset value */ |
mbed_official | 76:aeb1df146756 | 119 | OPAMP->CSR = 0x00010101; |
mbed_official | 76:aeb1df146756 | 120 | /*!< Set OPAMP_OTR register to reset value */ |
mbed_official | 76:aeb1df146756 | 121 | OPAMP->OTR = (uint32_t)(* (uint32_t*)FLASH_R_BASE + 0x00000038); |
mbed_official | 76:aeb1df146756 | 122 | /*!< Set OPAMP_LPOTR register to reset value */ |
mbed_official | 76:aeb1df146756 | 123 | OPAMP->LPOTR = (uint32_t)(* (uint32_t*)FLASH_R_BASE + 0x0000003C); |
mbed_official | 76:aeb1df146756 | 124 | } |
mbed_official | 76:aeb1df146756 | 125 | |
mbed_official | 76:aeb1df146756 | 126 | /** |
mbed_official | 76:aeb1df146756 | 127 | * @brief Close or Open the OPAMP switches. |
mbed_official | 76:aeb1df146756 | 128 | * @param OPAMP_OPAMPxSwitchy: selects the OPAMPx switch. |
mbed_official | 76:aeb1df146756 | 129 | * This parameter can be any combinations of the following values: |
mbed_official | 76:aeb1df146756 | 130 | * @arg OPAMP_OPAMP1Switch3: used to connect internally OPAMP1 output to |
mbed_official | 76:aeb1df146756 | 131 | * OPAMP1 negative input (internal follower) |
mbed_official | 76:aeb1df146756 | 132 | * @arg OPAMP_OPAMP1Switch4: used to connect PA2 to OPAMP1 negative input |
mbed_official | 76:aeb1df146756 | 133 | * @arg OPAMP_OPAMP1Switch5: used to connect PA1 to OPAMP1 positive input |
mbed_official | 76:aeb1df146756 | 134 | * @arg OPAMP_OPAMP1Switch6: used to connect DAC_OUT1 to OPAMP1 positive input |
mbed_official | 76:aeb1df146756 | 135 | * @arg OPAMP_OPAMP1SwitchANA: used to meet 1 nA input leakage |
mbed_official | 76:aeb1df146756 | 136 | * @arg OPAMP_OPAMP2Switch3: used to connect internally OPAMP2 output to |
mbed_official | 76:aeb1df146756 | 137 | * OPAMP2 negative input (internal follower) |
mbed_official | 76:aeb1df146756 | 138 | * @arg OPAMP_OPAMP2Switch4: used to connect PA7 to OPAMP2 negative input |
mbed_official | 76:aeb1df146756 | 139 | * @arg OPAMP_OPAMP2Switch5: used to connect PA6 to OPAMP2 positive input |
mbed_official | 76:aeb1df146756 | 140 | * @arg OPAMP_OPAMP2Switch6: used to connect DAC_OUT1 to OPAMP2 positive input |
mbed_official | 76:aeb1df146756 | 141 | * @arg OPAMP_OPAMP2Switch7: used to connect DAC_OUT2 to OPAMP2 positive input |
mbed_official | 76:aeb1df146756 | 142 | * @arg OPAMP_OPAMP2SwitchANA: used to meet 1 nA input leakage |
mbed_official | 76:aeb1df146756 | 143 | * @arg OPAMP_OPAMP3Switch3: used to connect internally OPAMP3 output to |
mbed_official | 76:aeb1df146756 | 144 | * OPAMP3 negative input (internal follower) |
mbed_official | 76:aeb1df146756 | 145 | * @arg OPAMP_OPAMP3Switch4: used to connect PC2 to OPAMP3 negative input |
mbed_official | 76:aeb1df146756 | 146 | * @arg OPAMP_OPAMP3Switch5: used to connect PC1 to OPAMP3 positive input |
mbed_official | 76:aeb1df146756 | 147 | * @arg OPAMP_OPAMP3Switch6: used to connect DAC_OUT1 to OPAMP3 positive input |
mbed_official | 76:aeb1df146756 | 148 | * @arg OPAMP_OPAMP3SwitchANA: used to meet 1 nA input leakage on negative input |
mbed_official | 76:aeb1df146756 | 149 | * |
mbed_official | 76:aeb1df146756 | 150 | * @param NewState: New state of the OPAMP switch. |
mbed_official | 76:aeb1df146756 | 151 | * This parameter can be: |
mbed_official | 76:aeb1df146756 | 152 | * ENABLE to close the OPAMP switch |
mbed_official | 76:aeb1df146756 | 153 | * or DISABLE to open the OPAMP switch |
mbed_official | 76:aeb1df146756 | 154 | * @note OPAMP_OPAMP2Switch6 and OPAMP_OPAMP2Switch7 mustn't be closed together. |
mbed_official | 76:aeb1df146756 | 155 | * @retval None |
mbed_official | 76:aeb1df146756 | 156 | */ |
mbed_official | 76:aeb1df146756 | 157 | void OPAMP_SwitchCmd(uint32_t OPAMP_OPAMPxSwitchy, FunctionalState NewState) |
mbed_official | 76:aeb1df146756 | 158 | { |
mbed_official | 76:aeb1df146756 | 159 | /* Check the parameter */ |
mbed_official | 76:aeb1df146756 | 160 | assert_param(IS_OPAMP_SWITCH(OPAMP_OPAMPxSwitchy)); |
mbed_official | 76:aeb1df146756 | 161 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 76:aeb1df146756 | 162 | |
mbed_official | 76:aeb1df146756 | 163 | if (NewState != DISABLE) |
mbed_official | 76:aeb1df146756 | 164 | { |
mbed_official | 76:aeb1df146756 | 165 | /* Close the selected switches */ |
mbed_official | 76:aeb1df146756 | 166 | OPAMP->CSR |= (uint32_t) OPAMP_OPAMPxSwitchy; |
mbed_official | 76:aeb1df146756 | 167 | } |
mbed_official | 76:aeb1df146756 | 168 | else |
mbed_official | 76:aeb1df146756 | 169 | { |
mbed_official | 76:aeb1df146756 | 170 | /* Open the selected switches */ |
mbed_official | 76:aeb1df146756 | 171 | OPAMP->CSR &= (~(uint32_t)OPAMP_OPAMPxSwitchy); |
mbed_official | 76:aeb1df146756 | 172 | } |
mbed_official | 76:aeb1df146756 | 173 | } |
mbed_official | 76:aeb1df146756 | 174 | |
mbed_official | 76:aeb1df146756 | 175 | /** |
mbed_official | 76:aeb1df146756 | 176 | * @brief Enable or disable the OPAMP peripheral. |
mbed_official | 76:aeb1df146756 | 177 | * @param OPAMP_Selection: the selected OPAMP. |
mbed_official | 76:aeb1df146756 | 178 | * This parameter can be one of the following values: |
mbed_official | 76:aeb1df146756 | 179 | * @arg OPAMP_Selection_OPAMP1: OPAMP1 is selected |
mbed_official | 76:aeb1df146756 | 180 | * @arg OPAMP_Selection_OPAMP2: OPAMP2 is selected |
mbed_official | 76:aeb1df146756 | 181 | * @arg OPAMP_Selection_OPAMP3: OPAMP3 is selected |
mbed_official | 76:aeb1df146756 | 182 | * @param NewState: new state of the selected OPAMP peripheral. |
mbed_official | 76:aeb1df146756 | 183 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 76:aeb1df146756 | 184 | * @retval None |
mbed_official | 76:aeb1df146756 | 185 | */ |
mbed_official | 76:aeb1df146756 | 186 | void OPAMP_Cmd(uint32_t OPAMP_Selection, FunctionalState NewState) |
mbed_official | 76:aeb1df146756 | 187 | { |
mbed_official | 76:aeb1df146756 | 188 | /* Check the parameter */ |
mbed_official | 76:aeb1df146756 | 189 | assert_param(IS_OPAMP_ALL_PERIPH(OPAMP_Selection)); |
mbed_official | 76:aeb1df146756 | 190 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 76:aeb1df146756 | 191 | |
mbed_official | 76:aeb1df146756 | 192 | if (NewState != DISABLE) |
mbed_official | 76:aeb1df146756 | 193 | { |
mbed_official | 76:aeb1df146756 | 194 | /* Enable the selected OPAMP */ |
mbed_official | 76:aeb1df146756 | 195 | OPAMP->CSR &= (~(uint32_t) OPAMP_Selection); |
mbed_official | 76:aeb1df146756 | 196 | } |
mbed_official | 76:aeb1df146756 | 197 | else |
mbed_official | 76:aeb1df146756 | 198 | { |
mbed_official | 76:aeb1df146756 | 199 | /* Disable the selected OPAMP */ |
mbed_official | 76:aeb1df146756 | 200 | OPAMP->CSR |= (uint32_t) OPAMP_Selection; |
mbed_official | 76:aeb1df146756 | 201 | } |
mbed_official | 76:aeb1df146756 | 202 | } |
mbed_official | 76:aeb1df146756 | 203 | |
mbed_official | 76:aeb1df146756 | 204 | /** |
mbed_official | 76:aeb1df146756 | 205 | * @brief Enable or disable the low power mode for OPAMP peripheral. |
mbed_official | 76:aeb1df146756 | 206 | * @param OPAMP_Selection: the selected OPAMP. |
mbed_official | 76:aeb1df146756 | 207 | * This parameter can be one of the following values: |
mbed_official | 76:aeb1df146756 | 208 | * @arg OPAMP_Selection_OPAMP1: OPAMP1 selected |
mbed_official | 76:aeb1df146756 | 209 | * @arg OPAMP_Selection_OPAMP2: OPAMP2 selected |
mbed_official | 76:aeb1df146756 | 210 | * @arg OPAMP_Selection_OPAMP3: OPAMP3 selected |
mbed_official | 76:aeb1df146756 | 211 | * @param NewState: new low power state of the selected OPAMP peripheral. |
mbed_official | 76:aeb1df146756 | 212 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 76:aeb1df146756 | 213 | * @retval None |
mbed_official | 76:aeb1df146756 | 214 | */ |
mbed_official | 76:aeb1df146756 | 215 | void OPAMP_LowPowerCmd(uint32_t OPAMP_Selection, FunctionalState NewState) |
mbed_official | 76:aeb1df146756 | 216 | { |
mbed_official | 76:aeb1df146756 | 217 | /* Check the parameter */ |
mbed_official | 76:aeb1df146756 | 218 | assert_param(IS_OPAMP_ALL_PERIPH(OPAMP_Selection)); |
mbed_official | 76:aeb1df146756 | 219 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 76:aeb1df146756 | 220 | |
mbed_official | 76:aeb1df146756 | 221 | if (NewState != DISABLE) |
mbed_official | 76:aeb1df146756 | 222 | { |
mbed_official | 76:aeb1df146756 | 223 | /* Set the selected OPAMP in low power mode */ |
mbed_official | 76:aeb1df146756 | 224 | OPAMP->CSR |= (uint32_t) (OPAMP_Selection << 7); |
mbed_official | 76:aeb1df146756 | 225 | } |
mbed_official | 76:aeb1df146756 | 226 | else |
mbed_official | 76:aeb1df146756 | 227 | { |
mbed_official | 76:aeb1df146756 | 228 | /* Disable the low power mode for the selected OPAMP */ |
mbed_official | 76:aeb1df146756 | 229 | OPAMP->CSR &= (~(uint32_t) (OPAMP_Selection << 7)); |
mbed_official | 76:aeb1df146756 | 230 | } |
mbed_official | 76:aeb1df146756 | 231 | } |
mbed_official | 76:aeb1df146756 | 232 | |
mbed_official | 76:aeb1df146756 | 233 | /** |
mbed_official | 76:aeb1df146756 | 234 | * @brief Select the OPAMP power range. |
mbed_official | 76:aeb1df146756 | 235 | * @note The OPAMP power range selection must be performed while OPAMPs are powered down. |
mbed_official | 76:aeb1df146756 | 236 | * @param OPAMP_Range: the selected OPAMP power range. |
mbed_official | 76:aeb1df146756 | 237 | * This parameter can be one of the following values: |
mbed_official | 76:aeb1df146756 | 238 | * @arg OPAMP_PowerRange_Low: Low power range is selected (VDDA is lower than 2.4V). |
mbed_official | 76:aeb1df146756 | 239 | * @arg OPAMP_PowerRange_High: High power range is selected (VDDA is higher than 2.4V). |
mbed_official | 76:aeb1df146756 | 240 | * @retval None |
mbed_official | 76:aeb1df146756 | 241 | */ |
mbed_official | 76:aeb1df146756 | 242 | void OPAMP_PowerRangeSelect(uint32_t OPAMP_PowerRange) |
mbed_official | 76:aeb1df146756 | 243 | { |
mbed_official | 76:aeb1df146756 | 244 | /* Check the parameter */ |
mbed_official | 76:aeb1df146756 | 245 | assert_param(IS_OPAMP_RANGE(OPAMP_PowerRange)); |
mbed_official | 76:aeb1df146756 | 246 | |
mbed_official | 76:aeb1df146756 | 247 | /* Reset the OPAMP range bit */ |
mbed_official | 76:aeb1df146756 | 248 | OPAMP->CSR &= (~(uint32_t) (OPAMP_CSR_AOP_RANGE)); |
mbed_official | 76:aeb1df146756 | 249 | |
mbed_official | 76:aeb1df146756 | 250 | /* Select the OPAMP power range */ |
mbed_official | 76:aeb1df146756 | 251 | OPAMP->CSR |= OPAMP_PowerRange; |
mbed_official | 76:aeb1df146756 | 252 | } |
mbed_official | 76:aeb1df146756 | 253 | |
mbed_official | 76:aeb1df146756 | 254 | /** |
mbed_official | 76:aeb1df146756 | 255 | * @} |
mbed_official | 76:aeb1df146756 | 256 | */ |
mbed_official | 76:aeb1df146756 | 257 | |
mbed_official | 76:aeb1df146756 | 258 | /** @defgroup OPAMP_Group2 Calibration functions |
mbed_official | 76:aeb1df146756 | 259 | * @brief Calibration functions |
mbed_official | 76:aeb1df146756 | 260 | * |
mbed_official | 76:aeb1df146756 | 261 | @verbatim |
mbed_official | 76:aeb1df146756 | 262 | =============================================================================== |
mbed_official | 76:aeb1df146756 | 263 | ##### Calibration functions ##### |
mbed_official | 76:aeb1df146756 | 264 | =============================================================================== |
mbed_official | 76:aeb1df146756 | 265 | |
mbed_official | 76:aeb1df146756 | 266 | @endverbatim |
mbed_official | 76:aeb1df146756 | 267 | * @{ |
mbed_official | 76:aeb1df146756 | 268 | */ |
mbed_official | 76:aeb1df146756 | 269 | |
mbed_official | 76:aeb1df146756 | 270 | /** |
mbed_official | 76:aeb1df146756 | 271 | * @brief Select the trimming mode. |
mbed_official | 76:aeb1df146756 | 272 | * @param OffsetTrimming: the selected offset trimming mode. |
mbed_official | 76:aeb1df146756 | 273 | * This parameter can be one of the following values: |
mbed_official | 76:aeb1df146756 | 274 | * @arg OffsetTrimming_Factory: factory trimming values are used for offset |
mbed_official | 76:aeb1df146756 | 275 | * calibration. |
mbed_official | 76:aeb1df146756 | 276 | * @arg OffsetTrimming_User: user trimming values are used for offset |
mbed_official | 76:aeb1df146756 | 277 | * calibration. |
mbed_official | 76:aeb1df146756 | 278 | * @note When OffsetTrimming_User is selected, use OPAMP_OffsetTrimConfig() |
mbed_official | 76:aeb1df146756 | 279 | * function or OPAMP_OffsetTrimLowPowerConfig() function to adjust |
mbed_official | 76:aeb1df146756 | 280 | * trimming value. |
mbed_official | 76:aeb1df146756 | 281 | * @retval None |
mbed_official | 76:aeb1df146756 | 282 | */ |
mbed_official | 76:aeb1df146756 | 283 | void OPAMP_OffsetTrimmingModeSelect(uint32_t OPAMP_Trimming) |
mbed_official | 76:aeb1df146756 | 284 | { |
mbed_official | 76:aeb1df146756 | 285 | /* Check the parameter */ |
mbed_official | 76:aeb1df146756 | 286 | assert_param(IS_OPAMP_TRIMMING(OPAMP_Trimming)); |
mbed_official | 76:aeb1df146756 | 287 | |
mbed_official | 76:aeb1df146756 | 288 | /* Reset the OPAMP_OTR range bit */ |
mbed_official | 80:66393a7b209d | 289 | OPAMP->OTR &= (~(uint32_t) (OPAMP_OTR_OT_USER)); |
mbed_official | 76:aeb1df146756 | 290 | |
mbed_official | 76:aeb1df146756 | 291 | /* Select the OPAMP offset trimming */ |
mbed_official | 80:66393a7b209d | 292 | OPAMP->OTR |= OPAMP_Trimming; |
mbed_official | 76:aeb1df146756 | 293 | |
mbed_official | 76:aeb1df146756 | 294 | } |
mbed_official | 76:aeb1df146756 | 295 | |
mbed_official | 76:aeb1df146756 | 296 | /** |
mbed_official | 76:aeb1df146756 | 297 | * @brief Configure the trimming value of OPAMPs in normal mode. |
mbed_official | 76:aeb1df146756 | 298 | * @param OPAMP_Selection: the selected OPAMP. |
mbed_official | 76:aeb1df146756 | 299 | * This parameter can be one of the following values: |
mbed_official | 76:aeb1df146756 | 300 | * @arg OPAMP_Selection_OPAMP1: OPAMP1 is selected to configure the trimming value. |
mbed_official | 76:aeb1df146756 | 301 | * @arg OPAMP_Selection_OPAMP2: OPAMP2 is selected to configure the trimming value. |
mbed_official | 76:aeb1df146756 | 302 | * @arg OPAMP_Selection_OPAMP3: OPAMP3 is selected to configure the trimming value. |
mbed_official | 76:aeb1df146756 | 303 | * @param OPAMP_Input: the selected OPAMP input. |
mbed_official | 76:aeb1df146756 | 304 | * This parameter can be one of the following values: |
mbed_official | 76:aeb1df146756 | 305 | * @arg OPAMP_Input_NMOS: NMOS input is selected to configure the trimming value. |
mbed_official | 76:aeb1df146756 | 306 | * @arg OPAMP_Input_PMOS: PMOS input is selected to configure the trimming value. |
mbed_official | 76:aeb1df146756 | 307 | * @param OPAMP_TrimValue: the trimming value. This parameter can be any value lower |
mbed_official | 76:aeb1df146756 | 308 | * or equal to 0x0000001F. |
mbed_official | 76:aeb1df146756 | 309 | * @retval None |
mbed_official | 76:aeb1df146756 | 310 | */ |
mbed_official | 76:aeb1df146756 | 311 | void OPAMP_OffsetTrimConfig(uint32_t OPAMP_Selection, uint32_t OPAMP_Input, uint32_t OPAMP_TrimValue) |
mbed_official | 76:aeb1df146756 | 312 | { |
mbed_official | 76:aeb1df146756 | 313 | uint32_t tmpreg = 0; |
mbed_official | 76:aeb1df146756 | 314 | |
mbed_official | 76:aeb1df146756 | 315 | /* Check the parameter */ |
mbed_official | 76:aeb1df146756 | 316 | assert_param(IS_OPAMP_ALL_PERIPH(OPAMP_Selection)); |
mbed_official | 76:aeb1df146756 | 317 | assert_param(IS_OPAMP_INPUT(OPAMP_Input)); |
mbed_official | 76:aeb1df146756 | 318 | assert_param(IS_OPAMP_TRIMMINGVALUE(OPAMP_TrimValue)); |
mbed_official | 76:aeb1df146756 | 319 | |
mbed_official | 76:aeb1df146756 | 320 | /* Get the OPAMP_OTR value */ |
mbed_official | 76:aeb1df146756 | 321 | tmpreg = OPAMP->OTR; |
mbed_official | 76:aeb1df146756 | 322 | |
mbed_official | 76:aeb1df146756 | 323 | if(OPAMP_Selection == OPAMP_Selection_OPAMP1) |
mbed_official | 76:aeb1df146756 | 324 | { |
mbed_official | 76:aeb1df146756 | 325 | /* Reset the OPAMP inputs selection */ |
mbed_official | 76:aeb1df146756 | 326 | tmpreg &= (uint32_t)~(OPAMP_CSR_OPA1CAL_L | OPAMP_CSR_OPA1CAL_H); |
mbed_official | 76:aeb1df146756 | 327 | /* Select the OPAMP input */ |
mbed_official | 76:aeb1df146756 | 328 | tmpreg |= OPAMP_Input; |
mbed_official | 76:aeb1df146756 | 329 | |
mbed_official | 76:aeb1df146756 | 330 | if(OPAMP_Input == OPAMP_Input_PMOS) |
mbed_official | 76:aeb1df146756 | 331 | { |
mbed_official | 76:aeb1df146756 | 332 | /* Reset the trimming value corresponding to OPAMP1 PMOS input */ |
mbed_official | 76:aeb1df146756 | 333 | tmpreg &= (0xFFFFFFE0); |
mbed_official | 76:aeb1df146756 | 334 | /* Set the new trimming value corresponding to OPAMP1 PMOS input */ |
mbed_official | 76:aeb1df146756 | 335 | tmpreg |= (OPAMP_TrimValue); |
mbed_official | 76:aeb1df146756 | 336 | } |
mbed_official | 76:aeb1df146756 | 337 | else |
mbed_official | 76:aeb1df146756 | 338 | { |
mbed_official | 76:aeb1df146756 | 339 | /* Reset the trimming value corresponding to OPAMP1 NMOS input */ |
mbed_official | 76:aeb1df146756 | 340 | tmpreg &= (0xFFFFFC1F); |
mbed_official | 76:aeb1df146756 | 341 | /* Set the new trimming value corresponding to OPAMP1 NMOS input */ |
mbed_official | 76:aeb1df146756 | 342 | tmpreg |= (OPAMP_TrimValue<<5); |
mbed_official | 76:aeb1df146756 | 343 | } |
mbed_official | 76:aeb1df146756 | 344 | } |
mbed_official | 76:aeb1df146756 | 345 | else if (OPAMP_Selection == OPAMP_Selection_OPAMP2) |
mbed_official | 76:aeb1df146756 | 346 | { |
mbed_official | 76:aeb1df146756 | 347 | /* Reset the OPAMP inputs selection */ |
mbed_official | 76:aeb1df146756 | 348 | tmpreg &= (uint32_t)~(OPAMP_CSR_OPA2CAL_L | OPAMP_CSR_OPA2CAL_H); |
mbed_official | 76:aeb1df146756 | 349 | /* Select the OPAMP input */ |
mbed_official | 76:aeb1df146756 | 350 | tmpreg |= (uint32_t)(OPAMP_Input<<8); |
mbed_official | 76:aeb1df146756 | 351 | |
mbed_official | 76:aeb1df146756 | 352 | if(OPAMP_Input == OPAMP_Input_PMOS) |
mbed_official | 76:aeb1df146756 | 353 | { |
mbed_official | 76:aeb1df146756 | 354 | /* Reset the trimming value corresponding to OPAMP2 PMOS input */ |
mbed_official | 76:aeb1df146756 | 355 | tmpreg &= (0xFFFF83FF); |
mbed_official | 76:aeb1df146756 | 356 | /* Set the new trimming value corresponding to OPAMP2 PMOS input */ |
mbed_official | 76:aeb1df146756 | 357 | tmpreg |= (OPAMP_TrimValue<<10); |
mbed_official | 76:aeb1df146756 | 358 | } |
mbed_official | 76:aeb1df146756 | 359 | else |
mbed_official | 76:aeb1df146756 | 360 | { |
mbed_official | 76:aeb1df146756 | 361 | /* Reset the trimming value corresponding to OPAMP2 NMOS input */ |
mbed_official | 76:aeb1df146756 | 362 | tmpreg &= (0xFFF07FFF); |
mbed_official | 76:aeb1df146756 | 363 | /* Set the new trimming value corresponding to OPAMP2 NMOS input */ |
mbed_official | 76:aeb1df146756 | 364 | tmpreg |= (OPAMP_TrimValue<<15); |
mbed_official | 76:aeb1df146756 | 365 | } |
mbed_official | 76:aeb1df146756 | 366 | } |
mbed_official | 76:aeb1df146756 | 367 | else |
mbed_official | 76:aeb1df146756 | 368 | { |
mbed_official | 76:aeb1df146756 | 369 | /* Reset the OPAMP inputs selection */ |
mbed_official | 76:aeb1df146756 | 370 | tmpreg &= (uint32_t)~(OPAMP_CSR_OPA3CAL_L | OPAMP_CSR_OPA3CAL_H); |
mbed_official | 76:aeb1df146756 | 371 | /* Select the OPAMP input */ |
mbed_official | 76:aeb1df146756 | 372 | tmpreg |= (uint32_t)(OPAMP_Input<<16); |
mbed_official | 76:aeb1df146756 | 373 | |
mbed_official | 76:aeb1df146756 | 374 | if(OPAMP_Input == OPAMP_Input_PMOS) |
mbed_official | 76:aeb1df146756 | 375 | { |
mbed_official | 76:aeb1df146756 | 376 | /* Reset the trimming value corresponding to OPAMP3 PMOS input */ |
mbed_official | 76:aeb1df146756 | 377 | tmpreg &= (0xFE0FFFFF); |
mbed_official | 76:aeb1df146756 | 378 | /* Set the new trimming value corresponding to OPAMP3 PMOS input */ |
mbed_official | 76:aeb1df146756 | 379 | tmpreg |= (OPAMP_TrimValue<<20); |
mbed_official | 76:aeb1df146756 | 380 | } |
mbed_official | 76:aeb1df146756 | 381 | else |
mbed_official | 76:aeb1df146756 | 382 | { |
mbed_official | 76:aeb1df146756 | 383 | /* Reset the trimming value corresponding to OPAMP3 NMOS input */ |
mbed_official | 76:aeb1df146756 | 384 | tmpreg &= (0xC1FFFFFF); |
mbed_official | 76:aeb1df146756 | 385 | /* Set the new trimming value corresponding to OPAMP3 NMOS input */ |
mbed_official | 76:aeb1df146756 | 386 | tmpreg |= (OPAMP_TrimValue<<25); |
mbed_official | 76:aeb1df146756 | 387 | } |
mbed_official | 76:aeb1df146756 | 388 | } |
mbed_official | 76:aeb1df146756 | 389 | |
mbed_official | 76:aeb1df146756 | 390 | /* Set the OPAMP_OTR register */ |
mbed_official | 76:aeb1df146756 | 391 | OPAMP->OTR = tmpreg; |
mbed_official | 76:aeb1df146756 | 392 | } |
mbed_official | 76:aeb1df146756 | 393 | |
mbed_official | 76:aeb1df146756 | 394 | /** |
mbed_official | 76:aeb1df146756 | 395 | * @brief Configure the trimming value of OPAMPs in low power mode. |
mbed_official | 76:aeb1df146756 | 396 | * @param OPAMP_Selection: the selected OPAMP. |
mbed_official | 76:aeb1df146756 | 397 | * This parameter can be one of the following values: |
mbed_official | 76:aeb1df146756 | 398 | * @arg OPAMP_Selection_OPAMP1: OPAMP1 is selected to configure the trimming value. |
mbed_official | 76:aeb1df146756 | 399 | * @arg OPAMP_Selection_OPAMP2: OPAMP2 is selected to configure the trimming value. |
mbed_official | 76:aeb1df146756 | 400 | * @arg OPAMP_Selection_OPAMP3: OPAMP3 is selected to configure the trimming value. |
mbed_official | 76:aeb1df146756 | 401 | * @param OPAMP_Input: the selected OPAMP input. |
mbed_official | 76:aeb1df146756 | 402 | * This parameter can be one of the following values: |
mbed_official | 76:aeb1df146756 | 403 | * @arg OPAMP_Input_NMOS: NMOS input is selected to configure the trimming value. |
mbed_official | 76:aeb1df146756 | 404 | * @arg OPAMP_Input_PMOS: PMOS input is selected to configure the trimming value. |
mbed_official | 76:aeb1df146756 | 405 | * @param OPAMP_TrimValue: the trimming value. |
mbed_official | 76:aeb1df146756 | 406 | * This parameter can be any value lower or equal to 0x0000001F. |
mbed_official | 76:aeb1df146756 | 407 | * @retval None |
mbed_official | 76:aeb1df146756 | 408 | */ |
mbed_official | 76:aeb1df146756 | 409 | void OPAMP_OffsetTrimLowPowerConfig(uint32_t OPAMP_Selection, uint32_t OPAMP_Input, uint32_t OPAMP_TrimValue) |
mbed_official | 76:aeb1df146756 | 410 | { |
mbed_official | 76:aeb1df146756 | 411 | uint32_t tmpreg = 0; |
mbed_official | 76:aeb1df146756 | 412 | |
mbed_official | 76:aeb1df146756 | 413 | /* Check the parameter */ |
mbed_official | 76:aeb1df146756 | 414 | assert_param(IS_OPAMP_ALL_PERIPH(OPAMP_Selection)); |
mbed_official | 76:aeb1df146756 | 415 | assert_param(IS_OPAMP_INPUT(OPAMP_Input)); |
mbed_official | 76:aeb1df146756 | 416 | assert_param(IS_OPAMP_TRIMMINGVALUE(OPAMP_TrimValue)); |
mbed_official | 76:aeb1df146756 | 417 | |
mbed_official | 76:aeb1df146756 | 418 | /* Get the OPAMP_LPOTR value */ |
mbed_official | 76:aeb1df146756 | 419 | tmpreg = OPAMP->LPOTR; |
mbed_official | 76:aeb1df146756 | 420 | |
mbed_official | 76:aeb1df146756 | 421 | if(OPAMP_Selection == OPAMP_Selection_OPAMP1) |
mbed_official | 76:aeb1df146756 | 422 | { |
mbed_official | 76:aeb1df146756 | 423 | /* Reset the OPAMP inputs selection */ |
mbed_official | 76:aeb1df146756 | 424 | tmpreg &= (uint32_t)~(OPAMP_CSR_OPA1CAL_L | OPAMP_CSR_OPA1CAL_H); |
mbed_official | 76:aeb1df146756 | 425 | /* Select the OPAMP input */ |
mbed_official | 76:aeb1df146756 | 426 | tmpreg |= OPAMP_Input; |
mbed_official | 76:aeb1df146756 | 427 | |
mbed_official | 76:aeb1df146756 | 428 | if(OPAMP_Input == OPAMP_Input_PMOS) |
mbed_official | 76:aeb1df146756 | 429 | { |
mbed_official | 76:aeb1df146756 | 430 | /* Reset the trimming value corresponding to OPAMP1 PMOS input */ |
mbed_official | 76:aeb1df146756 | 431 | tmpreg &= (0xFFFFFFE0); |
mbed_official | 76:aeb1df146756 | 432 | /* Set the new trimming value corresponding to OPAMP1 PMOS input */ |
mbed_official | 76:aeb1df146756 | 433 | tmpreg |= (OPAMP_TrimValue); |
mbed_official | 76:aeb1df146756 | 434 | } |
mbed_official | 76:aeb1df146756 | 435 | else |
mbed_official | 76:aeb1df146756 | 436 | { |
mbed_official | 76:aeb1df146756 | 437 | /* Reset the trimming value corresponding to OPAMP1 NMOS input */ |
mbed_official | 76:aeb1df146756 | 438 | tmpreg &= (0xFFFFFC1F); |
mbed_official | 76:aeb1df146756 | 439 | /* Set the new trimming value corresponding to OPAMP1 NMOS input */ |
mbed_official | 76:aeb1df146756 | 440 | tmpreg |= (OPAMP_TrimValue<<5); |
mbed_official | 76:aeb1df146756 | 441 | } |
mbed_official | 76:aeb1df146756 | 442 | } |
mbed_official | 76:aeb1df146756 | 443 | else if (OPAMP_Selection == OPAMP_Selection_OPAMP2) |
mbed_official | 76:aeb1df146756 | 444 | { |
mbed_official | 76:aeb1df146756 | 445 | /* Reset the OPAMP inputs selection */ |
mbed_official | 76:aeb1df146756 | 446 | tmpreg &= (uint32_t)~(OPAMP_CSR_OPA2CAL_L | OPAMP_CSR_OPA2CAL_H); |
mbed_official | 76:aeb1df146756 | 447 | /* Select the OPAMP input */ |
mbed_official | 76:aeb1df146756 | 448 | tmpreg |= (uint32_t)(OPAMP_Input<<8); |
mbed_official | 76:aeb1df146756 | 449 | |
mbed_official | 76:aeb1df146756 | 450 | if(OPAMP_Input == OPAMP_Input_PMOS) |
mbed_official | 76:aeb1df146756 | 451 | { |
mbed_official | 76:aeb1df146756 | 452 | /* Reset the trimming value corresponding to OPAMP2 PMOS input */ |
mbed_official | 76:aeb1df146756 | 453 | tmpreg &= (0xFFFF83FF); |
mbed_official | 76:aeb1df146756 | 454 | /* Set the new trimming value corresponding to OPAMP2 PMOS input */ |
mbed_official | 76:aeb1df146756 | 455 | tmpreg |= (OPAMP_TrimValue<<10); |
mbed_official | 76:aeb1df146756 | 456 | } |
mbed_official | 76:aeb1df146756 | 457 | else |
mbed_official | 76:aeb1df146756 | 458 | { |
mbed_official | 76:aeb1df146756 | 459 | /* Reset the trimming value corresponding to OPAMP2 NMOS input */ |
mbed_official | 76:aeb1df146756 | 460 | tmpreg &= (0xFFF07FFF); |
mbed_official | 76:aeb1df146756 | 461 | /* Set the new trimming value corresponding to OPAMP2 NMOS input */ |
mbed_official | 76:aeb1df146756 | 462 | tmpreg |= (OPAMP_TrimValue<<15); |
mbed_official | 76:aeb1df146756 | 463 | } |
mbed_official | 76:aeb1df146756 | 464 | } |
mbed_official | 76:aeb1df146756 | 465 | else |
mbed_official | 76:aeb1df146756 | 466 | { |
mbed_official | 76:aeb1df146756 | 467 | /* Reset the OPAMP inputs selection */ |
mbed_official | 76:aeb1df146756 | 468 | tmpreg &= (uint32_t)~(OPAMP_CSR_OPA3CAL_L | OPAMP_CSR_OPA3CAL_H); |
mbed_official | 76:aeb1df146756 | 469 | /* Select the OPAMP input */ |
mbed_official | 76:aeb1df146756 | 470 | tmpreg |= (uint32_t)(OPAMP_Input<<16); |
mbed_official | 76:aeb1df146756 | 471 | |
mbed_official | 76:aeb1df146756 | 472 | if(OPAMP_Input == OPAMP_Input_PMOS) |
mbed_official | 76:aeb1df146756 | 473 | { |
mbed_official | 76:aeb1df146756 | 474 | /* Reset the trimming value corresponding to OPAMP3 PMOS input */ |
mbed_official | 76:aeb1df146756 | 475 | tmpreg &= (0xFE0FFFFF); |
mbed_official | 76:aeb1df146756 | 476 | /* Set the new trimming value corresponding to OPAMP3 PMOS input */ |
mbed_official | 76:aeb1df146756 | 477 | tmpreg |= (OPAMP_TrimValue<<20); |
mbed_official | 76:aeb1df146756 | 478 | } |
mbed_official | 76:aeb1df146756 | 479 | else |
mbed_official | 76:aeb1df146756 | 480 | { |
mbed_official | 76:aeb1df146756 | 481 | /* Reset the trimming value corresponding to OPAMP3 NMOS input */ |
mbed_official | 76:aeb1df146756 | 482 | tmpreg &= (0xC1FFFFFF); |
mbed_official | 76:aeb1df146756 | 483 | /* Set the new trimming value corresponding to OPAMP3 NMOS input */ |
mbed_official | 76:aeb1df146756 | 484 | tmpreg |= (OPAMP_TrimValue<<25); |
mbed_official | 76:aeb1df146756 | 485 | } |
mbed_official | 76:aeb1df146756 | 486 | } |
mbed_official | 76:aeb1df146756 | 487 | |
mbed_official | 76:aeb1df146756 | 488 | /* Set the OPAMP_LPOTR register */ |
mbed_official | 76:aeb1df146756 | 489 | OPAMP->LPOTR = tmpreg; |
mbed_official | 76:aeb1df146756 | 490 | } |
mbed_official | 76:aeb1df146756 | 491 | |
mbed_official | 76:aeb1df146756 | 492 | /** |
mbed_official | 76:aeb1df146756 | 493 | * @brief Checks whether the specified OPAMP calibration flag is set or not. |
mbed_official | 76:aeb1df146756 | 494 | * @note User should wait until calibration flag change the value when changing |
mbed_official | 76:aeb1df146756 | 495 | * the trimming value. |
mbed_official | 76:aeb1df146756 | 496 | * @param OPAMP_Selection: the selected OPAMP. |
mbed_official | 76:aeb1df146756 | 497 | * This parameter can be one of the following values: |
mbed_official | 76:aeb1df146756 | 498 | * @arg OPAMP_Selection_OPAMP1: OPAMP1 is selected. |
mbed_official | 76:aeb1df146756 | 499 | * @arg OPAMP_Selection_OPAMP2: OPAMP2 is selected. |
mbed_official | 76:aeb1df146756 | 500 | * @arg OPAMP_Selection_OPAMP3: OPAMP3 is selected. |
mbed_official | 76:aeb1df146756 | 501 | * @retval The new state of the OPAMP calibration flag (SET or RESET). |
mbed_official | 76:aeb1df146756 | 502 | */ |
mbed_official | 76:aeb1df146756 | 503 | FlagStatus OPAMP_GetFlagStatus(uint32_t OPAMP_Selection) |
mbed_official | 76:aeb1df146756 | 504 | { |
mbed_official | 76:aeb1df146756 | 505 | FlagStatus bitstatus = RESET; |
mbed_official | 76:aeb1df146756 | 506 | uint32_t tmpreg = 0; |
mbed_official | 76:aeb1df146756 | 507 | |
mbed_official | 76:aeb1df146756 | 508 | /* Check the parameter */ |
mbed_official | 76:aeb1df146756 | 509 | assert_param(IS_OPAMP_ALL_PERIPH(OPAMP_Selection)); |
mbed_official | 76:aeb1df146756 | 510 | |
mbed_official | 76:aeb1df146756 | 511 | /* Get the CSR register value */ |
mbed_official | 76:aeb1df146756 | 512 | tmpreg = OPAMP->CSR; |
mbed_official | 76:aeb1df146756 | 513 | |
mbed_official | 76:aeb1df146756 | 514 | /* Check if OPAMP1 is selected */ |
mbed_official | 76:aeb1df146756 | 515 | if(OPAMP_Selection == OPAMP_Selection_OPAMP1) |
mbed_official | 76:aeb1df146756 | 516 | { |
mbed_official | 76:aeb1df146756 | 517 | /* Check OPAMP1 CAL bit status */ |
mbed_official | 76:aeb1df146756 | 518 | if ((tmpreg & OPAMP_CSR_OPA1CALOUT) != (uint32_t)RESET) |
mbed_official | 76:aeb1df146756 | 519 | { |
mbed_official | 76:aeb1df146756 | 520 | bitstatus = SET; |
mbed_official | 76:aeb1df146756 | 521 | } |
mbed_official | 76:aeb1df146756 | 522 | else |
mbed_official | 76:aeb1df146756 | 523 | { |
mbed_official | 76:aeb1df146756 | 524 | bitstatus = RESET; |
mbed_official | 76:aeb1df146756 | 525 | } |
mbed_official | 76:aeb1df146756 | 526 | } |
mbed_official | 76:aeb1df146756 | 527 | /* Check if OPAMP2 is selected */ |
mbed_official | 76:aeb1df146756 | 528 | else if(OPAMP_Selection == OPAMP_Selection_OPAMP2) |
mbed_official | 76:aeb1df146756 | 529 | { |
mbed_official | 76:aeb1df146756 | 530 | /* Check OPAMP2 CAL bit status */ |
mbed_official | 76:aeb1df146756 | 531 | if ((tmpreg & OPAMP_CSR_OPA2CALOUT) != (uint32_t)RESET) |
mbed_official | 76:aeb1df146756 | 532 | { |
mbed_official | 76:aeb1df146756 | 533 | bitstatus = SET; |
mbed_official | 76:aeb1df146756 | 534 | } |
mbed_official | 76:aeb1df146756 | 535 | else |
mbed_official | 76:aeb1df146756 | 536 | { |
mbed_official | 76:aeb1df146756 | 537 | bitstatus = RESET; |
mbed_official | 76:aeb1df146756 | 538 | } |
mbed_official | 76:aeb1df146756 | 539 | } |
mbed_official | 76:aeb1df146756 | 540 | else |
mbed_official | 76:aeb1df146756 | 541 | { |
mbed_official | 76:aeb1df146756 | 542 | /* Check OPAMP3 CAL bit status */ |
mbed_official | 76:aeb1df146756 | 543 | if ((tmpreg & OPAMP_CSR_OPA3CALOUT) != (uint32_t)RESET) |
mbed_official | 76:aeb1df146756 | 544 | { |
mbed_official | 76:aeb1df146756 | 545 | bitstatus = SET; |
mbed_official | 76:aeb1df146756 | 546 | } |
mbed_official | 76:aeb1df146756 | 547 | else |
mbed_official | 76:aeb1df146756 | 548 | { |
mbed_official | 76:aeb1df146756 | 549 | bitstatus = RESET; |
mbed_official | 76:aeb1df146756 | 550 | } |
mbed_official | 76:aeb1df146756 | 551 | } |
mbed_official | 76:aeb1df146756 | 552 | return bitstatus; |
mbed_official | 76:aeb1df146756 | 553 | } |
mbed_official | 76:aeb1df146756 | 554 | |
mbed_official | 76:aeb1df146756 | 555 | /** |
mbed_official | 76:aeb1df146756 | 556 | * @} |
mbed_official | 76:aeb1df146756 | 557 | */ |
mbed_official | 76:aeb1df146756 | 558 | |
mbed_official | 76:aeb1df146756 | 559 | /** |
mbed_official | 76:aeb1df146756 | 560 | * @} |
mbed_official | 76:aeb1df146756 | 561 | */ |
mbed_official | 76:aeb1df146756 | 562 | |
mbed_official | 76:aeb1df146756 | 563 | /** |
mbed_official | 76:aeb1df146756 | 564 | * @} |
mbed_official | 76:aeb1df146756 | 565 | */ |
mbed_official | 76:aeb1df146756 | 566 | |
mbed_official | 76:aeb1df146756 | 567 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |