modtronix H / mbed_nz32sc151
Committer:
modtronix
Date:
Fri Aug 14 18:48:46 2015 +1000
Revision:
10:6444e6c798ce
Parent:
1:71204b8406f2
Updated to STM32CubeL1 V1.0.3

Who changed what in which revision?

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