|
STM32G474xx HAL用户手册
|
00001 /** 00002 ****************************************************************************** 00003 * @file stm32g4xx_ll_opamp.h 00004 * @author MCD Application Team 00005 * @brief Header file of OPAMP LL module. 00006 ****************************************************************************** 00007 * @attention 00008 * 00009 * Copyright (c) 2019 STMicroelectronics. 00010 * All rights reserved. 00011 * 00012 * This software is licensed under terms that can be found in the LICENSE file 00013 * in the root directory of this software component. 00014 * If no LICENSE file comes with this software, it is provided AS-IS. 00015 * 00016 ****************************************************************************** 00017 */ 00018 00019 /* Define to prevent recursive inclusion -------------------------------------*/ 00020 #ifndef STM32G4xx_LL_OPAMP_H 00021 #define STM32G4xx_LL_OPAMP_H 00022 00023 #ifdef __cplusplus 00024 extern "C" { 00025 #endif 00027 /* Includes ------------------------------------------------------------------*/ 00028 #include "stm32g4xx.h" 00029 00030 /** @addtogroup STM32G4xx_LL_Driver 00031 * @{ 00032 */ 00033 00034 #if defined (OPAMP1) || defined (OPAMP2) || defined (OPAMP3) || defined (OPAMP4) || defined (OPAMP5) || defined (OPAMP6) 00035 00036 /** @defgroup OPAMP_LL OPAMP 00037 * @{ 00038 */ 00039 00040 /* Private types -------------------------------------------------------------*/ 00041 /* Private variables ---------------------------------------------------------*/ 00042 00043 /* Private constants ---------------------------------------------------------*/ 00044 /** @defgroup OPAMP_LL_Private_Constants OPAMP Private Constants 00045 * @{ 00046 */ 00047 00048 /* Internal mask for OPAMP trimming of transistors differential pair NMOS */ 00049 /* or PMOS. */ 00049 /* To select into literal LL_OPAMP_TRIMMING_x the relevant bits for: */ 00051 /* - OPAMP trimming selection of transistors differential pair */ 00052 /* - OPAMP trimming values of transistors differential pair */ 00053 #define OPAMP_TRIMMING_SELECT_MASK (OPAMP_CSR_CALSEL) 00054 #define OPAMP_TRIMMING_VALUE_MASK (OPAMP_CSR_TRIMOFFSETN | OPAMP_CSR_TRIMOFFSETP) 00055 00056 /** 00057 * @} 00058 */ 00059 00060 00061 /* Private macros ------------------------------------------------------------*/ 00062 /** @defgroup OPAMP_LL_Private_Macros OPAMP Private Macros 00063 * @{ 00064 */ 00065 00066 /** 00067 * @brief Driver macro reserved for internal use: set a pointer to 00067 * a register from a register basis from which an offset 00069 * is applied. 00070 * @param __REG__ Register basis from which the offset is applied. 00071 * @param __REG_OFFSET__ Offset to be applied (unit: number of registers). 00072 * @retval Register address 00073 */ 00074 #define __OPAMP_PTR_REG_OFFSET(__REG__, __REG_OFFSET__) \ 00075 ((__IO uint32_t *)((uint32_t) ((uint32_t)(&(__REG__)) + ((__REG_OFFSET__) << 2)))) 00076 00077 00078 00079 00080 /** 00081 * @} 00082 */ 00083 00085 /* Exported types ------------------------------------------------------------*/ 00086 #if defined(USE_FULL_LL_DRIVER) 00087 /** @defgroup OPAMP_LL_ES_INIT OPAMP Exported Init structure 00088 * @{ 00089 */ 00090 00091 /** 00092 * @brief Structure definition of some features of OPAMP instance. 00093 */ 00094 typedef struct 00095 { 00096 uint32_t PowerMode; /*!< Set OPAMP power mode. 00097 This parameter can be a value of @ref OPAMP_LL_EC_POWERMODE 00098 00099 This feature can be modified afterwards using unitary function @ref LL_OPAMP_SetPowerMode(). */ 00100 00101 00102 uint32_t FunctionalMode; /*!< Set OPAMP functional mode by setting internal connections: OPAMP operation in standalone, follower, ... 00103 This parameter can be a value of @ref OPAMP_LL_EC_FUNCTIONAL_MODE 00103 @note If OPAMP is configured in mode PGA, the gain can be configured using function @ref LL_OPAMP_SetPGAGain(). 00105 00106 This feature can be modified afterwards using unitary function @ref LL_OPAMP_SetFunctionalMode(). */ 00107 00108 uint32_t InputNonInverting; /*!< Set OPAMP input non-inverting connection. 00109 This parameter can be a value of @ref OPAMP_LL_EC_INPUT_NONINVERTING 00110 00111 This feature can be modified afterwards using unitary function @ref LL_OPAMP_SetInputNonInverting(). */ 00112 00113 uint32_t InputInverting; /*!< Set OPAMP inverting input connection. 00114 This parameter can be a value of @ref OPAMP_LL_EC_INPUT_INVERTING 00115 @note OPAMP inverting input is used with OPAMP in mode standalone or PGA with external capacitors for filtering circuit. Otherwise (OPAMP in mode follower), OPAMP inverting input is not used (not connected to GPIO pin), this parameter is discarded. 00116 00117 This feature can be modified afterwards using unitary function @ref LL_OPAMP_SetInputInverting(). */ 00118 00119 } LL_OPAMP_InitTypeDef; 00120 00121 /** 00122 * @} 00123 */ 00124 #endif /* USE_FULL_LL_DRIVER */ 00125 00126 /* Exported constants --------------------------------------------------------*/ 00127 /** @defgroup OPAMP_LL_Exported_Constants OPAMP Exported Constants 00128 * @{ 00129 */ 00130 00131 /** @defgroup OPAMP_LL_EC_MODE OPAMP mode calibration or functional. 00132 * @{ 00133 */ 00134 #define LL_OPAMP_MODE_FUNCTIONAL (0x00000000UL) /*!< OPAMP functional mode */ 00135 #define LL_OPAMP_MODE_CALIBRATION (OPAMP_CSR_CALON) /*!< OPAMP calibration mode */ 00136 /** 00137 * @} 00138 */ 00139 00140 /** @defgroup OPAMP_LL_EC_FUNCTIONAL_MODE OPAMP functional mode 00141 * @{ 00142 */ 00143 #define LL_OPAMP_MODE_STANDALONE (0x00000000UL) /*!< OPAMP functional mode, OPAMP operation in standalone */ 00144 #define LL_OPAMP_MODE_FOLLOWER (OPAMP_CSR_VMSEL_1 | OPAMP_CSR_VMSEL_0) /*!< OPAMP functional mode, OPAMP operation in follower */ 00145 #define LL_OPAMP_MODE_PGA (OPAMP_CSR_VMSEL_1) /*!< OPAMP functional mode, OPAMP operation in PGA */ 00146 #define LL_OPAMP_MODE_PGA_IO0 (OPAMP_CSR_PGGAIN_4|OPAMP_CSR_VMSEL_1) /*!< In PGA mode, the inverting input is connected to VINM0 for filtering */ 00147 #define LL_OPAMP_MODE_PGA_IO0_BIAS (OPAMP_CSR_PGGAIN_3|OPAMP_CSR_VMSEL_1) /*!< In PGA mode, the inverting input is connected to VINM0 00148 - Input signal on VINM0, bias on VINPx: negative gain 00149 - Bias on VINM0, input signal on VINPx: positive gain */ 00150 #define LL_OPAMP_MODE_PGA_IO0_IO1_BIAS (OPAMP_CSR_PGGAIN_4|OPAMP_CSR_PGGAIN_3|OPAMP_CSR_VMSEL_1) /*!< In PGA mode, the inverting input is connected to VINM0 00151 - Input signal on VINM0, bias on VINPx: negative gain 00152 - Bias on VINM0, input signal on VINPx: positive gain 00153 And VINM1 is connected too for filtering */ 00154 00155 /** 00156 * @} 00157 */ 00158 00159 /** @defgroup OPAMP_LL_EC_MODE_PGA_GAIN OPAMP PGA gain (relevant when OPAMP is in functional mode PGA) 00160 * @note Gain sign: 00161 * - is positive if the @ref OPAMP_LL_EC_FUNCTIONAL_MODE configuration is 00162 * @ref LL_OPAMP_MODE_PGA or LL_OPAMP_MODE_PGA_IO0 00163 * - may be positive or negative if the @ref OPAMP_LL_EC_FUNCTIONAL_MODE configuration is 00164 * @ref LL_OPAMP_MODE_PGA_IO0_BIAS or LL_OPAMP_MODE_PGA_IO0_IO1_BIAS 00165 * see @ref OPAMP_LL_EC_FUNCTIONAL_MODE for more details 00166 * @{ 00167 */ 00168 #define LL_OPAMP_PGA_GAIN_2_OR_MINUS_1 (0x00000000UL) /*!< OPAMP PGA gain 2 or -1 */ 00169 #define LL_OPAMP_PGA_GAIN_4_OR_MINUS_3 ( OPAMP_CSR_PGGAIN_0) /*!< OPAMP PGA gain 4 or -3 */ 00170 #define LL_OPAMP_PGA_GAIN_8_OR_MINUS_7 ( OPAMP_CSR_PGGAIN_1 ) /*!< OPAMP PGA gain 8 or -7 */ 00171 #define LL_OPAMP_PGA_GAIN_16_OR_MINUS_15 ( OPAMP_CSR_PGGAIN_1 | OPAMP_CSR_PGGAIN_0) /*!< OPAMP PGA gain 16 or -15 */ 00172 #define LL_OPAMP_PGA_GAIN_32_OR_MINUS_31 (OPAMP_CSR_PGGAIN_2 ) /*!< OPAMP PGA gain 32 or -31 */ 00173 #define LL_OPAMP_PGA_GAIN_64_OR_MINUS_63 (OPAMP_CSR_PGGAIN_2 | OPAMP_CSR_PGGAIN_0) /*!< OPAMP PGA gain 64 or -63 */ 00174 /** 00175 * @} 00176 */ 00177 00178 /** @defgroup OPAMP_LL_EC_INPUT_NONINVERTING OPAMP input non-inverting 00179 * @{ 00180 */ 00181 #define LL_OPAMP_INPUT_NONINVERT_IO0 (0x00000000UL) /*!< OPAMP non inverting input connected to I/O VINP0 00182 (PA1 for OPAMP1, PA7 for OPAMP2, PB0 for OPAMP3, PB13 for OPAMP4, PB14 for OPAMP5, PB12 for OPAMP6) 00183 Note: On this STM32 series, all OPAMPx are not available on all devices. Refer to device datasheet for more details */ 00184 #define LL_OPAMP_INPUT_NONINVERT_IO1 OPAMP_CSR_VPSEL_0 /*!< OPAMP non inverting input connected to I/O VINP1 00185 (PA3 for OPAMP1, PB14 for OPAMP2, PB13 for OPAMP3, PD11 for OPAMP4, PD12 for OPAMP5, PD9 for OPAMP6) 00186 Note: On this STM32 series, all OPAMPx are not available on all devices. Refer to device datasheet for more details */ 00187 #define LL_OPAMP_INPUT_NONINVERT_IO2 OPAMP_CSR_VPSEL_1 /*!< OPAMP non inverting input connected to I