Hal Drivers for L4
Dependents: BSP OneHopeOnePrayer FINAL_AUDIO_RECORD AudioDemo
Fork of STM32L4xx_HAL_Driver by
Inc/stm32l4xx_ll_opamp.h@2:7aef7655b0a8, 2015-11-25 (annotated)
- Committer:
- EricLew
- Date:
- Wed Nov 25 17:30:43 2015 +0000
- Revision:
- 2:7aef7655b0a8
- Parent:
- 0:80ee8f3b695e
commit;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
EricLew | 0:80ee8f3b695e | 1 | /** |
EricLew | 0:80ee8f3b695e | 2 | ****************************************************************************** |
EricLew | 0:80ee8f3b695e | 3 | * @file stm32l4xx_ll_opamp.h |
EricLew | 0:80ee8f3b695e | 4 | * @author MCD Application Team |
EricLew | 0:80ee8f3b695e | 5 | * @version V1.1.0 |
EricLew | 0:80ee8f3b695e | 6 | * @date 16-September-2015 |
EricLew | 0:80ee8f3b695e | 7 | * @brief Header file of OPAMP LL module. |
EricLew | 0:80ee8f3b695e | 8 | ****************************************************************************** |
EricLew | 0:80ee8f3b695e | 9 | * @attention |
EricLew | 0:80ee8f3b695e | 10 | * |
EricLew | 0:80ee8f3b695e | 11 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
EricLew | 0:80ee8f3b695e | 12 | * |
EricLew | 0:80ee8f3b695e | 13 | * Redistribution and use in source and binary forms, with or without modification, |
EricLew | 0:80ee8f3b695e | 14 | * are permitted provided that the following conditions are met: |
EricLew | 0:80ee8f3b695e | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
EricLew | 0:80ee8f3b695e | 16 | * this list of conditions and the following disclaimer. |
EricLew | 0:80ee8f3b695e | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
EricLew | 0:80ee8f3b695e | 18 | * this list of conditions and the following disclaimer in the documentation |
EricLew | 0:80ee8f3b695e | 19 | * and/or other materials provided with the distribution. |
EricLew | 0:80ee8f3b695e | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
EricLew | 0:80ee8f3b695e | 21 | * may be used to endorse or promote products derived from this software |
EricLew | 0:80ee8f3b695e | 22 | * without specific prior written permission. |
EricLew | 0:80ee8f3b695e | 23 | * |
EricLew | 0:80ee8f3b695e | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
EricLew | 0:80ee8f3b695e | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
EricLew | 0:80ee8f3b695e | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
EricLew | 0:80ee8f3b695e | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
EricLew | 0:80ee8f3b695e | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
EricLew | 0:80ee8f3b695e | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
EricLew | 0:80ee8f3b695e | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
EricLew | 0:80ee8f3b695e | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
EricLew | 0:80ee8f3b695e | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
EricLew | 0:80ee8f3b695e | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
EricLew | 0:80ee8f3b695e | 34 | * |
EricLew | 0:80ee8f3b695e | 35 | ****************************************************************************** |
EricLew | 0:80ee8f3b695e | 36 | */ |
EricLew | 0:80ee8f3b695e | 37 | |
EricLew | 0:80ee8f3b695e | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ |
EricLew | 0:80ee8f3b695e | 39 | #ifndef __STM32L4xx_LL_OPAMP_H |
EricLew | 0:80ee8f3b695e | 40 | #define __STM32L4xx_LL_OPAMP_H |
EricLew | 0:80ee8f3b695e | 41 | |
EricLew | 0:80ee8f3b695e | 42 | #ifdef __cplusplus |
EricLew | 0:80ee8f3b695e | 43 | extern "C" { |
EricLew | 0:80ee8f3b695e | 44 | #endif |
EricLew | 0:80ee8f3b695e | 45 | |
EricLew | 0:80ee8f3b695e | 46 | /* Includes ------------------------------------------------------------------*/ |
EricLew | 0:80ee8f3b695e | 47 | #include "stm32l4xx.h" |
EricLew | 0:80ee8f3b695e | 48 | |
EricLew | 0:80ee8f3b695e | 49 | /** @addtogroup STM32L4xx_LL_Driver |
EricLew | 0:80ee8f3b695e | 50 | * @{ |
EricLew | 0:80ee8f3b695e | 51 | */ |
EricLew | 0:80ee8f3b695e | 52 | |
EricLew | 0:80ee8f3b695e | 53 | #if defined (OPAMP1) || defined (OPAMP2) |
EricLew | 0:80ee8f3b695e | 54 | |
EricLew | 0:80ee8f3b695e | 55 | /** @defgroup OPAMP_LL OPAMP |
EricLew | 0:80ee8f3b695e | 56 | * @{ |
EricLew | 0:80ee8f3b695e | 57 | */ |
EricLew | 0:80ee8f3b695e | 58 | |
EricLew | 0:80ee8f3b695e | 59 | /* Private types -------------------------------------------------------------*/ |
EricLew | 0:80ee8f3b695e | 60 | /* Private variables ---------------------------------------------------------*/ |
EricLew | 0:80ee8f3b695e | 61 | |
EricLew | 0:80ee8f3b695e | 62 | /* Private constants ---------------------------------------------------------*/ |
EricLew | 0:80ee8f3b695e | 63 | /** @defgroup OPAMP_LL_Private_Constants OPAMP Private Constants |
EricLew | 0:80ee8f3b695e | 64 | * @{ |
EricLew | 0:80ee8f3b695e | 65 | */ |
EricLew | 0:80ee8f3b695e | 66 | /* Internal mask for OPAMP power mode: */ |
EricLew | 0:80ee8f3b695e | 67 | /* To select into literal LL_OPAMP_POWERMODE_x the relevant bits for: */ |
EricLew | 0:80ee8f3b695e | 68 | /* - OPAMP power mode into the control register */ |
EricLew | 0:80ee8f3b695e | 69 | /* - OPAMP trimming register offset */ |
EricLew | 0:80ee8f3b695e | 70 | |
EricLew | 0:80ee8f3b695e | 71 | /* Internal register offset for OPAMP trimming configuration */ |
EricLew | 0:80ee8f3b695e | 72 | #define OPAMP_POWERMODE_OTR_REGOFFSET ((uint32_t)0x00000000) |
EricLew | 0:80ee8f3b695e | 73 | #define OPAMP_POWERMODE_LPOTR_REGOFFSET ((uint32_t)0x00000001) |
EricLew | 0:80ee8f3b695e | 74 | |
EricLew | 0:80ee8f3b695e | 75 | #define OPAMP_POWERMODE_CSR_BIT_MASK (OPAMP_CSR_OPALPM) |
EricLew | 0:80ee8f3b695e | 76 | #define OPAMP_POWERMODE_OTRX_REGOFFSET_MASK (OPAMP_POWERMODE_LPOTR_REGOFFSET) |
EricLew | 0:80ee8f3b695e | 77 | |
EricLew | 0:80ee8f3b695e | 78 | /* Internal mask for OPAMP trimming of transistors differential pair NMOS */ |
EricLew | 0:80ee8f3b695e | 79 | /* or PMOS. */ |
EricLew | 0:80ee8f3b695e | 80 | /* To select into literal LL_OPAMP_TRIMMING_x the relevant bits for: */ |
EricLew | 0:80ee8f3b695e | 81 | /* - OPAMP trimming selection of transistors differential pair */ |
EricLew | 0:80ee8f3b695e | 82 | /* - OPAMP trimming values of transistors differential pair */ |
EricLew | 0:80ee8f3b695e | 83 | #define OPAMP_TRIMMING_SELECT_MASK (OPAMP1_CSR_CALSEL) |
EricLew | 0:80ee8f3b695e | 84 | #define OPAMP_TRIMMING_VALUE_MASK (OPAMP_OTR_TRIMOFFSETP | OPAMP_OTR_TRIMOFFSETN) |
EricLew | 0:80ee8f3b695e | 85 | |
EricLew | 0:80ee8f3b695e | 86 | /** |
EricLew | 0:80ee8f3b695e | 87 | * @} |
EricLew | 0:80ee8f3b695e | 88 | */ |
EricLew | 0:80ee8f3b695e | 89 | |
EricLew | 0:80ee8f3b695e | 90 | |
EricLew | 0:80ee8f3b695e | 91 | /* Private macros ------------------------------------------------------------*/ |
EricLew | 0:80ee8f3b695e | 92 | /** @defgroup OPAMP_LL_Private_Macros OPAMP Private Macros |
EricLew | 0:80ee8f3b695e | 93 | * @{ |
EricLew | 0:80ee8f3b695e | 94 | */ |
EricLew | 0:80ee8f3b695e | 95 | |
EricLew | 0:80ee8f3b695e | 96 | /** |
EricLew | 0:80ee8f3b695e | 97 | * @brief Driver macro reserved for internal use: set a pointer to |
EricLew | 0:80ee8f3b695e | 98 | * a register from a register basis from which an offset |
EricLew | 0:80ee8f3b695e | 99 | * is applied. |
EricLew | 0:80ee8f3b695e | 100 | * @param __REG__ Register basis from which the offset is applied. |
EricLew | 0:80ee8f3b695e | 101 | * @param __REG_OFFSET__ Offset to be applied (unit: number of registers). |
EricLew | 0:80ee8f3b695e | 102 | * @retval Register address |
EricLew | 0:80ee8f3b695e | 103 | */ |
EricLew | 0:80ee8f3b695e | 104 | #define __OPAMP_PTR_REG_OFFSET(__REG__, __REG_OFFSET__) \ |
EricLew | 0:80ee8f3b695e | 105 | ((uint32_t *)((uint32_t) ((uint32_t)(&(__REG__)) + ((__REG_OFFSET__) << 2)))) |
EricLew | 0:80ee8f3b695e | 106 | |
EricLew | 0:80ee8f3b695e | 107 | /** |
EricLew | 0:80ee8f3b695e | 108 | * @} |
EricLew | 0:80ee8f3b695e | 109 | */ |
EricLew | 0:80ee8f3b695e | 110 | |
EricLew | 0:80ee8f3b695e | 111 | |
EricLew | 0:80ee8f3b695e | 112 | /* Exported types ------------------------------------------------------------*/ |
EricLew | 0:80ee8f3b695e | 113 | /* Exported constants --------------------------------------------------------*/ |
EricLew | 0:80ee8f3b695e | 114 | /** @defgroup OPAMP_LL_Exported_Constants OPAMP Exported Constants |
EricLew | 0:80ee8f3b695e | 115 | * @{ |
EricLew | 0:80ee8f3b695e | 116 | */ |
EricLew | 0:80ee8f3b695e | 117 | |
EricLew | 0:80ee8f3b695e | 118 | /** @defgroup OPAMP_LL_EC_POWERSUPPLY_RANGE POWERSUPPLY RANGE |
EricLew | 0:80ee8f3b695e | 119 | * @{ |
EricLew | 0:80ee8f3b695e | 120 | */ |
EricLew | 0:80ee8f3b695e | 121 | #define LL_OPAMP_POWERSUPPLY_RANGE_LOW ((uint32_t)0x00000000) /*!< Power supply range low. On STM32L4: Vdda lower than 2.4V. */ |
EricLew | 0:80ee8f3b695e | 122 | #define LL_OPAMP_POWERSUPPLY_RANGE_HIGH (OPAMP1_CSR_OPARANGE) /*!< Power supply range high. On STM32L4: Vdda higher than 2.4V. */ |
EricLew | 0:80ee8f3b695e | 123 | |
EricLew | 0:80ee8f3b695e | 124 | /** |
EricLew | 0:80ee8f3b695e | 125 | * @} |
EricLew | 0:80ee8f3b695e | 126 | */ |
EricLew | 0:80ee8f3b695e | 127 | |
EricLew | 0:80ee8f3b695e | 128 | /** @defgroup OPAMP_LL_EC_POWERMODE POWERMODE |
EricLew | 0:80ee8f3b695e | 129 | * @{ |
EricLew | 0:80ee8f3b695e | 130 | */ |
EricLew | 0:80ee8f3b695e | 131 | #define LL_OPAMP_POWERMODE_NORMAL (OPAMP_POWERMODE_OTR_REGOFFSET) /*!< OPAMP power mode normal */ |
EricLew | 0:80ee8f3b695e | 132 | #define LL_OPAMP_POWERMODE_LOWPOWER (OPAMP_POWERMODE_LPOTR_REGOFFSET | OPAMP_CSR_OPALPM) /*!< OPAMP power mode low-power */ |
EricLew | 0:80ee8f3b695e | 133 | /** |
EricLew | 0:80ee8f3b695e | 134 | * @} |
EricLew | 0:80ee8f3b695e | 135 | */ |
EricLew | 0:80ee8f3b695e | 136 | |
EricLew | 0:80ee8f3b695e | 137 | /** @defgroup OPAMP_LL_EC_MODE MODE |
EricLew | 0:80ee8f3b695e | 138 | * @{ |
EricLew | 0:80ee8f3b695e | 139 | */ |
EricLew | 0:80ee8f3b695e | 140 | #define LL_OPAMP_MODE_FUNCTIONAL ((uint32_t)0x00000000) /*!< OPAMP functional mode */ |
EricLew | 0:80ee8f3b695e | 141 | #define LL_OPAMP_MODE_CALIBRATION (OPAMP1_CSR_CALON) /*!< OPAMP calibration mode */ |
EricLew | 0:80ee8f3b695e | 142 | /** |
EricLew | 0:80ee8f3b695e | 143 | * @} |
EricLew | 0:80ee8f3b695e | 144 | */ |
EricLew | 0:80ee8f3b695e | 145 | |
EricLew | 0:80ee8f3b695e | 146 | /** @defgroup OPAMP_LL_EC_FUNCTIONAL_MODE FUNCTIONAL_MODE |
EricLew | 0:80ee8f3b695e | 147 | * @{ |
EricLew | 0:80ee8f3b695e | 148 | */ |
EricLew | 0:80ee8f3b695e | 149 | #define LL_OPAMP_MODE_STANDALONE ((uint32_t)0x00000000) /*!< OPAMP functional mode, OPAMP operation in standalone */ |
EricLew | 0:80ee8f3b695e | 150 | #define LL_OPAMP_MODE_FOLLOWER (OPAMP_CSR_OPAMODE_1 | OPAMP_CSR_OPAMODE_0) /*!< OPAMP functional mode, OPAMP operation in follower */ |
EricLew | 0:80ee8f3b695e | 151 | #define LL_OPAMP_MODE_PGA (OPAMP_CSR_OPAMODE_1) /*!< OPAMP functional mode, OPAMP operation in PGA */ |
EricLew | 0:80ee8f3b695e | 152 | /** |
EricLew | 0:80ee8f3b695e | 153 | * @} |
EricLew | 0:80ee8f3b695e | 154 | */ |
EricLew | 0:80ee8f3b695e | 155 | |
EricLew | 0:80ee8f3b695e | 156 | /** @defgroup OPAMP_LL_EC_MODE_PGA_GAIN MODE PGA GAIN |
EricLew | 0:80ee8f3b695e | 157 | * @{ |
EricLew | 0:80ee8f3b695e | 158 | */ |
EricLew | 0:80ee8f3b695e | 159 | #define LL_OPAMP_PGA_GAIN_2 ((uint32_t)0x00000000) /*!< OPAMP PGA gain 2 */ |
EricLew | 0:80ee8f3b695e | 160 | #define LL_OPAMP_PGA_GAIN_4 (OPAMP_CSR_PGGAIN_0) /*!< OPAMP PGA gain 4 */ |
EricLew | 0:80ee8f3b695e | 161 | #define LL_OPAMP_PGA_GAIN_8 (OPAMP_CSR_PGGAIN_1) /*!< OPAMP PGA gain 8 */ |
EricLew | 0:80ee8f3b695e | 162 | #define LL_OPAMP_PGA_GAIN_16 (OPAMP_CSR_PGGAIN_1 | OPAMP_CSR_PGGAIN_0 ) /*!< OPAMP PGA gain 16 */ |
EricLew | 0:80ee8f3b695e | 163 | /** |
EricLew | 0:80ee8f3b695e | 164 | * @} |
EricLew | 0:80ee8f3b695e | 165 | */ |
EricLew | 0:80ee8f3b695e | 166 | |
EricLew | 0:80ee8f3b695e | 167 | /** @defgroup OPAMP_LL_EC_INVERTINGINPUT INVERTINGINPUT |
EricLew | 0:80ee8f3b695e | 168 | * @{ |
EricLew | 0:80ee8f3b695e | 169 | */ |
EricLew | 0:80ee8f3b695e | 170 | #define LL_OPAMP_INVERTINGINPUT_IO0 ((uint32_t)0x00000000) /*!< OPAMP inverting input connected to GPIO pin (valid also in PGA mode for filtering) */ |
EricLew | 0:80ee8f3b695e | 171 | #define LL_OPAMP_INVERTINGINPUT_IO1 (OPAMP1_CSR_VMSEL_0) /*!< OPAMP inverting input (low leakage input) connected to GPIO pin (available only on package BGA132) */ |
EricLew | 0:80ee8f3b695e | 172 | #define LL_OPAMP_INVERTINGINPUT_CONNECT_NO (OPAMP1_CSR_VMSEL_1) /*!< OPAMP inverting input not externally connected (intended for OPAMP in mode PGA) */ |
EricLew | 0:80ee8f3b695e | 173 | /** |
EricLew | 0:80ee8f3b695e | 174 | * @} |
EricLew | 0:80ee8f3b695e | 175 | */ |
EricLew | 0:80ee8f3b695e | 176 | |
EricLew | 0:80ee8f3b695e | 177 | /** @defgroup OPAMP_LL_EC_NonInvertingInput NonInvertingInput |
EricLew | 0:80ee8f3b695e | 178 | * @{ |
EricLew | 0:80ee8f3b695e | 179 | */ |
EricLew | 0:80ee8f3b695e | 180 | #define LL_OPAMP_NONINVERTINGINPUT_IO0 ((uint32_t)0x00000000) /*!< OPAMP non inverting input connected to GPIO pin */ |
EricLew | 0:80ee8f3b695e | 181 | #define LL_OPAMP_NONINVERTINGINPUT_DAC_CH (OPAMP1_CSR_VPSEL) /*!< OPAMP non inverting input connected to DAC1 channel1 output */ |
EricLew | 0:80ee8f3b695e | 182 | /** |
EricLew | 0:80ee8f3b695e | 183 | * @} |
EricLew | 0:80ee8f3b695e | 184 | */ |
EricLew | 0:80ee8f3b695e | 185 | |
EricLew | 0:80ee8f3b695e | 186 | /** @defgroup OPAMP_LL_EC_TRIMMING_MODE TRIMMING MODE |
EricLew | 0:80ee8f3b695e | 187 | * @{ |
EricLew | 0:80ee8f3b695e | 188 | */ |
EricLew | 0:80ee8f3b695e | 189 | #define LL_OPAMP_TRIMMING_FACTORY ((uint32_t)0x00000000) /*!< Factory trimming */ |
EricLew | 0:80ee8f3b695e | 190 | #define LL_OPAMP_TRIMMING_USER (OPAMP_CSR_USERTRIM) /*!< User trimming */ |
EricLew | 0:80ee8f3b695e | 191 | /** |
EricLew | 0:80ee8f3b695e | 192 | * @} |
EricLew | 0:80ee8f3b695e | 193 | */ |
EricLew | 0:80ee8f3b695e | 194 | |
EricLew | 0:80ee8f3b695e | 195 | /** @defgroup OPAMP_LL_EC_TRIMMING_TRANSISTORS_DIFF_PAIR TRIMMING OF TRANSISTORS DIFFERENTIAL PAIR |
EricLew | 0:80ee8f3b695e | 196 | * @{ |
EricLew | 0:80ee8f3b695e | 197 | */ |
EricLew | 0:80ee8f3b695e | 198 | #define LL_OPAMP_TRIMMING_NMOS (OPAMP_OTR_TRIMOFFSETN) /*!< Trimming of transistors differential pair NMOS */ |
EricLew | 0:80ee8f3b695e | 199 | #define LL_OPAMP_TRIMMING_PMOS (OPAMP_OTR_TRIMOFFSETP | OPAMP1_CSR_CALSEL) /*!< Trimming of transistors differential pair PMOS */ |
EricLew | 0:80ee8f3b695e | 200 | /** |
EricLew | 0:80ee8f3b695e | 201 | * @} |
EricLew | 0:80ee8f3b695e | 202 | */ |
EricLew | 0:80ee8f3b695e | 203 | |
EricLew | 0:80ee8f3b695e | 204 | /** |
EricLew | 0:80ee8f3b695e | 205 | * @} |
EricLew | 0:80ee8f3b695e | 206 | */ |
EricLew | 0:80ee8f3b695e | 207 | |
EricLew | 0:80ee8f3b695e | 208 | /* Exported macro ------------------------------------------------------------*/ |
EricLew | 0:80ee8f3b695e | 209 | /** @defgroup OPAMP_LL_Exported_Macros OPAMP Exported Macros |
EricLew | 0:80ee8f3b695e | 210 | * @{ |
EricLew | 0:80ee8f3b695e | 211 | */ |
EricLew | 0:80ee8f3b695e | 212 | /** @defgroup OPAMP_LL_EM_WRITE_READ Common Write and read registers macro |
EricLew | 0:80ee8f3b695e | 213 | * @{ |
EricLew | 0:80ee8f3b695e | 214 | */ |
EricLew | 0:80ee8f3b695e | 215 | /** |
EricLew | 0:80ee8f3b695e | 216 | * @brief Write a value in OPAMP register |
EricLew | 0:80ee8f3b695e | 217 | * @param __INSTANCE__ OPAMP Instance |
EricLew | 0:80ee8f3b695e | 218 | * @param __REG__ Register to be written |
EricLew | 0:80ee8f3b695e | 219 | * @param __VALUE__ Value to be written in the register |
EricLew | 0:80ee8f3b695e | 220 | * @retval None |
EricLew | 0:80ee8f3b695e | 221 | */ |
EricLew | 0:80ee8f3b695e | 222 | #define LL_OPAMP_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__)) |
EricLew | 0:80ee8f3b695e | 223 | |
EricLew | 0:80ee8f3b695e | 224 | /** |
EricLew | 0:80ee8f3b695e | 225 | * @brief Read a value in OPAMP register |
EricLew | 0:80ee8f3b695e | 226 | * @param __INSTANCE__ OPAMP Instance |
EricLew | 0:80ee8f3b695e | 227 | * @param __REG__ Register to be read |
EricLew | 0:80ee8f3b695e | 228 | * @retval Register value |
EricLew | 0:80ee8f3b695e | 229 | */ |
EricLew | 0:80ee8f3b695e | 230 | #define LL_OPAMP_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__) |
EricLew | 0:80ee8f3b695e | 231 | /** |
EricLew | 0:80ee8f3b695e | 232 | * @} |
EricLew | 0:80ee8f3b695e | 233 | */ |
EricLew | 0:80ee8f3b695e | 234 | |
EricLew | 0:80ee8f3b695e | 235 | |
EricLew | 0:80ee8f3b695e | 236 | /** |
EricLew | 0:80ee8f3b695e | 237 | * @} |
EricLew | 0:80ee8f3b695e | 238 | */ |
EricLew | 0:80ee8f3b695e | 239 | |
EricLew | 0:80ee8f3b695e | 240 | /* Exported functions --------------------------------------------------------*/ |
EricLew | 0:80ee8f3b695e | 241 | /** @defgroup OPAMP_LL_Exported_Functions OPAMP Exported Functions |
EricLew | 0:80ee8f3b695e | 242 | * @{ |
EricLew | 0:80ee8f3b695e | 243 | */ |
EricLew | 0:80ee8f3b695e | 244 | |
EricLew | 0:80ee8f3b695e | 245 | /** @defgroup OPAMP_LL_EF_Configuration_global Configuration of OPAMP global parameters |
EricLew | 0:80ee8f3b695e | 246 | * @{ |
EricLew | 0:80ee8f3b695e | 247 | */ |
EricLew | 0:80ee8f3b695e | 248 | /** |
EricLew | 0:80ee8f3b695e | 249 | * @brief Set OPAMP power range. |
EricLew | 0:80ee8f3b695e | 250 | * @note The OPAMP power range applies to all OPAMP instances. |
EricLew | 0:80ee8f3b695e | 251 | * @note The OPAMP power range selection must be performed while |
EricLew | 0:80ee8f3b695e | 252 | * OPAMPs are powered down. |
EricLew | 0:80ee8f3b695e | 253 | * @rmtoll CSR OPARANGE LL_OPAMP_SetPowerRange |
EricLew | 0:80ee8f3b695e | 254 | * @param PowerRange This parameter can be one of the following values: |
EricLew | 0:80ee8f3b695e | 255 | * @arg @ref LL_OPAMP_POWERSUPPLY_RANGE_LOW |
EricLew | 0:80ee8f3b695e | 256 | * @arg @ref LL_OPAMP_POWERSUPPLY_RANGE_HIGH |
EricLew | 0:80ee8f3b695e | 257 | * @retval None |
EricLew | 0:80ee8f3b695e | 258 | */ |
EricLew | 0:80ee8f3b695e | 259 | __STATIC_INLINE void LL_OPAMP_SetPowerRange(uint32_t PowerRange) |
EricLew | 0:80ee8f3b695e | 260 | { |
EricLew | 0:80ee8f3b695e | 261 | MODIFY_REG(OPAMP1->CSR, OPAMP1_CSR_OPARANGE, PowerRange); |
EricLew | 0:80ee8f3b695e | 262 | } |
EricLew | 0:80ee8f3b695e | 263 | |
EricLew | 0:80ee8f3b695e | 264 | /** |
EricLew | 0:80ee8f3b695e | 265 | * @brief Get OPAMP power range. |
EricLew | 0:80ee8f3b695e | 266 | * @note The OPAMP power range applies to all OPAMP instances. |
EricLew | 0:80ee8f3b695e | 267 | * @note The OPAMP power range selection must be performed while |
EricLew | 0:80ee8f3b695e | 268 | * OPAMPs are powered down. |
EricLew | 0:80ee8f3b695e | 269 | * @rmtoll CSR OPARANGE LL_OPAMP_GetPowerRange |
EricLew | 0:80ee8f3b695e | 270 | * @retval Returned value can be one of the following values: |
EricLew | 0:80ee8f3b695e | 271 | * @arg @ref LL_OPAMP_POWERSUPPLY_RANGE_LOW |
EricLew | 0:80ee8f3b695e | 272 | * @arg @ref LL_OPAMP_POWERSUPPLY_RANGE_HIGH |
EricLew | 0:80ee8f3b695e | 273 | */ |
EricLew | 0:80ee8f3b695e | 274 | __STATIC_INLINE uint32_t LL_OPAMP_GetPowerRange(void) |
EricLew | 0:80ee8f3b695e | 275 | { |
EricLew | 0:80ee8f3b695e | 276 | return (uint32_t)(READ_BIT(OPAMP1->CSR, OPAMP1_CSR_OPARANGE)); |
EricLew | 0:80ee8f3b695e | 277 | } |
EricLew | 0:80ee8f3b695e | 278 | |
EricLew | 0:80ee8f3b695e | 279 | /** |
EricLew | 0:80ee8f3b695e | 280 | * @brief Set OPAMP power mode. |
EricLew | 0:80ee8f3b695e | 281 | * @note The OPAMP must be disabled to change this configuration. |
EricLew | 0:80ee8f3b695e | 282 | * @rmtoll CSR OPALPM LL_OPAMP_SetPowerMode |
EricLew | 0:80ee8f3b695e | 283 | * @param OPAMPx OPAMP instance |
EricLew | 0:80ee8f3b695e | 284 | * @param PowerMode This parameter can be one of the following values: |
EricLew | 0:80ee8f3b695e | 285 | * @arg @ref LL_OPAMP_POWERMODE_NORMAL |
EricLew | 0:80ee8f3b695e | 286 | * @arg @ref LL_OPAMP_POWERMODE_LOWPOWER |
EricLew | 0:80ee8f3b695e | 287 | * @retval None |
EricLew | 0:80ee8f3b695e | 288 | */ |
EricLew | 0:80ee8f3b695e | 289 | __STATIC_INLINE void LL_OPAMP_SetPowerMode(OPAMP_TypeDef *OPAMPx, uint32_t PowerMode) |
EricLew | 0:80ee8f3b695e | 290 | { |
EricLew | 0:80ee8f3b695e | 291 | MODIFY_REG(OPAMPx->CSR, OPAMP_CSR_OPALPM, (PowerMode & OPAMP_POWERMODE_CSR_BIT_MASK)); |
EricLew | 0:80ee8f3b695e | 292 | } |
EricLew | 0:80ee8f3b695e | 293 | |
EricLew | 0:80ee8f3b695e | 294 | /** |
EricLew | 0:80ee8f3b695e | 295 | * @brief Get OPAMP power mode. |
EricLew | 0:80ee8f3b695e | 296 | * @rmtoll CSR OPALPM LL_OPAMP_GetPowerMode |
EricLew | 0:80ee8f3b695e | 297 | * @param OPAMPx OPAMP instance |
EricLew | 0:80ee8f3b695e | 298 | * @retval Returned value can be one of the following values: |
EricLew | 0:80ee8f3b695e | 299 | * @arg @ref LL_OPAMP_POWERMODE_NORMAL |
EricLew | 0:80ee8f3b695e | 300 | * @arg @ref LL_OPAMP_POWERMODE_LOWPOWER |
EricLew | 0:80ee8f3b695e | 301 | */ |
EricLew | 0:80ee8f3b695e | 302 | __STATIC_INLINE uint32_t LL_OPAMP_GetPowerMode(OPAMP_TypeDef *OPAMPx) |
EricLew | 0:80ee8f3b695e | 303 | { |
EricLew | 0:80ee8f3b695e | 304 | register uint32_t power_mode = (READ_BIT(OPAMPx->CSR, OPAMP_CSR_OPALPM)); |
EricLew | 0:80ee8f3b695e | 305 | |
EricLew | 0:80ee8f3b695e | 306 | return (uint32_t)(power_mode | (power_mode >> (POSITION_VAL(OPAMP_CSR_OPALPM)))); |
EricLew | 0:80ee8f3b695e | 307 | } |
EricLew | 0:80ee8f3b695e | 308 | |
EricLew | 0:80ee8f3b695e | 309 | /** |
EricLew | 0:80ee8f3b695e | 310 | * @brief Set OPAMP mode. |
EricLew | 0:80ee8f3b695e | 311 | * @note OPAMP mode corresponds to functional or calibration mode: |
EricLew | 0:80ee8f3b695e | 312 | * - functional mode: OPAMP operation in standalone, follower, ... |
EricLew | 0:80ee8f3b695e | 313 | * Set functional mode using function |
EricLew | 0:80ee8f3b695e | 314 | * @ref LL_OPAMP_SetFunctionalMode(). |
EricLew | 0:80ee8f3b695e | 315 | * - calibration mode: calibration of the selected transistors |
EricLew | 0:80ee8f3b695e | 316 | * differential pair NMOS or PMOS. |
EricLew | 0:80ee8f3b695e | 317 | * @rmtoll CSR CALON LL_OPAMP_SetMode |
EricLew | 0:80ee8f3b695e | 318 | * @param OPAMPx OPAMP instance |
EricLew | 0:80ee8f3b695e | 319 | * @param Mode This parameter can be one of the following values: |
EricLew | 0:80ee8f3b695e | 320 | * @arg @ref LL_OPAMP_MODE_FUNCTIONAL |
EricLew | 0:80ee8f3b695e | 321 | * @arg @ref LL_OPAMP_MODE_CALIBRATION |
EricLew | 0:80ee8f3b695e | 322 | * @retval None |
EricLew | 0:80ee8f3b695e | 323 | */ |
EricLew | 0:80ee8f3b695e | 324 | __STATIC_INLINE void LL_OPAMP_SetMode(OPAMP_TypeDef *OPAMPx, uint32_t Mode) |
EricLew | 0:80ee8f3b695e | 325 | { |
EricLew | 0:80ee8f3b695e | 326 | MODIFY_REG(OPAMPx->CSR, OPAMP_CSR_CALON, Mode); |
EricLew | 0:80ee8f3b695e | 327 | } |
EricLew | 0:80ee8f3b695e | 328 | |
EricLew | 0:80ee8f3b695e | 329 | /** |
EricLew | 0:80ee8f3b695e | 330 | * @brief Get OPAMP mode. |
EricLew | 0:80ee8f3b695e | 331 | * @note OPAMP mode corresponds to functional or calibration mode: |
EricLew | 0:80ee8f3b695e | 332 | * - functional mode: OPAMP operation in standalone, follower, ... |
EricLew | 0:80ee8f3b695e | 333 | * Set functional mode using function |
EricLew | 0:80ee8f3b695e | 334 | * @ref LL_OPAMP_SetFunctionalMode(). |
EricLew | 0:80ee8f3b695e | 335 | * - calibration mode: calibration of the selected transistors |
EricLew | 0:80ee8f3b695e | 336 | * differential pair NMOS or PMOS. |
EricLew | 0:80ee8f3b695e | 337 | * @rmtoll CSR CALON LL_OPAMP_GetMode |
EricLew | 0:80ee8f3b695e | 338 | * @param OPAMPx OPAMP instance |
EricLew | 0:80ee8f3b695e | 339 | * @retval Returned value can be one of the following values: |
EricLew | 0:80ee8f3b695e | 340 | * @arg @ref LL_OPAMP_MODE_FUNCTIONAL |
EricLew | 0:80ee8f3b695e | 341 | * @arg @ref LL_OPAMP_MODE_CALIBRATION |
EricLew | 0:80ee8f3b695e | 342 | */ |
EricLew | 0:80ee8f3b695e | 343 | __STATIC_INLINE uint32_t LL_OPAMP_GetMode(OPAMP_TypeDef *OPAMPx) |
EricLew | 0:80ee8f3b695e | 344 | { |
EricLew | 0:80ee8f3b695e | 345 | return (uint32_t)(READ_BIT(OPAMPx->CSR, OPAMP_CSR_CALON)); |
EricLew | 0:80ee8f3b695e | 346 | } |
EricLew | 0:80ee8f3b695e | 347 | |
EricLew | 0:80ee8f3b695e | 348 | /** |
EricLew | 0:80ee8f3b695e | 349 | * @brief Set OPAMP functional mode by setting internal connections. |
EricLew | 0:80ee8f3b695e | 350 | * OPAMP operation in standalone, follower, ... |
EricLew | 0:80ee8f3b695e | 351 | * @rmtoll CSR OPAMODE LL_OPAMP_SetFunctionalMode |
EricLew | 0:80ee8f3b695e | 352 | * @param OPAMPx OPAMP instance |
EricLew | 0:80ee8f3b695e | 353 | * @param Mode This parameter can be one of the following values: |
EricLew | 0:80ee8f3b695e | 354 | * @arg @ref LL_OPAMP_MODE_STANDALONE |
EricLew | 0:80ee8f3b695e | 355 | * @arg @ref LL_OPAMP_MODE_FOLLOWER |
EricLew | 0:80ee8f3b695e | 356 | * @arg @ref LL_OPAMP_MODE_PGA |
EricLew | 0:80ee8f3b695e | 357 | * @retval None |
EricLew | 0:80ee8f3b695e | 358 | */ |
EricLew | 0:80ee8f3b695e | 359 | __STATIC_INLINE void LL_OPAMP_SetFunctionalMode(OPAMP_TypeDef *OPAMPx, uint32_t Mode) |
EricLew | 0:80ee8f3b695e | 360 | { |
EricLew | 0:80ee8f3b695e | 361 | /* Note: Bit OPAMP_CSR_CALON reset to ensure to be in functional mode */ |
EricLew | 0:80ee8f3b695e | 362 | MODIFY_REG(OPAMPx->CSR, OPAMP_CSR_OPAMODE | OPAMP_CSR_CALON, Mode); |
EricLew | 0:80ee8f3b695e | 363 | } |
EricLew | 0:80ee8f3b695e | 364 | |
EricLew | 0:80ee8f3b695e | 365 | /** |
EricLew | 0:80ee8f3b695e | 366 | * @brief Get OPAMP functional mode from setting of internal connections. |
EricLew | 0:80ee8f3b695e | 367 | * OPAMP operation in standalone, follower, ... |
EricLew | 0:80ee8f3b695e | 368 | * @rmtoll CSR OPAMODE LL_OPAMP_GetFunctionalMode |
EricLew | 0:80ee8f3b695e | 369 | * @param OPAMPx OPAMP instance |
EricLew | 0:80ee8f3b695e | 370 | * @retval Returned value can be one of the following values: |
EricLew | 0:80ee8f3b695e | 371 | * @arg @ref LL_OPAMP_MODE_STANDALONE |
EricLew | 0:80ee8f3b695e | 372 | * @arg @ref LL_OPAMP_MODE_FOLLOWER |
EricLew | 0:80ee8f3b695e | 373 | * @arg @ref LL_OPAMP_MODE_PGA |
EricLew | 0:80ee8f3b695e | 374 | */ |
EricLew | 0:80ee8f3b695e | 375 | __STATIC_INLINE uint32_t LL_OPAMP_GetFunctionalMode(OPAMP_TypeDef *OPAMPx) |
EricLew | 0:80ee8f3b695e | 376 | { |
EricLew | 0:80ee8f3b695e | 377 | return (uint32_t)(READ_BIT(OPAMPx->CSR, OPAMP_CSR_OPAMODE)); |
EricLew | 0:80ee8f3b695e | 378 | } |
EricLew | 0:80ee8f3b695e | 379 | |
EricLew | 0:80ee8f3b695e | 380 | /** |
EricLew | 0:80ee8f3b695e | 381 | * @brief Set OPAMP PGA gain. |
EricLew | 0:80ee8f3b695e | 382 | * @note Preliminarily, OPAMP must be set in mode PGA |
EricLew | 0:80ee8f3b695e | 383 | * using function @ref LL_OPAMP_SetFunctionalMode(). |
EricLew | 0:80ee8f3b695e | 384 | * @rmtoll CSR PGGAIN LL_OPAMP_SetPGAGain |
EricLew | 0:80ee8f3b695e | 385 | * @param OPAMPx OPAMP instance |
EricLew | 0:80ee8f3b695e | 386 | * @param PGAGain This parameter can be one of the following values: |
EricLew | 0:80ee8f3b695e | 387 | * @arg @ref LL_OPAMP_PGA_GAIN_2 |
EricLew | 0:80ee8f3b695e | 388 | * @arg @ref LL_OPAMP_PGA_GAIN_4 |
EricLew | 0:80ee8f3b695e | 389 | * @arg @ref LL_OPAMP_PGA_GAIN_8 |
EricLew | 0:80ee8f3b695e | 390 | * @arg @ref LL_OPAMP_PGA_GAIN_16 |
EricLew | 0:80ee8f3b695e | 391 | * @retval None |
EricLew | 0:80ee8f3b695e | 392 | */ |
EricLew | 0:80ee8f3b695e | 393 | __STATIC_INLINE void LL_OPAMP_SetPGAGain(OPAMP_TypeDef *OPAMPx, uint32_t PGAGain) |
EricLew | 0:80ee8f3b695e | 394 | { |
EricLew | 0:80ee8f3b695e | 395 | MODIFY_REG(OPAMPx->CSR, OPAMP_CSR_PGGAIN, PGAGain); |
EricLew | 0:80ee8f3b695e | 396 | } |
EricLew | 0:80ee8f3b695e | 397 | |
EricLew | 0:80ee8f3b695e | 398 | /** |
EricLew | 0:80ee8f3b695e | 399 | * @brief Get OPAMP PGA gain. |
EricLew | 0:80ee8f3b695e | 400 | * @note Preliminarily, OPAMP must be set in mode PGA |
EricLew | 0:80ee8f3b695e | 401 | * using function @ref LL_OPAMP_SetFunctionalMode(). |
EricLew | 0:80ee8f3b695e | 402 | * @rmtoll CSR PGGAIN LL_OPAMP_GetPGAGain |
EricLew | 0:80ee8f3b695e | 403 | * @param OPAMPx OPAMP instance |
EricLew | 0:80ee8f3b695e | 404 | * @retval Returned value can be one of the following values: |
EricLew | 0:80ee8f3b695e | 405 | * @arg @ref LL_OPAMP_PGA_GAIN_2 |
EricLew | 0:80ee8f3b695e | 406 | * @arg @ref LL_OPAMP_PGA_GAIN_4 |
EricLew | 0:80ee8f3b695e | 407 | * @arg @ref LL_OPAMP_PGA_GAIN_8 |
EricLew | 0:80ee8f3b695e | 408 | * @arg @ref LL_OPAMP_PGA_GAIN_16 |
EricLew | 0:80ee8f3b695e | 409 | */ |
EricLew | 0:80ee8f3b695e | 410 | __STATIC_INLINE uint32_t LL_OPAMP_GetPGAGain(OPAMP_TypeDef *OPAMPx) |
EricLew | 0:80ee8f3b695e | 411 | { |
EricLew | 0:80ee8f3b695e | 412 | return (uint32_t)(READ_BIT(OPAMPx->CSR, OPAMP_CSR_PGGAIN)); |
EricLew | 0:80ee8f3b695e | 413 | } |
EricLew | 0:80ee8f3b695e | 414 | |
EricLew | 0:80ee8f3b695e | 415 | /** |
EricLew | 0:80ee8f3b695e | 416 | * @} |
EricLew | 0:80ee8f3b695e | 417 | */ |
EricLew | 0:80ee8f3b695e | 418 | |
EricLew | 0:80ee8f3b695e | 419 | /** @defgroup OPAMP_LL_EF_Configuration_inputs Configuration of OPAMP inputs |
EricLew | 0:80ee8f3b695e | 420 | * @{ |
EricLew | 0:80ee8f3b695e | 421 | */ |
EricLew | 0:80ee8f3b695e | 422 | /** |
EricLew | 0:80ee8f3b695e | 423 | * @brief Set OPAMP inverting input connection. |
EricLew | 0:80ee8f3b695e | 424 | * @rmtoll CSR VMSEL LL_OPAMP_SetInvertingInput |
EricLew | 0:80ee8f3b695e | 425 | * @param OPAMPx OPAMP instance |
EricLew | 0:80ee8f3b695e | 426 | * @param InvertingInput This parameter can be one of the following values: |
EricLew | 0:80ee8f3b695e | 427 | * @arg @ref LL_OPAMP_INVERTINGINPUT_IO0 |
EricLew | 0:80ee8f3b695e | 428 | * @arg @ref LL_OPAMP_INVERTINGINPUT_IO1 |
EricLew | 0:80ee8f3b695e | 429 | * @arg @ref LL_OPAMP_INVERTINGINPUT_CONNECT_NO |
EricLew | 0:80ee8f3b695e | 430 | * @retval None |
EricLew | 0:80ee8f3b695e | 431 | */ |
EricLew | 0:80ee8f3b695e | 432 | __STATIC_INLINE void LL_OPAMP_SetInvertingInput(OPAMP_TypeDef *OPAMPx, uint32_t InvertingInput) |
EricLew | 0:80ee8f3b695e | 433 | { |
EricLew | 0:80ee8f3b695e | 434 | MODIFY_REG(OPAMPx->CSR, OPAMP_CSR_VMSEL, InvertingInput); |
EricLew | 0:80ee8f3b695e | 435 | } |
EricLew | 0:80ee8f3b695e | 436 | |
EricLew | 0:80ee8f3b695e | 437 | /** |
EricLew | 0:80ee8f3b695e | 438 | * @brief Get OPAMP inverting input connection. |
EricLew | 0:80ee8f3b695e | 439 | * @rmtoll CSR VMSEL LL_OPAMP_GetInvertingInput |
EricLew | 0:80ee8f3b695e | 440 | * @param OPAMPx OPAMP instance |
EricLew | 0:80ee8f3b695e | 441 | * @retval Returned value can be one of the following values: |
EricLew | 0:80ee8f3b695e | 442 | * @arg @ref LL_OPAMP_INVERTINGINPUT_IO0 |
EricLew | 0:80ee8f3b695e | 443 | * @arg @ref LL_OPAMP_INVERTINGINPUT_IO1 |
EricLew | 0:80ee8f3b695e | 444 | * @arg @ref LL_OPAMP_INVERTINGINPUT_CONNECT_NO |
EricLew | 0:80ee8f3b695e | 445 | */ |
EricLew | 0:80ee8f3b695e | 446 | __STATIC_INLINE uint32_t LL_OPAMP_GetInvertingInput(OPAMP_TypeDef *OPAMPx) |
EricLew | 0:80ee8f3b695e | 447 | { |
EricLew | 0:80ee8f3b695e | 448 | return (uint32_t)(READ_BIT(OPAMPx->CSR, OPAMP_CSR_VMSEL)); |
EricLew | 0:80ee8f3b695e | 449 | } |
EricLew | 0:80ee8f3b695e | 450 | |
EricLew | 0:80ee8f3b695e | 451 | /** |
EricLew | 0:80ee8f3b695e | 452 | * @brief Set OPAMP non-inverting input connection. |
EricLew | 0:80ee8f3b695e | 453 | * @rmtoll CSR VPSEL LL_OPAMP_SetNonInvertingInput |
EricLew | 0:80ee8f3b695e | 454 | * @param OPAMPx OPAMP instance |
EricLew | 0:80ee8f3b695e | 455 | * @param NonInvertingInput This parameter can be one of the following values: |
EricLew | 0:80ee8f3b695e | 456 | * @arg @ref LL_OPAMP_NONINVERTINGINPUT_IO0 |
EricLew | 0:80ee8f3b695e | 457 | * @arg @ref LL_OPAMP_NONINVERTINGINPUT_DAC_CH |
EricLew | 0:80ee8f3b695e | 458 | * @retval None |
EricLew | 0:80ee8f3b695e | 459 | */ |
EricLew | 0:80ee8f3b695e | 460 | __STATIC_INLINE void LL_OPAMP_SetNonInvertingInput(OPAMP_TypeDef *OPAMPx, uint32_t NonInvertingInput) |
EricLew | 0:80ee8f3b695e | 461 | { |
EricLew | 0:80ee8f3b695e | 462 | MODIFY_REG(OPAMPx->CSR, OPAMP_CSR_VPSEL, NonInvertingInput); |
EricLew | 0:80ee8f3b695e | 463 | } |
EricLew | 0:80ee8f3b695e | 464 | |
EricLew | 0:80ee8f3b695e | 465 | /** |
EricLew | 0:80ee8f3b695e | 466 | * @brief Get OPAMP non-inverting input connection. |
EricLew | 0:80ee8f3b695e | 467 | * @rmtoll CSR VPSEL LL_OPAMP_GetNonInvertingInput |
EricLew | 0:80ee8f3b695e | 468 | * @param OPAMPx OPAMP instance |
EricLew | 0:80ee8f3b695e | 469 | * @retval Returned value can be one of the following values: |
EricLew | 0:80ee8f3b695e | 470 | * @arg @ref LL_OPAMP_NONINVERTINGINPUT_IO0 |
EricLew | 0:80ee8f3b695e | 471 | * @arg @ref LL_OPAMP_NONINVERTINGINPUT_DAC_CH |
EricLew | 0:80ee8f3b695e | 472 | */ |
EricLew | 0:80ee8f3b695e | 473 | __STATIC_INLINE uint32_t LL_OPAMP_GetNonInvertingInput(OPAMP_TypeDef *OPAMPx) |
EricLew | 0:80ee8f3b695e | 474 | { |
EricLew | 0:80ee8f3b695e | 475 | return (uint32_t)(READ_BIT(OPAMPx->CSR, OPAMP_CSR_VPSEL)); |
EricLew | 0:80ee8f3b695e | 476 | } |
EricLew | 0:80ee8f3b695e | 477 | |
EricLew | 0:80ee8f3b695e | 478 | /** |
EricLew | 0:80ee8f3b695e | 479 | * @} |
EricLew | 0:80ee8f3b695e | 480 | */ |
EricLew | 0:80ee8f3b695e | 481 | |
EricLew | 0:80ee8f3b695e | 482 | /** @defgroup OPAMP_LL_EF_OPAMP_trimming Configuration and operation of OPAMP trimming |
EricLew | 0:80ee8f3b695e | 483 | * @{ |
EricLew | 0:80ee8f3b695e | 484 | */ |
EricLew | 0:80ee8f3b695e | 485 | /** |
EricLew | 0:80ee8f3b695e | 486 | * @brief Set OPAMP trimming mode. |
EricLew | 0:80ee8f3b695e | 487 | * @rmtoll CSR USERTRIM LL_OPAMP_SetTrimmingMode |
EricLew | 0:80ee8f3b695e | 488 | * @param OPAMPx OPAMP instance |
EricLew | 0:80ee8f3b695e | 489 | * @param TrimmingMode This parameter can be one of the following values: |
EricLew | 0:80ee8f3b695e | 490 | * @arg @ref LL_OPAMP_TRIMMING_FACTORY |
EricLew | 0:80ee8f3b695e | 491 | * @arg @ref LL_OPAMP_TRIMMING_USER |
EricLew | 0:80ee8f3b695e | 492 | * @retval None |
EricLew | 0:80ee8f3b695e | 493 | */ |
EricLew | 0:80ee8f3b695e | 494 | __STATIC_INLINE void LL_OPAMP_SetTrimmingMode(OPAMP_TypeDef *OPAMPx, uint32_t TrimmingMode) |
EricLew | 0:80ee8f3b695e | 495 | { |
EricLew | 0:80ee8f3b695e | 496 | MODIFY_REG(OPAMPx->CSR, OPAMP_CSR_USERTRIM, TrimmingMode); |
EricLew | 0:80ee8f3b695e | 497 | } |
EricLew | 0:80ee8f3b695e | 498 | |
EricLew | 0:80ee8f3b695e | 499 | /** |
EricLew | 0:80ee8f3b695e | 500 | * @brief Get OPAMP trimming mode. |
EricLew | 0:80ee8f3b695e | 501 | * @rmtoll CSR USERTRIM LL_OPAMP_GetTrimmingMode |
EricLew | 0:80ee8f3b695e | 502 | * @param OPAMPx OPAMP instance |
EricLew | 0:80ee8f3b695e | 503 | * @retval Returned value can be one of the following values: |
EricLew | 0:80ee8f3b695e | 504 | * @arg @ref LL_OPAMP_TRIMMING_FACTORY |
EricLew | 0:80ee8f3b695e | 505 | * @arg @ref LL_OPAMP_TRIMMING_USER |
EricLew | 0:80ee8f3b695e | 506 | */ |
EricLew | 0:80ee8f3b695e | 507 | __STATIC_INLINE uint32_t LL_OPAMP_GetTrimmingMode(OPAMP_TypeDef *OPAMPx) |
EricLew | 0:80ee8f3b695e | 508 | { |
EricLew | 0:80ee8f3b695e | 509 | return (uint32_t)(READ_BIT(OPAMPx->CSR, OPAMP_CSR_USERTRIM)); |
EricLew | 0:80ee8f3b695e | 510 | } |
EricLew | 0:80ee8f3b695e | 511 | |
EricLew | 0:80ee8f3b695e | 512 | /** |
EricLew | 0:80ee8f3b695e | 513 | * @brief Set OPAMP offset to calibrate the selected transistors |
EricLew | 0:80ee8f3b695e | 514 | * differential pair NMOS or PMOS. |
EricLew | 0:80ee8f3b695e | 515 | * @note Preliminarily, OPAMP must be set in mode calibration |
EricLew | 0:80ee8f3b695e | 516 | * using function @ref LL_OPAMP_SetMode(). |
EricLew | 0:80ee8f3b695e | 517 | * @rmtoll CSR CALSEL LL_OPAMP_SetCalibrationSelection |
EricLew | 0:80ee8f3b695e | 518 | * @param OPAMPx OPAMP instance |
EricLew | 0:80ee8f3b695e | 519 | * @param TransistorsDiffPair This parameter can be one of the following values: |
EricLew | 0:80ee8f3b695e | 520 | * @arg @ref LL_OPAMP_TRIMMING_NMOS |
EricLew | 0:80ee8f3b695e | 521 | * @arg @ref LL_OPAMP_TRIMMING_PMOS |
EricLew | 0:80ee8f3b695e | 522 | * @retval None |
EricLew | 0:80ee8f3b695e | 523 | */ |
EricLew | 0:80ee8f3b695e | 524 | __STATIC_INLINE void LL_OPAMP_SetCalibrationSelection(OPAMP_TypeDef *OPAMPx, uint32_t TransistorsDiffPair) |
EricLew | 0:80ee8f3b695e | 525 | { |
EricLew | 0:80ee8f3b695e | 526 | /* Parameter used with mask "OPAMP_TRIMMING_SELECT_MASK" because */ |
EricLew | 0:80ee8f3b695e | 527 | /* containing other bits reserved for other purpose. */ |
EricLew | 0:80ee8f3b695e | 528 | MODIFY_REG(OPAMPx->CSR, OPAMP_CSR_CALSEL, (TransistorsDiffPair & OPAMP_TRIMMING_SELECT_MASK)); |
EricLew | 0:80ee8f3b695e | 529 | } |
EricLew | 0:80ee8f3b695e | 530 | |
EricLew | 0:80ee8f3b695e | 531 | /** |
EricLew | 0:80ee8f3b695e | 532 | * @brief Get OPAMP offset to calibrate the selected transistors |
EricLew | 0:80ee8f3b695e | 533 | * differential pair NMOS or PMOS. |
EricLew | 0:80ee8f3b695e | 534 | * @note Preliminarily, OPAMP must be set in mode calibration |
EricLew | 0:80ee8f3b695e | 535 | * using function @ref LL_OPAMP_SetMode(). |
EricLew | 0:80ee8f3b695e | 536 | * @rmtoll CSR CALSEL LL_OPAMP_GetCalibrationSelection |
EricLew | 0:80ee8f3b695e | 537 | * @param OPAMPx OPAMP instance |
EricLew | 0:80ee8f3b695e | 538 | * @retval Returned value can be one of the following values: |
EricLew | 0:80ee8f3b695e | 539 | * @arg @ref LL_OPAMP_TRIMMING_NMOS |
EricLew | 0:80ee8f3b695e | 540 | * @arg @ref LL_OPAMP_TRIMMING_PMOS |
EricLew | 0:80ee8f3b695e | 541 | */ |
EricLew | 0:80ee8f3b695e | 542 | __STATIC_INLINE uint32_t LL_OPAMP_GetCalibrationSelection(OPAMP_TypeDef *OPAMPx) |
EricLew | 0:80ee8f3b695e | 543 | { |
EricLew | 0:80ee8f3b695e | 544 | register uint32_t CalibrationSelection = (uint32_t)(READ_BIT(OPAMPx->CSR, OPAMP_CSR_CALSEL)); |
EricLew | 0:80ee8f3b695e | 545 | |
EricLew | 0:80ee8f3b695e | 546 | return (CalibrationSelection | |
EricLew | 0:80ee8f3b695e | 547 | ((OPAMP_OTR_TRIMOFFSETN) << (POSITION_VAL(OPAMP_OTR_TRIMOFFSETP) * (CalibrationSelection && OPAMP1_CSR_CALSEL)))); |
EricLew | 0:80ee8f3b695e | 548 | } |
EricLew | 0:80ee8f3b695e | 549 | |
EricLew | 0:80ee8f3b695e | 550 | /** |
EricLew | 0:80ee8f3b695e | 551 | * @brief Get OPAMP calibration result of toggling output. |
EricLew | 0:80ee8f3b695e | 552 | * @rmtoll CSR CALOUT LL_OPAMP_IsCalibrationOutputSet |
EricLew | 0:80ee8f3b695e | 553 | * @param OPAMPx OPAMP instance |
EricLew | 0:80ee8f3b695e | 554 | * @retval 0 if OPAMP calibration output is reset, |
EricLew | 0:80ee8f3b695e | 555 | * 1 if OPAMP calibration output is set. |
EricLew | 0:80ee8f3b695e | 556 | */ |
EricLew | 0:80ee8f3b695e | 557 | __STATIC_INLINE uint32_t LL_OPAMP_IsCalibrationOutputSet(OPAMP_TypeDef *OPAMPx) |
EricLew | 0:80ee8f3b695e | 558 | { |
EricLew | 0:80ee8f3b695e | 559 | return (READ_BIT(OPAMPx->CSR, OPAMP_CSR_CALOUT) == OPAMP_CSR_CALOUT); |
EricLew | 0:80ee8f3b695e | 560 | } |
EricLew | 0:80ee8f3b695e | 561 | |
EricLew | 0:80ee8f3b695e | 562 | /** |
EricLew | 0:80ee8f3b695e | 563 | * @brief Set OPAMP trimming factor for the selected transistors |
EricLew | 0:80ee8f3b695e | 564 | * differential pair NMOS or PMOS, corresponding to the selected |
EricLew | 0:80ee8f3b695e | 565 | * power mode. |
EricLew | 0:80ee8f3b695e | 566 | * @param OPAMPx OPAMP instance |
EricLew | 0:80ee8f3b695e | 567 | * @param PowerMode This parameter can be one of the following values: |
EricLew | 0:80ee8f3b695e | 568 | * @arg @ref LL_OPAMP_POWERMODE_NORMAL |
EricLew | 0:80ee8f3b695e | 569 | * @arg @ref LL_OPAMP_POWERMODE_LOWPOWER |
EricLew | 0:80ee8f3b695e | 570 | * @param TransistorsDiffPair This parameter can be one of the following values: |
EricLew | 0:80ee8f3b695e | 571 | * @arg @ref LL_OPAMP_TRIMMING_NMOS |
EricLew | 0:80ee8f3b695e | 572 | * @arg @ref LL_OPAMP_TRIMMING_PMOS |
EricLew | 0:80ee8f3b695e | 573 | * @param TrimmingValue 0x00...0x1F |
EricLew | 0:80ee8f3b695e | 574 | * @retval None |
EricLew | 0:80ee8f3b695e | 575 | */ |
EricLew | 0:80ee8f3b695e | 576 | __STATIC_INLINE void LL_OPAMP_SetTrimmingValue(OPAMP_TypeDef* OPAMPx, uint32_t PowerMode, uint32_t TransistorsDiffPair, uint32_t TrimmingValue) |
EricLew | 0:80ee8f3b695e | 577 | { |
EricLew | 0:80ee8f3b695e | 578 | register uint32_t *preg = __OPAMP_PTR_REG_OFFSET(OPAMPx->OTR, (PowerMode & OPAMP_POWERMODE_OTRX_REGOFFSET_MASK)); |
EricLew | 0:80ee8f3b695e | 579 | |
EricLew | 0:80ee8f3b695e | 580 | /* Set bits with position in register depending on parameter */ |
EricLew | 0:80ee8f3b695e | 581 | /* "TransistorsDiffPair". */ |
EricLew | 0:80ee8f3b695e | 582 | /* Parameter used with mask "OPAMP_TRIMMING_VALUE_MASK" because */ |
EricLew | 0:80ee8f3b695e | 583 | /* containing other bits reserved for other purpose. */ |
EricLew | 0:80ee8f3b695e | 584 | MODIFY_REG(*preg, |
EricLew | 0:80ee8f3b695e | 585 | (TransistorsDiffPair & OPAMP_TRIMMING_VALUE_MASK), |
EricLew | 0:80ee8f3b695e | 586 | TrimmingValue << (POSITION_VAL(TransistorsDiffPair & OPAMP_TRIMMING_VALUE_MASK))); |
EricLew | 0:80ee8f3b695e | 587 | } |
EricLew | 0:80ee8f3b695e | 588 | |
EricLew | 0:80ee8f3b695e | 589 | /** |
EricLew | 0:80ee8f3b695e | 590 | * @brief Get OPAMP trimming factor for the selected transistors |
EricLew | 0:80ee8f3b695e | 591 | * differential pair NMOS or PMOS, corresponding to the selected |
EricLew | 0:80ee8f3b695e | 592 | * power mode. |
EricLew | 0:80ee8f3b695e | 593 | * @param OPAMPx OPAMP instance |
EricLew | 0:80ee8f3b695e | 594 | * @param PowerMode This parameter can be one of the following values: |
EricLew | 0:80ee8f3b695e | 595 | * @arg @ref LL_OPAMP_POWERMODE_NORMAL |
EricLew | 0:80ee8f3b695e | 596 | * @arg @ref LL_OPAMP_POWERMODE_LOWPOWER |
EricLew | 0:80ee8f3b695e | 597 | * @param TransistorsDiffPair This parameter can be one of the following values: |
EricLew | 0:80ee8f3b695e | 598 | * @arg @ref LL_OPAMP_TRIMMING_NMOS |
EricLew | 0:80ee8f3b695e | 599 | * @arg @ref LL_OPAMP_TRIMMING_PMOS |
EricLew | 0:80ee8f3b695e | 600 | * @retval 0x0...0x1F |
EricLew | 0:80ee8f3b695e | 601 | */ |
EricLew | 0:80ee8f3b695e | 602 | __STATIC_INLINE uint32_t LL_OPAMP_GetTrimmingValue(OPAMP_TypeDef* OPAMPx, uint32_t PowerMode, uint32_t TransistorsDiffPair) |
EricLew | 0:80ee8f3b695e | 603 | { |
EricLew | 0:80ee8f3b695e | 604 | register uint32_t *preg = __OPAMP_PTR_REG_OFFSET(OPAMPx->OTR, (PowerMode & OPAMP_POWERMODE_OTRX_REGOFFSET_MASK)); |
EricLew | 0:80ee8f3b695e | 605 | |
EricLew | 0:80ee8f3b695e | 606 | /* Retrieve bits with position in register depending on parameter */ |
EricLew | 0:80ee8f3b695e | 607 | /* "TransistorsDiffPair". */ |
EricLew | 0:80ee8f3b695e | 608 | /* Parameter used with mask "OPAMP_TRIMMING_VALUE_MASK" because */ |
EricLew | 0:80ee8f3b695e | 609 | /* containing other bits reserved for other purpose. */ |
EricLew | 0:80ee8f3b695e | 610 | return (uint32_t)(READ_BIT(*preg, (TransistorsDiffPair & OPAMP_TRIMMING_VALUE_MASK)) |
EricLew | 0:80ee8f3b695e | 611 | >> (POSITION_VAL((TransistorsDiffPair & OPAMP_TRIMMING_VALUE_MASK))) |
EricLew | 0:80ee8f3b695e | 612 | ); |
EricLew | 0:80ee8f3b695e | 613 | } |
EricLew | 0:80ee8f3b695e | 614 | |
EricLew | 0:80ee8f3b695e | 615 | /** |
EricLew | 0:80ee8f3b695e | 616 | * @} |
EricLew | 0:80ee8f3b695e | 617 | */ |
EricLew | 0:80ee8f3b695e | 618 | |
EricLew | 0:80ee8f3b695e | 619 | /** @defgroup OPAMP_LL_EF_Operation Operation on OPAMP |
EricLew | 0:80ee8f3b695e | 620 | * @{ |
EricLew | 0:80ee8f3b695e | 621 | */ |
EricLew | 0:80ee8f3b695e | 622 | /** |
EricLew | 0:80ee8f3b695e | 623 | * @brief Enable OPAMP instance. |
EricLew | 0:80ee8f3b695e | 624 | * @rmtoll CSR OPAMPXEN LL_OPAMP_Enable |
EricLew | 0:80ee8f3b695e | 625 | * @param OPAMPx OPAMP instance |
EricLew | 0:80ee8f3b695e | 626 | * @retval None |
EricLew | 0:80ee8f3b695e | 627 | */ |
EricLew | 0:80ee8f3b695e | 628 | __STATIC_INLINE void LL_OPAMP_Enable(OPAMP_TypeDef *OPAMPx) |
EricLew | 0:80ee8f3b695e | 629 | { |
EricLew | 0:80ee8f3b695e | 630 | SET_BIT(OPAMPx->CSR, OPAMP_CSR_OPAMPxEN); |
EricLew | 0:80ee8f3b695e | 631 | } |
EricLew | 0:80ee8f3b695e | 632 | |
EricLew | 0:80ee8f3b695e | 633 | /** |
EricLew | 0:80ee8f3b695e | 634 | * @brief Disable OPAMP instance. |
EricLew | 0:80ee8f3b695e | 635 | * @rmtoll CSR OPAMPXEN LL_OPAMP_Disable |
EricLew | 0:80ee8f3b695e | 636 | * @param OPAMPx OPAMP instance |
EricLew | 0:80ee8f3b695e | 637 | * @retval None |
EricLew | 0:80ee8f3b695e | 638 | */ |
EricLew | 0:80ee8f3b695e | 639 | __STATIC_INLINE void LL_OPAMP_Disable(OPAMP_TypeDef *OPAMPx) |
EricLew | 0:80ee8f3b695e | 640 | { |
EricLew | 0:80ee8f3b695e | 641 | CLEAR_BIT(OPAMPx->CSR, OPAMP_CSR_OPAMPxEN); |
EricLew | 0:80ee8f3b695e | 642 | } |
EricLew | 0:80ee8f3b695e | 643 | |
EricLew | 0:80ee8f3b695e | 644 | /** |
EricLew | 0:80ee8f3b695e | 645 | * @brief Get OPAMP instance enable state |
EricLew | 0:80ee8f3b695e | 646 | * (0: OPAMP is disabled, 1: OPAMP is enabled) |
EricLew | 0:80ee8f3b695e | 647 | * @rmtoll CSR OPAMPXEN LL_OPAMP_IsEnabled |
EricLew | 0:80ee8f3b695e | 648 | * @param OPAMPx OPAMP instance |
EricLew | 0:80ee8f3b695e | 649 | * @retval State of bit (1 or 0). |
EricLew | 0:80ee8f3b695e | 650 | */ |
EricLew | 0:80ee8f3b695e | 651 | __STATIC_INLINE uint32_t LL_OPAMP_IsEnabled(OPAMP_TypeDef *OPAMPx) |
EricLew | 0:80ee8f3b695e | 652 | { |
EricLew | 0:80ee8f3b695e | 653 | return (READ_BIT(OPAMPx->CSR, OPAMP_CSR_OPAMPxEN) == (OPAMP_CSR_OPAMPxEN)); |
EricLew | 0:80ee8f3b695e | 654 | } |
EricLew | 0:80ee8f3b695e | 655 | |
EricLew | 0:80ee8f3b695e | 656 | /** |
EricLew | 0:80ee8f3b695e | 657 | * @} |
EricLew | 0:80ee8f3b695e | 658 | */ |
EricLew | 0:80ee8f3b695e | 659 | |
EricLew | 0:80ee8f3b695e | 660 | /** |
EricLew | 0:80ee8f3b695e | 661 | * @} |
EricLew | 0:80ee8f3b695e | 662 | */ |
EricLew | 0:80ee8f3b695e | 663 | |
EricLew | 0:80ee8f3b695e | 664 | /** |
EricLew | 0:80ee8f3b695e | 665 | * @} |
EricLew | 0:80ee8f3b695e | 666 | */ |
EricLew | 0:80ee8f3b695e | 667 | |
EricLew | 0:80ee8f3b695e | 668 | #endif /* OPAMP1 || OPAMP2 */ |
EricLew | 0:80ee8f3b695e | 669 | |
EricLew | 0:80ee8f3b695e | 670 | /** |
EricLew | 0:80ee8f3b695e | 671 | * @} |
EricLew | 0:80ee8f3b695e | 672 | */ |
EricLew | 0:80ee8f3b695e | 673 | |
EricLew | 0:80ee8f3b695e | 674 | #ifdef __cplusplus |
EricLew | 0:80ee8f3b695e | 675 | } |
EricLew | 0:80ee8f3b695e | 676 | #endif |
EricLew | 0:80ee8f3b695e | 677 | |
EricLew | 0:80ee8f3b695e | 678 | #endif /* __STM32L4xx_LL_OPAMP_H */ |
EricLew | 0:80ee8f3b695e | 679 | |
EricLew | 0:80ee8f3b695e | 680 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
EricLew | 0:80ee8f3b695e | 681 |