my fork

Dependents:   Nucleo_blueNRG

Fork of mbed by mbed official

Committer:
filartrix
Date:
Wed Apr 08 14:12:53 2015 +0000
Revision:
97:4298809c7c9e
Parent:
92:4fc01daae5a5
First reale BlueNRG module for nucleo 401 board

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 86:04dd9b1680ae 1 /**
bogdanm 86:04dd9b1680ae 2 ******************************************************************************
bogdanm 86:04dd9b1680ae 3 * @file stm32f3xx_hal_opamp.h
bogdanm 86:04dd9b1680ae 4 * @author MCD Application Team
bogdanm 92:4fc01daae5a5 5 * @version V1.1.0
bogdanm 92:4fc01daae5a5 6 * @date 12-Sept-2014
bogdanm 86:04dd9b1680ae 7 * @brief Header file of OPAMP HAL module.
bogdanm 86:04dd9b1680ae 8 ******************************************************************************
bogdanm 86:04dd9b1680ae 9 * @attention
bogdanm 86:04dd9b1680ae 10 *
bogdanm 86:04dd9b1680ae 11 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
bogdanm 86:04dd9b1680ae 12 *
bogdanm 86:04dd9b1680ae 13 * Redistribution and use in source and binary forms, with or without modification,
bogdanm 86:04dd9b1680ae 14 * are permitted provided that the following conditions are met:
bogdanm 86:04dd9b1680ae 15 * 1. Redistributions of source code must retain the above copyright notice,
bogdanm 86:04dd9b1680ae 16 * this list of conditions and the following disclaimer.
bogdanm 86:04dd9b1680ae 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
bogdanm 86:04dd9b1680ae 18 * this list of conditions and the following disclaimer in the documentation
bogdanm 86:04dd9b1680ae 19 * and/or other materials provided with the distribution.
bogdanm 86:04dd9b1680ae 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
bogdanm 86:04dd9b1680ae 21 * may be used to endorse or promote products derived from this software
bogdanm 86:04dd9b1680ae 22 * without specific prior written permission.
bogdanm 86:04dd9b1680ae 23 *
bogdanm 86:04dd9b1680ae 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
bogdanm 86:04dd9b1680ae 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
bogdanm 86:04dd9b1680ae 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
bogdanm 86:04dd9b1680ae 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
bogdanm 86:04dd9b1680ae 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
bogdanm 86:04dd9b1680ae 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
bogdanm 86:04dd9b1680ae 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
bogdanm 86:04dd9b1680ae 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
bogdanm 86:04dd9b1680ae 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
bogdanm 86:04dd9b1680ae 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bogdanm 86:04dd9b1680ae 34 *
bogdanm 86:04dd9b1680ae 35 ******************************************************************************
bogdanm 86:04dd9b1680ae 36 */
bogdanm 86:04dd9b1680ae 37
bogdanm 86:04dd9b1680ae 38 /* Define to prevent recursive inclusion -------------------------------------*/
bogdanm 86:04dd9b1680ae 39 #ifndef __STM32F3xx_HAL_OPAMP_H
bogdanm 86:04dd9b1680ae 40 #define __STM32F3xx_HAL_OPAMP_H
bogdanm 86:04dd9b1680ae 41
bogdanm 86:04dd9b1680ae 42 #ifdef __cplusplus
bogdanm 86:04dd9b1680ae 43 extern "C" {
bogdanm 86:04dd9b1680ae 44 #endif
bogdanm 86:04dd9b1680ae 45
bogdanm 92:4fc01daae5a5 46 #if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx) || \
bogdanm 92:4fc01daae5a5 47 defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx) || \
bogdanm 92:4fc01daae5a5 48 defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx) || \
bogdanm 92:4fc01daae5a5 49 defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
bogdanm 86:04dd9b1680ae 50
bogdanm 86:04dd9b1680ae 51 /* Includes ------------------------------------------------------------------*/
bogdanm 86:04dd9b1680ae 52 #include "stm32f3xx_hal_def.h"
bogdanm 86:04dd9b1680ae 53
bogdanm 86:04dd9b1680ae 54 /** @addtogroup STM32F3xx_HAL_Driver
bogdanm 86:04dd9b1680ae 55 * @{
bogdanm 86:04dd9b1680ae 56 */
bogdanm 86:04dd9b1680ae 57
bogdanm 86:04dd9b1680ae 58 /** @addtogroup OPAMP
bogdanm 86:04dd9b1680ae 59 * @{
bogdanm 86:04dd9b1680ae 60 */
bogdanm 86:04dd9b1680ae 61
bogdanm 86:04dd9b1680ae 62 /* Exported types ------------------------------------------------------------*/
bogdanm 92:4fc01daae5a5 63 /** @defgroup OPAMP_Exported_Types OPAMP Exported Types
bogdanm 92:4fc01daae5a5 64 * @{
bogdanm 92:4fc01daae5a5 65 */
bogdanm 86:04dd9b1680ae 66
bogdanm 86:04dd9b1680ae 67 /**
bogdanm 86:04dd9b1680ae 68 * @brief OPAMP Init structure definition
bogdanm 86:04dd9b1680ae 69 */
bogdanm 86:04dd9b1680ae 70
bogdanm 86:04dd9b1680ae 71 typedef struct
bogdanm 86:04dd9b1680ae 72 {
bogdanm 86:04dd9b1680ae 73 uint32_t Mode; /*!< Specifies the OPAMP mode
bogdanm 86:04dd9b1680ae 74 This parameter must be a value of @ref OPAMP_Mode
bogdanm 86:04dd9b1680ae 75 mode is either Standalone, - Follower or PGA */
bogdanm 86:04dd9b1680ae 76
bogdanm 86:04dd9b1680ae 77 uint32_t InvertingInput; /*!< Specifies the inverting input in Standalone & Pga modes
bogdanm 86:04dd9b1680ae 78 - In Standalone mode: i.e when mode is OPAMP_STANDALONE_MODE
bogdanm 86:04dd9b1680ae 79 This parameter must be a value of @ref OPAMP_InvertingInput
bogdanm 86:04dd9b1680ae 80 InvertingInput is either VM0 or VM1
bogdanm 86:04dd9b1680ae 81 - In PGA mode: i.e when mode is OPAMP_PGA_MODE
bogdanm 86:04dd9b1680ae 82 & in Follower mode i.e when mode is OPAMP_FOLLOWER_MODE
bogdanm 86:04dd9b1680ae 83 This parameter is Not Applicable */
bogdanm 86:04dd9b1680ae 84
bogdanm 86:04dd9b1680ae 85 uint32_t NonInvertingInput; /*!< Specifies the non inverting input of the opamp:
bogdanm 86:04dd9b1680ae 86 This parameter must be a value of @ref OPAMP_NonInvertingInput
bogdanm 92:4fc01daae5a5 87 NonInvertingInput is either VP0, VP1, VP2 or VP3 */
bogdanm 86:04dd9b1680ae 88
bogdanm 86:04dd9b1680ae 89 uint32_t TimerControlledMuxmode; /*!< Specifies if the Timer controlled Mux mode is enabled or disabled
bogdanm 86:04dd9b1680ae 90 This parameter must be a value of @ref OPAMP_TimerControlledMuxmode */
bogdanm 86:04dd9b1680ae 91
bogdanm 86:04dd9b1680ae 92 uint32_t InvertingInputSecondary; /*!< Specifies the inverting input (secondary) of the opamp when
bogdanm 86:04dd9b1680ae 93 TimerControlledMuxmode is enabled
bogdanm 86:04dd9b1680ae 94 i.e. when TimerControlledMuxmode is OPAMP_TIMERCONTROLLEDMUXMODE_ENABLE
bogdanm 86:04dd9b1680ae 95 - In Standalone mode: i.e when mode is OPAMP_STANDALONE_MODE
bogdanm 86:04dd9b1680ae 96 This parameter must be a value of @ref OPAMP_InvertingInputSecondary
bogdanm 86:04dd9b1680ae 97 InvertingInputSecondary is either VM0 or VM1
bogdanm 86:04dd9b1680ae 98 - In PGA mode: i.e when mode is OPAMP_PGA_MODE
bogdanm 86:04dd9b1680ae 99 & in Follower mode i.e when mode is OPAMP_FOLLOWER_MODE
bogdanm 86:04dd9b1680ae 100 This parameter is Not Applicable */
bogdanm 86:04dd9b1680ae 101
bogdanm 86:04dd9b1680ae 102 uint32_t NonInvertingInputSecondary; /*!< Specifies the non inverting input (secondary) of the opamp when
bogdanm 86:04dd9b1680ae 103 TimerControlledMuxmode is enabled
bogdanm 86:04dd9b1680ae 104 i.e. when TimerControlledMuxmode is OPAMP_TIMERCONTROLLEDMUXMODE_ENABLE
bogdanm 86:04dd9b1680ae 105 This parameter must be a value of @ref OPAMP_NonInvertingInputSecondary
bogdanm 92:4fc01daae5a5 106 NonInvertingInput is either VP0, VP1, VP2 or VP3 */
bogdanm 86:04dd9b1680ae 107
bogdanm 86:04dd9b1680ae 108 uint32_t PgaConnect; /*!< Specifies the inverting pin in PGA mode
bogdanm 86:04dd9b1680ae 109 i.e. when mode is OPAMP_PGA_MODE
bogdanm 86:04dd9b1680ae 110 This parameter must be a value of @ref OPAMP_PgaConnect
bogdanm 86:04dd9b1680ae 111 Either: not connected, connected to VM0, connected to VM1
bogdanm 86:04dd9b1680ae 112 (VM0 or VM1 are typically used for external filtering) */
bogdanm 86:04dd9b1680ae 113
bogdanm 86:04dd9b1680ae 114 uint32_t PgaGain; /*!< Specifies the gain in PGA mode
bogdanm 86:04dd9b1680ae 115 i.e. when mode is OPAMP_PGA_MODE.
bogdanm 86:04dd9b1680ae 116 This parameter must be a value of @ref OPAMP_PgaGain (2, 4, 8 or 16 ) */
bogdanm 86:04dd9b1680ae 117
bogdanm 86:04dd9b1680ae 118 uint32_t UserTrimming; /*!< Specifies the trimming mode
bogdanm 86:04dd9b1680ae 119 This parameter must be a value of @ref OPAMP_UserTrimming
bogdanm 92:4fc01daae5a5 120 UserTrimming is either factory or user trimming */
bogdanm 86:04dd9b1680ae 121
bogdanm 86:04dd9b1680ae 122 uint32_t TrimmingValueP; /*!< Specifies the offset trimming value (PMOS)
bogdanm 86:04dd9b1680ae 123 i.e. when UserTrimming is OPAMP_TRIMMING_USER.
bogdanm 86:04dd9b1680ae 124 This parameter must be a number between Min_Data = 1 and Max_Data = 31 */
bogdanm 86:04dd9b1680ae 125
bogdanm 86:04dd9b1680ae 126 uint32_t TrimmingValueN; /*!< Specifies the offset trimming value (NMOS)
bogdanm 86:04dd9b1680ae 127 i.e. when UserTrimming is OPAMP_TRIMMING_USER.
bogdanm 86:04dd9b1680ae 128 This parameter must be a number between Min_Data = 1 and Max_Data = 31 */
bogdanm 86:04dd9b1680ae 129
bogdanm 86:04dd9b1680ae 130 }OPAMP_InitTypeDef;
bogdanm 86:04dd9b1680ae 131
bogdanm 86:04dd9b1680ae 132 /**
bogdanm 86:04dd9b1680ae 133 * @brief HAL State structures definition
bogdanm 86:04dd9b1680ae 134 */
bogdanm 86:04dd9b1680ae 135
bogdanm 86:04dd9b1680ae 136 typedef enum
bogdanm 86:04dd9b1680ae 137 {
bogdanm 86:04dd9b1680ae 138 HAL_OPAMP_STATE_RESET = 0x00000000, /*!< OPMAP is not yet Initialized */
bogdanm 86:04dd9b1680ae 139
bogdanm 86:04dd9b1680ae 140 HAL_OPAMP_STATE_READY = 0x00000001, /*!< OPAMP is initialized and ready for use */
bogdanm 86:04dd9b1680ae 141 HAL_OPAMP_STATE_CALIBBUSY = 0x00000002, /*!< OPAMP is enabled in auto calibration mode */
bogdanm 86:04dd9b1680ae 142
bogdanm 86:04dd9b1680ae 143 HAL_OPAMP_STATE_BUSY = 0x00000004, /*!< OPAMP is enabled and running in normal mode */
bogdanm 86:04dd9b1680ae 144 HAL_OPAMP_STATE_BUSYLOCKED = 0x00000005, /*!< OPAMP is locked
bogdanm 86:04dd9b1680ae 145 only system reset allows reconfiguring the opamp. */
bogdanm 86:04dd9b1680ae 146
bogdanm 86:04dd9b1680ae 147 }HAL_OPAMP_StateTypeDef;
bogdanm 86:04dd9b1680ae 148
bogdanm 86:04dd9b1680ae 149 /**
bogdanm 92:4fc01daae5a5 150 * @brief OPAMP Handle Structure definition to @brief OPAMP Handle Structure definition
bogdanm 86:04dd9b1680ae 151 */
bogdanm 86:04dd9b1680ae 152 typedef struct
bogdanm 86:04dd9b1680ae 153 {
bogdanm 86:04dd9b1680ae 154 OPAMP_TypeDef *Instance; /*!< OPAMP instance's registers base address */
bogdanm 86:04dd9b1680ae 155 OPAMP_InitTypeDef Init; /*!< OPAMP required parameters */
bogdanm 86:04dd9b1680ae 156 HAL_StatusTypeDef Status; /*!< OPAMP peripheral status */
bogdanm 86:04dd9b1680ae 157 HAL_LockTypeDef Lock; /*!< Locking object */
bogdanm 86:04dd9b1680ae 158 __IO HAL_OPAMP_StateTypeDef State; /*!< OPAMP communication state */
bogdanm 86:04dd9b1680ae 159
bogdanm 86:04dd9b1680ae 160 } OPAMP_HandleTypeDef;
bogdanm 86:04dd9b1680ae 161
bogdanm 86:04dd9b1680ae 162 /**
bogdanm 86:04dd9b1680ae 163 * @brief OPAMP_TrimmingValueTypeDef @brief definition
bogdanm 86:04dd9b1680ae 164 */
bogdanm 86:04dd9b1680ae 165
bogdanm 86:04dd9b1680ae 166 typedef uint32_t OPAMP_TrimmingValueTypeDef;
bogdanm 92:4fc01daae5a5 167 /**
bogdanm 92:4fc01daae5a5 168 * @}
bogdanm 92:4fc01daae5a5 169 */
bogdanm 86:04dd9b1680ae 170
bogdanm 86:04dd9b1680ae 171 /* Exported constants --------------------------------------------------------*/
bogdanm 92:4fc01daae5a5 172 /** @defgroup OPAMP_Exported_Constants OPAMP Exported Constants
bogdanm 86:04dd9b1680ae 173 * @{
bogdanm 86:04dd9b1680ae 174 */
bogdanm 86:04dd9b1680ae 175
bogdanm 92:4fc01daae5a5 176 /** @defgroup CSR_INIT CSR init register Mask
bogdanm 92:4fc01daae5a5 177 * @{
bogdanm 86:04dd9b1680ae 178 */
bogdanm 86:04dd9b1680ae 179 /* Used for Init phase */
bogdanm 86:04dd9b1680ae 180 #define OPAMP_CSR_UPDATE_PARAMETERS_INIT_MASK (OPAMP_CSR_TRIMOFFSETN | OPAMP_CSR_TRIMOFFSETP \
bogdanm 86:04dd9b1680ae 181 | OPAMP_CSR_USERTRIM | OPAMP_CSR_PGGAIN | OPAMP_CSR_VPSSEL \
bogdanm 86:04dd9b1680ae 182 | OPAMP_CSR_VMSSEL | OPAMP_CSR_TCMEN | OPAMP_CSR_VPSEL \
bogdanm 86:04dd9b1680ae 183 | OPAMP_CSR_VPSEL | OPAMP_CSR_FORCEVP)
bogdanm 86:04dd9b1680ae 184
bogdanm 86:04dd9b1680ae 185 /**
bogdanm 86:04dd9b1680ae 186 * @}
bogdanm 86:04dd9b1680ae 187 */
bogdanm 86:04dd9b1680ae 188
bogdanm 92:4fc01daae5a5 189 /** @defgroup OPAMP_Mode OPAMP Mode
bogdanm 86:04dd9b1680ae 190 * @{
bogdanm 86:04dd9b1680ae 191 */
bogdanm 86:04dd9b1680ae 192 #define OPAMP_STANDALONE_MODE ((uint32_t)0x00000000) /*!< standalone mode */
bogdanm 86:04dd9b1680ae 193 #define OPAMP_PGA_MODE OPAMP_CSR_VMSEL_1 /*!< PGA mode */
bogdanm 86:04dd9b1680ae 194 #define OPAMP_FOLLOWER_MODE OPAMP_CSR_VMSEL /*!< follower mode */
bogdanm 86:04dd9b1680ae 195
bogdanm 86:04dd9b1680ae 196
bogdanm 86:04dd9b1680ae 197 #define IS_OPAMP_FUNCTIONAL_NORMALMODE(INPUT) (((INPUT) == OPAMP_STANDALONE_MODE) || \
bogdanm 86:04dd9b1680ae 198 ((INPUT) == OPAMP_PGA_MODE) || \
bogdanm 86:04dd9b1680ae 199 ((INPUT) == OPAMP_FOLLOWER_MODE))
bogdanm 86:04dd9b1680ae 200
bogdanm 86:04dd9b1680ae 201 /**
bogdanm 86:04dd9b1680ae 202 * @}
bogdanm 86:04dd9b1680ae 203 */
bogdanm 86:04dd9b1680ae 204
bogdanm 92:4fc01daae5a5 205 /** @defgroup OPAMP_NonInvertingInput OPAMP Non Inverting Input
bogdanm 86:04dd9b1680ae 206 * @{
bogdanm 86:04dd9b1680ae 207 */
bogdanm 86:04dd9b1680ae 208
bogdanm 86:04dd9b1680ae 209 #define OPAMP_NONINVERTINGINPUT_VP0 OPAMP_CSR_VPSEL /*!< VP0 (PA1 for OPAMP1, PA7 for OPAMP2, PB0 for OPAMP3, PB13 for OPAMP4)
bogdanm 86:04dd9b1680ae 210 connected to OPAMPx non inverting input */
bogdanm 86:04dd9b1680ae 211 #define OPAMP_NONINVERTINGINPUT_VP1 ((uint32_t)0x00000000) /*!< VP1 (PA7 for OPAMP1, PD14 for OPAMP2, PB13 for OPAMP3, PD11 for OPAMP4)
bogdanm 86:04dd9b1680ae 212 connected to OPAMPx non inverting input */
bogdanm 86:04dd9b1680ae 213 #define OPAMP_NONINVERTINGINPUT_VP2 OPAMP_CSR_VPSEL_1 /*!< VP2 (PA3 for OPAMP1, PB0 for OPAMP2, PA1 for OPAMP3, PA4 for OPAMP4)
bogdanm 86:04dd9b1680ae 214 connected to OPAMPx non inverting input */
bogdanm 86:04dd9b1680ae 215 #define OPAMP_NONINVERTINGINPUT_VP3 OPAMP_CSR_VPSEL_0 /*!< vp3 (PA5 for OPAMP1, PB14 for OPAMP2, PA5 for OPAMP3, PB11 for OPAMP4)
bogdanm 86:04dd9b1680ae 216 connected to OPAMPx non inverting input */
bogdanm 86:04dd9b1680ae 217
bogdanm 86:04dd9b1680ae 218 #define IS_OPAMP_NONINVERTING_INPUT(INPUT) (((INPUT) == OPAMP_NONINVERTINGINPUT_VP0) || \
bogdanm 86:04dd9b1680ae 219 ((INPUT) == OPAMP_NONINVERTINGINPUT_VP1) || \
bogdanm 86:04dd9b1680ae 220 ((INPUT) == OPAMP_NONINVERTINGINPUT_VP2) || \
bogdanm 86:04dd9b1680ae 221 ((INPUT) == OPAMP_NONINVERTINGINPUT_VP3))
bogdanm 86:04dd9b1680ae 222
bogdanm 86:04dd9b1680ae 223 /**
bogdanm 86:04dd9b1680ae 224 * @}
bogdanm 86:04dd9b1680ae 225 */
bogdanm 86:04dd9b1680ae 226
bogdanm 92:4fc01daae5a5 227 /** @defgroup OPAMP_InvertingInput OPAMP Inverting Input
bogdanm 86:04dd9b1680ae 228 * @{
bogdanm 86:04dd9b1680ae 229 */
bogdanm 86:04dd9b1680ae 230
bogdanm 86:04dd9b1680ae 231 #define IOPAMP_INVERTINGINPUT_VM0 ((uint32_t)0x00000000) /*!< inverting input connected to VM0 */
bogdanm 86:04dd9b1680ae 232 #define IOPAMP_INVERTINGINPUT_VM1 OPAMP_CSR_VMSEL_0 /*!< inverting input connected to VM1 */
bogdanm 86:04dd9b1680ae 233
bogdanm 86:04dd9b1680ae 234 #define IS_OPAMP_INVERTING_INPUT(INPUT) (((INPUT) == IOPAMP_INVERTINGINPUT_VM0) || \
bogdanm 86:04dd9b1680ae 235 ((INPUT) == IOPAMP_INVERTINGINPUT_VM1))
bogdanm 86:04dd9b1680ae 236
bogdanm 86:04dd9b1680ae 237 /**
bogdanm 86:04dd9b1680ae 238 * @}
bogdanm 86:04dd9b1680ae 239 */
bogdanm 86:04dd9b1680ae 240
bogdanm 92:4fc01daae5a5 241 /** @defgroup OPAMP_TimerControlledMuxmode OPAMP Timer Controlled Mux mode
bogdanm 86:04dd9b1680ae 242 * @{
bogdanm 86:04dd9b1680ae 243 */
bogdanm 86:04dd9b1680ae 244 #define OPAMP_TIMERCONTROLLEDMUXMODE_DISABLE ((uint32_t)0x00000000) /*!< Timer controlled Mux mode disabled */
bogdanm 86:04dd9b1680ae 245 #define OPAMP_TIMERCONTROLLEDMUXMODE_ENABLE OPAMP_CSR_TCMEN /*!< Timer controlled Mux mode enabled */
bogdanm 86:04dd9b1680ae 246
bogdanm 86:04dd9b1680ae 247 #define IS_OPAMP_TIMERCONTROLLED_MUXMODE(MUXMODE) (((MUXMODE) == OPAMP_TIMERCONTROLLEDMUXMODE_DISABLE) || \
bogdanm 86:04dd9b1680ae 248 ((MUXMODE) == OPAMP_TIMERCONTROLLEDMUXMODE_ENABLE))
bogdanm 86:04dd9b1680ae 249 /**
bogdanm 86:04dd9b1680ae 250 * @}
bogdanm 86:04dd9b1680ae 251 */
bogdanm 86:04dd9b1680ae 252
bogdanm 92:4fc01daae5a5 253 /** @defgroup OPAMP_NonInvertingInputSecondary OPAMP Non Inverting Input Secondary
bogdanm 86:04dd9b1680ae 254 * @{
bogdanm 86:04dd9b1680ae 255 */
bogdanm 86:04dd9b1680ae 256
bogdanm 86:04dd9b1680ae 257 #define OPAMP_SEC_NONINVERTINGINPUT_VP0 OPAMP_CSR_VPSSEL /*!< VP0 (PA1 for OPAMP1, PA7 for OPAMP2, PB0 for OPAMP3, PB13 for OPAMP4)
bogdanm 86:04dd9b1680ae 258 connected to OPAMPx non inverting input */
bogdanm 86:04dd9b1680ae 259 #define OPAMP_SEC_NONINVERTINGINPUT_VP1 ((uint32_t)0x00000000) /*!< VP1 (PA7 for OPAMP1, PD14 for OPAMP2, PB13 for OPAMP3, PD11 for OPAMP4)
bogdanm 86:04dd9b1680ae 260 connected to OPAMPx non inverting input */
bogdanm 86:04dd9b1680ae 261 #define OPAMP_SEC_NONINVERTINGINPUT_VP2 OPAMP_CSR_VPSSEL_1 /*!< VP2 (PA3 for OPAMP1, PB0 for OPAMP2, PA1 for OPAMP3, PA4 for OPAMP4)
bogdanm 86:04dd9b1680ae 262 connected to OPAMPx non inverting input */
bogdanm 86:04dd9b1680ae 263 #define OPAMP_SEC_NONINVERTINGINPUT_VP3 OPAMP_CSR_VPSSEL_0 /*!< VP3 (PA5 for OPAMP1, PB14 for OPAMP2, PA5 for OPAMP3, PB11 for OPAMP4)
bogdanm 86:04dd9b1680ae 264 connected to OPAMPx non inverting input */
bogdanm 86:04dd9b1680ae 265
bogdanm 86:04dd9b1680ae 266 #define IS_OPAMP_SEC_NONINVERTINGINPUT(INPUT) (((INPUT) == OPAMP_SEC_NONINVERTINGINPUT_VP0) || \
bogdanm 86:04dd9b1680ae 267 ((INPUT) == OPAMP_SEC_NONINVERTINGINPUT_VP1) || \
bogdanm 86:04dd9b1680ae 268 ((INPUT) == OPAMP_SEC_NONINVERTINGINPUT_VP2) || \
bogdanm 86:04dd9b1680ae 269 ((INPUT) == OPAMP_SEC_NONINVERTINGINPUT_VP3))
bogdanm 86:04dd9b1680ae 270
bogdanm 86:04dd9b1680ae 271 /**
bogdanm 86:04dd9b1680ae 272 * @}
bogdanm 86:04dd9b1680ae 273 */
bogdanm 86:04dd9b1680ae 274
bogdanm 92:4fc01daae5a5 275 /** @defgroup OPAMP_InvertingInputSecondary OPAMP Inverting Input Secondary
bogdanm 86:04dd9b1680ae 276 * @{
bogdanm 86:04dd9b1680ae 277 */
bogdanm 86:04dd9b1680ae 278
bogdanm 86:04dd9b1680ae 279 #define OPAMP_SEC_INVERTINGINPUT_VM0 ((uint32_t)0x00000000) /*!< VM0 (PC5 for OPAMP1 and OPAMP2, PB10 for OPAMP3 and OPAMP4)
bogdanm 86:04dd9b1680ae 280 connected to OPAMPx inverting input */
bogdanm 86:04dd9b1680ae 281 #define OPAMP_SEC_INVERTINGINPUT_VM1 OPAMP_CSR_VMSSEL /*!< VM1 (PA3 for OPAMP1, PA5 for OPAMP2, PB2 for OPAMP3, PD8 for OPAMP4)
bogdanm 86:04dd9b1680ae 282 connected to OPAMPx inverting input */
bogdanm 86:04dd9b1680ae 283
bogdanm 86:04dd9b1680ae 284 #define IS_OPAMP_SEC_INVERTINGINPUT(INPUT) (((INPUT) == OPAMP_SEC_INVERTINGINPUT_VM0) || \
bogdanm 86:04dd9b1680ae 285 ((INPUT) == OPAMP_SEC_INVERTINGINPUT_VM1))
bogdanm 86:04dd9b1680ae 286
bogdanm 86:04dd9b1680ae 287 /**
bogdanm 86:04dd9b1680ae 288 * @}
bogdanm 86:04dd9b1680ae 289 */
bogdanm 86:04dd9b1680ae 290
bogdanm 92:4fc01daae5a5 291 /** @defgroup OPAMP_PgaConnect OPAMP Pga Connect
bogdanm 86:04dd9b1680ae 292 * @{
bogdanm 86:04dd9b1680ae 293 */
bogdanm 86:04dd9b1680ae 294
bogdanm 86:04dd9b1680ae 295 #define OPAMP_PGACONNECT_NO ((uint32_t)0x00000000) /*!< In PGA mode, the non inverting input is not connected */
bogdanm 86:04dd9b1680ae 296 #define OPAMP_PGACONNECT_VM0 OPAMP_CSR_PGGAIN_3 /*!< In PGA mode, the non inverting input is connected to VM0 */
bogdanm 86:04dd9b1680ae 297 #define OPAMP_PGACONNECT_VM1 (OPAMP_CSR_PGGAIN_2 | OPAMP_CSR_PGGAIN_3) /*!< In PGA mode, the non inverting input is connected to VM1 */
bogdanm 86:04dd9b1680ae 298
bogdanm 86:04dd9b1680ae 299 #define IS_OPAMP_PGACONNECT(CONNECT) (((CONNECT) == OPAMP_PGACONNECT_NO) || \
bogdanm 86:04dd9b1680ae 300 ((CONNECT) == OPAMP_PGACONNECT_VM0) || \
bogdanm 86:04dd9b1680ae 301 ((CONNECT) == OPAMP_PGACONNECT_VM1))
bogdanm 86:04dd9b1680ae 302 /**
bogdanm 86:04dd9b1680ae 303 * @}
bogdanm 86:04dd9b1680ae 304 */
bogdanm 86:04dd9b1680ae 305
bogdanm 86:04dd9b1680ae 306
bogdanm 92:4fc01daae5a5 307 /** @defgroup OPAMP_PgaGain OPAMP Pga Gain
bogdanm 86:04dd9b1680ae 308 * @{
bogdanm 86:04dd9b1680ae 309 */
bogdanm 86:04dd9b1680ae 310
bogdanm 86:04dd9b1680ae 311 #define OPAMP_PGA_GAIN_2 ((uint32_t)0x00000000) /*!< PGA gain = 2 */
bogdanm 86:04dd9b1680ae 312 #define OPAMP_PGA_GAIN_4 OPAMP_CSR_PGGAIN_0 /*!< PGA gain = 4 */
bogdanm 86:04dd9b1680ae 313 #define OPAMP_PGA_GAIN_8 OPAMP_CSR_PGGAIN_1 /*!< PGA gain = 8 */
bogdanm 86:04dd9b1680ae 314 #define OPAMP_PGA_GAIN_16 (OPAMP_CSR_PGGAIN_0 | OPAMP_CSR_PGGAIN_1) /*!< PGA gain = 16 */
bogdanm 86:04dd9b1680ae 315
bogdanm 86:04dd9b1680ae 316 #define IS_OPAMP_PGA_GAIN(GAIN) (((GAIN) == OPAMP_PGA_GAIN_2) || \
bogdanm 86:04dd9b1680ae 317 ((GAIN) == OPAMP_PGA_GAIN_4) || \
bogdanm 86:04dd9b1680ae 318 ((GAIN) == OPAMP_PGA_GAIN_8) || \
bogdanm 86:04dd9b1680ae 319 ((GAIN) == OPAMP_PGA_GAIN_16))
bogdanm 86:04dd9b1680ae 320 /**
bogdanm 86:04dd9b1680ae 321 * @}
bogdanm 86:04dd9b1680ae 322 */
bogdanm 86:04dd9b1680ae 323
bogdanm 92:4fc01daae5a5 324 /** @defgroup OPAMP_UserTrimming OPAMP User Trimming
bogdanm 86:04dd9b1680ae 325 * @{
bogdanm 86:04dd9b1680ae 326 */
bogdanm 86:04dd9b1680ae 327
bogdanm 86:04dd9b1680ae 328 #define OPAMP_TRIMMING_FACTORY ((uint32_t)0x00000000) /*!< Factory trimming */
bogdanm 86:04dd9b1680ae 329 #define OPAMP_TRIMMING_USER OPAMP_CSR_USERTRIM /*!< User trimming */
bogdanm 86:04dd9b1680ae 330
bogdanm 86:04dd9b1680ae 331 #define IS_OPAMP_TRIMMING(TRIMMING) (((TRIMMING) == OPAMP_TRIMMING_FACTORY) || \
bogdanm 86:04dd9b1680ae 332 ((TRIMMING) == OPAMP_TRIMMING_USER))
bogdanm 86:04dd9b1680ae 333
bogdanm 92:4fc01daae5a5 334 /** @defgroup OPAMP_FactoryTrimming OPAMP Factory Trimming
bogdanm 86:04dd9b1680ae 335 * @{
bogdanm 86:04dd9b1680ae 336 */
bogdanm 86:04dd9b1680ae 337
bogdanm 86:04dd9b1680ae 338 #define OPAMP_FACTORYTRIMMING_DUMMY ((uint32_t)0xFFFFFFFF) /*!< Dummy trimming value */
bogdanm 86:04dd9b1680ae 339
bogdanm 86:04dd9b1680ae 340 #define OPAMP_FACTORYTRIMMING_N ((uint32_t)0x00000000) /*!< Offset trimming N */
bogdanm 86:04dd9b1680ae 341 #define OPAMP_FACTORYTRIMMING_P ((uint32_t)0x00000001) /*!< Offset trimming P */
bogdanm 86:04dd9b1680ae 342
bogdanm 86:04dd9b1680ae 343 #define IS_OPAMP_FACTORYTRIMMING(TRIMMING) (((TRIMMING) == OPAMP_FACTORYTRIMMING_N) || \
bogdanm 86:04dd9b1680ae 344 ((TRIMMING) == OPAMP_FACTORYTRIMMING_P))
bogdanm 86:04dd9b1680ae 345
bogdanm 86:04dd9b1680ae 346 /**
bogdanm 86:04dd9b1680ae 347 * @}
bogdanm 86:04dd9b1680ae 348 */
bogdanm 86:04dd9b1680ae 349
bogdanm 86:04dd9b1680ae 350
bogdanm 92:4fc01daae5a5 351 /** @defgroup OPAMP_TrimmingValue OPAMP Trimming Value
bogdanm 86:04dd9b1680ae 352 * @{
bogdanm 86:04dd9b1680ae 353 */
bogdanm 86:04dd9b1680ae 354
bogdanm 86:04dd9b1680ae 355 #define IS_OPAMP_TRIMMINGVALUE(TRIMMINGVALUE) ((TRIMMINGVALUE) <= 0x1F)
bogdanm 86:04dd9b1680ae 356
bogdanm 86:04dd9b1680ae 357
bogdanm 86:04dd9b1680ae 358 /**
bogdanm 86:04dd9b1680ae 359 * @}
bogdanm 86:04dd9b1680ae 360 */
bogdanm 86:04dd9b1680ae 361
bogdanm 86:04dd9b1680ae 362
bogdanm 92:4fc01daae5a5 363 /** @defgroup OPAMP_Input OPAMP Input
bogdanm 86:04dd9b1680ae 364 * @{
bogdanm 86:04dd9b1680ae 365 */
bogdanm 86:04dd9b1680ae 366
bogdanm 86:04dd9b1680ae 367 #define OPAMP_INPUT_INVERTING ((uint32_t) 24) /*!< Inverting input */
bogdanm 86:04dd9b1680ae 368 #define OPAMP_INPUT_NONINVERTING ((uint32_t) 19) /*!< Non inverting input */
bogdanm 86:04dd9b1680ae 369
bogdanm 86:04dd9b1680ae 370 #define IS_OPAMP_INPUT(INPUT) (((INPUT) == OPAMP_INPUT_INVERTING) || \
bogdanm 86:04dd9b1680ae 371 ((INPUT) == OPAMP_INPUT_NONINVERTING))
bogdanm 86:04dd9b1680ae 372 /**
bogdanm 86:04dd9b1680ae 373 * @}
bogdanm 86:04dd9b1680ae 374 */
bogdanm 86:04dd9b1680ae 375
bogdanm 86:04dd9b1680ae 376
bogdanm 92:4fc01daae5a5 377 /** @defgroup OPAMP_VREF OPAMP VREF
bogdanm 86:04dd9b1680ae 378 * @{
bogdanm 86:04dd9b1680ae 379 */
bogdanm 86:04dd9b1680ae 380
bogdanm 86:04dd9b1680ae 381 #define OPAMP_VREF_3VDDA ((uint32_t)0x00000000) /*!< OPMAP Vref = 3.3% VDDA */
bogdanm 86:04dd9b1680ae 382 #define OPAMP_VREF_10VDDA OPAMP_CSR_CALSEL_0 /*!< OPMAP Vref = 10% VDDA */
bogdanm 86:04dd9b1680ae 383 #define OPAMP_VREF_50VDDA OPAMP_CSR_CALSEL_1 /*!< OPMAP Vref = 50% VDDA */
bogdanm 86:04dd9b1680ae 384 #define OPAMP_VREF_90VDDA OPAMP_CSR_CALSEL /*!< OPMAP Vref = 90% VDDA */
bogdanm 86:04dd9b1680ae 385
bogdanm 86:04dd9b1680ae 386 #define IS_OPAMP_VREF(VREF) (((VREF) == OPAMP_VREF_3VDDA) || \
bogdanm 86:04dd9b1680ae 387 ((VREF) == OPAMP_VREF_10VDDA) || \
bogdanm 86:04dd9b1680ae 388 ((VREF) == OPAMP_VREF_50VDDA) || \
bogdanm 86:04dd9b1680ae 389 ((VREF) == OPAMP_VREF_90VDDA))
bogdanm 86:04dd9b1680ae 390
bogdanm 86:04dd9b1680ae 391 /**
bogdanm 86:04dd9b1680ae 392 * @}
bogdanm 86:04dd9b1680ae 393 */
bogdanm 86:04dd9b1680ae 394
bogdanm 92:4fc01daae5a5 395 /** @defgroup OPAMP_Vref2ADCforCalib OPAMP Vref2ADCforCalib
bogdanm 86:04dd9b1680ae 396 */
bogdanm 86:04dd9b1680ae 397
bogdanm 86:04dd9b1680ae 398 #define OPAMP_VREF_NOTCONNECTEDTO_ADC ((uint32_t)0x00000000) /*!< VREF not connected to ADC */
bogdanm 86:04dd9b1680ae 399 #define OPAMP_VREF_CONNECTEDTO_ADC ((uint32_t)0x00000001) /*!< VREF not connected to ADC */
bogdanm 86:04dd9b1680ae 400
bogdanm 86:04dd9b1680ae 401 #define IS_OPAMP_ALLOPAMPVREF_CONNECT(CONNECT) (((CONNECT) == OPAMP_VREF_NOTCONNECTEDTO_ADC) || \
bogdanm 86:04dd9b1680ae 402 ((CONNECT) == OPAMP_VREF_CONNECTEDTO_ADC))
bogdanm 86:04dd9b1680ae 403
bogdanm 86:04dd9b1680ae 404
bogdanm 86:04dd9b1680ae 405 /**
bogdanm 86:04dd9b1680ae 406 * @}
bogdanm 86:04dd9b1680ae 407 */
bogdanm 86:04dd9b1680ae 408
bogdanm 92:4fc01daae5a5 409 /**
bogdanm 92:4fc01daae5a5 410 * @}
bogdanm 92:4fc01daae5a5 411 */
bogdanm 92:4fc01daae5a5 412
bogdanm 86:04dd9b1680ae 413 /* Exported macros -----------------------------------------------------------*/
bogdanm 92:4fc01daae5a5 414 /** @defgroup OPAMP_Exported_Macros OPAMP Exported Macros
bogdanm 92:4fc01daae5a5 415 * @{
bogdanm 92:4fc01daae5a5 416 */
bogdanm 86:04dd9b1680ae 417
bogdanm 86:04dd9b1680ae 418 /** @brief Reset OPAMP handle state
bogdanm 86:04dd9b1680ae 419 * @param __HANDLE__: OPAMP handle.
bogdanm 86:04dd9b1680ae 420 * @retval None
bogdanm 86:04dd9b1680ae 421 */
bogdanm 86:04dd9b1680ae 422 #define __HAL_OPAMP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_OPAMP_STATE_RESET)
bogdanm 86:04dd9b1680ae 423
bogdanm 92:4fc01daae5a5 424 /**
bogdanm 92:4fc01daae5a5 425 * @}
bogdanm 92:4fc01daae5a5 426 */
bogdanm 92:4fc01daae5a5 427
bogdanm 92:4fc01daae5a5 428 /* Include OPAMP HAL Extended module */
bogdanm 86:04dd9b1680ae 429 #include "stm32f3xx_hal_opamp_ex.h"
bogdanm 86:04dd9b1680ae 430
bogdanm 86:04dd9b1680ae 431 /* Exported functions --------------------------------------------------------*/
bogdanm 92:4fc01daae5a5 432 /** @defgroup OPAMP_Exported_Functions OPAMP Exported Functions
bogdanm 92:4fc01daae5a5 433 * @{
bogdanm 92:4fc01daae5a5 434 */
bogdanm 92:4fc01daae5a5 435
bogdanm 92:4fc01daae5a5 436 /** @defgroup OPAMP_Exported_Functions_Group1 Initialization and de-initialization functions
bogdanm 92:4fc01daae5a5 437 * @{
bogdanm 92:4fc01daae5a5 438 */
bogdanm 86:04dd9b1680ae 439
bogdanm 86:04dd9b1680ae 440 /* Initialization/de-initialization functions **********************************/
bogdanm 86:04dd9b1680ae 441 HAL_StatusTypeDef HAL_OPAMP_Init(OPAMP_HandleTypeDef *hopamp);
bogdanm 86:04dd9b1680ae 442 HAL_StatusTypeDef HAL_OPAMP_DeInit (OPAMP_HandleTypeDef *hopamp);
bogdanm 86:04dd9b1680ae 443 void HAL_OPAMP_MspInit(OPAMP_HandleTypeDef *hopamp);
bogdanm 86:04dd9b1680ae 444 void HAL_OPAMP_MspDeInit(OPAMP_HandleTypeDef *hopamp);
bogdanm 92:4fc01daae5a5 445 /**
bogdanm 92:4fc01daae5a5 446 * @}
bogdanm 92:4fc01daae5a5 447 */
bogdanm 92:4fc01daae5a5 448
bogdanm 92:4fc01daae5a5 449
bogdanm 92:4fc01daae5a5 450 /** @defgroup OPAMP_Exported_Functions_Group2 Input and Output operation functions
bogdanm 92:4fc01daae5a5 451 * @{
bogdanm 92:4fc01daae5a5 452 */
bogdanm 86:04dd9b1680ae 453
bogdanm 86:04dd9b1680ae 454 /* I/O operation functions *****************************************************/
bogdanm 86:04dd9b1680ae 455 HAL_StatusTypeDef HAL_OPAMP_Start(OPAMP_HandleTypeDef *hopamp);
bogdanm 86:04dd9b1680ae 456 HAL_StatusTypeDef HAL_OPAMP_Stop(OPAMP_HandleTypeDef *hopamp);
bogdanm 86:04dd9b1680ae 457 HAL_StatusTypeDef HAL_OPAMP_SelfCalibrate(OPAMP_HandleTypeDef *hopamp);
bogdanm 86:04dd9b1680ae 458
bogdanm 92:4fc01daae5a5 459 /**
bogdanm 92:4fc01daae5a5 460 * @}
bogdanm 92:4fc01daae5a5 461 */
bogdanm 92:4fc01daae5a5 462
bogdanm 92:4fc01daae5a5 463 /** @defgroup OPAMP_Exported_Functions_Group3 Peripheral Control functions
bogdanm 92:4fc01daae5a5 464 * @{
bogdanm 92:4fc01daae5a5 465 */
bogdanm 92:4fc01daae5a5 466
bogdanm 86:04dd9b1680ae 467 /* Peripheral Control functions ************************************************/
bogdanm 86:04dd9b1680ae 468 HAL_StatusTypeDef HAL_OPAMP_Lock(OPAMP_HandleTypeDef *hopamp);
bogdanm 86:04dd9b1680ae 469
bogdanm 92:4fc01daae5a5 470 /**
bogdanm 92:4fc01daae5a5 471 * @}
bogdanm 92:4fc01daae5a5 472 */
bogdanm 92:4fc01daae5a5 473
bogdanm 92:4fc01daae5a5 474 /** @defgroup OPAMP_Exported_Functions_Group4 Peripheral State functions
bogdanm 92:4fc01daae5a5 475 * @{
bogdanm 92:4fc01daae5a5 476 */
bogdanm 92:4fc01daae5a5 477
bogdanm 86:04dd9b1680ae 478 /* Peripheral State functions **************************************************/
bogdanm 86:04dd9b1680ae 479 HAL_OPAMP_StateTypeDef HAL_OPAMP_GetState(OPAMP_HandleTypeDef *hopamp);
bogdanm 86:04dd9b1680ae 480 OPAMP_TrimmingValueTypeDef HAL_OPAMP_GetTrimOffset (OPAMP_HandleTypeDef *hopamp, uint32_t trimmingoffset);
bogdanm 86:04dd9b1680ae 481
bogdanm 86:04dd9b1680ae 482 /**
bogdanm 86:04dd9b1680ae 483 * @}
bogdanm 92:4fc01daae5a5 484 */
bogdanm 92:4fc01daae5a5 485
bogdanm 92:4fc01daae5a5 486 /**
bogdanm 92:4fc01daae5a5 487 * @}
bogdanm 92:4fc01daae5a5 488 */
bogdanm 92:4fc01daae5a5 489
bogdanm 92:4fc01daae5a5 490 /**
bogdanm 92:4fc01daae5a5 491 * @}
bogdanm 86:04dd9b1680ae 492 */
bogdanm 86:04dd9b1680ae 493
bogdanm 86:04dd9b1680ae 494 /**
bogdanm 86:04dd9b1680ae 495 * @}
bogdanm 86:04dd9b1680ae 496 */
bogdanm 86:04dd9b1680ae 497
bogdanm 92:4fc01daae5a5 498 #endif /* STM32F302xE || STM32F303xE || STM32F398xx || */
bogdanm 92:4fc01daae5a5 499 /* STM32F302xC || STM32F303xC || STM32F358xx || */
bogdanm 92:4fc01daae5a5 500 /* STM32F303x8 || STM32F334x8 || STM32F328xx || */
bogdanm 92:4fc01daae5a5 501 /* STM32F301x8 || STM32F302x8 || STM32F318xx */
bogdanm 86:04dd9b1680ae 502
bogdanm 86:04dd9b1680ae 503 #ifdef __cplusplus
bogdanm 86:04dd9b1680ae 504 }
bogdanm 86:04dd9b1680ae 505 #endif
bogdanm 86:04dd9b1680ae 506
bogdanm 86:04dd9b1680ae 507 #endif /* __STM32F3xx_HAL_OPAMP_H */
bogdanm 86:04dd9b1680ae 508
bogdanm 86:04dd9b1680ae 509 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/