File indexing completed on 2025-05-11 08:23:10
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #if defined(USE_FULL_LL_DRIVER) || defined(__rtems__)
0019
0020
0021 #include "stm32h7xx_ll_opamp.h"
0022
0023 #ifdef USE_FULL_ASSERT
0024 #include "stm32_assert.h"
0025 #else
0026 #define assert_param(expr) ((void)0U)
0027 #endif
0028
0029
0030
0031
0032
0033 #if defined (OPAMP1) || defined (OPAMP2)
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050 #define IS_LL_OPAMP_POWER_MODE(__POWER_MODE__) \
0051 ( ((__POWER_MODE__) == LL_OPAMP_POWERMODE_NORMAL) \
0052 || ((__POWER_MODE__) == LL_OPAMP_POWERMODE_HIGHSPEED))
0053
0054 #define IS_LL_OPAMP_FUNCTIONAL_MODE(__FUNCTIONAL_MODE__) \
0055 ( ((__FUNCTIONAL_MODE__) == LL_OPAMP_MODE_STANDALONE) \
0056 || ((__FUNCTIONAL_MODE__) == LL_OPAMP_MODE_FOLLOWER) \
0057 || ((__FUNCTIONAL_MODE__) == LL_OPAMP_MODE_PGA) \
0058 || ((__FUNCTIONAL_MODE__) == LL_OPAMP_MODE_PGA_IO0) \
0059 || ((__FUNCTIONAL_MODE__) == LL_OPAMP_MODE_PGA_IO0_BIAS) \
0060 || ((__FUNCTIONAL_MODE__) == LL_OPAMP_MODE_PGA_IO0_IO1_BIAS) \
0061 )
0062
0063 #if defined(DAC2)
0064 #define IS_LL_OPAMP_INPUT_NONINVERTING(__INPUT_NONINVERTING__) \
0065 ( ((__INPUT_NONINVERTING__) == LL_OPAMP_INPUT_NONINVERT_IO0) \
0066 || ((__INPUT_NONINVERTING__) == LL_OPAMP_INPUT_NONINVERT_DAC) \
0067 || ((__INPUT_NONINVERTING__) == LL_OPAMP_INPUT_NONINVERT_DAC2) \
0068 )
0069 #else
0070 #define IS_LL_OPAMP_INPUT_NONINVERTING(__INPUT_NONINVERTING__) \
0071 ( ((__INPUT_NONINVERTING__) == LL_OPAMP_INPUT_NONINVERT_IO0) \
0072 || ((__INPUT_NONINVERTING__) == LL_OPAMP_INPUT_NONINVERT_DAC) \
0073 )
0074 #endif
0075
0076
0077 #define IS_LL_OPAMP_INPUT_INVERTING(__INPUT_INVERTING__) \
0078 ( ((__INPUT_INVERTING__) == LL_OPAMP_INPUT_INVERT_IO0) \
0079 || ((__INPUT_INVERTING__) == LL_OPAMP_INPUT_INVERT_IO1) \
0080 || ((__INPUT_INVERTING__) == LL_OPAMP_INPUT_INVERT_CONNECT_NO) \
0081 )
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110 ErrorStatus LL_OPAMP_DeInit(OPAMP_TypeDef* OPAMPx)
0111 {
0112 ErrorStatus status = SUCCESS;
0113
0114
0115 assert_param(IS_OPAMP_ALL_INSTANCE(OPAMPx));
0116
0117 LL_OPAMP_WriteReg(OPAMPx, CSR, 0x00000000U);
0118
0119 return status;
0120 }
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134 ErrorStatus LL_OPAMP_Init(OPAMP_TypeDef *OPAMPx, LL_OPAMP_InitTypeDef *OPAMP_InitStruct)
0135 {
0136 ErrorStatus status = SUCCESS;
0137
0138
0139 assert_param(IS_OPAMP_ALL_INSTANCE(OPAMPx));
0140 assert_param(IS_LL_OPAMP_POWER_MODE(OPAMP_InitStruct->PowerMode));
0141 assert_param(IS_LL_OPAMP_FUNCTIONAL_MODE(OPAMP_InitStruct->FunctionalMode));
0142 assert_param(IS_LL_OPAMP_INPUT_NONINVERTING(OPAMP_InitStruct->InputNonInverting));
0143
0144
0145
0146
0147
0148 if(OPAMP_InitStruct->FunctionalMode != LL_OPAMP_MODE_FOLLOWER)
0149 {
0150 assert_param(IS_LL_OPAMP_INPUT_INVERTING(OPAMP_InitStruct->InputInverting));
0151 }
0152
0153
0154
0155
0156
0157
0158
0159 if(OPAMP_InitStruct->FunctionalMode != LL_OPAMP_MODE_FOLLOWER)
0160 {
0161 MODIFY_REG(OPAMPx->CSR,
0162 OPAMP_CSR_OPAHSM
0163 | OPAMP_CSR_CALON
0164 | OPAMP_CSR_VMSEL
0165 | OPAMP_CSR_VPSEL
0166 | OPAMP_CSR_PGGAIN_2 | OPAMP_CSR_PGGAIN_1
0167 ,
0168 (OPAMP_InitStruct->PowerMode & OPAMP_POWERMODE_CSR_BIT_MASK)
0169 | OPAMP_InitStruct->FunctionalMode
0170 | OPAMP_InitStruct->InputNonInverting
0171 | OPAMP_InitStruct->InputInverting
0172 );
0173 }
0174 else
0175 {
0176 MODIFY_REG(OPAMPx->CSR,
0177 OPAMP_CSR_OPAHSM
0178 | OPAMP_CSR_CALON
0179 | OPAMP_CSR_VMSEL
0180 | OPAMP_CSR_VPSEL
0181 | OPAMP_CSR_PGGAIN_2 | OPAMP_CSR_PGGAIN_1
0182 ,
0183 (OPAMP_InitStruct->PowerMode & OPAMP_POWERMODE_CSR_BIT_MASK)
0184 | LL_OPAMP_MODE_FOLLOWER
0185 | OPAMP_InitStruct->InputNonInverting
0186 );
0187 }
0188
0189 return status;
0190 }
0191
0192
0193
0194
0195
0196
0197
0198 void LL_OPAMP_StructInit(LL_OPAMP_InitTypeDef *OPAMP_InitStruct)
0199 {
0200
0201 OPAMP_InitStruct->PowerMode = LL_OPAMP_POWERMODE_NORMAL;
0202 OPAMP_InitStruct->FunctionalMode = LL_OPAMP_MODE_FOLLOWER;
0203 OPAMP_InitStruct->InputNonInverting = LL_OPAMP_INPUT_NONINVERT_IO0;
0204
0205
0206 OPAMP_InitStruct->InputInverting = LL_OPAMP_INPUT_INVERT_CONNECT_NO;
0207 }
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221 #endif
0222
0223
0224
0225
0226
0227 #endif
0228