Fork of the official mbed C/C SDK provides the software platform and libraries to build your applications for RenBED.

Dependents:   1-RenBuggyTimed RenBED_RGB RenBED_RGB_PWM RenBED_RGB

Fork of mbed by mbed official

Committer:
bogdanm
Date:
Wed Jul 02 13:22:23 2014 +0100
Revision:
86:04dd9b1680ae
Child:
92:4fc01daae5a5
Release 86 of the mbed library

Main changes:


- bug fixes in various backends
- mbed "error" replaced by assert logic (mbed_assert)
- new ST Nucleo targets

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 86:04dd9b1680ae 5 * @version V1.0.1
bogdanm 86:04dd9b1680ae 6 * @date 18-June-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 86:04dd9b1680ae 46 #if defined (STM32F303xC) || defined (STM32F358xx) || defined (STM32F302xC) || \
bogdanm 86:04dd9b1680ae 47 defined (STM32F303x8) || defined (STM32F328xx) || defined (STM32F302x8) || \
bogdanm 86:04dd9b1680ae 48 defined (STM32F301x8) || defined (STM32F318xx) || defined (STM32F334x8)
bogdanm 86:04dd9b1680ae 49
bogdanm 86:04dd9b1680ae 50 /* Includes ------------------------------------------------------------------*/
bogdanm 86:04dd9b1680ae 51 #include "stm32f3xx_hal_def.h"
bogdanm 86:04dd9b1680ae 52
bogdanm 86:04dd9b1680ae 53 /** @addtogroup STM32F3xx_HAL_Driver
bogdanm 86:04dd9b1680ae 54 * @{
bogdanm 86:04dd9b1680ae 55 */
bogdanm 86:04dd9b1680ae 56
bogdanm 86:04dd9b1680ae 57 /** @addtogroup OPAMP
bogdanm 86:04dd9b1680ae 58 * @{
bogdanm 86:04dd9b1680ae 59 */
bogdanm 86:04dd9b1680ae 60
bogdanm 86:04dd9b1680ae 61 /* Exported types ------------------------------------------------------------*/
bogdanm 86:04dd9b1680ae 62
bogdanm 86:04dd9b1680ae 63 /**
bogdanm 86:04dd9b1680ae 64 * @brief OPAMP Init structure definition
bogdanm 86:04dd9b1680ae 65 */
bogdanm 86:04dd9b1680ae 66
bogdanm 86:04dd9b1680ae 67 typedef struct
bogdanm 86:04dd9b1680ae 68 {
bogdanm 86:04dd9b1680ae 69 uint32_t Mode; /*!< Specifies the OPAMP mode
bogdanm 86:04dd9b1680ae 70 This parameter must be a value of @ref OPAMP_Mode
bogdanm 86:04dd9b1680ae 71 mode is either Standalone, - Follower or PGA */
bogdanm 86:04dd9b1680ae 72
bogdanm 86:04dd9b1680ae 73 uint32_t InvertingInput; /*!< Specifies the inverting input in Standalone & Pga modes
bogdanm 86:04dd9b1680ae 74 - In Standalone mode: i.e when mode is OPAMP_STANDALONE_MODE
bogdanm 86:04dd9b1680ae 75 This parameter must be a value of @ref OPAMP_InvertingInput
bogdanm 86:04dd9b1680ae 76 InvertingInput is either VM0 or VM1
bogdanm 86:04dd9b1680ae 77 - In PGA mode: i.e when mode is OPAMP_PGA_MODE
bogdanm 86:04dd9b1680ae 78 & in Follower mode i.e when mode is OPAMP_FOLLOWER_MODE
bogdanm 86:04dd9b1680ae 79 This parameter is Not Applicable */
bogdanm 86:04dd9b1680ae 80
bogdanm 86:04dd9b1680ae 81 uint32_t NonInvertingInput; /*!< Specifies the non inverting input of the opamp:
bogdanm 86:04dd9b1680ae 82 This parameter must be a value of @ref OPAMP_NonInvertingInput
bogdanm 86:04dd9b1680ae 83 NonInvertingInput is either VP0, VP1, VP3 or VP4 */
bogdanm 86:04dd9b1680ae 84
bogdanm 86:04dd9b1680ae 85 uint32_t TimerControlledMuxmode; /*!< Specifies if the Timer controlled Mux mode is enabled or disabled
bogdanm 86:04dd9b1680ae 86 This parameter must be a value of @ref OPAMP_TimerControlledMuxmode */
bogdanm 86:04dd9b1680ae 87
bogdanm 86:04dd9b1680ae 88 uint32_t InvertingInputSecondary; /*!< Specifies the inverting input (secondary) of the opamp when
bogdanm 86:04dd9b1680ae 89 TimerControlledMuxmode is enabled
bogdanm 86:04dd9b1680ae 90 i.e. when TimerControlledMuxmode is OPAMP_TIMERCONTROLLEDMUXMODE_ENABLE
bogdanm 86:04dd9b1680ae 91 - In Standalone mode: i.e when mode is OPAMP_STANDALONE_MODE
bogdanm 86:04dd9b1680ae 92 This parameter must be a value of @ref OPAMP_InvertingInputSecondary
bogdanm 86:04dd9b1680ae 93 InvertingInputSecondary is either VM0 or VM1
bogdanm 86:04dd9b1680ae 94 - In PGA mode: i.e when mode is OPAMP_PGA_MODE
bogdanm 86:04dd9b1680ae 95 & in Follower mode i.e when mode is OPAMP_FOLLOWER_MODE
bogdanm 86:04dd9b1680ae 96 This parameter is Not Applicable */
bogdanm 86:04dd9b1680ae 97
bogdanm 86:04dd9b1680ae 98 uint32_t NonInvertingInputSecondary; /*!< Specifies the non inverting input (secondary) of the opamp when
bogdanm 86:04dd9b1680ae 99 TimerControlledMuxmode is enabled
bogdanm 86:04dd9b1680ae 100 i.e. when TimerControlledMuxmode is OPAMP_TIMERCONTROLLEDMUXMODE_ENABLE
bogdanm 86:04dd9b1680ae 101 This parameter must be a value of @ref OPAMP_NonInvertingInputSecondary
bogdanm 86:04dd9b1680ae 102 NonInvertingInput is either VP0, VP1, VP3 or VP3 */
bogdanm 86:04dd9b1680ae 103
bogdanm 86:04dd9b1680ae 104 uint32_t PgaConnect; /*!< Specifies the inverting pin in PGA mode
bogdanm 86:04dd9b1680ae 105 i.e. when mode is OPAMP_PGA_MODE
bogdanm 86:04dd9b1680ae 106 This parameter must be a value of @ref OPAMP_PgaConnect
bogdanm 86:04dd9b1680ae 107 Either: not connected, connected to VM0, connected to VM1
bogdanm 86:04dd9b1680ae 108 (VM0 or VM1 are typically used for external filtering) */
bogdanm 86:04dd9b1680ae 109
bogdanm 86:04dd9b1680ae 110 uint32_t PgaGain; /*!< Specifies the gain in PGA mode
bogdanm 86:04dd9b1680ae 111 i.e. when mode is OPAMP_PGA_MODE.
bogdanm 86:04dd9b1680ae 112 This parameter must be a value of @ref OPAMP_PgaGain (2, 4, 8 or 16 ) */
bogdanm 86:04dd9b1680ae 113
bogdanm 86:04dd9b1680ae 114 uint32_t UserTrimming; /*!< Specifies the trimming mode
bogdanm 86:04dd9b1680ae 115 This parameter must be a value of @ref OPAMP_UserTrimming
bogdanm 86:04dd9b1680ae 116 UserTrimming is either factory or user timming */
bogdanm 86:04dd9b1680ae 117
bogdanm 86:04dd9b1680ae 118 uint32_t TrimmingValueP; /*!< Specifies the offset trimming value (PMOS)
bogdanm 86:04dd9b1680ae 119 i.e. when UserTrimming is OPAMP_TRIMMING_USER.
bogdanm 86:04dd9b1680ae 120 This parameter must be a number between Min_Data = 1 and Max_Data = 31 */
bogdanm 86:04dd9b1680ae 121
bogdanm 86:04dd9b1680ae 122 uint32_t TrimmingValueN; /*!< Specifies the offset trimming value (NMOS)
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 }OPAMP_InitTypeDef;
bogdanm 86:04dd9b1680ae 127
bogdanm 86:04dd9b1680ae 128 /**
bogdanm 86:04dd9b1680ae 129 * @brief HAL State structures definition
bogdanm 86:04dd9b1680ae 130 */
bogdanm 86:04dd9b1680ae 131
bogdanm 86:04dd9b1680ae 132 typedef enum
bogdanm 86:04dd9b1680ae 133 {
bogdanm 86:04dd9b1680ae 134 HAL_OPAMP_STATE_RESET = 0x00000000, /*!< OPMAP is not yet Initialized */
bogdanm 86:04dd9b1680ae 135
bogdanm 86:04dd9b1680ae 136 HAL_OPAMP_STATE_READY = 0x00000001, /*!< OPAMP is initialized and ready for use */
bogdanm 86:04dd9b1680ae 137 HAL_OPAMP_STATE_CALIBBUSY = 0x00000002, /*!< OPAMP is enabled in auto calibration mode */
bogdanm 86:04dd9b1680ae 138
bogdanm 86:04dd9b1680ae 139 HAL_OPAMP_STATE_BUSY = 0x00000004, /*!< OPAMP is enabled and running in normal mode */
bogdanm 86:04dd9b1680ae 140 HAL_OPAMP_STATE_BUSYLOCKED = 0x00000005, /*!< OPAMP is locked
bogdanm 86:04dd9b1680ae 141 only system reset allows reconfiguring the opamp. */
bogdanm 86:04dd9b1680ae 142
bogdanm 86:04dd9b1680ae 143 }HAL_OPAMP_StateTypeDef;
bogdanm 86:04dd9b1680ae 144
bogdanm 86:04dd9b1680ae 145 /**
bogdanm 86:04dd9b1680ae 146 * @brief PPP Handle Structure definition to @brief OPAMP Handle Structure definition
bogdanm 86:04dd9b1680ae 147 */
bogdanm 86:04dd9b1680ae 148 typedef struct
bogdanm 86:04dd9b1680ae 149 {
bogdanm 86:04dd9b1680ae 150 OPAMP_TypeDef *Instance; /*!< OPAMP instance's registers base address */
bogdanm 86:04dd9b1680ae 151 OPAMP_InitTypeDef Init; /*!< OPAMP required parameters */
bogdanm 86:04dd9b1680ae 152 HAL_StatusTypeDef Status; /*!< OPAMP peripheral status */
bogdanm 86:04dd9b1680ae 153 HAL_LockTypeDef Lock; /*!< Locking object */
bogdanm 86:04dd9b1680ae 154 __IO HAL_OPAMP_StateTypeDef State; /*!< OPAMP communication state */
bogdanm 86:04dd9b1680ae 155
bogdanm 86:04dd9b1680ae 156 } OPAMP_HandleTypeDef;
bogdanm 86:04dd9b1680ae 157
bogdanm 86:04dd9b1680ae 158 /**
bogdanm 86:04dd9b1680ae 159 * @brief OPAMP_TrimmingValueTypeDef @brief definition
bogdanm 86:04dd9b1680ae 160 */
bogdanm 86:04dd9b1680ae 161
bogdanm 86:04dd9b1680ae 162 typedef uint32_t OPAMP_TrimmingValueTypeDef;
bogdanm 86:04dd9b1680ae 163
bogdanm 86:04dd9b1680ae 164 /* Exported constants --------------------------------------------------------*/
bogdanm 86:04dd9b1680ae 165 /** @defgroup OPAMP_Exported_Constants
bogdanm 86:04dd9b1680ae 166 * @{
bogdanm 86:04dd9b1680ae 167 */
bogdanm 86:04dd9b1680ae 168
bogdanm 86:04dd9b1680ae 169 /**
bogdanm 86:04dd9b1680ae 170 * CSR register Mask
bogdanm 86:04dd9b1680ae 171 */
bogdanm 86:04dd9b1680ae 172 /* Used for Init phase */
bogdanm 86:04dd9b1680ae 173 #define OPAMP_CSR_UPDATE_PARAMETERS_INIT_MASK (OPAMP_CSR_TRIMOFFSETN | OPAMP_CSR_TRIMOFFSETP \
bogdanm 86:04dd9b1680ae 174 | OPAMP_CSR_USERTRIM | OPAMP_CSR_PGGAIN | OPAMP_CSR_VPSSEL \
bogdanm 86:04dd9b1680ae 175 | OPAMP_CSR_VMSSEL | OPAMP_CSR_TCMEN | OPAMP_CSR_VPSEL \
bogdanm 86:04dd9b1680ae 176 | OPAMP_CSR_VPSEL | OPAMP_CSR_FORCEVP)
bogdanm 86:04dd9b1680ae 177
bogdanm 86:04dd9b1680ae 178 /**
bogdanm 86:04dd9b1680ae 179 * @}
bogdanm 86:04dd9b1680ae 180 */
bogdanm 86:04dd9b1680ae 181
bogdanm 86:04dd9b1680ae 182 /** @defgroup OPAMP_Mode
bogdanm 86:04dd9b1680ae 183 * @{
bogdanm 86:04dd9b1680ae 184 */
bogdanm 86:04dd9b1680ae 185 #define OPAMP_STANDALONE_MODE ((uint32_t)0x00000000) /*!< standalone mode */
bogdanm 86:04dd9b1680ae 186 #define OPAMP_PGA_MODE OPAMP_CSR_VMSEL_1 /*!< PGA mode */
bogdanm 86:04dd9b1680ae 187 #define OPAMP_FOLLOWER_MODE OPAMP_CSR_VMSEL /*!< follower mode */
bogdanm 86:04dd9b1680ae 188
bogdanm 86:04dd9b1680ae 189
bogdanm 86:04dd9b1680ae 190 #define IS_OPAMP_FUNCTIONAL_NORMALMODE(INPUT) (((INPUT) == OPAMP_STANDALONE_MODE) || \
bogdanm 86:04dd9b1680ae 191 ((INPUT) == OPAMP_PGA_MODE) || \
bogdanm 86:04dd9b1680ae 192 ((INPUT) == OPAMP_FOLLOWER_MODE))
bogdanm 86:04dd9b1680ae 193
bogdanm 86:04dd9b1680ae 194 /**
bogdanm 86:04dd9b1680ae 195 * @}
bogdanm 86:04dd9b1680ae 196 */
bogdanm 86:04dd9b1680ae 197
bogdanm 86:04dd9b1680ae 198 /** @defgroup OPAMP_NonInvertingInput
bogdanm 86:04dd9b1680ae 199 * @{
bogdanm 86:04dd9b1680ae 200 */
bogdanm 86:04dd9b1680ae 201
bogdanm 86:04dd9b1680ae 202 #define OPAMP_NONINVERTINGINPUT_VP0 OPAMP_CSR_VPSEL /*!< VP0 (PA1 for OPAMP1, PA7 for OPAMP2, PB0 for OPAMP3, PB13 for OPAMP4)
bogdanm 86:04dd9b1680ae 203 connected to OPAMPx non inverting input */
bogdanm 86:04dd9b1680ae 204 #define OPAMP_NONINVERTINGINPUT_VP1 ((uint32_t)0x00000000) /*!< VP1 (PA7 for OPAMP1, PD14 for OPAMP2, PB13 for OPAMP3, PD11 for OPAMP4)
bogdanm 86:04dd9b1680ae 205 connected to OPAMPx non inverting input */
bogdanm 86:04dd9b1680ae 206 #define OPAMP_NONINVERTINGINPUT_VP2 OPAMP_CSR_VPSEL_1 /*!< VP2 (PA3 for OPAMP1, PB0 for OPAMP2, PA1 for OPAMP3, PA4 for OPAMP4)
bogdanm 86:04dd9b1680ae 207 connected to OPAMPx non inverting input */
bogdanm 86:04dd9b1680ae 208 #define OPAMP_NONINVERTINGINPUT_VP3 OPAMP_CSR_VPSEL_0 /*!< vp3 (PA5 for OPAMP1, PB14 for OPAMP2, PA5 for OPAMP3, PB11 for OPAMP4)
bogdanm 86:04dd9b1680ae 209 connected to OPAMPx non inverting input */
bogdanm 86:04dd9b1680ae 210
bogdanm 86:04dd9b1680ae 211 #define IS_OPAMP_NONINVERTING_INPUT(INPUT) (((INPUT) == OPAMP_NONINVERTINGINPUT_VP0) || \
bogdanm 86:04dd9b1680ae 212 ((INPUT) == OPAMP_NONINVERTINGINPUT_VP1) || \
bogdanm 86:04dd9b1680ae 213 ((INPUT) == OPAMP_NONINVERTINGINPUT_VP2) || \
bogdanm 86:04dd9b1680ae 214 ((INPUT) == OPAMP_NONINVERTINGINPUT_VP3))
bogdanm 86:04dd9b1680ae 215
bogdanm 86:04dd9b1680ae 216 /**
bogdanm 86:04dd9b1680ae 217 * @}
bogdanm 86:04dd9b1680ae 218 */
bogdanm 86:04dd9b1680ae 219
bogdanm 86:04dd9b1680ae 220 /** @defgroup OPAMP_InvertingInput
bogdanm 86:04dd9b1680ae 221 * @{
bogdanm 86:04dd9b1680ae 222 */
bogdanm 86:04dd9b1680ae 223
bogdanm 86:04dd9b1680ae 224 #define IOPAMP_INVERTINGINPUT_VM0 ((uint32_t)0x00000000) /*!< inverting input connected to VM0 */
bogdanm 86:04dd9b1680ae 225 #define IOPAMP_INVERTINGINPUT_VM1 OPAMP_CSR_VMSEL_0 /*!< inverting input connected to VM1 */
bogdanm 86:04dd9b1680ae 226
bogdanm 86:04dd9b1680ae 227 #define IS_OPAMP_INVERTING_INPUT(INPUT) (((INPUT) == IOPAMP_INVERTINGINPUT_VM0) || \
bogdanm 86:04dd9b1680ae 228 ((INPUT) == IOPAMP_INVERTINGINPUT_VM1))
bogdanm 86:04dd9b1680ae 229
bogdanm 86:04dd9b1680ae 230 /**
bogdanm 86:04dd9b1680ae 231 * @}
bogdanm 86:04dd9b1680ae 232 */
bogdanm 86:04dd9b1680ae 233
bogdanm 86:04dd9b1680ae 234 /** @defgroup OPAMP_TimerControlledMuxmode
bogdanm 86:04dd9b1680ae 235 * @{
bogdanm 86:04dd9b1680ae 236 */
bogdanm 86:04dd9b1680ae 237 #define OPAMP_TIMERCONTROLLEDMUXMODE_DISABLE ((uint32_t)0x00000000) /*!< Timer controlled Mux mode disabled */
bogdanm 86:04dd9b1680ae 238 #define OPAMP_TIMERCONTROLLEDMUXMODE_ENABLE OPAMP_CSR_TCMEN /*!< Timer controlled Mux mode enabled */
bogdanm 86:04dd9b1680ae 239
bogdanm 86:04dd9b1680ae 240 #define IS_OPAMP_TIMERCONTROLLED_MUXMODE(MUXMODE) (((MUXMODE) == OPAMP_TIMERCONTROLLEDMUXMODE_DISABLE) || \
bogdanm 86:04dd9b1680ae 241 ((MUXMODE) == OPAMP_TIMERCONTROLLEDMUXMODE_ENABLE))
bogdanm 86:04dd9b1680ae 242 /**
bogdanm 86:04dd9b1680ae 243 * @}
bogdanm 86:04dd9b1680ae 244 */
bogdanm 86:04dd9b1680ae 245
bogdanm 86:04dd9b1680ae 246 /** @defgroup OPAMP_NonInvertingInputSecondary
bogdanm 86:04dd9b1680ae 247 * @{
bogdanm 86:04dd9b1680ae 248 */
bogdanm 86:04dd9b1680ae 249
bogdanm 86:04dd9b1680ae 250 #define OPAMP_SEC_NONINVERTINGINPUT_VP0 OPAMP_CSR_VPSSEL /*!< VP0 (PA1 for OPAMP1, PA7 for OPAMP2, PB0 for OPAMP3, PB13 for OPAMP4)
bogdanm 86:04dd9b1680ae 251 connected to OPAMPx non inverting input */
bogdanm 86:04dd9b1680ae 252 #define OPAMP_SEC_NONINVERTINGINPUT_VP1 ((uint32_t)0x00000000) /*!< VP1 (PA7 for OPAMP1, PD14 for OPAMP2, PB13 for OPAMP3, PD11 for OPAMP4)
bogdanm 86:04dd9b1680ae 253 connected to OPAMPx non inverting input */
bogdanm 86:04dd9b1680ae 254 #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 255 connected to OPAMPx non inverting input */
bogdanm 86:04dd9b1680ae 256 #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 257 connected to OPAMPx non inverting input */
bogdanm 86:04dd9b1680ae 258
bogdanm 86:04dd9b1680ae 259 #define IS_OPAMP_SEC_NONINVERTINGINPUT(INPUT) (((INPUT) == OPAMP_SEC_NONINVERTINGINPUT_VP0) || \
bogdanm 86:04dd9b1680ae 260 ((INPUT) == OPAMP_SEC_NONINVERTINGINPUT_VP1) || \
bogdanm 86:04dd9b1680ae 261 ((INPUT) == OPAMP_SEC_NONINVERTINGINPUT_VP2) || \
bogdanm 86:04dd9b1680ae 262 ((INPUT) == OPAMP_SEC_NONINVERTINGINPUT_VP3))
bogdanm 86:04dd9b1680ae 263
bogdanm 86:04dd9b1680ae 264 /**
bogdanm 86:04dd9b1680ae 265 * @}
bogdanm 86:04dd9b1680ae 266 */
bogdanm 86:04dd9b1680ae 267
bogdanm 86:04dd9b1680ae 268 /** @defgroup OPAMP_InvertingInputSecondary
bogdanm 86:04dd9b1680ae 269 * @{
bogdanm 86:04dd9b1680ae 270 */
bogdanm 86:04dd9b1680ae 271
bogdanm 86:04dd9b1680ae 272 #define OPAMP_SEC_INVERTINGINPUT_VM0 ((uint32_t)0x00000000) /*!< VM0 (PC5 for OPAMP1 and OPAMP2, PB10 for OPAMP3 and OPAMP4)
bogdanm 86:04dd9b1680ae 273 connected to OPAMPx inverting input */
bogdanm 86:04dd9b1680ae 274 #define OPAMP_SEC_INVERTINGINPUT_VM1 OPAMP_CSR_VMSSEL /*!< VM1 (PA3 for OPAMP1, PA5 for OPAMP2, PB2 for OPAMP3, PD8 for OPAMP4)
bogdanm 86:04dd9b1680ae 275 connected to OPAMPx inverting input */
bogdanm 86:04dd9b1680ae 276
bogdanm 86:04dd9b1680ae 277 #define IS_OPAMP_SEC_INVERTINGINPUT(INPUT) (((INPUT) == OPAMP_SEC_INVERTINGINPUT_VM0) || \
bogdanm 86:04dd9b1680ae 278 ((INPUT) == OPAMP_SEC_INVERTINGINPUT_VM1))
bogdanm 86:04dd9b1680ae 279
bogdanm 86:04dd9b1680ae 280 /**
bogdanm 86:04dd9b1680ae 281 * @}
bogdanm 86:04dd9b1680ae 282 */
bogdanm 86:04dd9b1680ae 283
bogdanm 86:04dd9b1680ae 284 /** @defgroup OPAMP_PgaConnect
bogdanm 86:04dd9b1680ae 285 * @{
bogdanm 86:04dd9b1680ae 286 */
bogdanm 86:04dd9b1680ae 287
bogdanm 86:04dd9b1680ae 288 #define OPAMP_PGACONNECT_NO ((uint32_t)0x00000000) /*!< In PGA mode, the non inverting input is not connected */
bogdanm 86:04dd9b1680ae 289 #define OPAMP_PGACONNECT_VM0 OPAMP_CSR_PGGAIN_3 /*!< In PGA mode, the non inverting input is connected to VM0 */
bogdanm 86:04dd9b1680ae 290 #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 291
bogdanm 86:04dd9b1680ae 292 #define IS_OPAMP_PGACONNECT(CONNECT) (((CONNECT) == OPAMP_PGACONNECT_NO) || \
bogdanm 86:04dd9b1680ae 293 ((CONNECT) == OPAMP_PGACONNECT_VM0) || \
bogdanm 86:04dd9b1680ae 294 ((CONNECT) == OPAMP_PGACONNECT_VM1))
bogdanm 86:04dd9b1680ae 295 /**
bogdanm 86:04dd9b1680ae 296 * @}
bogdanm 86:04dd9b1680ae 297 */
bogdanm 86:04dd9b1680ae 298
bogdanm 86:04dd9b1680ae 299
bogdanm 86:04dd9b1680ae 300 /** @defgroup OPAMP_PgaGain
bogdanm 86:04dd9b1680ae 301 * @{
bogdanm 86:04dd9b1680ae 302 */
bogdanm 86:04dd9b1680ae 303
bogdanm 86:04dd9b1680ae 304 #define OPAMP_PGA_GAIN_2 ((uint32_t)0x00000000) /*!< PGA gain = 2 */
bogdanm 86:04dd9b1680ae 305 #define OPAMP_PGA_GAIN_4 OPAMP_CSR_PGGAIN_0 /*!< PGA gain = 4 */
bogdanm 86:04dd9b1680ae 306 #define OPAMP_PGA_GAIN_8 OPAMP_CSR_PGGAIN_1 /*!< PGA gain = 8 */
bogdanm 86:04dd9b1680ae 307 #define OPAMP_PGA_GAIN_16 (OPAMP_CSR_PGGAIN_0 | OPAMP_CSR_PGGAIN_1) /*!< PGA gain = 16 */
bogdanm 86:04dd9b1680ae 308
bogdanm 86:04dd9b1680ae 309 #define IS_OPAMP_PGA_GAIN(GAIN) (((GAIN) == OPAMP_PGA_GAIN_2) || \
bogdanm 86:04dd9b1680ae 310 ((GAIN) == OPAMP_PGA_GAIN_4) || \
bogdanm 86:04dd9b1680ae 311 ((GAIN) == OPAMP_PGA_GAIN_8) || \
bogdanm 86:04dd9b1680ae 312 ((GAIN) == OPAMP_PGA_GAIN_16))
bogdanm 86:04dd9b1680ae 313 /**
bogdanm 86:04dd9b1680ae 314 * @}
bogdanm 86:04dd9b1680ae 315 */
bogdanm 86:04dd9b1680ae 316
bogdanm 86:04dd9b1680ae 317 /** @defgroup OPAMP_UserTrimming
bogdanm 86:04dd9b1680ae 318 * @{
bogdanm 86:04dd9b1680ae 319 */
bogdanm 86:04dd9b1680ae 320
bogdanm 86:04dd9b1680ae 321 #define OPAMP_TRIMMING_FACTORY ((uint32_t)0x00000000) /*!< Factory trimming */
bogdanm 86:04dd9b1680ae 322 #define OPAMP_TRIMMING_USER OPAMP_CSR_USERTRIM /*!< User trimming */
bogdanm 86:04dd9b1680ae 323
bogdanm 86:04dd9b1680ae 324 #define IS_OPAMP_TRIMMING(TRIMMING) (((TRIMMING) == OPAMP_TRIMMING_FACTORY) || \
bogdanm 86:04dd9b1680ae 325 ((TRIMMING) == OPAMP_TRIMMING_USER))
bogdanm 86:04dd9b1680ae 326
bogdanm 86:04dd9b1680ae 327 /** @defgroup OPAMP_FactoryTrimming
bogdanm 86:04dd9b1680ae 328 * @{
bogdanm 86:04dd9b1680ae 329 */
bogdanm 86:04dd9b1680ae 330
bogdanm 86:04dd9b1680ae 331 #define OPAMP_FACTORYTRIMMING_DUMMY ((uint32_t)0xFFFFFFFF) /*!< Dummy trimming value */
bogdanm 86:04dd9b1680ae 332
bogdanm 86:04dd9b1680ae 333 #define OPAMP_FACTORYTRIMMING_N ((uint32_t)0x00000000) /*!< Offset trimming N */
bogdanm 86:04dd9b1680ae 334 #define OPAMP_FACTORYTRIMMING_P ((uint32_t)0x00000001) /*!< Offset trimming P */
bogdanm 86:04dd9b1680ae 335
bogdanm 86:04dd9b1680ae 336 #define IS_OPAMP_FACTORYTRIMMING(TRIMMING) (((TRIMMING) == OPAMP_FACTORYTRIMMING_N) || \
bogdanm 86:04dd9b1680ae 337 ((TRIMMING) == OPAMP_FACTORYTRIMMING_P))
bogdanm 86:04dd9b1680ae 338
bogdanm 86:04dd9b1680ae 339 /**
bogdanm 86:04dd9b1680ae 340 * @}
bogdanm 86:04dd9b1680ae 341 */
bogdanm 86:04dd9b1680ae 342
bogdanm 86:04dd9b1680ae 343
bogdanm 86:04dd9b1680ae 344 /** @defgroup OPAMP_TrimmingValue
bogdanm 86:04dd9b1680ae 345 * @{
bogdanm 86:04dd9b1680ae 346 */
bogdanm 86:04dd9b1680ae 347
bogdanm 86:04dd9b1680ae 348 #define IS_OPAMP_TRIMMINGVALUE(TRIMMINGVALUE) ((TRIMMINGVALUE) <= 0x1F)
bogdanm 86:04dd9b1680ae 349
bogdanm 86:04dd9b1680ae 350
bogdanm 86:04dd9b1680ae 351 /**
bogdanm 86:04dd9b1680ae 352 * @}
bogdanm 86:04dd9b1680ae 353 */
bogdanm 86:04dd9b1680ae 354
bogdanm 86:04dd9b1680ae 355
bogdanm 86:04dd9b1680ae 356 /** @defgroup OPAMP_Input
bogdanm 86:04dd9b1680ae 357 * @{
bogdanm 86:04dd9b1680ae 358 */
bogdanm 86:04dd9b1680ae 359
bogdanm 86:04dd9b1680ae 360 #define OPAMP_INPUT_INVERTING ((uint32_t) 24) /*!< Inverting input */
bogdanm 86:04dd9b1680ae 361 #define OPAMP_INPUT_NONINVERTING ((uint32_t) 19) /*!< Non inverting input */
bogdanm 86:04dd9b1680ae 362
bogdanm 86:04dd9b1680ae 363 #define IS_OPAMP_INPUT(INPUT) (((INPUT) == OPAMP_INPUT_INVERTING) || \
bogdanm 86:04dd9b1680ae 364 ((INPUT) == OPAMP_INPUT_NONINVERTING))
bogdanm 86:04dd9b1680ae 365 /**
bogdanm 86:04dd9b1680ae 366 * @}
bogdanm 86:04dd9b1680ae 367 */
bogdanm 86:04dd9b1680ae 368
bogdanm 86:04dd9b1680ae 369
bogdanm 86:04dd9b1680ae 370 /** @defgroup OPAMP_VREF
bogdanm 86:04dd9b1680ae 371 * @{
bogdanm 86:04dd9b1680ae 372 */
bogdanm 86:04dd9b1680ae 373
bogdanm 86:04dd9b1680ae 374 #define OPAMP_VREF_3VDDA ((uint32_t)0x00000000) /*!< OPMAP Vref = 3.3% VDDA */
bogdanm 86:04dd9b1680ae 375 #define OPAMP_VREF_10VDDA OPAMP_CSR_CALSEL_0 /*!< OPMAP Vref = 10% VDDA */
bogdanm 86:04dd9b1680ae 376 #define OPAMP_VREF_50VDDA OPAMP_CSR_CALSEL_1 /*!< OPMAP Vref = 50% VDDA */
bogdanm 86:04dd9b1680ae 377 #define OPAMP_VREF_90VDDA OPAMP_CSR_CALSEL /*!< OPMAP Vref = 90% VDDA */
bogdanm 86:04dd9b1680ae 378
bogdanm 86:04dd9b1680ae 379 #define IS_OPAMP_VREF(VREF) (((VREF) == OPAMP_VREF_3VDDA) || \
bogdanm 86:04dd9b1680ae 380 ((VREF) == OPAMP_VREF_10VDDA) || \
bogdanm 86:04dd9b1680ae 381 ((VREF) == OPAMP_VREF_50VDDA) || \
bogdanm 86:04dd9b1680ae 382 ((VREF) == OPAMP_VREF_90VDDA))
bogdanm 86:04dd9b1680ae 383
bogdanm 86:04dd9b1680ae 384 /**
bogdanm 86:04dd9b1680ae 385 * @}
bogdanm 86:04dd9b1680ae 386 */
bogdanm 86:04dd9b1680ae 387
bogdanm 86:04dd9b1680ae 388 /** @defgroup OPAMP_Vref2ADCforCalib
bogdanm 86:04dd9b1680ae 389 */
bogdanm 86:04dd9b1680ae 390
bogdanm 86:04dd9b1680ae 391 #define OPAMP_VREF_NOTCONNECTEDTO_ADC ((uint32_t)0x00000000) /*!< VREF not connected to ADC */
bogdanm 86:04dd9b1680ae 392 #define OPAMP_VREF_CONNECTEDTO_ADC ((uint32_t)0x00000001) /*!< VREF not connected to ADC */
bogdanm 86:04dd9b1680ae 393
bogdanm 86:04dd9b1680ae 394 #define IS_OPAMP_ALLOPAMPVREF_CONNECT(CONNECT) (((CONNECT) == OPAMP_VREF_NOTCONNECTEDTO_ADC) || \
bogdanm 86:04dd9b1680ae 395 ((CONNECT) == OPAMP_VREF_CONNECTEDTO_ADC))
bogdanm 86:04dd9b1680ae 396
bogdanm 86:04dd9b1680ae 397
bogdanm 86:04dd9b1680ae 398 /**
bogdanm 86:04dd9b1680ae 399 * @}
bogdanm 86:04dd9b1680ae 400 */
bogdanm 86:04dd9b1680ae 401
bogdanm 86:04dd9b1680ae 402 /* Exported macros -----------------------------------------------------------*/
bogdanm 86:04dd9b1680ae 403
bogdanm 86:04dd9b1680ae 404 /** @brief Reset OPAMP handle state
bogdanm 86:04dd9b1680ae 405 * @param __HANDLE__: OPAMP handle.
bogdanm 86:04dd9b1680ae 406 * @retval None
bogdanm 86:04dd9b1680ae 407 */
bogdanm 86:04dd9b1680ae 408 #define __HAL_OPAMP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_OPAMP_STATE_RESET)
bogdanm 86:04dd9b1680ae 409
bogdanm 86:04dd9b1680ae 410 /* Include OPAMP HAL Extension module */
bogdanm 86:04dd9b1680ae 411 #include "stm32f3xx_hal_opamp_ex.h"
bogdanm 86:04dd9b1680ae 412
bogdanm 86:04dd9b1680ae 413 /* Exported functions --------------------------------------------------------*/
bogdanm 86:04dd9b1680ae 414
bogdanm 86:04dd9b1680ae 415 /* Initialization/de-initialization functions **********************************/
bogdanm 86:04dd9b1680ae 416 HAL_StatusTypeDef HAL_OPAMP_Init(OPAMP_HandleTypeDef *hopamp);
bogdanm 86:04dd9b1680ae 417 HAL_StatusTypeDef HAL_OPAMP_DeInit (OPAMP_HandleTypeDef *hopamp);
bogdanm 86:04dd9b1680ae 418 void HAL_OPAMP_MspInit(OPAMP_HandleTypeDef *hopamp);
bogdanm 86:04dd9b1680ae 419 void HAL_OPAMP_MspDeInit(OPAMP_HandleTypeDef *hopamp);
bogdanm 86:04dd9b1680ae 420
bogdanm 86:04dd9b1680ae 421 /* I/O operation functions *****************************************************/
bogdanm 86:04dd9b1680ae 422 HAL_StatusTypeDef HAL_OPAMP_Start(OPAMP_HandleTypeDef *hopamp);
bogdanm 86:04dd9b1680ae 423 HAL_StatusTypeDef HAL_OPAMP_Stop(OPAMP_HandleTypeDef *hopamp);
bogdanm 86:04dd9b1680ae 424 HAL_StatusTypeDef HAL_OPAMP_SelfCalibrate(OPAMP_HandleTypeDef *hopamp);
bogdanm 86:04dd9b1680ae 425
bogdanm 86:04dd9b1680ae 426 /* Peripheral Control functions ************************************************/
bogdanm 86:04dd9b1680ae 427 HAL_StatusTypeDef HAL_OPAMP_Lock(OPAMP_HandleTypeDef *hopamp);
bogdanm 86:04dd9b1680ae 428
bogdanm 86:04dd9b1680ae 429 /* Peripheral State functions **************************************************/
bogdanm 86:04dd9b1680ae 430 HAL_OPAMP_StateTypeDef HAL_OPAMP_GetState(OPAMP_HandleTypeDef *hopamp);
bogdanm 86:04dd9b1680ae 431 OPAMP_TrimmingValueTypeDef HAL_OPAMP_GetTrimOffset (OPAMP_HandleTypeDef *hopamp, uint32_t trimmingoffset);
bogdanm 86:04dd9b1680ae 432
bogdanm 86:04dd9b1680ae 433 /**
bogdanm 86:04dd9b1680ae 434 * @}
bogdanm 86:04dd9b1680ae 435 */
bogdanm 86:04dd9b1680ae 436
bogdanm 86:04dd9b1680ae 437 /**
bogdanm 86:04dd9b1680ae 438 * @}
bogdanm 86:04dd9b1680ae 439 */
bogdanm 86:04dd9b1680ae 440
bogdanm 86:04dd9b1680ae 441 #endif /* STM32F303xC STM32F358xx STM32F302xC STM32F303x8 STM32F328xx
bogdanm 86:04dd9b1680ae 442 STM32F302x8 STM32F301x8 STM32F318xx STM32F334x8 */
bogdanm 86:04dd9b1680ae 443
bogdanm 86:04dd9b1680ae 444 #ifdef __cplusplus
bogdanm 86:04dd9b1680ae 445 }
bogdanm 86:04dd9b1680ae 446 #endif
bogdanm 86:04dd9b1680ae 447
bogdanm 86:04dd9b1680ae 448 #endif /* __STM32F3xx_HAL_OPAMP_H */
bogdanm 86:04dd9b1680ae 449
bogdanm 86:04dd9b1680ae 450 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/