The official mbed C/C SDK provides the software platform and libraries to build your applications.

Fork of mbed by mbed official

Committer:
Mikchel
Date:
Sun May 03 16:04:42 2015 +0000
Revision:
99:7f6c6de930c0
Parent:
90:cb3d968589d8
12

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 90:cb3d968589d8 1 /**
Kojto 90:cb3d968589d8 2 ******************************************************************************
Kojto 90:cb3d968589d8 3 * @file stm32l1xx_hal_opamp.h
Kojto 90:cb3d968589d8 4 * @author MCD Application Team
Kojto 90:cb3d968589d8 5 * @version V1.0.0
Kojto 90:cb3d968589d8 6 * @date 5-September-2014
Kojto 90:cb3d968589d8 7 * @brief Header file of OPAMP HAL module.
Kojto 90:cb3d968589d8 8 ******************************************************************************
Kojto 90:cb3d968589d8 9 * @attention
Kojto 90:cb3d968589d8 10 *
Kojto 90:cb3d968589d8 11 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
Kojto 90:cb3d968589d8 12 *
Kojto 90:cb3d968589d8 13 * Redistribution and use in source and binary forms, with or without modification,
Kojto 90:cb3d968589d8 14 * are permitted provided that the following conditions are met:
Kojto 90:cb3d968589d8 15 * 1. Redistributions of source code must retain the above copyright notice,
Kojto 90:cb3d968589d8 16 * this list of conditions and the following disclaimer.
Kojto 90:cb3d968589d8 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
Kojto 90:cb3d968589d8 18 * this list of conditions and the following disclaimer in the documentation
Kojto 90:cb3d968589d8 19 * and/or other materials provided with the distribution.
Kojto 90:cb3d968589d8 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Kojto 90:cb3d968589d8 21 * may be used to endorse or promote products derived from this software
Kojto 90:cb3d968589d8 22 * without specific prior written permission.
Kojto 90:cb3d968589d8 23 *
Kojto 90:cb3d968589d8 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Kojto 90:cb3d968589d8 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Kojto 90:cb3d968589d8 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Kojto 90:cb3d968589d8 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Kojto 90:cb3d968589d8 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Kojto 90:cb3d968589d8 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Kojto 90:cb3d968589d8 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Kojto 90:cb3d968589d8 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Kojto 90:cb3d968589d8 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Kojto 90:cb3d968589d8 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Kojto 90:cb3d968589d8 34 *
Kojto 90:cb3d968589d8 35 ******************************************************************************
Kojto 90:cb3d968589d8 36 */
Kojto 90:cb3d968589d8 37
Kojto 90:cb3d968589d8 38 /* Define to prevent recursive inclusion -------------------------------------*/
Kojto 90:cb3d968589d8 39 #ifndef __STM32L1xx_HAL_OPAMP_H
Kojto 90:cb3d968589d8 40 #define __STM32L1xx_HAL_OPAMP_H
Kojto 90:cb3d968589d8 41
Kojto 90:cb3d968589d8 42 #ifdef __cplusplus
Kojto 90:cb3d968589d8 43 extern "C" {
Kojto 90:cb3d968589d8 44 #endif
Kojto 90:cb3d968589d8 45
Kojto 90:cb3d968589d8 46 #if defined (STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined (STM32L151xE) || defined (STM32L152xE) || defined (STM32L162xE) || defined (STM32L162xC) || defined (STM32L152xC) || defined (STM32L151xC)
Kojto 90:cb3d968589d8 47
Kojto 90:cb3d968589d8 48 /* Includes ------------------------------------------------------------------*/
Kojto 90:cb3d968589d8 49 #include "stm32l1xx_hal_def.h"
Kojto 90:cb3d968589d8 50
Kojto 90:cb3d968589d8 51 /** @addtogroup STM32L1xx_HAL_Driver
Kojto 90:cb3d968589d8 52 * @{
Kojto 90:cb3d968589d8 53 */
Kojto 90:cb3d968589d8 54
Kojto 90:cb3d968589d8 55 /** @addtogroup OPAMP
Kojto 90:cb3d968589d8 56 * @{
Kojto 90:cb3d968589d8 57 */
Kojto 90:cb3d968589d8 58
Kojto 90:cb3d968589d8 59 /* Exported types ------------------------------------------------------------*/
Kojto 90:cb3d968589d8 60
Kojto 90:cb3d968589d8 61 /** @defgroup OPAMP_Exported_Types OPAMP Exported Types
Kojto 90:cb3d968589d8 62 * @{
Kojto 90:cb3d968589d8 63 */
Kojto 90:cb3d968589d8 64 /**
Kojto 90:cb3d968589d8 65 * @brief OPAMP Init structure definition
Kojto 90:cb3d968589d8 66 */
Kojto 90:cb3d968589d8 67
Kojto 90:cb3d968589d8 68 typedef struct
Kojto 90:cb3d968589d8 69 {
Kojto 90:cb3d968589d8 70 uint32_t PowerSupplyRange; /*!< Specifies the power supply range: above or under 2.4V.
Kojto 90:cb3d968589d8 71 This parameter must be a value of @ref OPAMP_PowerSupplyRange
Kojto 90:cb3d968589d8 72 Caution: This parameter is common to all OPAMP instances: a modification of this parameter for the selected OPAMP impacts the other OPAMP instances. */
Kojto 90:cb3d968589d8 73
Kojto 90:cb3d968589d8 74 uint32_t UserTrimming; /*!< Specifies the trimming mode
Kojto 90:cb3d968589d8 75 This parameter must be a value of @ref OPAMP_UserTrimming
Kojto 90:cb3d968589d8 76 UserTrimming is either factory or user trimming.
Kojto 90:cb3d968589d8 77 Caution: This parameter is common to all OPAMP instances: a modification of this parameter for the selected OPAMP impacts the other OPAMP instances. */
Kojto 90:cb3d968589d8 78
Kojto 90:cb3d968589d8 79 uint32_t Mode; /*!< Specifies the OPAMP mode
Kojto 90:cb3d968589d8 80 This parameter must be a value of @ref OPAMP_Mode
Kojto 90:cb3d968589d8 81 mode is either Standalone or Follower */
Kojto 90:cb3d968589d8 82
Kojto 90:cb3d968589d8 83 uint32_t InvertingInput; /*!< Specifies the inverting input in Standalone mode
Kojto 90:cb3d968589d8 84 - In Standalone mode: i.e when mode is OPAMP_STANDALONE_MODE
Kojto 90:cb3d968589d8 85 This parameter must be a value of @ref OPAMP_InvertingInput
Kojto 90:cb3d968589d8 86 InvertingInput is either VM0 or VM1
Kojto 90:cb3d968589d8 87 - In Follower mode: i.e when mode is OPAMP_FOLLOWER_MODE
Kojto 90:cb3d968589d8 88 This parameter is Not Applicable */
Kojto 90:cb3d968589d8 89
Kojto 90:cb3d968589d8 90 uint32_t NonInvertingInput; /*!< Specifies the non inverting input of the opamp:
Kojto 90:cb3d968589d8 91 This parameter must be a value of @ref OPAMP_NonInvertingInput
Kojto 90:cb3d968589d8 92 NonInvertingInput is either VP0, VP1 or VP2 */
Kojto 90:cb3d968589d8 93
Kojto 90:cb3d968589d8 94 uint32_t PowerMode; /*!< Specifies the power mode Normal or Low-Power.
Kojto 90:cb3d968589d8 95 This parameter must be a value of @ref OPAMP_PowerMode */
Kojto 90:cb3d968589d8 96
Kojto 90:cb3d968589d8 97 uint32_t TrimmingValueP; /*!< Specifies the offset trimming value (PMOS)
Kojto 90:cb3d968589d8 98 i.e. when UserTrimming is OPAMP_TRIMMING_USER.
Kojto 90:cb3d968589d8 99 This parameter must be a number between Min_Data = 0 and Max_Data = 30 (Trimming value 31 is forbidden) */
Kojto 90:cb3d968589d8 100
Kojto 90:cb3d968589d8 101 uint32_t TrimmingValueN; /*!< Specifies the offset trimming value (NMOS)
Kojto 90:cb3d968589d8 102 i.e. when UserTrimming is OPAMP_TRIMMING_USER.
Kojto 90:cb3d968589d8 103 This parameter must be a number between Min_Data = 0 and Max_Data = 30 (Trimming value 31 is forbidden) */
Kojto 90:cb3d968589d8 104
Kojto 90:cb3d968589d8 105 uint32_t TrimmingValuePLowPower; /*!< Specifies the offset trimming value (PMOS)
Kojto 90:cb3d968589d8 106 i.e. when UserTrimming is OPAMP_TRIMMING_USER.
Kojto 90:cb3d968589d8 107 This parameter must be a number between Min_Data = 0 and Max_Data = 30 (Trimming value 31 is forbidden) */
Kojto 90:cb3d968589d8 108
Kojto 90:cb3d968589d8 109 uint32_t TrimmingValueNLowPower; /*!< Specifies the offset trimming value (NMOS)
Kojto 90:cb3d968589d8 110 i.e. when UserTrimming is OPAMP_TRIMMING_USER.
Kojto 90:cb3d968589d8 111 This parameter must be a number between Min_Data = 0 and Max_Data = 30 (Trimming value 31 is forbidden) */
Kojto 90:cb3d968589d8 112
Kojto 90:cb3d968589d8 113 }OPAMP_InitTypeDef;
Kojto 90:cb3d968589d8 114
Kojto 90:cb3d968589d8 115 /**
Kojto 90:cb3d968589d8 116 * @brief HAL State structures definition
Kojto 90:cb3d968589d8 117 */
Kojto 90:cb3d968589d8 118
Kojto 90:cb3d968589d8 119 typedef enum
Kojto 90:cb3d968589d8 120 {
Kojto 90:cb3d968589d8 121 HAL_OPAMP_STATE_RESET = 0x00000000, /*!< OPMAP is not yet Initialized */
Kojto 90:cb3d968589d8 122
Kojto 90:cb3d968589d8 123 HAL_OPAMP_STATE_READY = 0x00000001, /*!< OPAMP is initialized and ready for use */
Kojto 90:cb3d968589d8 124 HAL_OPAMP_STATE_CALIBBUSY = 0x00000002, /*!< OPAMP is enabled in auto calibration mode */
Kojto 90:cb3d968589d8 125
Kojto 90:cb3d968589d8 126 HAL_OPAMP_STATE_BUSY = 0x00000004, /*!< OPAMP is enabled and running in normal mode */
Kojto 90:cb3d968589d8 127 HAL_OPAMP_STATE_BUSYLOCKED = 0x00000005, /*!< OPAMP is locked
Kojto 90:cb3d968589d8 128 only system reset allows reconfiguring the opamp. */
Kojto 90:cb3d968589d8 129
Kojto 90:cb3d968589d8 130 }HAL_OPAMP_StateTypeDef;
Kojto 90:cb3d968589d8 131
Kojto 90:cb3d968589d8 132 /**
Kojto 90:cb3d968589d8 133 * @brief OPAMP Handle Structure definition
Kojto 90:cb3d968589d8 134 */
Kojto 90:cb3d968589d8 135 typedef struct
Kojto 90:cb3d968589d8 136 {
Kojto 90:cb3d968589d8 137 OPAMP_TypeDef *Instance; /*!< OPAMP instance's registers base address */
Kojto 90:cb3d968589d8 138 OPAMP_InitTypeDef Init; /*!< OPAMP required parameters */
Kojto 90:cb3d968589d8 139 HAL_StatusTypeDef Status; /*!< OPAMP peripheral status */
Kojto 90:cb3d968589d8 140 HAL_LockTypeDef Lock; /*!< Locking object */
Kojto 90:cb3d968589d8 141 __IO HAL_OPAMP_StateTypeDef State; /*!< OPAMP communication state */
Kojto 90:cb3d968589d8 142
Kojto 90:cb3d968589d8 143 } OPAMP_HandleTypeDef;
Kojto 90:cb3d968589d8 144
Kojto 90:cb3d968589d8 145 /**
Kojto 90:cb3d968589d8 146 * @brief OPAMP_TrimmingValueTypeDef @brief definition
Kojto 90:cb3d968589d8 147 */
Kojto 90:cb3d968589d8 148
Kojto 90:cb3d968589d8 149 typedef uint32_t OPAMP_TrimmingValueTypeDef;
Kojto 90:cb3d968589d8 150
Kojto 90:cb3d968589d8 151 /**
Kojto 90:cb3d968589d8 152 * @}
Kojto 90:cb3d968589d8 153 */
Kojto 90:cb3d968589d8 154
Kojto 90:cb3d968589d8 155 /* Exported constants --------------------------------------------------------*/
Kojto 90:cb3d968589d8 156 /** @defgroup OPAMP_Exported_Constants OPAMP Exported Constants
Kojto 90:cb3d968589d8 157 * @{
Kojto 90:cb3d968589d8 158 */
Kojto 90:cb3d968589d8 159
Kojto 90:cb3d968589d8 160 /**
Kojto 90:cb3d968589d8 161 * OTR register Mask
Kojto 90:cb3d968589d8 162 */
Kojto 90:cb3d968589d8 163 #define OPAMP_TRIM_VALUE_MASK OPAMP_OTR_AO1_OPT_OFFSET_TRIM_LOW
Kojto 90:cb3d968589d8 164
Kojto 90:cb3d968589d8 165 /**
Kojto 90:cb3d968589d8 166 * CSR register Mask
Kojto 90:cb3d968589d8 167 */
Kojto 90:cb3d968589d8 168 #define OPAMP_CSR_INSTANCE_OFFSET ((uint32_t) 8) /* Offset of each OPAMP instance into register CSR */
Kojto 90:cb3d968589d8 169 #define OPAMP_OTR_INSTANCE_OFFSET ((uint32_t) 10) /* Offset of each OPAMP instance into register OTR */
Kojto 90:cb3d968589d8 170
Kojto 90:cb3d968589d8 171
Kojto 90:cb3d968589d8 172 /** @defgroup OPAMP_Mode OPAMP Mode
Kojto 90:cb3d968589d8 173 * @{
Kojto 90:cb3d968589d8 174 */
Kojto 90:cb3d968589d8 175 #define OPAMP_STANDALONE_MODE ((uint32_t)0x00000000) /*!< OPAMP standalone mode */
Kojto 90:cb3d968589d8 176 #define OPAMP_FOLLOWER_MODE ((uint32_t)0x00000001) /*!< OPAMP follower mode */
Kojto 90:cb3d968589d8 177
Kojto 90:cb3d968589d8 178 #define IS_OPAMP_FUNCTIONAL_NORMALMODE(INPUT) (((INPUT) == OPAMP_STANDALONE_MODE) || \
Kojto 90:cb3d968589d8 179 ((INPUT) == OPAMP_FOLLOWER_MODE))
Kojto 90:cb3d968589d8 180 /**
Kojto 90:cb3d968589d8 181 * @}
Kojto 90:cb3d968589d8 182 */
Kojto 90:cb3d968589d8 183
Kojto 90:cb3d968589d8 184 /** @defgroup OPAMP_NonInvertingInput OPAMP NonInvertingInput
Kojto 90:cb3d968589d8 185 * @{
Kojto 90:cb3d968589d8 186 */
Kojto 90:cb3d968589d8 187 #define OPAMP_NONINVERTINGINPUT_VP0 ((uint32_t)0x00000000) /*!< Comparator non-inverting input connected to dedicated IO pin low-leakage */
Kojto 90:cb3d968589d8 188 #define OPAMP_NONINVERTINGINPUT_DAC_CH1 ((uint32_t)0x00000001) /*!< Comparator non-inverting input connected internally to DAC channel 1 */
Kojto 90:cb3d968589d8 189 #define OPAMP_NONINVERTINGINPUT_DAC_CH2 ((uint32_t)0x00000002) /*!< Comparator non-inverting input connected internally to DAC channel 2. Available on OPAMP2 only. */
Kojto 90:cb3d968589d8 190
Kojto 90:cb3d968589d8 191 #define IS_OPAMP_NONINVERTING_INPUT(INPUT) (((INPUT) == OPAMP_NONINVERTINGINPUT_VP0) || \
Kojto 90:cb3d968589d8 192 ((INPUT) == OPAMP_NONINVERTINGINPUT_DAC_CH1) || \
Kojto 90:cb3d968589d8 193 ((INPUT) == OPAMP_NONINVERTINGINPUT_DAC_CH2) )
Kojto 90:cb3d968589d8 194 /**
Kojto 90:cb3d968589d8 195 * @}
Kojto 90:cb3d968589d8 196 */
Kojto 90:cb3d968589d8 197
Kojto 90:cb3d968589d8 198 /** @defgroup OPAMP_InvertingInput OPAMP InvertingInput
Kojto 90:cb3d968589d8 199 * @{
Kojto 90:cb3d968589d8 200 */
Kojto 90:cb3d968589d8 201 #define OPAMP_INVERTINGINPUT_VM0 ((uint32_t)0x00000000) /*!< Comparator inverting input connected to dedicated IO pin low-leakage */
Kojto 90:cb3d968589d8 202 #define OPAMP_INVERTINGINPUT_VM1 ((uint32_t)0x00000001) /*!< Comparator inverting input connected to alternative IO pin available on some device packages */
Kojto 90:cb3d968589d8 203
Kojto 90:cb3d968589d8 204 #define OPAMP_INVERTINGINPUT_VINM OPAMP_INVERTINGINPUT_VM1 /*!< Alternate name for comparator inverting input connected to alternative IO pin available on some device packages */
Kojto 90:cb3d968589d8 205
Kojto 90:cb3d968589d8 206 #define IOPAMP_INVERTINGINPUT_VM0 OPAMP_INVERTINGINPUT_VM0 /* For compatibility with other STM32 devices */
Kojto 90:cb3d968589d8 207 #define IOPAMP_INVERTINGINPUT_VM1 OPAMP_INVERTINGINPUT_VM1 /* For compatibility with other STM32 devices */
Kojto 90:cb3d968589d8 208
Kojto 90:cb3d968589d8 209 #define IS_OPAMP_INVERTING_INPUT(INPUT) (((INPUT) == OPAMP_INVERTINGINPUT_VM0) || \
Kojto 90:cb3d968589d8 210 ((INPUT) == OPAMP_INVERTINGINPUT_VM1) )
Kojto 90:cb3d968589d8 211 /**
Kojto 90:cb3d968589d8 212 * @}
Kojto 90:cb3d968589d8 213 */
Kojto 90:cb3d968589d8 214
Kojto 90:cb3d968589d8 215 /** @defgroup OPAMP_PowerMode OPAMP PowerMode
Kojto 90:cb3d968589d8 216 * @{
Kojto 90:cb3d968589d8 217 */
Kojto 90:cb3d968589d8 218 #define OPAMP_POWERMODE_NORMAL ((uint32_t)0x00000000)
Kojto 90:cb3d968589d8 219 #define OPAMP_POWERMODE_LOWPOWER ((uint32_t)0x00000001)
Kojto 90:cb3d968589d8 220
Kojto 90:cb3d968589d8 221 #define IS_OPAMP_POWERMODE(TRIMMING) (((TRIMMING) == OPAMP_POWERMODE_NORMAL) || \
Kojto 90:cb3d968589d8 222 ((TRIMMING) == OPAMP_POWERMODE_LOWPOWER) )
Kojto 90:cb3d968589d8 223 /**
Kojto 90:cb3d968589d8 224 * @}
Kojto 90:cb3d968589d8 225 */
Kojto 90:cb3d968589d8 226
Kojto 90:cb3d968589d8 227 /** @defgroup OPAMP_PowerSupplyRange OPAMP PowerSupplyRange
Kojto 90:cb3d968589d8 228 * @{
Kojto 90:cb3d968589d8 229 */
Kojto 90:cb3d968589d8 230 #define OPAMP_POWERSUPPLY_LOW ((uint32_t)0x00000000) /*!< Power supply range low (VDDA lower than 2.4V) */
Kojto 90:cb3d968589d8 231 #define OPAMP_POWERSUPPLY_HIGH OPAMP_CSR_AOP_RANGE /*!< Power supply range high (VDDA higher than 2.4V) */
Kojto 90:cb3d968589d8 232
Kojto 90:cb3d968589d8 233 #define IS_OPAMP_POWER_SUPPLY_RANGE(RANGE) (((RANGE) == OPAMP_POWERSUPPLY_LOW) || \
Kojto 90:cb3d968589d8 234 ((RANGE) == OPAMP_POWERSUPPLY_HIGH) )
Kojto 90:cb3d968589d8 235 /**
Kojto 90:cb3d968589d8 236 * @}
Kojto 90:cb3d968589d8 237 */
Kojto 90:cb3d968589d8 238
Kojto 90:cb3d968589d8 239 /** @defgroup OPAMP_UserTrimming OPAMP UserTrimming
Kojto 90:cb3d968589d8 240 * @{
Kojto 90:cb3d968589d8 241 */
Kojto 90:cb3d968589d8 242 #define OPAMP_TRIMMING_FACTORY ((uint32_t)0x00000000) /*!< Factory trimming */
Kojto 90:cb3d968589d8 243 #define OPAMP_TRIMMING_USER OPAMP_OTR_OT_USER /*!< User trimming */
Kojto 90:cb3d968589d8 244
Kojto 90:cb3d968589d8 245 #define IS_OPAMP_TRIMMING(TRIMMING) (((TRIMMING) == OPAMP_TRIMMING_FACTORY) || \
Kojto 90:cb3d968589d8 246 ((TRIMMING) == OPAMP_TRIMMING_USER))
Kojto 90:cb3d968589d8 247 /**
Kojto 90:cb3d968589d8 248 * @}
Kojto 90:cb3d968589d8 249 */
Kojto 90:cb3d968589d8 250
Kojto 90:cb3d968589d8 251 /** @defgroup OPAMP_FactoryTrimming OPAMP FactoryTrimming
Kojto 90:cb3d968589d8 252 * @{
Kojto 90:cb3d968589d8 253 */
Kojto 90:cb3d968589d8 254 #define OPAMP_FACTORYTRIMMING_DUMMY ((uint32_t)0xFFFFFFFF) /*!< Dummy value if trimming value could not be retrieved */
Kojto 90:cb3d968589d8 255
Kojto 90:cb3d968589d8 256 #define OPAMP_FACTORYTRIMMING_P ((uint32_t)0x00000000) /*!< Offset trimming P */
Kojto 90:cb3d968589d8 257 #define OPAMP_FACTORYTRIMMING_N POSITION_VAL(OPAMP_OTR_AO1_OPT_OFFSET_TRIM_HIGH) /*!< Offset trimming N */
Kojto 90:cb3d968589d8 258
Kojto 90:cb3d968589d8 259 #define IS_OPAMP_FACTORYTRIMMING(TRIMMING) (((TRIMMING) == OPAMP_FACTORYTRIMMING_N) || \
Kojto 90:cb3d968589d8 260 ((TRIMMING) == OPAMP_FACTORYTRIMMING_P) )
Kojto 90:cb3d968589d8 261 /**
Kojto 90:cb3d968589d8 262 * @}
Kojto 90:cb3d968589d8 263 */
Kojto 90:cb3d968589d8 264
Kojto 90:cb3d968589d8 265 /**
Kojto 90:cb3d968589d8 266 * @}
Kojto 90:cb3d968589d8 267 */
Kojto 90:cb3d968589d8 268
Kojto 90:cb3d968589d8 269 /* Private constants ---------------------------------------------------------*/
Kojto 90:cb3d968589d8 270 /** @defgroup OPAMP_Private_Constants OPAMP Private Constants
Kojto 90:cb3d968589d8 271 * @{
Kojto 90:cb3d968589d8 272 */
Kojto 90:cb3d968589d8 273
Kojto 90:cb3d968589d8 274 /* Offset trimming time: during calibration, minimum time needed between two */
Kojto 90:cb3d968589d8 275 /* steps to have 1 mV accuracy. */
Kojto 90:cb3d968589d8 276 /* Refer to datasheet, electrical characteristics: parameter tOFFTRIM Typ=1ms.*/
Kojto 90:cb3d968589d8 277 /* Unit: ms. */
Kojto 90:cb3d968589d8 278 #define OPAMP_TRIMMING_DELAY ((uint32_t) 1)
Kojto 90:cb3d968589d8 279
Kojto 90:cb3d968589d8 280 /**
Kojto 90:cb3d968589d8 281 * @}
Kojto 90:cb3d968589d8 282 */
Kojto 90:cb3d968589d8 283
Kojto 90:cb3d968589d8 284
Kojto 90:cb3d968589d8 285 /* Exported macros -----------------------------------------------------------*/
Kojto 90:cb3d968589d8 286
Kojto 90:cb3d968589d8 287 /** @defgroup OPAMP_Private_Macro OPAMP Private Macro
Kojto 90:cb3d968589d8 288 * @{
Kojto 90:cb3d968589d8 289 */
Kojto 90:cb3d968589d8 290
Kojto 90:cb3d968589d8 291 /** @brief Reset OPAMP handle state
Kojto 90:cb3d968589d8 292 * @param __HANDLE__: OPAMP handle.
Kojto 90:cb3d968589d8 293 * @retval None
Kojto 90:cb3d968589d8 294 */
Kojto 90:cb3d968589d8 295 #define __HAL_OPAMP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_OPAMP_STATE_RESET)
Kojto 90:cb3d968589d8 296
Kojto 90:cb3d968589d8 297 /**
Kojto 90:cb3d968589d8 298 * @}
Kojto 90:cb3d968589d8 299 */
Kojto 90:cb3d968589d8 300
Kojto 90:cb3d968589d8 301
Kojto 90:cb3d968589d8 302 /* Private macro -------------------------------------------------------------*/
Kojto 90:cb3d968589d8 303
Kojto 90:cb3d968589d8 304 /** @defgroup OPAMP_Private_Macro OPAMP Private Macro
Kojto 90:cb3d968589d8 305 * @{
Kojto 90:cb3d968589d8 306 */
Kojto 90:cb3d968589d8 307
Kojto 90:cb3d968589d8 308 /**
Kojto 90:cb3d968589d8 309 * @brief Select the OPAMP bit OPAxPD (power-down) corresponding to the
Kojto 90:cb3d968589d8 310 * selected OPAMP instance.
Kojto 90:cb3d968589d8 311 * @param __HANDLE__: OPAMP handle
Kojto 90:cb3d968589d8 312 * @retval None
Kojto 90:cb3d968589d8 313 */
Kojto 90:cb3d968589d8 314 #define __OPAMP_CSR_OPAXPD(__HANDLE__) \
Kojto 90:cb3d968589d8 315 (OPAMP_CSR_OPA1PD << (__OPAMP_INSTANCE_DECIMAL__(__HANDLE__) * OPAMP_CSR_INSTANCE_OFFSET))
Kojto 90:cb3d968589d8 316
Kojto 90:cb3d968589d8 317 /**
Kojto 90:cb3d968589d8 318 * @brief Select the OPAMP bit S3SELx (switch 3) corresponding to the
Kojto 90:cb3d968589d8 319 * selected OPAMP instance.
Kojto 90:cb3d968589d8 320 * @param __HANDLE__: OPAMP handle
Kojto 90:cb3d968589d8 321 * @retval None
Kojto 90:cb3d968589d8 322 */
Kojto 90:cb3d968589d8 323 #define __OPAMP_CSR_S3SELX(__HANDLE__) \
Kojto 90:cb3d968589d8 324 (OPAMP_CSR_S3SEL1 << (__OPAMP_INSTANCE_DECIMAL__(__HANDLE__) * OPAMP_CSR_INSTANCE_OFFSET))
Kojto 90:cb3d968589d8 325
Kojto 90:cb3d968589d8 326 /**
Kojto 90:cb3d968589d8 327 * @brief Select the OPAMP bit S4SELx (switch 4) corresponding to the
Kojto 90:cb3d968589d8 328 * selected OPAMP instance.
Kojto 90:cb3d968589d8 329 * @param __HANDLE__: OPAMP handle
Kojto 90:cb3d968589d8 330 * @retval None
Kojto 90:cb3d968589d8 331 */
Kojto 90:cb3d968589d8 332 #define __OPAMP_CSR_S4SELX(__HANDLE__) \
Kojto 90:cb3d968589d8 333 (OPAMP_CSR_S4SEL1 << (__OPAMP_INSTANCE_DECIMAL__(__HANDLE__) * OPAMP_CSR_INSTANCE_OFFSET))
Kojto 90:cb3d968589d8 334
Kojto 90:cb3d968589d8 335 /**
Kojto 90:cb3d968589d8 336 * @brief Select the OPAMP bit S5SELx (switch 5) corresponding to the
Kojto 90:cb3d968589d8 337 * selected OPAMP instance.
Kojto 90:cb3d968589d8 338 * @param __HANDLE__: OPAMP handle
Kojto 90:cb3d968589d8 339 * @retval None
Kojto 90:cb3d968589d8 340 */
Kojto 90:cb3d968589d8 341 #define __OPAMP_CSR_S5SELX(__HANDLE__) \
Kojto 90:cb3d968589d8 342 (OPAMP_CSR_S5SEL1 << (__OPAMP_INSTANCE_DECIMAL__(__HANDLE__) * OPAMP_CSR_INSTANCE_OFFSET))
Kojto 90:cb3d968589d8 343
Kojto 90:cb3d968589d8 344 /**
Kojto 90:cb3d968589d8 345 * @brief Select the OPAMP bit S3SELx (switch 6) corresponding to the
Kojto 90:cb3d968589d8 346 * selected OPAMP instance.
Kojto 90:cb3d968589d8 347 * @param __HANDLE__: OPAMP handle
Kojto 90:cb3d968589d8 348 * @retval None
Kojto 90:cb3d968589d8 349 */
Kojto 90:cb3d968589d8 350 #define __OPAMP_CSR_S6SELX(__HANDLE__) \
Kojto 90:cb3d968589d8 351 (OPAMP_CSR_S6SEL1 << (__OPAMP_INSTANCE_DECIMAL__(__HANDLE__) * OPAMP_CSR_INSTANCE_OFFSET))
Kojto 90:cb3d968589d8 352
Kojto 90:cb3d968589d8 353 /**
Kojto 90:cb3d968589d8 354 * @brief Select the OPAMP bit OPAxCAL_L (offset calibration for differential
Kojto 90:cb3d968589d8 355 * pair P) corresponding to the selected OPAMP instance.
Kojto 90:cb3d968589d8 356 * @param __HANDLE__: OPAMP handle
Kojto 90:cb3d968589d8 357 * @retval None
Kojto 90:cb3d968589d8 358 */
Kojto 90:cb3d968589d8 359 #define __OPAMP_CSR_OPAXCAL_L(__HANDLE__) \
Kojto 90:cb3d968589d8 360 (OPAMP_CSR_OPA1CAL_L << (__OPAMP_INSTANCE_DECIMAL__(__HANDLE__) * OPAMP_CSR_INSTANCE_OFFSET))
Kojto 90:cb3d968589d8 361
Kojto 90:cb3d968589d8 362 /**
Kojto 90:cb3d968589d8 363 * @brief Select the OPAMP bit OPAxCAL_H (offset calibration for differential
Kojto 90:cb3d968589d8 364 * pair N) corresponding to the selected OPAMP instance.
Kojto 90:cb3d968589d8 365 * @param __HANDLE__: OPAMP handle
Kojto 90:cb3d968589d8 366 * @retval None
Kojto 90:cb3d968589d8 367 */
Kojto 90:cb3d968589d8 368 #define __OPAMP_CSR_OPAXCAL_H(__HANDLE__) \
Kojto 90:cb3d968589d8 369 (OPAMP_CSR_OPA1CAL_H << (__OPAMP_INSTANCE_DECIMAL__(__HANDLE__) * OPAMP_CSR_INSTANCE_OFFSET))
Kojto 90:cb3d968589d8 370
Kojto 90:cb3d968589d8 371 /**
Kojto 90:cb3d968589d8 372 * @brief Select the OPAMP bit OPAxLPM (low power mode) corresponding to the
Kojto 90:cb3d968589d8 373 * selected OPAMP instance.
Kojto 90:cb3d968589d8 374 * @param __HANDLE__: OPAMP handle
Kojto 90:cb3d968589d8 375 * @retval None
Kojto 90:cb3d968589d8 376 */
Kojto 90:cb3d968589d8 377 #define __OPAMP_CSR_OPAXLPM(__HANDLE__) \
Kojto 90:cb3d968589d8 378 (OPAMP_CSR_OPA1LPM << (__OPAMP_INSTANCE_DECIMAL__(__HANDLE__) * OPAMP_CSR_INSTANCE_OFFSET))
Kojto 90:cb3d968589d8 379
Kojto 90:cb3d968589d8 380 /**
Kojto 90:cb3d968589d8 381 * @brief Select the OPAMP bits of all switches corresponding to the
Kojto 90:cb3d968589d8 382 * selected OPAMP instance.
Kojto 90:cb3d968589d8 383 * @param __HANDLE__: OPAMP handle
Kojto 90:cb3d968589d8 384 * @retval None
Kojto 90:cb3d968589d8 385 */
Kojto 90:cb3d968589d8 386 #define __OPAMP_CSR_ALL_SWITCHES(__HANDLE__) \
Kojto 90:cb3d968589d8 387 ( ( ((__HANDLE__)->Instance != OPAMP2) \
Kojto 90:cb3d968589d8 388 )? \
Kojto 90:cb3d968589d8 389 ( \
Kojto 90:cb3d968589d8 390 ((OPAMP_CSR_S3SEL1 | OPAMP_CSR_S4SEL1 | OPAMP_CSR_S5SEL1 | OPAMP_CSR_S6SEL1) << (__OPAMP_INSTANCE_DECIMAL__(__HANDLE__) * OPAMP_CSR_INSTANCE_OFFSET)) \
Kojto 90:cb3d968589d8 391 | \
Kojto 90:cb3d968589d8 392 (OPAMP_CSR_ANAWSEL1 << (__OPAMP_INSTANCE_DECIMAL__(__HANDLE__))) \
Kojto 90:cb3d968589d8 393 ) \
Kojto 90:cb3d968589d8 394 : \
Kojto 90:cb3d968589d8 395 ( \
Kojto 90:cb3d968589d8 396 ((OPAMP_CSR_S3SEL1 | OPAMP_CSR_S4SEL1 | OPAMP_CSR_S5SEL1 | OPAMP_CSR_S6SEL1) << (__OPAMP_INSTANCE_DECIMAL__(__HANDLE__) * OPAMP_CSR_INSTANCE_OFFSET)) \
Kojto 90:cb3d968589d8 397 | \
Kojto 90:cb3d968589d8 398 (OPAMP_CSR_ANAWSEL1 << (__OPAMP_INSTANCE_DECIMAL__(__HANDLE__))) \
Kojto 90:cb3d968589d8 399 | \
Kojto 90:cb3d968589d8 400 (OPAMP_CSR_S7SEL2) \
Kojto 90:cb3d968589d8 401 ) \
Kojto 90:cb3d968589d8 402 )
Kojto 90:cb3d968589d8 403
Kojto 90:cb3d968589d8 404 /**
Kojto 90:cb3d968589d8 405 * @brief Select the OPAMP bit ANAWSELx (switch SanA) corresponding to the
Kojto 90:cb3d968589d8 406 * selected OPAMP instance.
Kojto 90:cb3d968589d8 407 * @param __HANDLE__: OPAMP handle
Kojto 90:cb3d968589d8 408 * @retval None
Kojto 90:cb3d968589d8 409 */
Kojto 90:cb3d968589d8 410 #define __OPAMP_CSR_ANAWSELX(__HANDLE__) \
Kojto 90:cb3d968589d8 411 (OPAMP_CSR_ANAWSEL1 << (__OPAMP_INSTANCE_DECIMAL__(__HANDLE__)))
Kojto 90:cb3d968589d8 412
Kojto 90:cb3d968589d8 413 /**
Kojto 90:cb3d968589d8 414 * @brief Select the OPAMP bit OPAxCALOUT in function of the selected
Kojto 90:cb3d968589d8 415 * OPAMP instance.
Kojto 90:cb3d968589d8 416 * @param __HANDLE__: OPAMP handle
Kojto 90:cb3d968589d8 417 * @retval None
Kojto 90:cb3d968589d8 418 */
Kojto 90:cb3d968589d8 419 #define __OPAMP_CSR_OPAXCALOUT(__HANDLE__) \
Kojto 90:cb3d968589d8 420 (OPAMP_CSR_OPA1CALOUT << (__OPAMP_INSTANCE_DECIMAL__(__HANDLE__)))
Kojto 90:cb3d968589d8 421
Kojto 90:cb3d968589d8 422 /**
Kojto 90:cb3d968589d8 423 * @brief Select the OPAMP trimming bits position value (position of LSB)
Kojto 90:cb3d968589d8 424 * in register OPAMP_OTR or register OPAMP_LPOTR in function of the selected
Kojto 90:cb3d968589d8 425 * OPAMP instance and the transistors differential pair high (PMOS) or
Kojto 90:cb3d968589d8 426 * low (NMOS).
Kojto 90:cb3d968589d8 427 * @param __HANDLE__: OPAMP handle
Kojto 90:cb3d968589d8 428 * @param __TRIM_HIGH_LOW__: transistors differential pair high or low.
Kojto 90:cb3d968589d8 429 * Must be a value of @ref OPAMP_FactoryTrimming.
Kojto 90:cb3d968589d8 430 * @retval None
Kojto 90:cb3d968589d8 431 */
Kojto 90:cb3d968589d8 432 #define __OPAMP_OFFSET_TRIM_BITSPOSITION(__HANDLE__, __TRIM_HIGH_LOW__) \
Kojto 90:cb3d968589d8 433 ((__OPAMP_INSTANCE_DECIMAL__((__HANDLE__)) * OPAMP_OTR_INSTANCE_OFFSET) + (__TRIM_HIGH_LOW__))
Kojto 90:cb3d968589d8 434
Kojto 90:cb3d968589d8 435 /**
Kojto 90:cb3d968589d8 436 * @brief Shift the OPAMP trimming bits to register OPAMP_OTR or register
Kojto 90:cb3d968589d8 437 * OPAMP_LPOTR in function of the selected OPAMP instance and the transistors
Kojto 90:cb3d968589d8 438 * differential pair high (PMOS) or low (NMOS).
Kojto 90:cb3d968589d8 439 * @param __HANDLE__: OPAMP handle
Kojto 90:cb3d968589d8 440 * @param __TRIM_HIGH_LOW__: transistors differential pair high or low.
Kojto 90:cb3d968589d8 441 * Must be a value of @ref OPAMP_FactoryTrimming.
Kojto 90:cb3d968589d8 442 * @param __TRIMMING_VALUE__: Trimming value
Kojto 90:cb3d968589d8 443 * @retval None
Kojto 90:cb3d968589d8 444 */
Kojto 90:cb3d968589d8 445 #define __OPAMP_OFFSET_TRIM_SET(__HANDLE__, __TRIM_HIGH_LOW__, __TRIMMING_VALUE__) \
Kojto 90:cb3d968589d8 446 ((__TRIMMING_VALUE__) << (__OPAMP_OFFSET_TRIM_BITSPOSITION((__HANDLE__), (__TRIM_HIGH_LOW__))))
Kojto 90:cb3d968589d8 447
Kojto 90:cb3d968589d8 448 /**
Kojto 90:cb3d968589d8 449 * @brief Check that trimming value is within correct range
Kojto 90:cb3d968589d8 450 * @param TRIMMINGVALUE: OPAMP trimming value
Kojto 90:cb3d968589d8 451 * @retval None
Kojto 90:cb3d968589d8 452 */
Kojto 90:cb3d968589d8 453 #define IS_OPAMP_TRIMMINGVALUE(TRIMMINGVALUE) ((TRIMMINGVALUE) <= 0x1E)
Kojto 90:cb3d968589d8 454
Kojto 90:cb3d968589d8 455 /**
Kojto 90:cb3d968589d8 456 * @}
Kojto 90:cb3d968589d8 457 */
Kojto 90:cb3d968589d8 458
Kojto 90:cb3d968589d8 459
Kojto 90:cb3d968589d8 460 /* Include OPAMP HAL Extension module */
Kojto 90:cb3d968589d8 461 #include "stm32l1xx_hal_opamp_ex.h"
Kojto 90:cb3d968589d8 462
Kojto 90:cb3d968589d8 463 /* Exported functions --------------------------------------------------------*/
Kojto 90:cb3d968589d8 464
Kojto 90:cb3d968589d8 465 /** @addtogroup OPAMP_Exported_Functions
Kojto 90:cb3d968589d8 466 * @{
Kojto 90:cb3d968589d8 467 */
Kojto 90:cb3d968589d8 468
Kojto 90:cb3d968589d8 469 /** @addtogroup OPAMP_Exported_Functions_Group1
Kojto 90:cb3d968589d8 470 * @{
Kojto 90:cb3d968589d8 471 */
Kojto 90:cb3d968589d8 472 /* Initialization/de-initialization functions **********************************/
Kojto 90:cb3d968589d8 473 HAL_StatusTypeDef HAL_OPAMP_Init(OPAMP_HandleTypeDef *hopamp);
Kojto 90:cb3d968589d8 474 HAL_StatusTypeDef HAL_OPAMP_DeInit (OPAMP_HandleTypeDef *hopamp);
Kojto 90:cb3d968589d8 475 void HAL_OPAMP_MspInit(OPAMP_HandleTypeDef *hopamp);
Kojto 90:cb3d968589d8 476 void HAL_OPAMP_MspDeInit(OPAMP_HandleTypeDef *hopamp);
Kojto 90:cb3d968589d8 477 /**
Kojto 90:cb3d968589d8 478 * @}
Kojto 90:cb3d968589d8 479 */
Kojto 90:cb3d968589d8 480
Kojto 90:cb3d968589d8 481 /** @addtogroup OPAMP_Exported_Functions_Group2
Kojto 90:cb3d968589d8 482 * @{
Kojto 90:cb3d968589d8 483 */
Kojto 90:cb3d968589d8 484 /* I/O operation functions *****************************************************/
Kojto 90:cb3d968589d8 485 HAL_StatusTypeDef HAL_OPAMP_Start(OPAMP_HandleTypeDef *hopamp);
Kojto 90:cb3d968589d8 486 HAL_StatusTypeDef HAL_OPAMP_Stop(OPAMP_HandleTypeDef *hopamp);
Kojto 90:cb3d968589d8 487 HAL_StatusTypeDef HAL_OPAMP_SelfCalibrate(OPAMP_HandleTypeDef *hopamp);
Kojto 90:cb3d968589d8 488 OPAMP_TrimmingValueTypeDef HAL_OPAMP_GetTrimOffset (OPAMP_HandleTypeDef *hopamp, uint32_t trimmingoffset);
Kojto 90:cb3d968589d8 489 /**
Kojto 90:cb3d968589d8 490 * @}
Kojto 90:cb3d968589d8 491 */
Kojto 90:cb3d968589d8 492
Kojto 90:cb3d968589d8 493 /** @addtogroup OPAMP_Exported_Functions_Group3
Kojto 90:cb3d968589d8 494 * @{
Kojto 90:cb3d968589d8 495 */
Kojto 90:cb3d968589d8 496 /* Peripheral Control functions ************************************************/
Kojto 90:cb3d968589d8 497 HAL_StatusTypeDef HAL_OPAMP_Lock(OPAMP_HandleTypeDef *hopamp);
Kojto 90:cb3d968589d8 498 /**
Kojto 90:cb3d968589d8 499 * @}
Kojto 90:cb3d968589d8 500 */
Kojto 90:cb3d968589d8 501
Kojto 90:cb3d968589d8 502 /** @addtogroup OPAMP_Exported_Functions_Group4
Kojto 90:cb3d968589d8 503 * @{
Kojto 90:cb3d968589d8 504 */
Kojto 90:cb3d968589d8 505 /* Peripheral State functions **************************************************/
Kojto 90:cb3d968589d8 506 HAL_OPAMP_StateTypeDef HAL_OPAMP_GetState(OPAMP_HandleTypeDef *hopamp);
Kojto 90:cb3d968589d8 507 /**
Kojto 90:cb3d968589d8 508 * @}
Kojto 90:cb3d968589d8 509 */
Kojto 90:cb3d968589d8 510
Kojto 90:cb3d968589d8 511 /**
Kojto 90:cb3d968589d8 512 * @}
Kojto 90:cb3d968589d8 513 */
Kojto 90:cb3d968589d8 514
Kojto 90:cb3d968589d8 515
Kojto 90:cb3d968589d8 516
Kojto 90:cb3d968589d8 517
Kojto 90:cb3d968589d8 518 /**
Kojto 90:cb3d968589d8 519 * @}
Kojto 90:cb3d968589d8 520 */
Kojto 90:cb3d968589d8 521
Kojto 90:cb3d968589d8 522 /**
Kojto 90:cb3d968589d8 523 * @}
Kojto 90:cb3d968589d8 524 */
Kojto 90:cb3d968589d8 525
Kojto 90:cb3d968589d8 526 #endif /* STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L152xE || STM32L162xE || STM32L162xC || STM32L152xC || STM32L151xC */
Kojto 90:cb3d968589d8 527 #ifdef __cplusplus
Kojto 90:cb3d968589d8 528 }
Kojto 90:cb3d968589d8 529 #endif
Kojto 90:cb3d968589d8 530
Kojto 90:cb3d968589d8 531 #endif /* __STM32L1xx_HAL_OPAMP_H */
Kojto 90:cb3d968589d8 532
Kojto 90:cb3d968589d8 533 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/