![]() |
|
|||
File indexing completed on 2025-05-11 08:23:37
0001 /** 0002 ****************************************************************************** 0003 * @file stm32h7xx_ll_adc.h 0004 * @author MCD Application Team 0005 * @brief Header file of ADC LL module. 0006 ****************************************************************************** 0007 * @attention 0008 * 0009 * Copyright (c) 2017 STMicroelectronics. 0010 * All rights reserved. 0011 * 0012 * This software is licensed under terms that can be found in the LICENSE file 0013 * in the root directory of this software component. 0014 * If no LICENSE file comes with this software, it is provided AS-IS. 0015 * 0016 ****************************************************************************** 0017 */ 0018 0019 /* Define to prevent recursive inclusion -------------------------------------*/ 0020 #ifndef STM32H7xx_LL_ADC_H 0021 #define STM32H7xx_LL_ADC_H 0022 0023 #ifdef __cplusplus 0024 extern "C" { 0025 #endif 0026 0027 /* Includes ------------------------------------------------------------------*/ 0028 #include "stm32h7xx.h" 0029 0030 /** @addtogroup STM32H7xx_LL_Driver 0031 * @{ 0032 */ 0033 0034 #if defined (ADC1) || defined (ADC2) || defined (ADC3) 0035 0036 /** @defgroup ADC_LL ADC 0037 * @ingroup RTEMSBSPsARMSTM32H7 0038 * @{ 0039 */ 0040 0041 /* Private types -------------------------------------------------------------*/ 0042 /* Private variables ---------------------------------------------------------*/ 0043 0044 /* Private constants ---------------------------------------------------------*/ 0045 /** @defgroup ADC_LL_Private_Constants ADC Private Constants 0046 * @ingroup RTEMSBSPsARMSTM32H7 0047 * @{ 0048 */ 0049 0050 /* Internal mask for ADC calibration: */ 0051 /* Internal register offset for ADC calibration factors configuration */ 0052 0053 /* To select into literals LL_ADC_CALIB_OFFSET, LL_ADC_CALIB_LINEARITY, ... */ 0054 /* the relevant bits for: */ 0055 /* (concatenation of multiple bits used in different registers) */ 0056 /* - ADC calibration configuration: configuration before calibration start */ 0057 /* - ADC calibration factors: register offset */ 0058 #define ADC_CALIB_FACTOR_OFFSET_REGOFFSET (0x00000000UL) /* Register CALFACT defined as reference register */ 0059 #define ADC_CALIB_FACTOR_LINEARITY_REGOFFSET (0x00000001UL) /* Register CALFACT2 offset vs register CALFACT */ 0060 #define ADC_CALIB_FACTOR_REGOFFSET_MASK (ADC_CALIB_FACTOR_OFFSET_REGOFFSET | ADC_CALIB_FACTOR_LINEARITY_REGOFFSET) 0061 #define ADC_CALIB_MODE_MASK (ADC_CR_ADCALLIN) 0062 #define ADC_CALIB_MODE_BINARY_MASK (ADC_CALIB_FACTOR_REGOFFSET_MASK) /* Mask to get binary value of calibration mode: 0 for offset, 1 for linearity */ 0063 0064 0065 /* Internal mask for ADC group regular sequencer: */ 0066 /* To select into literal LL_ADC_REG_RANK_x the relevant bits for: */ 0067 /* - sequencer register offset */ 0068 /* - sequencer rank bits position into the selected register */ 0069 0070 /* Internal register offset for ADC group regular sequencer configuration */ 0071 /* (offset placed into a spare area of literal definition) */ 0072 #define ADC_SQR1_REGOFFSET (0x00000000UL) 0073 #define ADC_SQR2_REGOFFSET (0x00000100UL) 0074 #define ADC_SQR3_REGOFFSET (0x00000200UL) 0075 #define ADC_SQR4_REGOFFSET (0x00000300UL) 0076 0077 #define ADC_REG_SQRX_REGOFFSET_MASK (ADC_SQR1_REGOFFSET | ADC_SQR2_REGOFFSET | ADC_SQR3_REGOFFSET | ADC_SQR4_REGOFFSET) 0078 #define ADC_SQRX_REGOFFSET_POS (8UL) /* Position of bits ADC_SQRx_REGOFFSET in ADC_REG_SQRX_REGOFFSET_MASK */ 0079 #define ADC_REG_RANK_ID_SQRX_MASK (ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0) 0080 0081 /* Definition of ADC group regular sequencer bits information to be inserted */ 0082 /* into ADC group regular sequencer ranks literals definition. */ 0083 #define ADC_REG_RANK_1_SQRX_BITOFFSET_POS ( 6UL) /* Value equivalent to bitfield "ADC_SQR1_SQ1" position in register */ 0084 #define ADC_REG_RANK_2_SQRX_BITOFFSET_POS (12UL) /* Value equivalent to bitfield "ADC_SQR1_SQ2" position in register */ 0085 #define ADC_REG_RANK_3_SQRX_BITOFFSET_POS (18UL) /* Value equivalent to bitfield "ADC_SQR1_SQ3" position in register */ 0086 #define ADC_REG_RANK_4_SQRX_BITOFFSET_POS (24UL) /* Value equivalent to bitfield "ADC_SQR1_SQ4" position in register */ 0087 #define ADC_REG_RANK_5_SQRX_BITOFFSET_POS ( 0UL) /* Value equivalent to bitfield "ADC_SQR2_SQ5" position in register */ 0088 #define ADC_REG_RANK_6_SQRX_BITOFFSET_POS ( 6UL) /* Value equivalent to bitfield "ADC_SQR2_SQ6" position in register */ 0089 #define ADC_REG_RANK_7_SQRX_BITOFFSET_POS (12UL) /* Value equivalent to bitfield "ADC_SQR2_SQ7" position in register */ 0090 #define ADC_REG_RANK_8_SQRX_BITOFFSET_POS (18UL) /* Value equivalent to bitfield "ADC_SQR2_SQ8" position in register */ 0091 #define ADC_REG_RANK_9_SQRX_BITOFFSET_POS (24UL) /* Value equivalent to bitfield "ADC_SQR2_SQ9" position in register */ 0092 #define ADC_REG_RANK_10_SQRX_BITOFFSET_POS ( 0UL) /* Value equivalent to bitfield "ADC_SQR3_SQ10" position in register */ 0093 #define ADC_REG_RANK_11_SQRX_BITOFFSET_POS ( 6UL) /* Value equivalent to bitfield "ADC_SQR3_SQ11" position in register */ 0094 #define ADC_REG_RANK_12_SQRX_BITOFFSET_POS (12UL) /* Value equivalent to bitfield "ADC_SQR3_SQ12" position in register */ 0095 #define ADC_REG_RANK_13_SQRX_BITOFFSET_POS (18UL) /* Value equivalent to bitfield "ADC_SQR3_SQ13" position in register */ 0096 #define ADC_REG_RANK_14_SQRX_BITOFFSET_POS (24UL) /* Value equivalent to bitfield "ADC_SQR3_SQ14" position in register */ 0097 #define ADC_REG_RANK_15_SQRX_BITOFFSET_POS ( 0UL) /* Value equivalent to bitfield "ADC_SQR4_SQ15" position in register */ 0098 #define ADC_REG_RANK_16_SQRX_BITOFFSET_POS ( 6UL) /* Value equivalent to bitfield "ADC_SQR4_SQ16" position in register */ 0099 0100 0101 0102 /* Internal mask for ADC group injected sequencer: */ 0103 /* To select into literal LL_ADC_INJ_RANK_x the relevant bits for: */ 0104 /* - data register offset */ 0105 /* - sequencer rank bits position into the selected register */ 0106 0107 /* Internal register offset for ADC group injected data register */ 0108 /* (offset placed into a spare area of literal definition) */ 0109 #define ADC_JDR1_REGOFFSET (0x00000000UL) 0110 #define ADC_JDR2_REGOFFSET (0x00000100UL) 0111 #define ADC_JDR3_REGOFFSET (0x00000200UL) 0112 #define ADC_JDR4_REGOFFSET (0x00000300UL) 0113 0114 #define ADC_INJ_JDRX_REGOFFSET_MASK (ADC_JDR1_REGOFFSET | ADC_JDR2_REGOFFSET | ADC_JDR3_REGOFFSET | ADC_JDR4_REGOFFSET) 0115 #define ADC_INJ_RANK_ID_JSQR_MASK (ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0) 0116 #define ADC_JDRX_REGOFFSET_POS (8UL) /* Position of bits ADC_JDRx_REGOFFSET in ADC_INJ_JDRX_REGOFFSET_MASK */ 0117 0118 /* Definition of ADC group injected sequencer bits information to be inserted */ 0119 /* into ADC group injected sequencer ranks literals definition. */ 0120 #define ADC_INJ_RANK_1_JSQR_BITOFFSET_POS (ADC_JSQR_JSQ1_Pos) 0121 #define ADC_INJ_RANK_2_JSQR_BITOFFSET_POS (ADC_JSQR_JSQ2_Pos) 0122 #define ADC_INJ_RANK_3_JSQR_BITOFFSET_POS (ADC_JSQR_JSQ3_Pos) 0123 #define ADC_INJ_RANK_4_JSQR_BITOFFSET_POS (ADC_JSQR_JSQ4_Pos) 0124 0125 0126 0127 /* Internal mask for ADC group regular trigger: */ 0128 /* To select into literal LL_ADC_REG_TRIG_x the relevant bits for: */ 0129 /* - regular trigger source */ 0130 /* - regular trigger edge */ 0131 #define ADC_REG_TRIG_EXT_EDGE_DEFAULT (ADC_CFGR_EXTEN_0) /* Trigger edge set to rising edge (default setting for compatibility with some ADC on other STM32 families having this setting set by HW default value) */ 0132 0133 /* Mask containing trigger source masks for each of possible */ 0134 /* trigger edge selection duplicated with shifts [0; 4; 8; 12] */ 0135 /* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */ 0136 #define ADC_REG_TRIG_SOURCE_MASK (((LL_ADC_REG_TRIG_SOFTWARE & ADC_CFGR_EXTSEL) << (4U * 0UL)) | \ 0137 ((ADC_CFGR_EXTSEL) << (4U * 1UL)) | \ 0138 ((ADC_CFGR_EXTSEL) << (4U * 2UL)) | \ 0139 ((ADC_CFGR_EXTSEL) << (4U * 3UL)) ) 0140 0141 /* Mask containing trigger edge masks for each of possible */ 0142 /* trigger edge selection duplicated with shifts [0; 4; 8; 12] */ 0143 /* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */ 0144 #define ADC_REG_TRIG_EDGE_MASK (((LL_ADC_REG_TRIG_SOFTWARE & ADC_CFGR_EXTEN) << (4U * 0UL)) | \ 0145 ((ADC_REG_TRIG_EXT_EDGE_DEFAULT) << (4U * 1UL)) | \ 0146 ((ADC_REG_TRIG_EXT_EDGE_DEFAULT) << (4U * 2UL)) | \ 0147 ((ADC_REG_TRIG_EXT_EDGE_DEFAULT) << (4U * 3UL)) ) 0148 0149 /* Definition of ADC group regular trigger bits information. */ 0150 #define ADC_REG_TRIG_EXTSEL_BITOFFSET_POS ( 6UL) /* Value equivalent to bitfield "ADC_CFGR_EXTSEL" position in register */ 0151 #define ADC_REG_TRIG_EXTEN_BITOFFSET_POS (10UL) /* Value equivalent to bitfield "ADC_CFGR_EXTEN" position in register */ 0152 0153 0154 0155 /* Internal mask for ADC group injected trigger: */ 0156 /* To select into literal LL_ADC_INJ_TRIG_x the relevant bits for: */ 0157 /* - injected trigger source */ 0158 /* - injected trigger edge */ 0159 #define ADC_INJ_TRIG_EXT_EDGE_DEFAULT (ADC_JSQR_JEXTEN_0) /* Trigger edge set to rising edge (default setting for compatibility with some ADC on other STM32 families having this setting set by HW default value) */ 0160 0161 /* Mask containing trigger source masks for each of possible */ 0162 /* trigger edge selection duplicated with shifts [0; 4; 8; 12] */ 0163 /* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */ 0164 #define ADC_INJ_TRIG_SOURCE_MASK (((LL_ADC_INJ_TRIG_SOFTWARE & ADC_JSQR_JEXTSEL) << (4U * 0UL)) | \ 0165 ((ADC_JSQR_JEXTSEL) << (4U * 1UL)) | \ 0166 ((ADC_JSQR_JEXTSEL) << (4U * 2UL)) | \ 0167 ((ADC_JSQR_JEXTSEL) << (4U * 3UL)) ) 0168 0169 /* Mask containing trigger edge masks for each of possible */ 0170 /* trigger edge selection duplicated with shifts [0; 4; 8; 12] */ 0171 /* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */ 0172 #define ADC_INJ_TRIG_EDGE_MASK (((LL_ADC_INJ_TRIG_SOFTWARE & ADC_JSQR_JEXTEN) << (4U * 0UL)) | \ 0173 ((ADC_INJ_TRIG_EXT_EDGE_DEFAULT) << (4U * 1UL)) | \ 0174 ((ADC_INJ_TRIG_EXT_EDGE_DEFAULT) << (4U * 2UL)) | \ 0175 ((ADC_INJ_TRIG_EXT_EDGE_DEFAULT) << (4U * 3UL)) ) 0176 0177 /* Definition of ADC group injected trigger bits information. */ 0178 #define ADC_INJ_TRIG_EXTSEL_BITOFFSET_POS ( 2UL) /* Value equivalent to bitfield "ADC_JSQR_JEXTSEL" position in register */ 0179 #define ADC_INJ_TRIG_EXTEN_BITOFFSET_POS ( 6UL) /* Value equivalent to bitfield "ADC_JSQR_JEXTEN" position in register */ 0180 0181 0182 0183 0184 0185 0186 /* Internal mask for ADC channel: */ 0187 /* To select into literal LL_ADC_CHANNEL_x the relevant bits for: */ 0188 /* - channel identifier defined by number */ 0189 /* - channel identifier defined by bitfield */ 0190 /* - channel differentiation between external channels (connected to */ 0191 /* GPIO pins) and internal channels (connected to internal paths) */ 0192 /* - channel sampling time defined by SMPRx register offset */ 0193 /* and SMPx bits positions into SMPRx register */ 0194 #define ADC_CHANNEL_ID_NUMBER_MASK (ADC_CFGR_AWD1CH) 0195 #define ADC_CHANNEL_ID_BITFIELD_MASK (ADC_AWD2CR_AWD2CH) 0196 #define ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS (26UL)/* Value equivalent to bitfield "ADC_CHANNEL_ID_NUMBER_MASK" position in register */ 0197 #define ADC_CHANNEL_ID_MASK (ADC_CHANNEL_ID_NUMBER_MASK | ADC_CHANNEL_ID_BITFIELD_MASK | ADC_CHANNEL_ID_INTERNAL_CH_MASK) 0198 /* Equivalent mask of ADC_CHANNEL_NUMBER_MASK aligned on register LSB (bit 0) */ 0199 #define ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0 (ADC_SQR2_SQ5) /* Equivalent to shift: (ADC_CHANNEL_NUMBER_MASK >> [Position of bitfield "ADC_CHANNEL_NUMBER_MASK" in register]) */ 0200 0201 /* Channel differentiation between external and internal channels */ 0202 #define ADC_CHANNEL_ID_INTERNAL_CH (0x80000000UL) /* Marker of internal channel */ 0203 #define ADC_CHANNEL_ID_INTERNAL_CH_MASK (ADC_CHANNEL_ID_INTERNAL_CH) 0204 0205 /* Internal register offset for ADC channel sampling time configuration */ 0206 /* (offset placed into a spare area of literal definition) */ 0207 #define ADC_SMPR1_REGOFFSET (0x00000000UL) 0208 #define ADC_SMPR2_REGOFFSET (0x02000000UL) 0209 #define ADC_CHANNEL_SMPRX_REGOFFSET_MASK (ADC_SMPR1_REGOFFSET | ADC_SMPR2_REGOFFSET) 0210 #define ADC_SMPRX_REGOFFSET_POS (25UL) /* Position of bits ADC_SMPRx_REGOFFSET in ADC_CHANNEL_SMPRX_REGOFFSET_MASK */ 0211 0212 #define ADC_CHANNEL_SMPx_BITOFFSET_MASK (0x01F00000UL) 0213 #define ADC_CHANNEL_SMPx_BITOFFSET_POS (20UL) /* Value equivalent to bitfield "ADC_CHANNEL_SMPx_BITOFFSET_MASK" position in register */ 0214 0215 /* Definition of channels ID number information to be inserted into */ 0216 /* channels literals definition. */ 0217 #define ADC_CHANNEL_0_NUMBER (0x00000000UL) 0218 #define ADC_CHANNEL_1_NUMBER ( ADC_CFGR_AWD1CH_0) 0219 #define ADC_CHANNEL_2_NUMBER ( ADC_CFGR_AWD1CH_1 ) 0220 #define ADC_CHANNEL_3_NUMBER ( ADC_CFGR_AWD1CH_1 | ADC_CFGR_AWD1CH_0) 0221 #define ADC_CHANNEL_4_NUMBER ( ADC_CFGR_AWD1CH_2 ) 0222 #define ADC_CHANNEL_5_NUMBER ( ADC_CFGR_AWD1CH_2 | ADC_CFGR_AWD1CH_0) 0223 #define ADC_CHANNEL_6_NUMBER ( ADC_CFGR_AWD1CH_2 | ADC_CFGR_AWD1CH_1 ) 0224 #define ADC_CHANNEL_7_NUMBER ( ADC_CFGR_AWD1CH_2 | ADC_CFGR_AWD1CH_1 | ADC_CFGR_AWD1CH_0) 0225 #define ADC_CHANNEL_8_NUMBER ( ADC_CFGR_AWD1CH_3 ) 0226 #define ADC_CHANNEL_9_NUMBER ( ADC_CFGR_AWD1CH_3 | ADC_CFGR_AWD1CH_0) 0227 #define ADC_CHANNEL_10_NUMBER ( ADC_CFGR_AWD1CH_3 | ADC_CFGR_AWD1CH_1 ) 0228 #define ADC_CHANNEL_11_NUMBER ( ADC_CFGR_AWD1CH_3 | ADC_CFGR_AWD1CH_1 | ADC_CFGR_AWD1CH_0) 0229 #define ADC_CHANNEL_12_NUMBER ( ADC_CFGR_AWD1CH_3 | ADC_CFGR_AWD1CH_2 ) 0230 #define ADC_CHANNEL_13_NUMBER ( ADC_CFGR_AWD1CH_3 | ADC_CFGR_AWD1CH_2 | ADC_CFGR_AWD1CH_0) 0231 #define ADC_CHANNEL_14_NUMBER ( ADC_CFGR_AWD1CH_3 | ADC_CFGR_AWD1CH_2 | ADC_CFGR_AWD1CH_1 ) 0232 #define ADC_CHANNEL_15_NUMBER ( ADC_CFGR_AWD1CH_3 | ADC_CFGR_AWD1CH_2 | ADC_CFGR_AWD1CH_1 | ADC_CFGR_AWD1CH_0) 0233 #define ADC_CHANNEL_16_NUMBER (ADC_CFGR_AWD1CH_4 ) 0234 #define ADC_CHANNEL_17_NUMBER (ADC_CFGR_AWD1CH_4 | ADC_CFGR_AWD1CH_0) 0235 #define ADC_CHANNEL_18_NUMBER (ADC_CFGR_AWD1CH_4 | ADC_CFGR_AWD1CH_1 ) 0236 #define ADC_CHANNEL_19_NUMBER (ADC_CFGR_AWD1CH_4 | ADC_CFGR_AWD1CH_1 | ADC_CFGR_AWD1CH_0) 0237 0238 /* Definition of channels ID bitfield information to be inserted into */ 0239 /* channels literals definition. */ 0240 #define ADC_CHANNEL_0_BITFIELD (ADC_AWD2CR_AWD2CH_0) 0241 #define ADC_CHANNEL_1_BITFIELD (ADC_AWD2CR_AWD2CH_1) 0242 #define ADC_CHANNEL_2_BITFIELD (ADC_AWD2CR_AWD2CH_2) 0243 #define ADC_CHANNEL_3_BITFIELD (ADC_AWD2CR_AWD2CH_3) 0244 #define ADC_CHANNEL_4_BITFIELD (ADC_AWD2CR_AWD2CH_4) 0245 #define ADC_CHANNEL_5_BITFIELD (ADC_AWD2CR_AWD2CH_5) 0246 #define ADC_CHANNEL_6_BITFIELD (ADC_AWD2CR_AWD2CH_6) 0247 #define ADC_CHANNEL_7_BITFIELD (ADC_AWD2CR_AWD2CH_7) 0248 #define ADC_CHANNEL_8_BITFIELD (ADC_AWD2CR_AWD2CH_8) 0249 #define ADC_CHANNEL_9_BITFIELD (ADC_AWD2CR_AWD2CH_9) 0250 #define ADC_CHANNEL_10_BITFIELD (ADC_AWD2CR_AWD2CH_10) 0251 #define ADC_CHANNEL_11_BITFIELD (ADC_AWD2CR_AWD2CH_11) 0252 #define ADC_CHANNEL_12_BITFIELD (ADC_AWD2CR_AWD2CH_12) 0253 #define ADC_CHANNEL_13_BITFIELD (ADC_AWD2CR_AWD2CH_13) 0254 #define ADC_CHANNEL_14_BITFIELD (ADC_AWD2CR_AWD2CH_14) 0255 #define ADC_CHANNEL_15_BITFIELD (ADC_AWD2CR_AWD2CH_15) 0256 #define ADC_CHANNEL_16_BITFIELD (ADC_AWD2CR_AWD2CH_16) 0257 #define ADC_CHANNEL_17_BITFIELD (ADC_AWD2CR_AWD2CH_17) 0258 #define ADC_CHANNEL_18_BITFIELD (ADC_AWD2CR_AWD2CH_18) 0259 #define ADC_CHANNEL_19_BITFIELD (ADC_AWD2CR_AWD2CH_19) 0260 0261 /* Definition of channels sampling time information to be inserted into */ 0262 /* channels literals definition. */ 0263 #define ADC_CHANNEL_0_SMP (ADC_SMPR1_REGOFFSET | (( 0UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to bitfield "ADC_SMPR1_SMP0" position in register */ 0264 #define ADC_CHANNEL_1_SMP (ADC_SMPR1_REGOFFSET | (( 3UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to bitfield "ADC_SMPR1_SMP1" position in register */ 0265 #define ADC_CHANNEL_2_SMP (ADC_SMPR1_REGOFFSET | (( 6UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to bitfield "ADC_SMPR1_SMP2" position in register */ 0266 #define ADC_CHANNEL_3_SMP (ADC_SMPR1_REGOFFSET | (( 9UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to bitfield "ADC_SMPR1_SMP3" position in register */ 0267 #define ADC_CHANNEL_4_SMP (ADC_SMPR1_REGOFFSET | ((12UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to bitfield "ADC_SMPR1_SMP4" position in register */ 0268 #define ADC_CHANNEL_5_SMP (ADC_SMPR1_REGOFFSET | ((15UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to bitfield "ADC_SMPR1_SMP5" position in register */ 0269 #define ADC_CHANNEL_6_SMP (ADC_SMPR1_REGOFFSET | ((18UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to bitfield "ADC_SMPR1_SMP6" position in register */ 0270 #define ADC_CHANNEL_7_SMP (ADC_SMPR1_REGOFFSET | ((21UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to bitfield "ADC_SMPR1_SMP7" position in register */ 0271 #define ADC_CHANNEL_8_SMP (ADC_SMPR1_REGOFFSET | ((24UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to bitfield "ADC_SMPR1_SMP8" position in register */ 0272 #define ADC_CHANNEL_9_SMP (ADC_SMPR1_REGOFFSET | ((27UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to bitfield "ADC_SMPR1_SMP9" position in register */ 0273 #define ADC_CHANNEL_10_SMP (ADC_SMPR2_REGOFFSET | (( 0UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to bitfield "ADC_SMPR2_SMP10" position in register */ 0274 #define ADC_CHANNEL_11_SMP (ADC_SMPR2_REGOFFSET | (( 3UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to bitfield "ADC_SMPR2_SMP11" position in register */ 0275 #define ADC_CHANNEL_12_SMP (ADC_SMPR2_REGOFFSET | (( 6UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to bitfield "ADC_SMPR2_SMP12" position in register */ 0276 #define ADC_CHANNEL_13_SMP (ADC_SMPR2_REGOFFSET | (( 9UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to bitfield "ADC_SMPR2_SMP13" position in register */ 0277 #define ADC_CHANNEL_14_SMP (ADC_SMPR2_REGOFFSET | ((12UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to bitfield "ADC_SMPR2_SMP14" position in register */ 0278 #define ADC_CHANNEL_15_SMP (ADC_SMPR2_REGOFFSET | ((15UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to bitfield "ADC_SMPR2_SMP15" position in register */ 0279 #define ADC_CHANNEL_16_SMP (ADC_SMPR2_REGOFFSET | ((18UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to bitfield "ADC_SMPR2_SMP16" position in register */ 0280 #define ADC_CHANNEL_17_SMP (ADC_SMPR2_REGOFFSET | ((21UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to bitfield "ADC_SMPR2_SMP17" position in register */ 0281 #define ADC_CHANNEL_18_SMP (ADC_SMPR2_REGOFFSET | ((24UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to bitfield "ADC_SMPR2_SMP18" position in register */ 0282 #define ADC_CHANNEL_19_SMP (ADC_SMPR2_REGOFFSET | ((27UL) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to bitfield "ADC_SMPR2_SMP19" position in register */ 0283 0284 0285 /* Internal mask for ADC mode single or differential ended: */ 0286 /* To select into literals LL_ADC_SINGLE_ENDED or LL_ADC_SINGLE_DIFFERENTIAL */ 0287 /* the relevant bits for: */ 0288 /* (concatenation of multiple bits used in different registers) */ 0289 /* - ADC calibration: calibration start, calibration factor get or set */ 0290 /* - ADC channels: set each ADC channel ending mode */ 0291 #define ADC_SINGLEDIFF_CALIB_START_MASK (ADC_CR_ADCALDIF) 0292 #define ADC_SINGLEDIFF_CALIB_FACTOR_MASK (ADC_CALFACT_CALFACT_D | ADC_CALFACT_CALFACT_S) 0293 #define ADC_SINGLEDIFF_CHANNEL_MASK (ADC_CHANNEL_ID_BITFIELD_MASK) /* Equivalent to ADC_DIFSEL_DIFSEL */ 0294 #define ADC_SINGLEDIFF_CHANNEL_SHIFT_MASK (ADC_CALFACT_CALFACT_S_4 | ADC_CALFACT_CALFACT_S_3) /* Bits chosen to perform of shift when single mode is selected, shift value out of channels bits range. */ 0295 #define ADC_SINGLEDIFF_CALIB_F_BIT_D_MASK (0x00010000UL) /* Selection of 1 bit to discriminate differential mode: mask of bit */ 0296 #define ADC_SINGLEDIFF_CALIB_F_BIT_D_POS (16UL) /* Selection of 1 bit to discriminate differential mode: position of bit */ 0297 #define ADC_SINGLEDIFF_CALIB_F_BIT_D_SHIFT4 (ADC_SINGLEDIFF_CALIB_F_BIT_D_POS - 4UL) /* Shift of bit ADC_SINGLEDIFF_CALIB_F_BIT_D to position to perform a shift of 4 ranks */ 0298 0299 /* Internal mask for ADC analog watchdog: */ 0300 /* To select into literals LL_ADC_AWD_CHANNELx_xxx the relevant bits for: */ 0301 /* (concatenation of multiple bits used in different analog watchdogs, */ 0302 /* (feature of several watchdogs not available on all STM32 families)). */ 0303 /* - analog watchdog 1: monitored channel defined by number, */ 0304 /* selection of ADC group (ADC groups regular and-or injected). */ 0305 /* - analog watchdog 2 and 3: monitored channel defined by bitfield, no */ 0306 /* selection on groups. */ 0307 0308 /* Internal register offset for ADC analog watchdog channel configuration */ 0309 #define ADC_AWD_CR1_REGOFFSET (0x00000000UL) 0310 #define ADC_AWD_CR2_REGOFFSET (0x00100000UL) 0311 #define ADC_AWD_CR3_REGOFFSET (0x00200000UL) 0312 0313 /* Register offset gap between AWD1 and AWD2-AWD3 configuration registers */ 0314 /* (Set separately as ADC_AWD_CRX_REGOFFSET to spare 32 bits space */ 0315 #define ADC_AWD_CR12_REGOFFSETGAP_MASK (ADC_AWD2CR_AWD2CH_0) 0316 #define ADC_AWD_CR12_REGOFFSETGAP_VAL (0x00000024UL) 0317 0318 #define ADC_AWD_CRX_REGOFFSET_MASK (ADC_AWD_CR1_REGOFFSET | ADC_AWD_CR2_REGOFFSET | ADC_AWD_CR3_REGOFFSET) 0319 0320 #define ADC_AWD_CR1_CHANNEL_MASK (ADC_CFGR_AWD1CH | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) 0321 #define ADC_AWD_CR23_CHANNEL_MASK (ADC_AWD2CR_AWD2CH) 0322 #define ADC_AWD_CR_ALL_CHANNEL_MASK (ADC_AWD_CR1_CHANNEL_MASK | ADC_AWD_CR23_CHANNEL_MASK) 0323 0324 #define ADC_AWD_CRX_REGOFFSET_POS (20UL) /* Position of bits ADC_AWD_CRx_REGOFFSET in ADC_AWD_CRX_REGOFFSET_MASK */ 0325 0326 /* Internal register offset for ADC analog watchdog threshold configuration */ 0327 #define ADC_AWD_TR1_REGOFFSET (ADC_AWD_CR1_REGOFFSET) 0328 #define ADC_AWD_TR2_REGOFFSET (ADC_AWD_CR2_REGOFFSET) 0329 #define ADC_AWD_TR3_REGOFFSET (ADC_AWD_CR3_REGOFFSET) 0330 #define ADC_AWD_TRX_REGOFFSET_MASK (ADC_AWD_TR1_REGOFFSET | ADC_AWD_TR2_REGOFFSET | ADC_AWD_TR3_REGOFFSET) 0331 #define ADC_AWD_TRX_REGOFFSET_POS (ADC_AWD_CRX_REGOFFSET_POS) /* Position of bits ADC_TRx_REGOFFSET in ADC_AWD_TRX_REGOFFSET_MASK */ 0332 #if defined(ADC_VER_V5_V90) 0333 #define ADC_AWD_TRX_BIT_HIGH_MASK (0x00010000UL) /* Selection of 1 bit to discriminate threshold high: mask of bit */ 0334 #define ADC_AWD_TRX_BIT_HIGH_POS (16UL) /* Selection of 1 bit to discriminate threshold high: position of bit */ 0335 #define ADC_AWD_TRX_BIT_HIGH_SHIFT4 (ADC_AWD_TRX_BIT_HIGH_POS - 4UL) /* Shift of bit ADC_AWD_TRX_BIT_HIGH to position to perform a shift of 4 ranks */ 0336 #endif /* ADC_VER_V5_V90 */ 0337 0338 /* Register offset gap between AWD1 and AWD2-AWD3 thresholds registers */ 0339 /* (Set separately as ADC_AWD_TRX_REGOFFSET to spare 32 bits space */ 0340 #define ADC_AWD_TR12_REGOFFSETGAP_MASK (ADC_AWD2CR_AWD2CH_0) 0341 #define ADC_AWD_TR12_REGOFFSETGAP_VAL (0x00000022UL) 0342 0343 /* Legacy literals */ 0344 #define LL_ADC_AWD1_TR LL_ADC_AWD1 0345 #define LL_ADC_AWD2_TR LL_ADC_AWD2 0346 #define LL_ADC_AWD3_TR LL_ADC_AWD3 0347 0348 /* Internal mask for ADC offset: */ 0349 /* Internal register offset for ADC offset number configuration */ 0350 #define ADC_OFR1_REGOFFSET (0x00000000UL) 0351 #define ADC_OFR2_REGOFFSET (0x00000001UL) 0352 #define ADC_OFR3_REGOFFSET (0x00000002UL) 0353 #define ADC_OFR4_REGOFFSET (0x00000003UL) 0354 #define ADC_OFRx_REGOFFSET_MASK (ADC_OFR1_REGOFFSET | ADC_OFR2_REGOFFSET | ADC_OFR3_REGOFFSET | ADC_OFR4_REGOFFSET) 0355 0356 0357 /* ADC registers bits positions */ 0358 #define ADC_CFGR_RES_BITOFFSET_POS (ADC_CFGR_RES_Pos) 0359 #define ADC_CFGR_AWD1SGL_BITOFFSET_POS (ADC_CFGR_AWD1SGL_Pos) 0360 #define ADC_CFGR_AWD1EN_BITOFFSET_POS (ADC_CFGR_AWD1EN_Pos) 0361 #define ADC_CFGR_JAWD1EN_BITOFFSET_POS (ADC_CFGR_JAWD1EN_Pos) 0362 #if defined(ADC_VER_V5_V90) 0363 #define ADC_CFGR_RES_BITOFFSET_POS_ADC3 (ADC3_CFGR_RES_Pos) 0364 #endif /* ADC_VER_V5_V90 */ 0365 0366 0367 /* ADC registers bits groups */ 0368 #define ADC_CR_BITS_PROPERTY_RS (ADC_CR_ADCAL | ADC_CR_JADSTP | ADC_CR_ADSTP | ADC_CR_JADSTART | ADC_CR_ADSTART | ADC_CR_ADDIS | ADC_CR_ADEN) /* ADC register CR bits with HW property "rs": Software can read as well as set this bit. Writing '0' has no effect on the bit value. */ 0369 0370 0371 /* ADC internal channels related definitions */ 0372 /* Internal voltage reference VrefInt */ 0373 #if defined(ADC_VER_V5_3) 0374 #define VREFINT_CAL_ADDR ((uint16_t*) (0x8fff810UL)) /* Internal voltage reference, address of parameter VREFINT_CAL: VrefInt ADC raw data acquired at temperature 30 DegC (tolerance: +-5 DegC), Vref+ = 3.3 V (tolerance: +-10 mV). */ 0375 /* Address related to STM32H7A3 */ 0376 #else /* ADC_VER_V5_90 || ADC_VER_V5_X */ 0377 #define VREFINT_CAL_ADDR ((uint16_t*) (0x1FF1E860UL)) /* Internal voltage reference, address of parameter VREFINT_CAL: VrefInt ADC raw data acquired at temperature 30 DegC (tolerance: +-5 DegC), Vref+ = 3.3 V (tolerance: +-10 mV). */ 0378 #endif /* ADC_VER_V5_3 */ 0379 #define VREFINT_CAL_VREF (3300UL) /* Analog voltage reference (Vref+) value with which temperature sensor has been calibrated in production (tolerance: +-10 mV) (unit: mV). */ 0380 /* Temperature sensor */ 0381 #if defined(ADC_VER_V5_3) 0382 #define TEMPSENSOR_CAL1_ADDR ((uint16_t*) (0x8fff814UL)) /* Internal temperature sensor, address of parameter TS_CAL1: On STM32H7, temperature sensor ADC raw data acquired at temperature 30 DegC (tolerance: +-5 DegC), Vref+ = 3.3 V (tolerance: +-10 mV). */ 0383 #define TEMPSENSOR_CAL2_ADDR ((uint16_t*) (0x8fff818UL)) /* Internal temperature sensor, address of parameter TS_CAL2: On STM32H7, temperature sensor ADC raw data acquired at temperature 110 DegC (tolerance: +-5 DegC), Vref+ = 3.3 V (tolerance: +-10 mV). */ 0384 /* Addresses related to STM32H7A3 */ 0385 #else /* ADC_VER_V5_90 || ADC_VER_V5_X */ 0386 #define TEMPSENSOR_CAL1_ADDR ((uint16_t*) (0x1FF1E820UL)) /* Internal temperature sensor, address of parameter TS_CAL1: On STM32H7, temperature sensor ADC raw data acquired at temperature 30 DegC (tolerance: +-5 DegC), Vref+ = 3.3 V (tolerance: +-10 mV). */ 0387 #define TEMPSENSOR_CAL2_ADDR ((uint16_t*) (0x1FF1E840UL)) /* Internal temperature sensor, address of parameter TS_CAL2: On STM32H7, temperature sensor ADC raw data acquired at temperature 110 DegC (tolerance: +-5 DegC), Vref+ = 3.3 V (tolerance: +-10 mV). */ 0388 #endif /* ADC_VER_V5_3 */ 0389 0390 #define TEMPSENSOR_CAL1_TEMP (30L) /* Internal temperature sensor, temperature at which temperature sensor has been calibrated in production for data into TEMPSENSOR_CAL1_ADDR (tolerance: +-5 DegC) (unit: DegC). */ 0391 #if defined (STM32H742xx) || defined (STM32H743xx) || defined (STM32H753xx) 0392 #define TEMPSENSOR_CAL2_TEMP ((((DBGMCU->IDCODE) >> 16) <= ((uint32_t)0x1003)) ? 110L : 130L) /* Internal temperature sensor , 0393 temperature at which temperature sensor has been calibrated in production for data into TEMPSENSOR_CAL2_ADDR 0394 110 °C for revision Y and 130 °C for revision V (tolerance: +-5 DegC) (unit: DegC). */ 0395 #else 0396 #define TEMPSENSOR_CAL2_TEMP (110L) /* Internal temperature sensor, temperature at which temperature sensor has been 0397 calibrated in production for data into TEMPSENSOR_CAL2_ADDR (tolerance: +-5 DegC) (unit: DegC). */ 0398 #endif /* defined (STM32H742xx) || defined (STM32H743xx) || defined (STM32H753xx) */ 0399 #define TEMPSENSOR_CAL_VREFANALOG (3300UL) /* Analog voltage reference (Vref+) voltage with which temperature sensor has been calibrated in production (+-10 mV) (unit: mV). */ 0400 0401 /* Registers addresses with ADC linearity calibration content (programmed during device production, specific to each device) */ 0402 #define ADC_LINEAR_CALIB_REG_1_ADDR ((uint32_t*) (0x1FF1EC00UL)) 0403 #define ADC_LINEAR_CALIB_REG_2_ADDR ((uint32_t*) (0x1FF1EC04UL)) 0404 #define ADC_LINEAR_CALIB_REG_3_ADDR ((uint32_t*) (0x1FF1EC08UL)) 0405 #define ADC_LINEAR_CALIB_REG_4_ADDR ((uint32_t*) (0x1FF1EC0CUL)) 0406 #define ADC_LINEAR_CALIB_REG_5_ADDR ((uint32_t*) (0x1FF1EC10UL)) 0407 #define ADC_LINEAR_CALIB_REG_6_ADDR ((uint32_t*) (0x1FF1EC14UL)) 0408 #define ADC_LINEAR_CALIB_REG_COUNT (6UL) 0409 /** 0410 * @} 0411 */ 0412 0413 /** @defgroup ADC_LL_Alias_definition ADC Alias definition 0414 * @ingroup RTEMSBSPsARMSTM32H7 0415 * @{ 0416 */ 0417 #define LL_ADC_SetChannelPreSelection LL_ADC_SetChannelPreselection /* Alias of LL_ADC_SetChannelPreselection for backward compatibility. */ 0418 0419 /** 0420 * @} 0421 */ 0422 0423 /* Private macros ------------------------------------------------------------*/ 0424 /** @defgroup ADC_LL_Private_Macros ADC Private Macros 0425 * @ingroup RTEMSBSPsARMSTM32H7 0426 * @{ 0427 */ 0428 0429 /** 0430 * @brief Driver macro reserved for internal use: set a pointer to 0431 * a register from a register basis from which an offset 0432 * is applied. 0433 * @param __REG__ Register basis from which the offset is applied. 0434 * @param __REG_OFFFSET__ Offset to be applied (unit: number of registers). 0435 * @retval Pointer to register address 0436 */ 0437 #define __ADC_PTR_REG_OFFSET(__REG__, __REG_OFFFSET__) \ 0438 ((__IO uint32_t *)((uint32_t) ((uint32_t)(&(__REG__)) + ((__REG_OFFFSET__) << 2UL)))) 0439 0440 /** 0441 * @} 0442 */ 0443 0444 0445 /* Exported types ------------------------------------------------------------*/ 0446 #if defined(USE_FULL_LL_DRIVER) || defined(__rtems__) 0447 /** @defgroup ADC_LL_ES_INIT ADC Exported Init structure 0448 * @ingroup RTEMSBSPsARMSTM32H7 0449 * @{ 0450 */ 0451 0452 /** 0453 * @brief Structure definition of some features of ADC common parameters 0454 * and multimode 0455 * (all ADC instances belonging to the same ADC common instance). 0456 * @note The setting of these parameters by function @ref LL_ADC_CommonInit() 0457 * is conditioned to ADC instances state (all ADC instances 0458 * sharing the same ADC common instance): 0459 * All ADC instances sharing the same ADC common instance must be 0460 * disabled. 0461 */ 0462 typedef struct 0463 { 0464 uint32_t CommonClock; /*!< Set parameter common to several ADC: Clock source and prescaler. 0465 This parameter can be a value of @ref ADC_LL_EC_COMMON_CLOCK_SOURCE 0466 @note On this STM32 series, if ADC group injected is used, some 0467 clock ratio constraints between ADC clock and AHB clock 0468 must be respected. Refer to reference manual. 0469 0470 This feature can be modified afterwards using unitary function @ref LL_ADC_SetCommonClock(). */ 0471 0472 uint32_t Multimode; /*!< Set ADC multimode configuration to operate in independent mode or multimode (for devices with several ADC instances). 0473 This parameter can be a value of @ref ADC_LL_EC_MULTI_MODE 0474 0475 This feature can be modified afterwards using unitary function @ref LL_ADC_SetMultimode(). */ 0476 0477 uint32_t MultiDMATransfer; /*!< Set ADC dual ADC mode DMA transfer data format: Each DMA, 32 down to 10-bits or 8-bits resolution. 0478 This parameter can be a value of @ref ADC_LL_EC_MULTI_DMA_TRANSFER 0479 0480 This feature can be modified afterwards using unitary function @ref LL_ADC_SetMultiDMATransfer(). */ 0481 0482 uint32_t MultiTwoSamplingDelay; /*!< Set ADC multimode delay between 2 sampling phases. 0483 This parameter can be a value of @ref ADC_LL_EC_MULTI_TWOSMP_DELAY 0484 0485 This feature can be modified afterwards using unitary function @ref LL_ADC_SetMultiTwoSamplingDelay(). */ 0486 0487 } LL_ADC_CommonInitTypeDef; 0488 0489 /** 0490 * @brief Structure definition of some features of ADC instance. 0491 * @note These parameters have an impact on ADC scope: ADC instance. 0492 * Affects both group regular and group injected (availability 0493 * of ADC group injected depends on STM32 families). 0494 * Refer to corresponding unitary functions into 0495 * @ref ADC_LL_EF_Configuration_ADC_Instance . 0496 * @note The setting of these parameters by function @ref LL_ADC_Init() 0497 * is conditioned to ADC state: 0498 * ADC instance must be disabled. 0499 * This condition is applied to all ADC features, for efficiency 0500 * and compatibility over all STM32 families. However, the different 0501 * features can be set under different ADC state conditions 0502 * (setting possible with ADC enabled without conversion on going, 0503 * ADC enabled with conversion on going, ...) 0504 * Each feature can be updated afterwards with a unitary function 0505 * and potentially with ADC in a different state than disabled, 0506 * refer to description of each function for setting 0507 * conditioned to ADC state. 0508 */ 0509 typedef struct 0510 { 0511 uint32_t Resolution; /*!< Set ADC resolution. 0512 This parameter can be a value of @ref ADC_LL_EC_RESOLUTION 0513 0514 This feature can be modified afterwards using unitary function @ref LL_ADC_SetResolution(). */ 0515 0516 uint32_t LeftBitShift; /*!< Configures the left shifting applied to the final result with or without oversampling. 0517 This parameter can be a value of @ref ADC_LL_EC_LEFT_BIT_SHIFT. */ 0518 0519 uint32_t LowPowerMode; /*!< Set ADC low power mode. 0520 This parameter can be a value of @ref ADC_LL_EC_LP_MODE 0521 0522 This feature can be modified afterwards using unitary function @ref LL_ADC_SetLowPowerMode(). */ 0523 0524 } LL_ADC_InitTypeDef; 0525 0526 /** 0527 * @brief Structure definition of some features of ADC group regular. 0528 * @note These parameters have an impact on ADC scope: ADC group regular. 0529 * Refer to corresponding unitary functions into 0530 * @ref ADC_LL_EF_Configuration_ADC_Group_Regular 0531 * (functions with prefix "REG"). 0532 * @note The setting of these parameters by function @ref LL_ADC_REG_Init() 0533 * is conditioned to ADC state: 0534 * ADC instance must be disabled. 0535 * This condition is applied to all ADC features, for efficiency 0536 * and compatibility over all STM32 families. However, the different 0537 * features can be set under different ADC state conditions 0538 * (setting possible with ADC enabled without conversion on going, 0539 * ADC enabled with conversion on going, ...) 0540 * Each feature can be updated afterwards with a unitary function 0541 * and potentially with ADC in a different state than disabled, 0542 * refer to description of each function for setting 0543 * conditioned to ADC state. 0544 */ 0545 typedef struct 0546 { 0547 uint32_t TriggerSource; /*!< Set ADC group regular conversion trigger source: internal (SW start) or from external peripheral (timer event, external interrupt line). 0548 This parameter can be a value of @ref ADC_LL_EC_REG_TRIGGER_SOURCE 0549 @note On this STM32 series, setting trigger source to external trigger also set trigger polarity to rising edge 0550 (default setting for compatibility with some ADC on other STM32 families having this setting set by HW default value). 0551 In case of need to modify trigger edge, use function @ref LL_ADC_REG_SetTriggerEdge(). 0552 0553 This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetTriggerSource(). */ 0554 0555 uint32_t SequencerLength; /*!< Set ADC group regular sequencer length. 0556 This parameter can be a value of @ref ADC_LL_EC_REG_SEQ_SCAN_LENGTH 0557 0558 This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetSequencerLength(). */ 0559 0560 uint32_t SequencerDiscont; /*!< Set ADC group regular sequencer discontinuous mode: sequence subdivided and scan conversions interrupted every selected number of ranks. 0561 This parameter can be a value of @ref ADC_LL_EC_REG_SEQ_DISCONT_MODE 0562 @note This parameter has an effect only if group regular sequencer is enabled 0563 (scan length of 2 ranks or more). 0564 0565 This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetSequencerDiscont(). */ 0566 0567 uint32_t ContinuousMode; /*!< Set ADC continuous conversion mode on ADC group regular, whether ADC conversions are performed in single mode (one conversion per trigger) or in continuous mode (after the first trigger, following conversions launched successively automatically). 0568 This parameter can be a value of @ref ADC_LL_EC_REG_CONTINUOUS_MODE 0569 Note: It is not possible to enable both ADC group regular continuous mode and discontinuous mode. 0570 0571 This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetContinuousMode(). */ 0572 0573 uint32_t DataTransferMode; /*!< Set ADC group regular conversion data transfer mode: no transfer, transfer by DMA (Limited/Unlimited) or DFSDM. 0574 This parameter can be a value of @ref ADC_LL_EC_REG_DATA_TRANSFER_MODE 0575 0576 This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetDataTransferMode(). */ 0577 0578 uint32_t Overrun; /*!< Set ADC group regular behavior in case of overrun: 0579 data preserved or overwritten. 0580 This parameter can be a value of @ref ADC_LL_EC_REG_OVR_DATA_BEHAVIOR 0581 0582 This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetOverrun(). */ 0583 0584 } LL_ADC_REG_InitTypeDef; 0585 0586 /** 0587 * @brief Structure definition of some features of ADC group injected. 0588 * @note These parameters have an impact on ADC scope: ADC group injected. 0589 * Refer to corresponding unitary functions into 0590 * @ref ADC_LL_EF_Configuration_ADC_Group_Regular 0591 * (functions with prefix "INJ"). 0592 * @note The setting of these parameters by function @ref LL_ADC_INJ_Init() 0593 * is conditioned to ADC state: 0594 * ADC instance must be disabled. 0595 * This condition is applied to all ADC features, for efficiency 0596 * and compatibility over all STM32 families. However, the different 0597 * features can be set under different ADC state conditions 0598 * (setting possible with ADC enabled without conversion on going, 0599 * ADC enabled with conversion on going, ...) 0600 * Each feature can be updated afterwards with a unitary function 0601 * and potentially with ADC in a different state than disabled, 0602 * refer to description of each function for setting 0603 * conditioned to ADC state. 0604 */ 0605 typedef struct 0606 { 0607 uint32_t TriggerSource; /*!< Set ADC group injected conversion trigger source: internal (SW start) or from external peripheral (timer event, external interrupt line). 0608 This parameter can be a value of @ref ADC_LL_EC_INJ_TRIGGER_SOURCE 0609 @note On this STM32 series, setting trigger source to external trigger also set trigger polarity to rising edge 0610 (default setting for compatibility with some ADC on other STM32 families having this setting set by HW default value). 0611 In case of need to modify trigger edge, use function @ref LL_ADC_INJ_SetTriggerEdge(). 0612 0613 This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetTriggerSource(). */ 0614 0615 uint32_t SequencerLength; /*!< Set ADC group injected sequencer length. 0616 This parameter can be a value of @ref ADC_LL_EC_INJ_SEQ_SCAN_LENGTH 0617 0618 This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetSequencerLength(). */ 0619 0620 uint32_t SequencerDiscont; /*!< Set ADC group injected sequencer discontinuous mode: sequence subdivided and scan conversions interrupted every selected number of ranks. 0621 This parameter can be a value of @ref ADC_LL_EC_INJ_SEQ_DISCONT_MODE 0622 @note This parameter has an effect only if group injected sequencer is enabled 0623 (scan length of 2 ranks or more). 0624 0625 This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetSequencerDiscont(). */ 0626 0627 uint32_t TrigAuto; /*!< Set ADC group injected conversion trigger: independent or from ADC group regular. 0628 This parameter can be a value of @ref ADC_LL_EC_INJ_TRIG_AUTO 0629 Note: This parameter must be set to set to independent trigger if injected trigger source is set to an external trigger. 0630 0631 This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetTrigAuto(). */ 0632 0633 } LL_ADC_INJ_InitTypeDef; 0634 0635 /** 0636 * @} 0637 */ 0638 #endif /* USE_FULL_LL_DRIVER */ 0639 0640 /* Exported constants --------------------------------------------------------*/ 0641 /** @defgroup ADC_LL_Exported_Constants ADC Exported Constants 0642 * @ingroup RTEMSBSPsARMSTM32H7 0643 * @{ 0644 */ 0645 0646 /** @defgroup ADC_LL_EC_FLAG ADC flags 0647 * @ingroup RTEMSBSPsARMSTM32H7 0648 * @brief Flags defines which can be used with LL_ADC_ReadReg function 0649 * @{ 0650 */ 0651 #define LL_ADC_FLAG_ADRDY ADC_ISR_ADRDY /*!< ADC flag ADC instance ready */ 0652 #define LL_ADC_FLAG_EOC ADC_ISR_EOC /*!< ADC flag ADC group regular end of unitary conversion */ 0653 #define LL_ADC_FLAG_EOS ADC_ISR_EOS /*!< ADC flag ADC group regular end of sequence conversions */ 0654 #define LL_ADC_FLAG_OVR ADC_ISR_OVR /*!< ADC flag ADC group regular overrun */ 0655 #define LL_ADC_FLAG_EOSMP ADC_ISR_EOSMP /*!< ADC flag ADC group regular end of sampling phase */ 0656 #define LL_ADC_FLAG_JEOC ADC_ISR_JEOC /*!< ADC flag ADC group injected end of unitary conversion */ 0657 #define LL_ADC_FLAG_JEOS ADC_ISR_JEOS /*!< ADC flag ADC group injected end of sequence conversions */ 0658 #define LL_ADC_FLAG_JQOVF ADC_ISR_JQOVF /*!< ADC flag ADC group injected contexts queue overflow */ 0659 #define LL_ADC_FLAG_AWD1 ADC_ISR_AWD1 /*!< ADC flag ADC analog watchdog 1 */ 0660 #define LL_ADC_FLAG_AWD2 ADC_ISR_AWD2 /*!< ADC flag ADC analog watchdog 2 */ 0661 #define LL_ADC_FLAG_AWD3 ADC_ISR_AWD3 /*!< ADC flag ADC analog watchdog 3 */ 0662 #define LL_ADC_FLAG_LDORDY ADC_ISR_LDORDY /*!< ADC flag ADC LDO output voltage ready bit */ 0663 #define LL_ADC_FLAG_ADRDY_MST ADC_CSR_ADRDY_MST /*!< ADC flag ADC multimode master instance ready */ 0664 #define LL_ADC_FLAG_ADRDY_SLV ADC_CSR_ADRDY_SLV /*!< ADC flag ADC multimode slave instance ready */ 0665 #define LL_ADC_FLAG_EOC_MST ADC_CSR_EOC_MST /*!< ADC flag ADC multimode master group regular end of unitary conversion */ 0666 #define LL_ADC_FLAG_EOC_SLV ADC_CSR_EOC_SLV /*!< ADC flag ADC multimode slave group regular end of unitary conversion */ 0667 #define LL_ADC_FLAG_EOS_MST ADC_CSR_EOS_MST /*!< ADC flag ADC multimode master group regular end of sequence conversions */ 0668 #define LL_ADC_FLAG_EOS_SLV ADC_CSR_EOS_SLV /*!< ADC flag ADC multimode slave group regular end of sequence conversions */ 0669 #define LL_ADC_FLAG_OVR_MST ADC_CSR_OVR_MST /*!< ADC flag ADC multimode master group regular overrun */ 0670 #define LL_ADC_FLAG_OVR_SLV ADC_CSR_OVR_SLV /*!< ADC flag ADC multimode slave group regular overrun */ 0671 #define LL_ADC_FLAG_EOSMP_MST ADC_CSR_EOSMP_MST /*!< ADC flag ADC multimode master group regular end of sampling phase */ 0672 #define LL_ADC_FLAG_EOSMP_SLV ADC_CSR_EOSMP_SLV /*!< ADC flag ADC multimode slave group regular end of sampling phase */ 0673 #define LL_ADC_FLAG_JEOC_MST ADC_CSR_JEOC_MST /*!< ADC flag ADC multimode master group injected end of unitary conversion */ 0674 #define LL_ADC_FLAG_JEOC_SLV ADC_CSR_JEOC_SLV /*!< ADC flag ADC multimode slave group injected end of unitary conversion */ 0675 #define LL_ADC_FLAG_JEOS_MST ADC_CSR_JEOS_MST /*!< ADC flag ADC multimode master group injected end of sequence conversions */ 0676 #define LL_ADC_FLAG_JEOS_SLV ADC_CSR_JEOS_SLV /*!< ADC flag ADC multimode slave group injected end of sequence conversions */ 0677 #define LL_ADC_FLAG_JQOVF_MST ADC_CSR_JQOVF_MST /*!< ADC flag ADC multimode master group injected contexts queue overflow */ 0678 #define LL_ADC_FLAG_JQOVF_SLV ADC_CSR_JQOVF_SLV /*!< ADC flag ADC multimode slave group injected contexts queue overflow */ 0679 #define LL_ADC_FLAG_AWD1_MST ADC_CSR_AWD1_MST /*!< ADC flag ADC multimode master analog watchdog 1 of the ADC master */ 0680 #define LL_ADC_FLAG_AWD1_SLV ADC_CSR_AWD1_SLV /*!< ADC flag ADC multimode slave analog watchdog 1 of the ADC slave */ 0681 #define LL_ADC_FLAG_AWD2_MST ADC_CSR_AWD2_MST /*!< ADC flag ADC multimode master analog watchdog 2 of the ADC master */ 0682 #define LL_ADC_FLAG_AWD2_SLV ADC_CSR_AWD2_SLV /*!< ADC flag ADC multimode slave analog watchdog 2 of the ADC slave */ 0683 #define LL_ADC_FLAG_AWD3_MST ADC_CSR_AWD3_MST /*!< ADC flag ADC multimode master analog watchdog 3 of the ADC master */ 0684 #define LL_ADC_FLAG_AWD3_SLV ADC_CSR_AWD3_SLV /*!< ADC flag ADC multimode slave analog watchdog 3 of the ADC slave */ 0685 /** 0686 * @} 0687 */ 0688 0689 /** @defgroup ADC_LL_EC_IT ADC interruptions for configuration (interruption enable or disable) 0690 * @ingroup RTEMSBSPsARMSTM32H7 0691 * @brief IT defines which can be used with LL_ADC_ReadReg and LL_ADC_WriteReg functions 0692 * @{ 0693 */ 0694 #define LL_ADC_IT_ADRDY ADC_IER_ADRDYIE /*!< ADC interruption ADC instance ready */ 0695 #define LL_ADC_IT_EOC ADC_IER_EOCIE /*!< ADC interruption ADC group regular end of unitary conversion */ 0696 #define LL_ADC_IT_EOS ADC_IER_EOSIE /*!< ADC interruption ADC group regular end of sequence conversions */ 0697 #define LL_ADC_IT_OVR ADC_IER_OVRIE /*!< ADC interruption ADC group regular overrun */ 0698 #define LL_ADC_IT_EOSMP ADC_IER_EOSMPIE /*!< ADC interruption ADC group regular end of sampling phase */ 0699 #define LL_ADC_IT_JEOC ADC_IER_JEOCIE /*!< ADC interruption ADC group injected end of unitary conversion */ 0700 #define LL_ADC_IT_JEOS ADC_IER_JEOSIE /*!< ADC interruption ADC group injected end of sequence conversions */ 0701 #define LL_ADC_IT_JQOVF ADC_IER_JQOVFIE /*!< ADC interruption ADC group injected contexts queue overflow */ 0702 #define LL_ADC_IT_AWD1 ADC_IER_AWD1IE /*!< ADC interruption ADC analog watchdog 1 */ 0703 #define LL_ADC_IT_AWD2 ADC_IER_AWD2IE /*!< ADC interruption ADC analog watchdog 2 */ 0704 #define LL_ADC_IT_AWD3 ADC_IER_AWD3IE /*!< ADC interruption ADC analog watchdog 3 */ 0705 /** 0706 * @} 0707 */ 0708 0709 /** @defgroup ADC_LL_EC_REGISTERS ADC registers compliant with specific purpose 0710 * @ingroup RTEMSBSPsARMSTM32H7 0711 * @{ 0712 */ 0713 /* List of ADC registers intended to be used (most commonly) with */ 0714 /* DMA transfer. */ 0715 /* Refer to function @ref LL_ADC_DMA_GetRegAddr(). */ 0716 #define LL_ADC_DMA_REG_REGULAR_DATA (0x00000000UL) /* ADC group regular conversion data register (corresponding to register DR) to be used with ADC configured in independent mode. Without DMA transfer, register accessed by LL function @ref LL_ADC_REG_ReadConversionData32() and other functions @ref LL_ADC_REG_ReadConversionDatax() */ 0717 #define LL_ADC_DMA_REG_REGULAR_DATA_MULTI (0x00000001UL) /* ADC group regular conversion data register (corresponding to register CDR) to be used with ADC configured in multimode (available on STM32 devices with several ADC instances). Without DMA transfer, register accessed by LL function @ref LL_ADC_REG_ReadMultiConversionData32() */ 0718 /** 0719 * @} 0720 */ 0721 0722 /** @defgroup ADC_LL_EC_COMMON_CLOCK_SOURCE ADC common - Clock source 0723 * @ingroup RTEMSBSPsARMSTM32H7 0724 * @{ 0725 */ 0726 #define LL_ADC_CLOCK_SYNC_PCLK_DIV1 (ADC_CCR_CKMODE_0) /*!< ADC synchronous clock derived from AHB clock without prescaler */ 0727 #define LL_ADC_CLOCK_SYNC_PCLK_DIV2 (ADC_CCR_CKMODE_1 ) /*!< ADC synchronous clock derived from AHB clock with prescaler division by 2 */ 0728 #define LL_ADC_CLOCK_SYNC_PCLK_DIV4 (ADC_CCR_CKMODE_1 | ADC_CCR_CKMODE_0) /*!< ADC synchronous clock derived from AHB clock with prescaler division by 4 */ 0729 #define LL_ADC_CLOCK_ASYNC_DIV1 (0x00000000UL) /*!< ADC asynchronous clock without prescaler */ 0730 #define LL_ADC_CLOCK_ASYNC_DIV2 (ADC_CCR_PRESC_0) /*!< ADC asynchronous clock with prescaler division by 2 */ 0731 #define LL_ADC_CLOCK_ASYNC_DIV4 (ADC_CCR_PRESC_1 ) /*!< ADC asynchronous clock with prescaler division by 4 */ 0732 #define LL_ADC_CLOCK_ASYNC_DIV6 (ADC_CCR_PRESC_1 | ADC_CCR_PRESC_0) /*!< ADC asynchronous clock with prescaler division by 6 */ 0733 #define LL_ADC_CLOCK_ASYNC_DIV8 (ADC_CCR_PRESC_2 ) /*!< ADC asynchronous clock with prescaler division by 8 */ 0734 #define LL_ADC_CLOCK_ASYNC_DIV10 (ADC_CCR_PRESC_2 | ADC_CCR_PRESC_0) /*!< ADC asynchronous clock with prescaler division by 10 */ 0735 #define LL_ADC_CLOCK_ASYNC_DIV12 (ADC_CCR_PRESC_2 | ADC_CCR_PRESC_1 ) /*!< ADC asynchronous clock with prescaler division by 12 */ 0736 #define LL_ADC_CLOCK_ASYNC_DIV16 (ADC_CCR_PRESC_2 | ADC_CCR_PRESC_1 | ADC_CCR_PRESC_0) /*!< ADC asynchronous clock with prescaler division by 16 */ 0737 #define LL_ADC_CLOCK_ASYNC_DIV32 (ADC_CCR_PRESC_3) /*!< ADC asynchronous clock with prescaler division by 32 */ 0738 #define LL_ADC_CLOCK_ASYNC_DIV64 (ADC_CCR_PRESC_3 | ADC_CCR_PRESC_0) /*!< ADC asynchronous clock with prescaler division by 64 */ 0739 #define LL_ADC_CLOCK_ASYNC_DIV128 (ADC_CCR_PRESC_3 | ADC_CCR_PRESC_1) /*!< ADC asynchronous clock with prescaler division by 128 */ 0740 #define LL_ADC_CLOCK_ASYNC_DIV256 (ADC_CCR_PRESC_3 | ADC_CCR_PRESC_1 | ADC_CCR_PRESC_0) /*!< ADC asynchronous clock with prescaler division by 256 */ 0741 /** 0742 * @} 0743 */ 0744 0745 /** @defgroup ADC_LL_EC_COMMON_PATH_INTERNAL ADC common - Measurement path to internal channels 0746 * @ingroup RTEMSBSPsARMSTM32H7 0747 * @{ 0748 */ 0749 /* Note: Other measurement paths to internal channels may be available */ 0750 /* (connections to other peripherals). */ 0751 /* If they are not listed below, they do not require any specific */ 0752 /* path enable. In this case, Access to measurement path is done */ 0753 /* only by selecting the corresponding ADC internal channel. */ 0754 #define LL_ADC_PATH_INTERNAL_NONE (0x00000000UL) /*!< ADC measurement paths all disabled */ 0755 #define LL_ADC_PATH_INTERNAL_VREFINT (ADC_CCR_VREFEN) /*!< ADC measurement path to internal channel VrefInt */ 0756 #define LL_ADC_PATH_INTERNAL_TEMPSENSOR (ADC_CCR_TSEN) /*!< ADC measurement path to internal channel temperature sensor */ 0757 #define LL_ADC_PATH_INTERNAL_VBAT (ADC_CCR_VBATEN) /*!< ADC measurement path to internal channel Vbat */ 0758 /** 0759 * @} 0760 */ 0761 0762 /** @defgroup ADC_LL_EC_BOOST_MODE ADC instance - Boost mode 0763 * @ingroup RTEMSBSPsARMSTM32H7 0764 * @{ 0765 */ 0766 #define LL_ADC_BOOST_MODE_6MHZ25 (0x00000000UL) /*!< Boost mode is configured for frequency <= 6.25Mhz */ 0767 #define LL_ADC_BOOST_MODE_12MHZ5 ( ADC_CR_BOOST_0) /*!< Boost mode is configured for 6.25Mhz < frequency <= 12.5Mhz */ 0768 #define LL_ADC_BOOST_MODE_20MHZ ( ADC_CR_BOOST_1 ) /*!< Boost mode is configured for 12.5Mhz < frequency <= 20Mhz */ 0769 #define LL_ADC_BOOST_MODE_25MHZ ((ADC_CR_BOOST_0 <<2) | ADC_CR_BOOST_1 ) /*!< Boost mode is configured for 20Mhz < frequency <= 25Mhz */ 0770 #define LL_ADC_BOOST_MODE_50MHZ ((ADC_CR_BOOST_0 <<2) | ADC_CR_BOOST_1 | ADC_CR_BOOST_0) /*!< Boost mode is configured for frequency > 25Mhz */ 0771 /** 0772 * @} 0773 */ 0774 0775 /** @defgroup ADC_LL_EC_CALIBRATION_OFFSET_LINEARITY ADC instance - Calibration mode for offset and linearity 0776 * @ingroup RTEMSBSPsARMSTM32H7 0777 * @{ 0778 */ 0779 #define LL_ADC_CALIB_OFFSET (ADC_CALIB_FACTOR_OFFSET_REGOFFSET) /*!< Calibration of ADC offset. Duration of calibration of offset duration: 1280 ADC clock cycles. For devices with differential mode available: Calibration of offset is specific to each of single-ended and differential modes. */ 0780 #define LL_ADC_CALIB_LINEARITY (ADC_CALIB_FACTOR_LINEARITY_REGOFFSET) /*!< Calibration of ADC linearity. Duration of calibration of linearity: 15104 ADC clock cycles. For devices with differential mode available: Calibration of linearity is common to both single-ended and differential modes. */ 0781 #define LL_ADC_CALIB_OFFSET_LINEARITY (ADC_CALIB_FACTOR_LINEARITY_REGOFFSET | ADC_CR_ADCALLIN) /*!< Calibration of ADC offset and linearity. Duration of calibration of offset and linearity: 16384 ADC clock cycles. For devices with differential mode available: Calibration of offset is specific to each of single-ended and differential modes, calibration of linearity is common to both single-ended and differential modes. */ 0782 /** 0783 * @} 0784 */ 0785 0786 /** @defgroup ADC_LL_EC_CALIBRATION_LINEARITY_WORD ADC instance - Calibration linearity words 0787 * @ingroup RTEMSBSPsARMSTM32H7 0788 * @{ 0789 */ 0790 #define LL_ADC_CALIB_LINEARITY_WORD1 (ADC_CR_LINCALRDYW1) /*!< ADC calibration linearity word 1 */ 0791 #define LL_ADC_CALIB_LINEARITY_WORD2 (ADC_CR_LINCALRDYW2) /*!< ADC calibration linearity word 2 */ 0792 #define LL_ADC_CALIB_LINEARITY_WORD3 (ADC_CR_LINCALRDYW3) /*!< ADC calibration linearity word 3 */ 0793 #define LL_ADC_CALIB_LINEARITY_WORD4 (ADC_CR_LINCALRDYW4) /*!< ADC calibration linearity word 4 */ 0794 #define LL_ADC_CALIB_LINEARITY_WORD5 (ADC_CR_LINCALRDYW5) /*!< ADC calibration linearity word 5 */ 0795 #define LL_ADC_CALIB_LINEARITY_WORD6 (ADC_CR_LINCALRDYW6) /*!< ADC calibration linearity word 6 */ 0796 /** 0797 * @} 0798 */ 0799 0800 /** @defgroup ADC_LL_EC_RESOLUTION ADC instance - Resolution 0801 * @ingroup RTEMSBSPsARMSTM32H7 0802 * @{ 0803 */ 0804 #define LL_ADC_RESOLUTION_16B (0x00000000UL) /*!< ADC resolution 16 bits */ 0805 #define LL_ADC_RESOLUTION_14B ( ADC_CFGR_RES_0) /*!< ADC resolution 12 bits */ 0806 #define LL_ADC_RESOLUTION_12B ( ADC_CFGR_RES_1 ) /*!< ADC resolution 12 bits */ 0807 #define LL_ADC_RESOLUTION_10B ( ADC_CFGR_RES_1 | ADC_CFGR_RES_0) /*!< ADC resolution 10 bits */ 0808 0809 #if defined (ADC_VER_V5_X) 0810 #define LL_ADC_RESOLUTION_14B_OPT (ADC_CFGR_RES_2 | ADC_CFGR_RES_0) /*!< ADC resolution 14 bits optimized for power consumption, available on for devices revision V only */ 0811 #define LL_ADC_RESOLUTION_12B_OPT (ADC_CFGR_RES_2 | ADC_CFGR_RES_1 ) /*!< ADC resolution 12 bits optimized for power consumption, available on for devices revision V only */ 0812 #endif 0813 0814 #if defined (ADC_VER_V5_3) || defined(ADC_VER_V5_V90) 0815 #define LL_ADC_RESOLUTION_8B (ADC_CFGR_RES_2|ADC_CFGR_RES_1 | ADC_CFGR_RES_0) /*!< ADC resolution 8 bits */ 0816 #else 0817 #define LL_ADC_RESOLUTION_8B (ADC_CFGR_RES_2 ) /*!< ADC resolution 8 bits */ 0818 /*!< The resolution setting is managed internally in the driver: 0819 "LL_ADC_RESOLUTION_8B" definition: keep using the "100b" value (corresponding to STM32H74x/5x rev Y). 0820 Rev.V value "111b" is handled through functions "LL_ADC_SetResolution/LL_ADC_GetResolution" with a dedicated check on DBGMCU IDCODE register */ 0821 #endif 0822 #if defined(ADC_VER_V5_V90) 0823 #define LL_ADC_RESOLUTION_6B (ADC3_CFGR_RES_1 | ADC3_CFGR_RES_0) /*!< ADC resolution 6 bits. Value available for ADC3 on STM32H72xx/3xx devices only*/ 0824 #endif /* ADC_VER_V5_V90 */ 0825 /** 0826 * @} 0827 */ 0828 0829 #if defined(ADC_VER_V5_V90) 0830 /** @defgroup ADC_LL_EC_DATA_ALIGN ADC instance - Data alignment 0831 * @ingroup RTEMSBSPsARMSTM32H7 0832 * @{ 0833 */ 0834 #define LL_ADC_DATA_ALIGN_RIGHT (0x00000000UL) /*!< ADC conversion data alignment: right aligned (alignment on data register LSB bit 0)*/ 0835 #define LL_ADC_DATA_ALIGN_LEFT (ADC3_CFGR_ALIGN) /*!< ADC conversion data alignment: left aligned (alignment on data register MSB bit 15)*/ 0836 /** 0837 * @} 0838 */ 0839 0840 #endif /* ADC_VER_V5_V90 */ 0841 0842 /** @defgroup ADC_LL_EC_LEFT_BIT_SHIFT ADC left Shift 0843 * @ingroup RTEMSBSPsARMSTM32H7 0844 * @{ 0845 */ 0846 #define LL_ADC_LEFT_BIT_SHIFT_NONE (0x00000000UL) /*!< ADC no bit shift left applied on the final ADC conversion data */ 0847 #define LL_ADC_LEFT_BIT_SHIFT_1 (ADC_CFGR2_LSHIFT_0) /*!< ADC 1 bit shift left applied on the final ADC conversion data */ 0848 #define LL_ADC_LEFT_BIT_SHIFT_2 (ADC_CFGR2_LSHIFT_1) /*!< ADC 2 bits shift left applied on the final ADC conversion data */ 0849 #define LL_ADC_LEFT_BIT_SHIFT_3 (ADC_CFGR2_LSHIFT_1 | ADC_CFGR2_LSHIFT_0) /*!< ADC 3 bits shift left applied on the final ADC conversion data */ 0850 #define LL_ADC_LEFT_BIT_SHIFT_4 (ADC_CFGR2_LSHIFT_2) /*!< ADC 4 bits shift left applied on the final ADC conversion data */ 0851 #define LL_ADC_LEFT_BIT_SHIFT_5 (ADC_CFGR2_LSHIFT_2 | ADC_CFGR2_LSHIFT_0) /*!< ADC 5 bits shift left applied on the final ADC conversion data */ 0852 #define LL_ADC_LEFT_BIT_SHIFT_6 (ADC_CFGR2_LSHIFT_2 | ADC_CFGR2_LSHIFT_1) /*!< ADC 6 bits shift left applied on the final ADC conversion data */ 0853 #define LL_ADC_LEFT_BIT_SHIFT_7 (ADC_CFGR2_LSHIFT_2 | ADC_CFGR2_LSHIFT_1 | ADC_CFGR2_LSHIFT_0) /*!< ADC 7 bits shift left applied on the final ADC conversion data */ 0854 #define LL_ADC_LEFT_BIT_SHIFT_8 (ADC_CFGR2_LSHIFT_3) /*!< ADC 8 bits shift left applied on the final ADC conversion data */ 0855 #define LL_ADC_LEFT_BIT_SHIFT_9 (ADC_CFGR2_LSHIFT_3 | ADC_CFGR2_LSHIFT_0) /*!< ADC 9 bits shift left applied on the final ADC conversion data */ 0856 #define LL_ADC_LEFT_BIT_SHIFT_10 (ADC_CFGR2_LSHIFT_3 | ADC_CFGR2_LSHIFT_1) /*!< ADC 10 bits shift left applied on the final ADC conversion data */ 0857 #define LL_ADC_LEFT_BIT_SHIFT_11 (ADC_CFGR2_LSHIFT_3 | ADC_CFGR2_LSHIFT_1 | ADC_CFGR2_LSHIFT_0) /*!< ADC 11 bits shift left applied on the final ADC conversion data */ 0858 #define LL_ADC_LEFT_BIT_SHIFT_12 (ADC_CFGR2_LSHIFT_3 | ADC_CFGR2_LSHIFT_2) /*!< ADC 12 bits shift left applied on the final ADC conversion data */ 0859 #define LL_ADC_LEFT_BIT_SHIFT_13 (ADC_CFGR2_LSHIFT_3 | ADC_CFGR2_LSHIFT_2 | ADC_CFGR2_LSHIFT_0) /*!< ADC 13 bits shift left applied on the final ADC conversion data */ 0860 #define LL_ADC_LEFT_BIT_SHIFT_14 (ADC_CFGR2_LSHIFT_3 | ADC_CFGR2_LSHIFT_2 | ADC_CFGR2_LSHIFT_1) /*!< ADC 14 bits shift left applied on the final ADC conversion data */ 0861 #define LL_ADC_LEFT_BIT_SHIFT_15 (ADC_CFGR2_LSHIFT_3 | ADC_CFGR2_LSHIFT_2 | ADC_CFGR2_LSHIFT_1 | ADC_CFGR2_LSHIFT_0) /*!< ADC 15 bits shift left applied on the final ADC conversion data */ 0862 /** 0863 * @} 0864 */ 0865 0866 /** @defgroup ADC_LL_EC_LP_MODE ADC instance - Low power mode 0867 * @ingroup RTEMSBSPsARMSTM32H7 0868 * @{ 0869 */ 0870 #define LL_ADC_LP_MODE_NONE (0x00000000UL) /*!< No ADC low power mode activated */ 0871 #define LL_ADC_LP_AUTOWAIT (ADC_CFGR_AUTDLY) /*!< ADC low power mode auto delay: Dynamic low power mode, ADC conversions are performed only when necessary (when previous ADC conversion data is read). See description with function @ref LL_ADC_SetLowPowerMode(). */ 0872 /** 0873 * @} 0874 */ 0875 0876 /** @defgroup ADC_LL_EC_OFFSET_NB ADC instance - Offset number 0877 * @ingroup RTEMSBSPsARMSTM32H7 0878 * @{ 0879 */ 0880 #define LL_ADC_OFFSET_1 ADC_OFR1_REGOFFSET /*!< ADC offset number 1: ADC channel and offset level to which the offset programmed will be applied (independently of channel mapped on ADC group regular or group injected) */ 0881 #define LL_ADC_OFFSET_2 ADC_OFR2_REGOFFSET /*!< ADC offset number 2: ADC channel and offset level to which the offset programmed will be applied (independently of channel mapped on ADC group regular or group injected) */ 0882 #define LL_ADC_OFFSET_3 ADC_OFR3_REGOFFSET /*!< ADC offset number 3: ADC channel and offset level to which the offset programmed will be applied (independently of channel mapped on ADC group regular or group injected) */ 0883 #define LL_ADC_OFFSET_4 ADC_OFR4_REGOFFSET /*!< ADC offset number 4: ADC channel and offset level to which the offset programmed will be applied (independently of channel mapped on ADC group regular or group injected) */ 0884 /** 0885 * @} 0886 */ 0887 0888 /** @defgroup ADC_LL_EC_OFFSET_SIGNED_SATURATION ADC instance - Offset signed saturation mode 0889 * @ingroup RTEMSBSPsARMSTM32H7 0890 * @{ 0891 */ 0892 #define LL_ADC_OFFSET_SIGNED_SATURATION_DISABLE (0x00000000UL) /*!< ADC offset signed saturation is disabled (among ADC selected offset number 1, 2, 3 or 4) */ 0893 #define LL_ADC_OFFSET_SIGNED_SATURATION_ENABLE (ADC_OFR1_SSATE) /*!< ADC offset signed saturation is enabled (among ADC selected offset number 1, 2, 3 or 4) */ 0894 /** 0895 * @} 0896 */ 0897 0898 /** @defgroup ADC_LL_EC_OFFSET_RSHIFT ADC instance - Offset right shift 0899 * @ingroup RTEMSBSPsARMSTM32H7 0900 * @{ 0901 */ 0902 #define LL_ADC_OFFSET_RSHIFT_DISABLE (0x00000000UL) /*!< ADC offset right shift is disabled (among ADC selected offset number 1, 2, 3 or 4) */ 0903 #define LL_ADC_OFFSET_RSHIFT_ENABLE (ADC_CFGR2_RSHIFT1) /*!< ADC offset right shift is enabled (among ADC selected offset number 1, 2, 3 or 4) */ 0904 /** 0905 * @} 0906 */ 0907 #if defined(ADC_VER_V5_V90) 0908 /** @defgroup ADC_LL_EC_OFFSET_SATURATION ADC instance - Offset saturation mode 0909 * @ingroup RTEMSBSPsARMSTM32H7 0910 * @{ 0911 */ 0912 #define LL_ADC_OFFSET_SATURATION_DISABLE (0x00000000UL) /*!< ADC offset saturation is disabled (among ADC selected offset number 1, 2, 3 or 4). On devices STM32H72xx and STM32H73xx */ 0913 #define LL_ADC_OFFSET_SATURATION_ENABLE (ADC3_OFR1_SATEN) /*!< ADC offset saturation is enabled (among ADC selected offset number 1, 2, 3 or 4). On devices STM32H72xx and STM32H73xx */ 0914 /** 0915 * @} 0916 */ 0917 0918 /** @defgroup ADC_LL_EC_OFFSET_STATE ADC instance - Offset state 0919 * @ingroup RTEMSBSPsARMSTM32H7 0920 * @{ 0921 */ 0922 #define LL_ADC_OFFSET_DISABLE (0x00000000UL) /*!< ADC offset disabled (among ADC selected offset number 1, 2, 3 or 4) */ 0923 #define LL_ADC_OFFSET_ENABLE (ADC3_OFR1_OFFSET1_EN) /*!< ADC offset enabled (among ADC selected offset number 1, 2, 3 or 4) */ 0924 /** 0925 * @} 0926 */ 0927 #if defined(ADC_VER_V5_V90) 0928 /** @defgroup ADC_LL_EC_OFFSET_SIGN ADC instance - Offset sign 0929 * @ingroup RTEMSBSPsARMSTM32H7 0930 * @{ 0931 */ 0932 #define LL_ADC_OFFSET_SIGN_NEGATIVE (0x00000000UL) /*!< ADC offset is negative (among ADC selected offset number 1, 2, 3 or 4). On devices STM32H72xx and STM32H73xx */ 0933 #define LL_ADC_OFFSET_SIGN_POSITIVE (ADC3_OFR1_OFFSETPOS) /*!< ADC offset is positive (among ADC selected offset number 1, 2, 3 or 4). On devices STM32H72xx and STM32H73xx */ 0934 /** 0935 * @} 0936 */ 0937 #endif /* ADC_VER_V5_V90 */ 0938 0939 #endif /* ADC_VER_V5_V90 */ 0940 0941 /** @defgroup ADC_LL_EC_GROUPS ADC instance - Groups 0942 * @ingroup RTEMSBSPsARMSTM32H7 0943 * @{ 0944 */ 0945 #define LL_ADC_GROUP_REGULAR (0x00000001UL) /*!< ADC group regular (available on all STM32 devices) */ 0946 #define LL_ADC_GROUP_INJECTED (0x00000002UL) /*!< ADC group injected (not available on all STM32 devices)*/ 0947 #define LL_ADC_GROUP_REGULAR_INJECTED (0x00000003UL) /*!< ADC both groups regular and injected */ 0948 /** 0949 * @} 0950 */ 0951 0952 /** @defgroup ADC_LL_EC_CHANNEL ADC instance - Channel number 0953 * @ingroup RTEMSBSPsARMSTM32H7 0954 * @{ 0955 */ 0956 #define LL_ADC_CHANNEL_0 (ADC_CHANNEL_0_NUMBER | ADC_CHANNEL_0_SMP | ADC_CHANNEL_0_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN0 */ 0957 #define LL_ADC_CHANNEL_1 (ADC_CHANNEL_1_NUMBER | ADC_CHANNEL_1_SMP | ADC_CHANNEL_1_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN1 */ 0958 #define LL_ADC_CHANNEL_2 (ADC_CHANNEL_2_NUMBER | ADC_CHANNEL_2_SMP | ADC_CHANNEL_2_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN2 */ 0959 #define LL_ADC_CHANNEL_3 (ADC_CHANNEL_3_NUMBER | ADC_CHANNEL_3_SMP | ADC_CHANNEL_3_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN3 */ 0960 #define LL_ADC_CHANNEL_4 (ADC_CHANNEL_4_NUMBER | ADC_CHANNEL_4_SMP | ADC_CHANNEL_4_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN4 */ 0961 #define LL_ADC_CHANNEL_5 (ADC_CHANNEL_5_NUMBER | ADC_CHANNEL_5_SMP | ADC_CHANNEL_5_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN5 */ 0962 #define LL_ADC_CHANNEL_6 (ADC_CHANNEL_6_NUMBER | ADC_CHANNEL_6_SMP | ADC_CHANNEL_6_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN6 */ 0963 #define LL_ADC_CHANNEL_7 (ADC_CHANNEL_7_NUMBER | ADC_CHANNEL_7_SMP | ADC_CHANNEL_7_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN7 */ 0964 #define LL_ADC_CHANNEL_8 (ADC_CHANNEL_8_NUMBER | ADC_CHANNEL_8_SMP | ADC_CHANNEL_8_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN8 */ 0965 #define LL_ADC_CHANNEL_9 (ADC_CHANNEL_9_NUMBER | ADC_CHANNEL_9_SMP | ADC_CHANNEL_9_BITFIELD ) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN9 */ 0966 #define LL_ADC_CHANNEL_10 (ADC_CHANNEL_10_NUMBER | ADC_CHANNEL_10_SMP | ADC_CHANNEL_10_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN10 */ 0967 #define LL_ADC_CHANNEL_11 (ADC_CHANNEL_11_NUMBER | ADC_CHANNEL_11_SMP | ADC_CHANNEL_11_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN11 */ 0968 #define LL_ADC_CHANNEL_12 (ADC_CHANNEL_12_NUMBER | ADC_CHANNEL_12_SMP | ADC_CHANNEL_12_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN12 */ 0969 #define LL_ADC_CHANNEL_13 (ADC_CHANNEL_13_NUMBER | ADC_CHANNEL_13_SMP | ADC_CHANNEL_13_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN13 */ 0970 #define LL_ADC_CHANNEL_14 (ADC_CHANNEL_14_NUMBER | ADC_CHANNEL_14_SMP | ADC_CHANNEL_14_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN14 */ 0971 #define LL_ADC_CHANNEL_15 (ADC_CHANNEL_15_NUMBER | ADC_CHANNEL_15_SMP | ADC_CHANNEL_15_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN15 */ 0972 #define LL_ADC_CHANNEL_16 (ADC_CHANNEL_16_NUMBER | ADC_CHANNEL_16_SMP | ADC_CHANNEL_16_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN16 */ 0973 #define LL_ADC_CHANNEL_17 (ADC_CHANNEL_17_NUMBER | ADC_CHANNEL_17_SMP | ADC_CHANNEL_17_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN17 */ 0974 #define LL_ADC_CHANNEL_18 (ADC_CHANNEL_18_NUMBER | ADC_CHANNEL_18_SMP | ADC_CHANNEL_18_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN18 */ 0975 #define LL_ADC_CHANNEL_19 (ADC_CHANNEL_19_NUMBER | ADC_CHANNEL_19_SMP | ADC_CHANNEL_19_BITFIELD) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN19 */ 0976 #if defined(ADC3) 0977 #if defined(ADC_VER_V5_V90) 0978 #define LL_ADC_CHANNEL_VREFINT (LL_ADC_CHANNEL_18 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to VrefInt: Internal voltage reference. On STM32H7, ADC channel available only on ADC instance: ADC3. */ 0979 #define LL_ADC_CHANNEL_TEMPSENSOR (LL_ADC_CHANNEL_17 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to Temperature sensor. On STM32H7, ADC channel available only on ADC instance: ADC3. */ 0980 #define LL_ADC_CHANNEL_VBAT (LL_ADC_CHANNEL_16 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to Vbat/3: Vbat voltage through a divider ladder of factor 1/4 to have Vbat always below Vdda. On STM32H7, ADC channel available only on ADC instance: ADC3. */ 0981 #else 0982 #define LL_ADC_CHANNEL_VREFINT (LL_ADC_CHANNEL_19 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to VrefInt: Internal voltage reference. On STM32H7, ADC channel available only on ADC instance: ADC3. */ 0983 #define LL_ADC_CHANNEL_TEMPSENSOR (LL_ADC_CHANNEL_18 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to Temperature sensor. On STM32H7, ADC channel available only on ADC instance: ADC3. */ 0984 #define LL_ADC_CHANNEL_VBAT (LL_ADC_CHANNEL_17 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to Vbat/3: Vbat voltage through a divider ladder of factor 1/4 to have Vbat always below Vdda. On STM32H7, ADC channel available only on ADC instance: ADC3. */ 0985 #endif /* ADC_VER_V5_V90 */ 0986 #else 0987 /*!< Specific define for STM32H7A3xx and STM32HB3xx varieties of STM32H7XXX */ 0988 #define LL_ADC_CHANNEL_VREFINT (LL_ADC_CHANNEL_19 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to VrefInt: Internal voltage reference. On STM32H7, ADC channel available only on ADC instance: ADC2. */ 0989 #define LL_ADC_CHANNEL_TEMPSENSOR (LL_ADC_CHANNEL_18 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to Temperature sensor. On STM32H7, ADC channel available only on ADC instance: ADC2. */ 0990 #define LL_ADC_CHANNEL_VBAT (LL_ADC_CHANNEL_14 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to Vbat/3: Vbat voltage through a divider ladder of factor 1/4 to have Vbat always below Vdda. On STM32H7, ADC channel available only on ADC instance: ADC2. */ 0991 #endif 0992 #define LL_ADC_CHANNEL_DAC1CH1_ADC2 (LL_ADC_CHANNEL_16 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to DAC1 channel 1, channel specific to ADC2 */ 0993 #define LL_ADC_CHANNEL_DAC1CH2_ADC2 (LL_ADC_CHANNEL_17 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to DAC1 channel 2, channel specific to ADC2 */ 0994 #if defined(DAC2) 0995 /*!< Specific define for STM32H7A3xx and STM32HB3xx varieties of STM32H7XXX */ 0996 #define LL_ADC_CHANNEL_DAC2CH1_ADC2 (LL_ADC_CHANNEL_15 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to DAC2 channel 1, channel specific to ADC2 */ 0997 #endif 0998 /** 0999 * @} 1000 */ 1001 1002 /** @defgroup ADC_LL_EC_REG_TRIGGER_SOURCE ADC group regular - Trigger source 1003 * @ingroup RTEMSBSPsARMSTM32H7 1004 * @{ 1005 */ 1006 #define LL_ADC_REG_TRIG_SOFTWARE (0x00000000UL) /*!< ADC group regular conversion trigger internal: SW start. */ 1007 #define LL_ADC_REG_TRIG_EXT_TIM1_CH1 (ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external peripheral: TIM1 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */ 1008 #define LL_ADC_REG_TRIG_EXT_TIM1_CH2 (ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external peripheral: TIM1 channel 2 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */ 1009 #define LL_ADC_REG_TRIG_EXT_TIM1_CH3 (ADC_CFGR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external peripheral: TIM1 channel 3 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */ 1010 #define LL_ADC_REG_TRIG_EXT_TIM2_CH2 (ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external peripheral: TIM2 channel 2 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */ 1011 #define LL_ADC_REG_TRIG_EXT_TIM3_TRGO (ADC_CFGR_EXTSEL_2 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external peripheral: TIM3 TRGO event. Trigger edge set to rising edge (default setting). */ 1012 #define LL_ADC_REG_TRIG_EXT_TIM4_CH4 (ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external peripheral: TIM4 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */ 1013 #define LL_ADC_REG_TRIG_EXT_EXTI_LINE11 (ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external peripheral: external interrupt line 11 event. Trigger edge set to rising edge (default setting). */ 1014 #define LL_ADC_REG_TRIG_EXT_TIM8_TRGO (ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external peripheral: TIM8 TRGO event. Trigger edge set to rising edge (default setting). */ 1015 #define LL_ADC_REG_TRIG_EXT_TIM8_TRGO2 (ADC_CFGR_EXTSEL_3 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external peripheral: TIM8 TRGO2 event. Trigger edge set to rising edge (default setting). */ 1016 #define LL_ADC_REG_TRIG_EXT_TIM1_TRGO (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external peripheral: TIM1 TRGO event. Trigger edge set to rising edge (default setting). */ 1017 #define LL_ADC_REG_TRIG_EXT_TIM1_TRGO2 (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external peripheral: TIM1 TRGO2 event. Trigger edge set to rising edge (default setting). */ 1018 #define LL_ADC_REG_TRIG_EXT_TIM2_TRGO (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external peripheral: TIM2 TRGO event. Trigger edge set to rising edge (default setting). */ 1019 #define LL_ADC_REG_TRIG_EXT_TIM4_TRGO (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external peripheral: TIM4 TRGO event. Trigger edge set to rising edge (default setting). */ 1020 #define LL_ADC_REG_TRIG_EXT_TIM6_TRGO (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external peripheral: TIM6 TRGO event. Trigger edge set to rising edge (default setting). */ 1021 #define LL_ADC_REG_TRIG_EXT_TIM15_TRGO (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external peripheral: TIM15 TRGO event. Trigger edge set to rising edge (default setting). */ 1022 #define LL_ADC_REG_TRIG_EXT_TIM3_CH4 (ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external peripheral: TIM3 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */ 1023 #define LL_ADC_REG_TRIG_EXT_HRTIM_TRG1 (ADC_CFGR_EXTSEL_4 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external peripheral: HRTIM TRG1 event. Trigger edge set to rising edge (default setting). */ 1024 #define LL_ADC_REG_TRIG_EXT_HRTIM_TRG3 (ADC_CFGR_EXTSEL_4 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external peripheral: HRTIM TRG2 event. Trigger edge set to rising edge (default setting). */ 1025 #define LL_ADC_REG_TRIG_EXT_LPTIM1_OUT (ADC_CFGR_EXTSEL_4 | ADC_CFGR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external peripheral: LPTIM1 OUT event. Trigger edge set to rising edge (default setting). */ 1026 #define LL_ADC_REG_TRIG_EXT_LPTIM2_OUT (ADC_CFGR_EXTSEL_4 | ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external peripheral: LPTIM2 OUT event. Trigger edge set to rising edge (default setting). */ 1027 #define LL_ADC_REG_TRIG_EXT_LPTIM3_OUT (ADC_CFGR_EXTSEL_4 | ADC_CFGR_EXTSEL_2 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external peripheral: LPTIM3 event OUT. Trigger edge set to rising edge (default setting). */ 1028 #if defined (TIM23) 1029 #define LL_ADC_REG_TRIG_EXT_TIM23_TRGO (ADC_CFGR_EXTSEL_4 | ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external peripheral: TIM23 TRGO event. Trigger edge set to rising edge (default setting). */ 1030 #endif /* TIM23 */ 1031 #if defined (TIM24) 1032 #define LL_ADC_REG_TRIG_EXT_TIM24_TRGO (ADC_CFGR_EXTSEL_4 | ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external peripheral: TIM24 TRGO event. Trigger edge set to rising edge (default setting). */ 1033 #endif /* TIM24 */ 1034 /** 1035 * @} 1036 */ 1037 1038 /** @defgroup ADC_LL_EC_REG_TRIGGER_EDGE ADC group regular - Trigger edge 1039 * @ingroup RTEMSBSPsARMSTM32H7 1040 * @{ 1041 */ 1042 #define LL_ADC_REG_TRIG_EXT_RISING ( ADC_CFGR_EXTEN_0) /*!< ADC group regular conversion trigger polarity set to rising edge */ 1043 #define LL_ADC_REG_TRIG_EXT_FALLING (ADC_CFGR_EXTEN_1 ) /*!< ADC group regular conversion trigger polarity set to falling edge */ 1044 #define LL_ADC_REG_TRIG_EXT_RISINGFALLING (ADC_CFGR_EXTEN_1 | ADC_CFGR_EXTEN_0) /*!< ADC group regular conversion trigger polarity set to both rising and falling edges */ 1045 /** 1046 * @} 1047 */ 1048 #if defined(ADC_VER_V5_V90) 1049 /** @defgroup ADC_LL_EC_REG_SAMPLING_MODE ADC group regular - Sampling mode 1050 * @ingroup RTEMSBSPsARMSTM32H7 1051 * @{ 1052 */ 1053 #define LL_ADC_REG_SAMPLING_MODE_NORMAL (0x00000000UL) /*!< ADC conversions sampling phase duration is defined using @ref ADC_LL_EC_CHANNEL_SAMPLINGTIME. On devices STM32H72xx and STM32H73xx */ 1054 #define LL_ADC_REG_SAMPLING_MODE_BULB (ADC3_CFGR2_BULB) /*!< ADC conversions sampling phase starts immediately after end of conversion, and stops upon trigger event. 1055 Note: First conversion is using minimal sampling time (see @ref ADC_LL_EC_CHANNEL_SAMPLINGTIME). On devices STM32H72xx and STM32H73xx */ 1056 #define LL_ADC_REG_SAMPLING_MODE_TRIGGER_CONTROLED (ADC3_CFGR2_SMPTRIG) /*!< ADC conversions sampling phase is controlled by trigger events: 1057 Trigger rising edge = start sampling 1058 Trigger falling edge = stop sampling and start conversion. On devices STM32H72xx and STM32H73xx */ 1059 /** 1060 * @} 1061 */ 1062 #endif /* ADC_VER_V5_V90 */ 1063 1064 /** @defgroup ADC_LL_EC_REG_CONTINUOUS_MODE ADC group regular - Continuous mode 1065 * @ingroup RTEMSBSPsARMSTM32H7 1066 * @{ 1067 */ 1068 #define LL_ADC_REG_CONV_SINGLE (0x00000000UL) /*!< ADC conversions are performed in single mode: one conversion per trigger */ 1069 #define LL_ADC_REG_CONV_CONTINUOUS (ADC_CFGR_CONT) /*!< ADC conversions are performed in continuous mode: after the first trigger, following conversions launched successively automatically */ 1070 /** 1071 * @} 1072 */ 1073 1074 /** @defgroup ADC_LL_EC_REG_DATA_TRANSFER_MODE ADC group regular - Data transfer mode of ADC conversion data 1075 * @ingroup RTEMSBSPsARMSTM32H7 1076 * @{ 1077 */ 1078 #define LL_ADC_REG_DR_TRANSFER (0x00000000UL) /*!< ADC conversions are transferred to DR rigister */ 1079 #define LL_ADC_REG_DMA_TRANSFER_LIMITED ( ADC_CFGR_DMNGT_0) /*!< ADC conversion data are transferred by DMA, in limited mode (one shot mode): DMA transfer requests are stopped when number of DMA data transfers (number of ADC conversions) is reached. This ADC mode is intended to be used with DMA mode non-circular. */ 1080 #define LL_ADC_REG_DMA_TRANSFER_UNLIMITED (ADC_CFGR_DMNGT_1 | ADC_CFGR_DMNGT_0) /*!< ADC conversion data are transferred by DMA, in unlimited mode: DMA transfer requests are unlimited, whatever number of DMA data transferred (number of ADC conversions). This ADC mode is intended to be used with DMA mode circular. */ 1081 #define LL_ADC_REG_DFSDM_TRANSFER (ADC_CFGR_DMNGT_1 ) /*!< ADC conversion data are transferred to DFSDM */ 1082 /** 1083 * @} 1084 */ 1085 1086 #if defined(ADC_VER_V5_V90) 1087 /** @defgroup ADC_LL_EC_REG_DMA_TRANSFER ADC group regular - DMA transfer of ADC conversion data 1088 * @ingroup RTEMSBSPsARMSTM32H7 1089 * @{ 1090 */ 1091 1092 #define LL_ADC3_REG_DMA_TRANSFER_NONE (0x00000000UL) /*!< ADC conversions are not transferred by DMA. On ADC3 of devices STM32H72xx and STM32H73xx */ 1093 #define LL_ADC3_REG_DMA_TRANSFER_LIMITED ( ADC3_CFGR_DMAEN) /*!< ADC conversion data are transferred by DMA, in limited mode (one shot mode): DMA transfer requests are stopped when number of DMA data transfers (number of ADC conversions) is reached. This ADC mode is intended to be used with DMA mode non-circular. On ADC3 of devices STM32H72xx and STM32H73xx */ 1094 #define LL_ADC3_REG_DMA_TRANSFER_UNLIMITED (ADC3_CFGR_DMACFG | ADC3_CFGR_DMAEN) /*!< ADC conversion data are transferred by DMA, in unlimited mode: DMA transfer requests are unlimited, whatever number of DMA data transferred (number of ADC conversions). This ADC mode is intended to be used with DMA mode circular. On ADC3 of devices STM32H72xx and STM32H73xx*/ 1095 /** 1096 * @} 1097 */ 1098 #endif /* ADC_VER_V5_V90 */ 1099 1100 /** @defgroup ADC_LL_EC_REG_OVR_DATA_BEHAVIOR ADC group regular - Overrun behavior on conversion data 1101 * @ingroup RTEMSBSPsARMSTM32H7 1102 * @{ 1103 */ 1104 #define LL_ADC_REG_OVR_DATA_PRESERVED (0x00000000UL) /*!< ADC group regular behavior in case of overrun: data preserved */ 1105 #define LL_ADC_REG_OVR_DATA_OVERWRITTEN (ADC_CFGR_OVRMOD) /*!< ADC group regular behavior in case of overrun: data overwritten */ 1106 /** 1107 * @} 1108 */ 1109 1110 /** @defgroup ADC_LL_EC_REG_SEQ_SCAN_LENGTH ADC group regular - Sequencer scan length 1111 * @ingroup RTEMSBSPsARMSTM32H7 1112 * @{ 1113 */ 1114 #define LL_ADC_REG_SEQ_SCAN_DISABLE (0x00000000UL) /*!< ADC group regular sequencer disable (equivalent to sequencer of 1 rank: ADC conversion on only 1 channel) */ 1115 #define LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS ( ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 2 ranks in the sequence */ 1116 #define LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS ( ADC_SQR1_L_1 ) /*!< ADC group regular sequencer enable with 3 ranks in the sequence */ 1117 #define LL_ADC_REG_SEQ_SCAN_ENABLE_4RANKS ( ADC_SQR1_L_1 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 4 ranks in the sequence */ 1118 #define LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS ( ADC_SQR1_L_2 ) /*!< ADC group regular sequencer enable with 5 ranks in the sequence */ 1119 #define LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS ( ADC_SQR1_L_2 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 6 ranks in the sequence */ 1120 #define LL_ADC_REG_SEQ_SCAN_ENABLE_7RANKS ( ADC_SQR1_L_2 | ADC_SQR1_L_1 ) /*!< ADC group regular sequencer enable with 7 ranks in the sequence */ 1121 #define LL_ADC_REG_SEQ_SCAN_ENABLE_8RANKS ( ADC_SQR1_L_2 | ADC_SQR1_L_1 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 8 ranks in the sequence */ 1122 #define LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS (ADC_SQR1_L_3 ) /*!< ADC group regular sequencer enable with 9 ranks in the sequence */ 1123 #define LL_ADC_REG_SEQ_SCAN_ENABLE_10RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 10 ranks in the sequence */ 1124 #define LL_ADC_REG_SEQ_SCAN_ENABLE_11RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_1 ) /*!< ADC group regular sequencer enable with 11 ranks in the sequence */ 1125 #define LL_ADC_REG_SEQ_SCAN_ENABLE_12RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_1 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 12 ranks in the sequence */ 1126 #define LL_ADC_REG_SEQ_SCAN_ENABLE_13RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_2 ) /*!< ADC group regular sequencer enable with 13 ranks in the sequence */ 1127 #define LL_ADC_REG_SEQ_SCAN_ENABLE_14RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_2 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 14 ranks in the sequence */ 1128 #define LL_ADC_REG_SEQ_SCAN_ENABLE_15RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_2 | ADC_SQR1_L_1 ) /*!< ADC group regular sequencer enable with 15 ranks in the sequence */ 1129 #define LL_ADC_REG_SEQ_SCAN_ENABLE_16RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_2 | ADC_SQR1_L_1 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 16 ranks in the sequence */ 1130 /** 1131 * @} 1132 */ 1133 1134 /** @defgroup ADC_LL_EC_REG_SEQ_DISCONT_MODE ADC group regular - Sequencer discontinuous mode 1135 * @ingroup RTEMSBSPsARMSTM32H7 1136 * @{ 1137 */ 1138 #define LL_ADC_REG_SEQ_DISCONT_DISABLE (0x00000000UL) /*!< ADC group regular sequencer discontinuous mode disable */ 1139 #define LL_ADC_REG_SEQ_DISCONT_1RANK ( ADC_CFGR_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every rank */ 1140 #define LL_ADC_REG_SEQ_DISCONT_2RANKS ( ADC_CFGR_DISCNUM_0 | ADC_CFGR_DISCEN) /*!< ADC group regular sequencer discontinuous mode enabled with sequence interruption every 2 ranks */ 1141 #define LL_ADC_REG_SEQ_DISCONT_3RANKS ( ADC_CFGR_DISCNUM_1 | ADC_CFGR_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 3 ranks */ 1142 #define LL_ADC_REG_SEQ_DISCONT_4RANKS ( ADC_CFGR_DISCNUM_1 | ADC_CFGR_DISCNUM_0 | ADC_CFGR_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 4 ranks */ 1143 #define LL_ADC_REG_SEQ_DISCONT_5RANKS (ADC_CFGR_DISCNUM_2 | ADC_CFGR_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 5 ranks */ 1144 #define LL_ADC_REG_SEQ_DISCONT_6RANKS (ADC_CFGR_DISCNUM_2 | ADC_CFGR_DISCNUM_0 | ADC_CFGR_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 6 ranks */ 1145 #define LL_ADC_REG_SEQ_DISCONT_7RANKS (ADC_CFGR_DISCNUM_2 | ADC_CFGR_DISCNUM_1 | ADC_CFGR_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 7 ranks */ 1146 #define LL_ADC_REG_SEQ_DISCONT_8RANKS (ADC_CFGR_DISCNUM_2 | ADC_CFGR_DISCNUM_1 | ADC_CFGR_DISCNUM_0 | ADC_CFGR_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 8 ranks */ 1147 /** 1148 * @} 1149 */ 1150 1151 /** @defgroup ADC_LL_EC_REG_SEQ_RANKS ADC group regular - Sequencer ranks 1152 * @ingroup RTEMSBSPsARMSTM32H7 1153 * @{ 1154 */ 1155 #define LL_ADC_REG_RANK_1 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_1_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 1 */ 1156 #define LL_ADC_REG_RANK_2 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_2_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 2 */ 1157 #define LL_ADC_REG_RANK_3 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_3_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 3 */ 1158 #define LL_ADC_REG_RANK_4 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_4_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 4 */ 1159 #define LL_ADC_REG_RANK_5 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_5_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 5 */ 1160 #define LL_ADC_REG_RANK_6 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_6_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 6 */ 1161 #define LL_ADC_REG_RANK_7 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_7_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 7 */ 1162 #define LL_ADC_REG_RANK_8 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_8_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 8 */ 1163 #define LL_ADC_REG_RANK_9 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_9_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 9 */ 1164 #define LL_ADC_REG_RANK_10 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_10_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 10 */ 1165 #define LL_ADC_REG_RANK_11 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_11_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 11 */ 1166 #define LL_ADC_REG_RANK_12 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_12_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 12 */ 1167 #define LL_ADC_REG_RANK_13 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_13_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 13 */ 1168 #define LL_ADC_REG_RANK_14 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_14_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 14 */ 1169 #define LL_ADC_REG_RANK_15 (ADC_SQR4_REGOFFSET | ADC_REG_RANK_15_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 15 */ 1170 #define LL_ADC_REG_RANK_16 (ADC_SQR4_REGOFFSET | ADC_REG_RANK_16_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 16 */ 1171 /** 1172 * @} 1173 */ 1174 1175 /** @defgroup ADC_LL_EC_INJ_TRIGGER_SOURCE ADC group injected - Trigger source 1176 * @ingroup RTEMSBSPsARMSTM32H7 1177 * @{ 1178 */ 1179 #define LL_ADC_INJ_TRIG_SOFTWARE (0x00000000UL) /*!< ADC group injected conversion trigger internal: SW start. */ 1180 #define LL_ADC_INJ_TRIG_EXT_TIM1_TRGO (ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external peripheral: TIM1 TRGO event. Trigger edge set to rising edge (default setting). */ 1181 #define LL_ADC_INJ_TRIG_EXT_TIM1_CH4 (ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external peripheral: TIM1 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */ 1182 #define LL_ADC_INJ_TRIG_EXT_TIM2_TRGO (ADC_JSQR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external peripheral: TIM2 TRGO event. Trigger edge set to rising edge (default setting). */ 1183 #define LL_ADC_INJ_TRIG_EXT_TIM2_CH1 (ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external peripheral: TIM2 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */ 1184 #define LL_ADC_INJ_TRIG_EXT_TIM3_CH4 (ADC_JSQR_JEXTSEL_2 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external peripheral: TIM3 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */ 1185 #define LL_ADC_INJ_TRIG_EXT_TIM4_TRGO (ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external peripheral: TIM4 TRGO event. Trigger edge set to rising edge (default setting). */ 1186 #define LL_ADC_INJ_TRIG_EXT_EXTI_LINE15 (ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external peripheral: external interrupt line 15. Trigger edge set to rising edge (default setting). */ 1187 #define LL_ADC_INJ_TRIG_EXT_TIM8_CH4 (ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external peripheral: TIM8 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */ 1188 #define LL_ADC_INJ_TRIG_EXT_TIM1_TRGO2 (ADC_JSQR_JEXTSEL_3 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external peripheral: TIM1 TRGO2 event. Trigger edge set to rising edge (default setting). */ 1189 #define LL_ADC_INJ_TRIG_EXT_TIM8_TRGO (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external peripheral: TIM8 TRGO event. Trigger edge set to rising edge (default setting). */ 1190 #define LL_ADC_INJ_TRIG_EXT_TIM8_TRGO2 (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external peripheral: TIM8 TRGO2 event. Trigger edge set to rising edge (default setting). */ 1191 #define LL_ADC_INJ_TRIG_EXT_TIM3_CH3 (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external peripheral: TIM3 channel 3 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */ 1192 #define LL_ADC_INJ_TRIG_EXT_TIM3_TRGO (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external peripheral: TIM3 TRGO event. Trigger edge set to rising edge (default setting). */ 1193 #define LL_ADC_INJ_TRIG_EXT_TIM3_CH1 (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external peripheral: TIM3 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */ 1194 #define LL_ADC_INJ_TRIG_EXT_TIM6_TRGO (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external peripheral: TIM6 TRGO event. Trigger edge set to rising edge (default setting). */ 1195 #define LL_ADC_INJ_TRIG_EXT_TIM15_TRGO (ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external peripheral: TIM15 TRGO event. Trigger edge set to rising edge (default setting). */ 1196 #if defined(HRTIM1) 1197 #define LL_ADC_INJ_TRIG_EXT_HRTIM_TRG2 (ADC_JSQR_JEXTSEL_4 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external peripheral: HRTIM1 TRG2 event. Trigger edge set to rising edge (default setting). */ 1198 #define LL_ADC_INJ_TRIG_EXT_HRTIM_TRG4 (ADC_JSQR_JEXTSEL_4 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external peripheral: HRTIM1 TRG4 event. Trigger edge set to rising edge (default setting). */ 1199 #endif /* HRTIM1 */ 1200 #define LL_ADC_INJ_TRIG_EXT_LPTIM1_OUT (ADC_JSQR_JEXTSEL_4 | ADC_JSQR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external peripheral: LPTIM1 OUT event. Trigger edge set to rising edge (default setting). */ 1201 #define LL_ADC_INJ_TRIG_EXT_LPTIM2_OUT (ADC_JSQR_JEXTSEL_4 | ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external peripheral: LPTIM2 OUT event. Trigger edge set to rising edge (default setting). */ 1202 #define LL_ADC_INJ_TRIG_EXT_LPTIM3_OUT (ADC_JSQR_JEXTSEL_4 | ADC_JSQR_JEXTSEL_2 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external peripheral: LPTIM3 OUT event. 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */ 1203 #define LL_ADC_INJ_TRIG_EXT_TIM23_TRGO (ADC_JSQR_JEXTSEL_4 | ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external peripheral: TIM23 TRGO event. Trigger edge set to rising edge (default setting). */ 1204 #define LL_ADC_INJ_TRIG_EXT_TIM24_TRGO (ADC_JSQR_JEXTSEL_4 | ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external peripheral: TIM24 TRGO event. Trigger edge set to rising edge (default setting). */ 1205 /** 1206 * @} 1207 */ 1208 1209 /** @defgroup ADC_LL_EC_INJ_TRIGGER_EDGE ADC group injected - Trigger edge 1210 * @ingroup RTEMSBSPsARMSTM32H7 1211 * @{ 1212 */ 1213 #define LL_ADC_INJ_TRIG_EXT_RISING ( ADC_JSQR_JEXTEN_0) /*!< ADC group injected conversion trigger polarity set to rising edge */ 1214 #define LL_ADC_INJ_TRIG_EXT_FALLING (ADC_JSQR_JEXTEN_1 ) /*!< ADC group injected conversion trigger polarity set to falling edge */ 1215 #define LL_ADC_INJ_TRIG_EXT_RISINGFALLING (ADC_JSQR_JEXTEN_1 | ADC_JSQR_JEXTEN_0) /*!< ADC group injected conversion trigger polarity set to both rising and falling edges */ 1216 /** 1217 * @} 1218 */ 1219 1220 /** @defgroup ADC_LL_EC_INJ_TRIG_AUTO ADC group injected - Automatic trigger mode 1221 * @ingroup RTEMSBSPsARMSTM32H7 1222 * @{ 1223 */ 1224 #define LL_ADC_INJ_TRIG_INDEPENDENT (0x00000000UL) /*!< ADC group injected conversion trigger independent. Setting mandatory if ADC group injected injected trigger source is set to an external trigger. */ 1225 #define LL_ADC_INJ_TRIG_FROM_GRP_REGULAR (ADC_CFGR_JAUTO) /*!< ADC group injected conversion trigger from ADC group regular. Setting compliant only with group injected trigger source set to SW start, without any further action on ADC group injected conversion start or stop: in this case, ADC group injected is controlled only from ADC group regular. */ 1226 /** 1227 * @} 1228 */ 1229 1230 /** @defgroup ADC_LL_EC_INJ_CONTEXT_QUEUE ADC group injected - Context queue mode 1231 * @ingroup RTEMSBSPsARMSTM32H7 1232 * @{ 1233 */ 1234 #define LL_ADC_INJ_QUEUE_2CONTEXTS_LAST_ACTIVE (0x00000000UL) /* Group injected sequence context queue is enabled and can contain up to 2 contexts. When all contexts have been processed, the queue maintains the last context active perpetually. */ 1235 #define LL_ADC_INJ_QUEUE_2CONTEXTS_END_EMPTY (ADC_CFGR_JQM) /* Group injected sequence context queue is enabled and can contain up to 2 contexts. When all contexts have been processed, the queue is empty and injected group triggers are disabled. */ 1236 #define LL_ADC_INJ_QUEUE_DISABLE (ADC_CFGR_JQDIS) /* Group injected sequence context queue is disabled: only 1 sequence can be configured and is active perpetually. */ 1237 /** 1238 * @} 1239 */ 1240 1241 /** @defgroup ADC_LL_EC_INJ_SEQ_SCAN_LENGTH ADC group injected - Sequencer scan length 1242 * @ingroup RTEMSBSPsARMSTM32H7 1243 * @{ 1244 */ 1245 #define LL_ADC_INJ_SEQ_SCAN_DISABLE (0x00000000UL) /*!< ADC group injected sequencer disable (equivalent to sequencer of 1 rank: ADC conversion on only 1 channel) */ 1246 #define LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS ( ADC_JSQR_JL_0) /*!< ADC group injected sequencer enable with 2 ranks in the sequence */ 1247 #define LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS (ADC_JSQR_JL_1 ) /*!< ADC group injected sequencer enable with 3 ranks in the sequence */ 1248 #define LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS (ADC_JSQR_JL_1 | ADC_JSQR_JL_0) /*!< ADC group injected sequencer enable with 4 ranks in the sequence */ 1249 /** 1250 * @} 1251 */ 1252 1253 /** @defgroup ADC_LL_EC_INJ_SEQ_DISCONT_MODE ADC group injected - Sequencer discontinuous mode 1254 * @ingroup RTEMSBSPsARMSTM32H7 1255 * @{ 1256 */ 1257 #define LL_ADC_INJ_SEQ_DISCONT_DISABLE (0x00000000UL) /*!< ADC group injected sequencer discontinuous mode disable */ 1258 #define LL_ADC_INJ_SEQ_DISCONT_1RANK (ADC_CFGR_JDISCEN) /*!< ADC group injected sequencer discontinuous mode enable with sequence interruption every rank */ 1259 /** 1260 * @} 1261 */ 1262 1263 /** @defgroup ADC_LL_EC_INJ_SEQ_RANKS ADC group injected - Sequencer ranks 1264 * @ingroup RTEMSBSPsARMSTM32H7 1265 * @{ 1266 */ 1267 #define LL_ADC_INJ_RANK_1 (ADC_JDR1_REGOFFSET | ADC_INJ_RANK_1_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 1 */ 1268 #define LL_ADC_INJ_RANK_2 (ADC_JDR2_REGOFFSET | ADC_INJ_RANK_2_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 2 */ 1269 #define LL_ADC_INJ_RANK_3 (ADC_JDR3_REGOFFSET | ADC_INJ_RANK_3_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 3 */ 1270 #define LL_ADC_INJ_RANK_4 (ADC_JDR4_REGOFFSET | ADC_INJ_RANK_4_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 4 */ 1271 /** 1272 * @} 1273 */ 1274 1275 /** @defgroup ADC_LL_EC_CHANNEL_SAMPLINGTIME Channel - Sampling time 1276 * @ingroup RTEMSBSPsARMSTM32H7 1277 * @{ 1278 */ 1279 #define LL_ADC_SAMPLINGTIME_1CYCLE_5 (0x00000000UL) /*!< Sampling time 1.5 ADC clock cycles */ 1280 #define LL_ADC_SAMPLINGTIME_2CYCLES_5 ( ADC_SMPR2_SMP10_0) /*!< Sampling time 2.5 ADC clock cycles */ 1281 #define LL_ADC_SAMPLINGTIME_8CYCLES_5 ( ADC_SMPR2_SMP10_1 ) /*!< Sampling time 8.5 ADC clock cycles */ 1282 #define LL_ADC_SAMPLINGTIME_16CYCLES_5 ( ADC_SMPR2_SMP10_1 | ADC_SMPR2_SMP10_0) /*!< Sampling time 16.5 ADC clock cycles */ 1283 #define LL_ADC_SAMPLINGTIME_32CYCLES_5 (ADC_SMPR2_SMP10_2 ) /*!< Sampling time 32.5 ADC clock cycles */ 1284 #define LL_ADC_SAMPLINGTIME_64CYCLES_5 (ADC_SMPR2_SMP10_2 | ADC_SMPR2_SMP10_0) /*!< Sampling time 64.5 ADC clock cycles */ 1285 #define LL_ADC_SAMPLINGTIME_387CYCLES_5 (ADC_SMPR2_SMP10_2 | ADC_SMPR2_SMP10_1 ) /*!< Sampling time 387.5 ADC clock cycles */ 1286 #define LL_ADC_SAMPLINGTIME_810CYCLES_5 (ADC_SMPR2_SMP10_2 | ADC_SMPR2_SMP10_1 | ADC_SMPR2_SMP10_0) /*!< Sampling time 810.5 ADC clock cycles */ 1287 /** 1288 * @} 1289 */ 1290 #if defined(ADC_VER_V5_V90) 1291 /** @defgroup ADC_LL_EC_CHANNEL_SAMPLINGTIME Channel - Sampling time 1292 * @ingroup RTEMSBSPsARMSTM32H7 1293 * @{ 1294 */ 1295 #define LL_ADC_SAMPLINGTIME_ADC3_2CYCLES_5 (0x00000000UL) /*!< Sampling time 2.5 ADC clock cycles. On ADC3 of devices STM32H72xx and STM32H73xx */ 1296 #define LL_ADC_SAMPLINGTIME_ADC3_6CYCLES_5 ( ADC_SMPR2_SMP10_0) /*!< Sampling time 6.5 ADC clock cycles. On ADC3 of devices STM32H72xx and STM32H73xx */ 1297 #define LL_ADC_SAMPLINGTIME_ADC3_12CYCLES_5 ( ADC_SMPR2_SMP10_1 ) /*!< Sampling time 12.5 ADC clock cycles. On ADC3 of devices STM32H72xx and STM32H73xx */ 1298 #define LL_ADC_SAMPLINGTIME_ADC3_24CYCLES_5 ( ADC_SMPR2_SMP10_1 | ADC_SMPR2_SMP10_0) /*!< Sampling time 24.5 ADC clock cycles. On ADC3 of devices STM32H72xx and STM32H73xx */ 1299 #define LL_ADC_SAMPLINGTIME_ADC3_47CYCLES_5 (ADC_SMPR2_SMP10_2 ) /*!< Sampling time 47.5 ADC clock cycles. On ADC3 of devices STM32H72xx and STM32H73xx */ 1300 #define LL_ADC_SAMPLINGTIME_ADC3_92CYCLES_5 (ADC_SMPR2_SMP10_2 | ADC_SMPR2_SMP10_0) /*!< Sampling time 92.5 ADC clock cycles. On ADC3 of devices STM32H72xx and STM32H73xx */ 1301 #define LL_ADC_SAMPLINGTIME_ADC3_247CYCLES_5 (ADC_SMPR2_SMP10_2 | ADC_SMPR2_SMP10_1 ) /*!< Sampling time 247.5 ADC clock cycles. On ADC3 of devices STM32H72xx and STM32H73xx */ 1302 #define LL_ADC_SAMPLINGTIME_ADC3_640CYCLES_5 (ADC_SMPR2_SMP10_2 | ADC_SMPR2_SMP10_1 | ADC_SMPR2_SMP10_0) /*!< Sampling time 640.5 ADC clock cycles. On ADC3 of devices STM32H72xx and STM32H73xx */ 1303 /** 1304 * @} 1305 */ 1306 #endif /* ADC_VER_V5_V90 */ 1307 1308 /** @defgroup ADC_LL_EC_CHANNEL_SINGLE_DIFF_ENDING Channel - Single or differential ending 1309 * @ingroup RTEMSBSPsARMSTM32H7 1310 * @{ 1311 */ 1312 #define LL_ADC_SINGLE_ENDED ( ADC_CALFACT_CALFACT_S) /*!< ADC channel ending set to single ended (literal also used to set calibration mode) */ 1313 #define LL_ADC_DIFFERENTIAL_ENDED (ADC_CR_ADCALDIF | ADC_CALFACT_CALFACT_D) /*!< ADC channel ending set to differential (literal also used to set calibration mode) */ 1314 #define LL_ADC_BOTH_SINGLE_DIFF_ENDED (LL_ADC_SINGLE_ENDED | LL_ADC_DIFFERENTIAL_ENDED) /*!< ADC channel ending set to both single ended and differential (literal used only to set calibration factors) */ 1315 /** 1316 * @} 1317 */ 1318 1319 /** @defgroup ADC_LL_EC_AWD_NUMBER Analog watchdog - Analog watchdog number 1320 * @ingroup RTEMSBSPsARMSTM32H7 1321 * @{ 1322 */ 1323 #define LL_ADC_AWD1 (ADC_AWD_CR1_CHANNEL_MASK | ADC_AWD_CR1_REGOFFSET) /*!< ADC analog watchdog number 1 */ 1324 #define LL_ADC_AWD2 (ADC_AWD_CR23_CHANNEL_MASK | ADC_AWD_CR2_REGOFFSET) /*!< ADC analog watchdog number 2 */ 1325 #define LL_ADC_AWD3 (ADC_AWD_CR23_CHANNEL_MASK | ADC_AWD_CR3_REGOFFSET) /*!< ADC analog watchdog number 3 */ 1326 /** 1327 * @} 1328 */ 1329 1330 /** @defgroup ADC_LL_EC_AWD_CHANNELS Analog watchdog - Monitored channels 1331 * @ingroup RTEMSBSPsARMSTM32H7 1332 * @{ 1333 */ 1334 #define LL_ADC_AWD_DISABLE (0x00000000UL) /*!< ADC analog watchdog monitoring disabled */ 1335 #define LL_ADC_AWD_ALL_CHANNELS_REG (ADC_AWD_CR23_CHANNEL_MASK | ADC_CFGR_AWD1EN ) /*!< ADC analog watchdog monitoring of all channels, converted by group regular only */ 1336 #define LL_ADC_AWD_ALL_CHANNELS_INJ (ADC_AWD_CR23_CHANNEL_MASK | ADC_CFGR_JAWD1EN ) /*!< ADC analog watchdog monitoring of all channels, converted by group injected only */ 1337 #define LL_ADC_AWD_ALL_CHANNELS_REG_INJ (ADC_AWD_CR23_CHANNEL_MASK | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN ) /*!< ADC analog watchdog monitoring of all channels, converted by either group regular or injected */ 1338 #define LL_ADC_AWD_CHANNEL_0_REG ((LL_ADC_CHANNEL_0 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN0, converted by group regular only */ 1339 #define LL_ADC_AWD_CHANNEL_0_INJ ((LL_ADC_CHANNEL_0 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN0, converted by group injected only */ 1340 #define LL_ADC_AWD_CHANNEL_0_REG_INJ ((LL_ADC_CHANNEL_0 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN0, converted by either group regular or injected */ 1341 #define LL_ADC_AWD_CHANNEL_1_REG ((LL_ADC_CHANNEL_1 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN1, converted by group regular only */ 1342 #define LL_ADC_AWD_CHANNEL_1_INJ ((LL_ADC_CHANNEL_1 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN1, converted by group injected only */ 1343 #define LL_ADC_AWD_CHANNEL_1_REG_INJ ((LL_ADC_CHANNEL_1 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN1, converted by either group regular or injected */ 1344 #define LL_ADC_AWD_CHANNEL_2_REG ((LL_ADC_CHANNEL_2 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN2, converted by group regular only */ 1345 #define LL_ADC_AWD_CHANNEL_2_INJ ((LL_ADC_CHANNEL_2 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN2, converted by group injected only */ 1346 #define LL_ADC_AWD_CHANNEL_2_REG_INJ ((LL_ADC_CHANNEL_2 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN2, converted by either group regular or injected */ 1347 #define LL_ADC_AWD_CHANNEL_3_REG ((LL_ADC_CHANNEL_3 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN3, converted by group regular only */ 1348 #define LL_ADC_AWD_CHANNEL_3_INJ ((LL_ADC_CHANNEL_3 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN3, converted by group injected only */ 1349 #define LL_ADC_AWD_CHANNEL_3_REG_INJ ((LL_ADC_CHANNEL_3 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN3, converted by either group regular or injected */ 1350 #define LL_ADC_AWD_CHANNEL_4_REG ((LL_ADC_CHANNEL_4 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN4, converted by group regular only */ 1351 #define LL_ADC_AWD_CHANNEL_4_INJ ((LL_ADC_CHANNEL_4 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN4, converted by group injected only */ 1352 #define LL_ADC_AWD_CHANNEL_4_REG_INJ ((LL_ADC_CHANNEL_4 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN4, converted by either group regular or injected */ 1353 #define LL_ADC_AWD_CHANNEL_5_REG ((LL_ADC_CHANNEL_5 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN5, converted by group regular only */ 1354 #define LL_ADC_AWD_CHANNEL_5_INJ ((LL_ADC_CHANNEL_5 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN5, converted by group injected only */ 1355 #define LL_ADC_AWD_CHANNEL_5_REG_INJ ((LL_ADC_CHANNEL_5 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN5, converted by either group regular or injected */ 1356 #define LL_ADC_AWD_CHANNEL_6_REG ((LL_ADC_CHANNEL_6 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN6, converted by group regular only */ 1357 #define LL_ADC_AWD_CHANNEL_6_INJ ((LL_ADC_CHANNEL_6 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN6, converted by group injected only */ 1358 #define LL_ADC_AWD_CHANNEL_6_REG_INJ ((LL_ADC_CHANNEL_6 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN6, converted by either group regular or injected */ 1359 #define LL_ADC_AWD_CHANNEL_7_REG ((LL_ADC_CHANNEL_7 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN7, converted by group regular only */ 1360 #define LL_ADC_AWD_CHANNEL_7_INJ ((LL_ADC_CHANNEL_7 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN7, converted by group injected only */ 1361 #define LL_ADC_AWD_CHANNEL_7_REG_INJ ((LL_ADC_CHANNEL_7 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN7, converted by either group regular or injected */ 1362 #define LL_ADC_AWD_CHANNEL_8_REG ((LL_ADC_CHANNEL_8 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN8, converted by group regular only */ 1363 #define LL_ADC_AWD_CHANNEL_8_INJ ((LL_ADC_CHANNEL_8 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN8, converted by group injected only */ 1364 #define LL_ADC_AWD_CHANNEL_8_REG_INJ ((LL_ADC_CHANNEL_8 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN8, converted by either group regular or injected */ 1365 #define LL_ADC_AWD_CHANNEL_9_REG ((LL_ADC_CHANNEL_9 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN9, converted by group regular only */ 1366 #define LL_ADC_AWD_CHANNEL_9_INJ ((LL_ADC_CHANNEL_9 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN9, converted by group injected only */ 1367 #define LL_ADC_AWD_CHANNEL_9_REG_INJ ((LL_ADC_CHANNEL_9 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN9, converted by either group regular or injected */ 1368 #define LL_ADC_AWD_CHANNEL_10_REG ((LL_ADC_CHANNEL_10 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN10, converted by group regular only */ 1369 #define LL_ADC_AWD_CHANNEL_10_INJ ((LL_ADC_CHANNEL_10 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN10, converted by group injected only */ 1370 #define LL_ADC_AWD_CHANNEL_10_REG_INJ ((LL_ADC_CHANNEL_10 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN10, converted by either group regular or injected */ 1371 #define LL_ADC_AWD_CHANNEL_11_REG ((LL_ADC_CHANNEL_11 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN11, converted by group regular only */ 1372 #define LL_ADC_AWD_CHANNEL_11_INJ ((LL_ADC_CHANNEL_11 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN11, converted by group injected only */ 1373 #define LL_ADC_AWD_CHANNEL_11_REG_INJ ((LL_ADC_CHANNEL_11 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN11, converted by either group regular or injected */ 1374 #define LL_ADC_AWD_CHANNEL_12_REG ((LL_ADC_CHANNEL_12 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN12, converted by group regular only */ 1375 #define LL_ADC_AWD_CHANNEL_12_INJ ((LL_ADC_CHANNEL_12 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN12, converted by group injected only */ 1376 #define LL_ADC_AWD_CHANNEL_12_REG_INJ ((LL_ADC_CHANNEL_12 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN12, converted by either group regular or injected */ 1377 #define LL_ADC_AWD_CHANNEL_13_REG ((LL_ADC_CHANNEL_13 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN13, converted by group regular only */ 1378 #define LL_ADC_AWD_CHANNEL_13_INJ ((LL_ADC_CHANNEL_13 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN13, converted by group injected only */ 1379 #define LL_ADC_AWD_CHANNEL_13_REG_INJ ((LL_ADC_CHANNEL_13 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN13, converted by either group regular or injected */ 1380 #define LL_ADC_AWD_CHANNEL_14_REG ((LL_ADC_CHANNEL_14 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN14, converted by group regular only */ 1381 #define LL_ADC_AWD_CHANNEL_14_INJ ((LL_ADC_CHANNEL_14 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN14, converted by group injected only */ 1382 #define LL_ADC_AWD_CHANNEL_14_REG_INJ ((LL_ADC_CHANNEL_14 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN14, converted by either group regular or injected */ 1383 #define LL_ADC_AWD_CHANNEL_15_REG ((LL_ADC_CHANNEL_15 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN15, converted by group regular only */ 1384 #define LL_ADC_AWD_CHANNEL_15_INJ ((LL_ADC_CHANNEL_15 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN15, converted by group injected only */ 1385 #define LL_ADC_AWD_CHANNEL_15_REG_INJ ((LL_ADC_CHANNEL_15 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN15, converted by either group regular or injected */ 1386 #define LL_ADC_AWD_CHANNEL_16_REG ((LL_ADC_CHANNEL_16 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN16, converted by group regular only */ 1387 #define LL_ADC_AWD_CHANNEL_16_INJ ((LL_ADC_CHANNEL_16 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN16, converted by group injected only */ 1388 #define LL_ADC_AWD_CHANNEL_16_REG_INJ ((LL_ADC_CHANNEL_16 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN16, converted by either group regular or injected */ 1389 #define LL_ADC_AWD_CHANNEL_17_REG ((LL_ADC_CHANNEL_17 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN17, converted by group regular only */ 1390 #define LL_ADC_AWD_CHANNEL_17_INJ ((LL_ADC_CHANNEL_17 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN17, converted by group injected only */ 1391 #define LL_ADC_AWD_CHANNEL_17_REG_INJ ((LL_ADC_CHANNEL_17 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN17, converted by either group regular or injected */ 1392 #define LL_ADC_AWD_CHANNEL_18_REG ((LL_ADC_CHANNEL_18 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN18, converted by group regular only */ 1393 #define LL_ADC_AWD_CHANNEL_18_INJ ((LL_ADC_CHANNEL_18 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN18, converted by group injected only */ 1394 #define LL_ADC_AWD_CHANNEL_18_REG_INJ ((LL_ADC_CHANNEL_18 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN18, converted by either group regular or injected */ 1395 #define LL_ADC_AWD_CHANNEL_19_REG ((LL_ADC_CHANNEL_19 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN19, converted by group regular only */ 1396 #define LL_ADC_AWD_CHANNEL_19_INJ ((LL_ADC_CHANNEL_19 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN19, converted by group injected only */ 1397 #define LL_ADC_AWD_CHANNEL_19_REG_INJ ((LL_ADC_CHANNEL_19 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN19, converted by either group regular or injected */ 1398 #define LL_ADC_AWD_CH_VREFINT_REG ((LL_ADC_CHANNEL_VREFINT & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to VrefInt: Internal voltage reference, converted by group regular only */ 1399 #define LL_ADC_AWD_CH_VREFINT_INJ ((LL_ADC_CHANNEL_VREFINT & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to VrefInt: Internal voltage reference, converted by group injected only */ 1400 #define LL_ADC_AWD_CH_VREFINT_REG_INJ ((LL_ADC_CHANNEL_VREFINT & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to VrefInt: Internal voltage reference, converted by either group regular or injected */ 1401 #define LL_ADC_AWD_CH_TEMPSENSOR_REG ((LL_ADC_CHANNEL_TEMPSENSOR & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Temperature sensor, converted by group regular only */ 1402 #define LL_ADC_AWD_CH_TEMPSENSOR_INJ ((LL_ADC_CHANNEL_TEMPSENSOR & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Temperature sensor, converted by group injected only */ 1403 #define LL_ADC_AWD_CH_TEMPSENSOR_REG_INJ ((LL_ADC_CHANNEL_TEMPSENSOR & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Temperature sensor, converted by either group regular or injected */ 1404 #define LL_ADC_AWD_CH_VBAT_REG ((LL_ADC_CHANNEL_VBAT & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Vbat/4: Vbat voltage through a divider ladder of factor 1/4 to have Vbat always below Vdda, converted by group regular only */ 1405 #define LL_ADC_AWD_CH_VBAT_INJ ((LL_ADC_CHANNEL_VBAT & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Vbat/4: Vbat voltage through a divider ladder of factor 1/4 to have Vbat always below Vdda, converted by group injected only */ 1406 #define LL_ADC_AWD_CH_VBAT_REG_INJ ((LL_ADC_CHANNEL_VBAT & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Vbat/4: Vbat voltage through a divider ladder of factor 1/4 to have Vbat always below Vdda */ 1407 #define LL_ADC_AWD_CH_DAC1CH1_ADC2_REG ((LL_ADC_CHANNEL_DAC1CH1_ADC2 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to DAC1 channel 1, channel specific to ADC2, converted by group regular only */ 1408 #define LL_ADC_AWD_CH_DAC1CH1_ADC2_INJ ((LL_ADC_CHANNEL_DAC1CH1_ADC2 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to DAC1 channel 1, channel specific to ADC2, converted by group injected only */ 1409 #define LL_ADC_AWD_CH_DAC1CH1_ADC2_REG_INJ ((LL_ADC_CHANNEL_DAC1CH1_ADC2 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to DAC1 channel 1, channel specific to ADC2, converted by either group regular or injected */ 1410 #define LL_ADC_AWD_CH_DAC1CH2_ADC2_REG ((LL_ADC_CHANNEL_DAC1CH2_ADC2 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to DAC1 channel 1, channel specific to ADC2, converted by group regular only */ 1411 #define LL_ADC_AWD_CH_DAC1CH2_ADC2_INJ ((LL_ADC_CHANNEL_DAC1CH2_ADC2 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to DAC1 channel 1, channel specific to ADC2, converted by group injected only */ 1412 #define LL_ADC_AWD_CH_DAC1CH2_ADC2_REG_INJ ((LL_ADC_CHANNEL_DAC1CH2_ADC2 & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to DAC1 channel 1, channel specific to ADC2, converted by either group regular or injected */ 1413 /** 1414 * @} 1415 */ 1416 1417 /** @defgroup ADC_LL_EC_AWD_THRESHOLDS Analog watchdog - Thresholds 1418 * @ingroup RTEMSBSPsARMSTM32H7 1419 * @{ 1420 */ 1421 #define LL_ADC_AWD_THRESHOLD_HIGH (0x1UL) /*!< ADC analog watchdog threshold high */ 1422 #define LL_ADC_AWD_THRESHOLD_LOW (0x0UL) /*!< ADC analog watchdog threshold low */ 1423 /** 1424 * @} 1425 */ 1426 #if defined(ADC_VER_V5_V90) 1427 /** @defgroup ADC_LL_EC_AWD_FILTERING_CONFIG Analog watchdog - filtering config 1428 * @ingroup RTEMSBSPsARMSTM32H7 1429 * @{ 1430 */ 1431 #define LL_ADC_AWD_FILTERING_NONE (0x00000000UL) /*!< ADC analog watchdog no filtering, one out-of-window sample is needed to raise flag or interrupt. On ADC3 of devices STM32H72xx and STM32H73xx */ 1432 #define LL_ADC_AWD_FILTERING_2SAMPLES ( ADC3_TR1_AWDFILT_0) /*!< ADC analog watchdog 2 consecutives out-of-window samples are needed to raise flag or interrupt. On ADC3 of devices STM32H72xx and STM32H73xx */ 1433 #define LL_ADC_AWD_FILTERING_3SAMPLES ( ADC3_TR1_AWDFILT_1 ) /*!< ADC analog watchdog 3 consecutives out-of-window samples are needed to raise flag or interrupt. On ADC3 of devices STM32H72xx and STM32H73xx */ 1434 #define LL_ADC_AWD_FILTERING_4SAMPLES ( ADC3_TR1_AWDFILT_1 | ADC3_TR1_AWDFILT_0) /*!< ADC analog watchdog 4 consecutives out-of-window samples are needed to raise flag or interrupt. On ADC3 of devices STM32H72xx and STM32H73xx */ 1435 #define LL_ADC_AWD_FILTERING_5SAMPLES (ADC3_TR1_AWDFILT_2 ) /*!< ADC analog watchdog 5 consecutives out-of-window samples are needed to raise flag or interrupt. On ADC3 of devices STM32H72xx and STM32H73xx */ 1436 #define LL_ADC_AWD_FILTERING_6SAMPLES (ADC3_TR1_AWDFILT_2 | ADC3_TR1_AWDFILT_0) /*!< ADC analog watchdog 6 consecutives out-of-window samples are needed to raise flag or interrupt. On ADC3 of devices STM32H72xx and STM32H73xx */ 1437 #define LL_ADC_AWD_FILTERING_7SAMPLES (ADC3_TR1_AWDFILT_2 | ADC3_TR1_AWDFILT_1 ) /*!< ADC analog watchdog 7 consecutives out-of-window samples are needed to raise flag or interrupt. On ADC3 of devices STM32H72xx and STM32H73xx */ 1438 #define LL_ADC_AWD_FILTERING_8SAMPLES (ADC3_TR1_AWDFILT_2 | ADC3_TR1_AWDFILT_1 | ADC3_TR1_AWDFILT_0) /*!< ADC analog watchdog 8 consecutives out-of-window samples are needed to raise flag or interrupt. On ADC3 of devices STM32H72xx and STM32H73xx */ 1439 /** 1440 * @} 1441 */ 1442 #endif /* ADC_VER_V5_V90 */ 1443 1444 /** @defgroup ADC_LL_EC_OVS_SCOPE Oversampling - Oversampling scope 1445 * @ingroup RTEMSBSPsARMSTM32H7 1446 * @{ 1447 */ 1448 #define LL_ADC_OVS_DISABLE (0x00000000UL) /*!< ADC oversampling disabled. */ 1449 #define LL_ADC_OVS_GRP_REGULAR_CONTINUED ( ADC_CFGR2_ROVSE) /*!< ADC oversampling on conversions of ADC group regular. If group injected interrupts group regular: when ADC group injected is triggered, the oversampling on ADC group regular is temporary stopped and continued afterwards. */ 1450 #define LL_ADC_OVS_GRP_REGULAR_RESUMED (ADC_CFGR2_ROVSM | ADC_CFGR2_ROVSE) /*!< ADC oversampling on conversions of ADC group regular. If group injected interrupts group regular: when ADC group injected is triggered, the oversampling on ADC group regular is resumed from start (oversampler buffer reset). */ 1451 #define LL_ADC_OVS_GRP_INJECTED ( ADC_CFGR2_JOVSE ) /*!< ADC oversampling on conversions of ADC group injected. */ 1452 #define LL_ADC_OVS_GRP_INJ_REG_RESUMED ( ADC_CFGR2_JOVSE | ADC_CFGR2_ROVSE) /*!< ADC oversampling on conversions of both ADC groups regular and injected. If group injected interrupting group regular: when ADC group injected is triggered, the oversampling on ADC group regular is resumed from start (oversampler buffer reset). */ 1453 /** 1454 * @} 1455 */ 1456 1457 /** @defgroup ADC_LL_EC_OVS_DISCONT_MODE Oversampling - Discontinuous mode 1458 * @ingroup RTEMSBSPsARMSTM32H7 1459 * @{ 1460 */ 1461 #define LL_ADC_OVS_REG_CONT (0x00000000UL) /*!< ADC oversampling discontinuous mode: continuous mode (all conversions of oversampling ratio are done from 1 trigger) */ 1462 #define LL_ADC_OVS_REG_DISCONT (ADC_CFGR2_TROVS) /*!< ADC oversampling discontinuous mode: discontinuous mode (each conversion of oversampling ratio needs a trigger) */ 1463 /** 1464 * @} 1465 */ 1466 #if defined(ADC_VER_V5_V90) 1467 /** @defgroup ADC_LL_EC_OVS_RATIO Oversampling - Ratio 1468 * @ingroup RTEMSBSPsARMSTM32H7 1469 * @{ 1470 */ 1471 #define LL_ADC_OVS_RATIO_2 (0x00000000UL) /*!< ADC oversampling ratio of 2 (2 ADC conversions are performed, sum of these conversions data is computed to result as the ADC oversampling conversion data (before potential shift) */ 1472 #define LL_ADC_OVS_RATIO_4 ( ADC3_CFGR2_OVSR_0) /*!< ADC oversampling ratio of 4 (4 ADC conversions are performed, sum of these conversions data is computed to result as the ADC oversampling conversion data (before potential shift) */ 1473 #define LL_ADC_OVS_RATIO_8 ( ADC3_CFGR2_OVSR_1 ) /*!< ADC oversampling ratio of 8 (8 ADC conversions are performed, sum of these conversions data is computed to result as the ADC oversampling conversion data (before potential shift) */ 1474 #define LL_ADC_OVS_RATIO_16 ( ADC3_CFGR2_OVSR_1 | ADC3_CFGR2_OVSR_0) /*!< ADC oversampling ratio of 16 (16 ADC conversions are performed, sum of these conversions data is computed to result as the ADC oversampling conversion data (before potential shift) */ 1475 #define LL_ADC_OVS_RATIO_32 (ADC3_CFGR2_OVSR_2 ) /*!< ADC oversampling ratio of 32 (32 ADC conversions are performed, sum of these conversions data is computed to result as the ADC oversampling conversion data (before potential shift) */ 1476 #define LL_ADC_OVS_RATIO_64 (ADC3_CFGR2_OVSR_2 | ADC3_CFGR2_OVSR_0) /*!< ADC oversampling ratio of 64 (64 ADC conversions are performed, sum of these conversions data is computed to result as the ADC oversampling conversion data (before potential shift) */ 1477 #define LL_ADC_OVS_RATIO_128 (ADC3_CFGR2_OVSR_2 | ADC3_CFGR2_OVSR_1 ) /*!< ADC oversampling ratio of 128 (128 ADC conversions are performed, sum of these conversions data is computed to result as the ADC oversampling conversion data (before potential shift) */ 1478 #define LL_ADC_OVS_RATIO_256 (ADC3_CFGR2_OVSR_2 | ADC3_CFGR2_OVSR_1 | ADC3_CFGR2_OVSR_0) /*!< ADC oversampling ratio of 256 (256 ADC conversions are performed, sum of these conversions data is computed to result as the ADC oversampling conversion data (before potential shift) */ 1479 /** 1480 * @} 1481 */ 1482 #endif /* ADC_VER_V5_V90 */ 1483 1484 /** @defgroup ADC_LL_EC_OVS_SHIFT Oversampling - Data shift 1485 * @ingroup RTEMSBSPsARMSTM32H7 1486 * @{ 1487 */ 1488 #define LL_ADC_OVS_SHIFT_NONE (0x00000000UL) /*!< ADC oversampling no shift (sum of the ADC conversions data is not divided to result as the ADC oversampling conversion data) */ 1489 #define LL_ADC_OVS_SHIFT_RIGHT_1 ( ADC_CFGR2_OVSS_0) /*!< ADC oversampling shift of 1 (sum of the ADC conversions data is divided by 2 to result as the ADC oversampling conversion data) */ 1490 #define LL_ADC_OVS_SHIFT_RIGHT_2 ( ADC_CFGR2_OVSS_1 ) /*!< ADC oversampling shift of 2 (sum of the ADC conversions data is divided by 4 to result as the ADC oversampling conversion data) */ 1491 #define LL_ADC_OVS_SHIFT_RIGHT_3 ( ADC_CFGR2_OVSS_1 | ADC_CFGR2_OVSS_0) /*!< ADC oversampling shift of 3 (sum of the ADC conversions data is divided by 8 to result as the ADC oversampling conversion data) */ 1492 #define LL_ADC_OVS_SHIFT_RIGHT_4 ( ADC_CFGR2_OVSS_2 ) /*!< ADC oversampling shift of 4 (sum of the ADC conversions data is divided by 16 to result as the ADC oversampling conversion data) */ 1493 #define LL_ADC_OVS_SHIFT_RIGHT_5 ( ADC_CFGR2_OVSS_2 | ADC_CFGR2_OVSS_0) /*!< ADC oversampling shift of 5 (sum of the ADC conversions data is divided by 32 to result as the ADC oversampling conversion data) */ 1494 #define LL_ADC_OVS_SHIFT_RIGHT_6 ( ADC_CFGR2_OVSS_2 | ADC_CFGR2_OVSS_1 ) /*!< ADC oversampling shift of 6 (sum of the ADC conversions data is divided by 64 to result as the ADC oversampling conversion data) */ 1495 #define LL_ADC_OVS_SHIFT_RIGHT_7 ( ADC_CFGR2_OVSS_2 | ADC_CFGR2_OVSS_1 | ADC_CFGR2_OVSS_0) /*!< ADC oversampling shift of 7 (sum of the ADC conversions data is divided by 128 to result as the ADC oversampling conversion data) */ 1496 #define LL_ADC_OVS_SHIFT_RIGHT_8 (ADC_CFGR2_OVSS_3 ) /*!< ADC oversampling shift of 8 (sum of the ADC conversions data is divided by 256 to result as the ADC oversampling conversion data) */ 1497 #define LL_ADC_OVS_SHIFT_RIGHT_9 (ADC_CFGR2_OVSS_3 | ADC_CFGR2_OVSS_0) /*!< ADC oversampling shift of 9 (sum of the ADC conversions data is divided by 512 to result as the ADC oversampling conversion data) */ 1498 #define LL_ADC_OVS_SHIFT_RIGHT_10 (ADC_CFGR2_OVSS_3 | ADC_CFGR2_OVSS_1 ) /*!< ADC oversampling shift of 10 (sum of the ADC conversions data is divided by 1024 to result as the ADC oversampling conversion data) */ 1499 #define LL_ADC_OVS_SHIFT_RIGHT_11 (ADC_CFGR2_OVSS_3 | ADC_CFGR2_OVSS_1 | ADC_CFGR2_OVSS_0) /*!< ADC oversampling shift of 11 (sum of the ADC conversions data is divided by 2048 to result as the ADC oversampling conversion data) */ 1500 /** 1501 * @} 1502 */ 1503 1504 /** @defgroup ADC_LL_EC_MULTI_MODE Multimode - Mode 1505 * @ingroup RTEMSBSPsARMSTM32H7 1506 * @{ 1507 */ 1508 #define LL_ADC_MULTI_INDEPENDENT (0x00000000UL) /*!< ADC dual mode disabled (ADC independent mode) */ 1509 #define LL_ADC_MULTI_DUAL_REG_SIMULT ( ADC_CCR_DUAL_2 | ADC_CCR_DUAL_1 ) /*!< ADC dual mode enabled: group regular simultaneous */ 1510 #define LL_ADC_MULTI_DUAL_REG_INTERL ( ADC_CCR_DUAL_2 | ADC_CCR_DUAL_1 | ADC_CCR_DUAL_0) /*!< ADC dual mode enabled: Combined group regular interleaved */ 1511 #define LL_ADC_MULTI_DUAL_INJ_SIMULT ( ADC_CCR_DUAL_2 | ADC_CCR_DUAL_0) /*!< ADC dual mode enabled: group injected simultaneous */ 1512 #define LL_ADC_MULTI_DUAL_INJ_ALTERN (ADC_CCR_DUAL_3 | ADC_CCR_DUAL_0) /*!< ADC dual mode enabled: group injected alternate trigger. Works only with external triggers (not internal SW start) */ 1513 #define LL_ADC_MULTI_DUAL_REG_SIM_INJ_SIM ( ADC_CCR_DUAL_0) /*!< ADC dual mode enabled: Combined group regular simultaneous + group injected simultaneous */ 1514 #define LL_ADC_MULTI_DUAL_REG_SIM_INJ_ALT ( ADC_CCR_DUAL_1 ) /*!< ADC dual mode enabled: Combined group regular simultaneous + group injected alternate trigger */ 1515 #define LL_ADC_MULTI_DUAL_REG_INT_INJ_SIM ( ADC_CCR_DUAL_1 | ADC_CCR_DUAL_0) /*!< ADC dual mode enabled: Combined group regular interleaved + group injected simultaneous */ 1516 /** 1517 * @} 1518 */ 1519 1520 /** @defgroup ADC_LL_EC_MULTI_DMA_TRANSFER Multimode - DMA transfer 1521 * @ingroup RTEMSBSPsARMSTM32H7 1522 * @{ 1523 */ 1524 #define LL_ADC_MULTI_REG_DMA_EACH_ADC (0x00000000UL) /*!< ADC multimode group regular conversions are transferred by DMA: each ADC uses its own DMA channel, with its individual DMA transfer settings */ 1525 #define LL_ADC_MULTI_REG_DMA_RES_32_10B (ADC_CCR_DAMDF_1 ) /*!< ADC multimode group regular conversions are transferred by DMA, one DMA channel for both ADC (DMA of ADC master). Setting for ADC resolution of 32 (16x2) down to 10 bits */ 1526 #define LL_ADC_MULTI_REG_DMA_RES_8B (ADC_CCR_DAMDF_1 | ADC_CCR_DAMDF_0) /*!< ADC multimode group regular conversions are transferred by DMA, one DMA channel for both ADC (DMA of ADC master). Setting for ADC resolution of 8 bits */ 1527 /** 1528 * @} 1529 */ 1530 1531 /** @defgroup ADC_LL_EC_MULTI_TWOSMP_DELAY Multimode - Delay between two sampling phases 1532 * @ingroup RTEMSBSPsARMSTM32H7 1533 * @{ 1534 */ 1535 #define LL_ADC_MULTI_TWOSMP_DELAY_1CYCLE_5 (0x00000000UL) /*!< ADC multimode delay between two sampling phases: 1.5 ADC clock cycle for all resolution */ 1536 #define LL_ADC_MULTI_TWOSMP_DELAY_2CYCLES_5 ( ADC_CCR_DELAY_0) /*!< ADC multimode delay between two sampling phases: 2.5 ADC clock cycles for all resolution */ 1537 #define LL_ADC_MULTI_TWOSMP_DELAY_3CYCLES_5 ( ADC_CCR_DELAY_1 ) /*!< ADC multimode delay between two sampling phases: 3.5 ADC clock cycles for all resolution */ 1538 #define LL_ADC_MULTI_TWOSMP_DELAY_4CYCLES_5 ( ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0) /*!< ADC multimode delay between two sampling phases: 4.5 ADC clock cycles for 16, 14, 12 or 10 bits resolution */ 1539 #define LL_ADC_MULTI_TWOSMP_DELAY_4CYCLES_5_8_BITS ( ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0) /*!< ADC multimode delay between two sampling phases: 4.5 ADC clock cycles for 8 bits resolution */ 1540 #define LL_ADC_MULTI_TWOSMP_DELAY_5CYCLES_5 ( ADC_CCR_DELAY_2 ) /*!< ADC multimode delay between two sampling phases: 5.5 ADC clock cycles for 16, 14, 12 bits resolution */ 1541 #define LL_ADC_MULTI_TWOSMP_DELAY_5CYCLES_5_10_BITS ( ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0) /*!< ADC multimode delay between two sampling phases: 5.5 ADC clock cycles for 10 bits resolution */ 1542 #define LL_ADC_MULTI_TWOSMP_DELAY_6CYCLES (ADC_CCR_DELAY_3 ) /*!< ADC multimode delay between two sampling phases: 6 ADC clock cycles for 10 or 8 bits resolution */ 1543 #define LL_ADC_MULTI_TWOSMP_DELAY_6CYCLES_5 ( ADC_CCR_DELAY_2 | ADC_CCR_DELAY_0) /*!< ADC multimode delay between two sampling phases: 6.5 ADC clock cycles for 16 or 14 bits resolution */ 1544 #define LL_ADC_MULTI_TWOSMP_DELAY_6CYCLES_5_12_BITS ( ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0) /*!< ADC multimode delay between two sampling phases: 6.5 ADC clock cycles for 12 bits resolution */ 1545 #define LL_ADC_MULTI_TWOSMP_DELAY_7CYCLES_5 ( ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0) /*!< ADC multimode delay between two sampling phases: 7.5 ADC clock cycles for 16 bits resolution */ 1546 #define LL_ADC_MULTI_TWOSMP_DELAY_8CYCLES (ADC_CCR_DELAY_3 ) /*!< ADC multimode delay between two sampling phases: 8 ADC clock cycles for 12 bits resolution */ 1547 #define LL_ADC_MULTI_TWOSMP_DELAY_9CYCLES (ADC_CCR_DELAY_3 ) /*!< ADC multimode delay between two sampling phases: 9 ADC clock cycles for 16 or 14 bits resolution */ 1548 /** 1549 * @} 1550 */ 1551 1552 /** @defgroup ADC_LL_EC_MULTI_MASTER_SLAVE Multimode - ADC master or slave 1553 * @ingroup RTEMSBSPsARMSTM32H7 1554 * @{ 1555 */ 1556 #define LL_ADC_MULTI_MASTER ( ADC_CDR_RDATA_MST) /*!< In multimode, selection among several ADC instances: ADC master */ 1557 #define LL_ADC_MULTI_SLAVE (ADC_CDR_RDATA_SLV ) /*!< In multimode, selection among several ADC instances: ADC slave */ 1558 #define LL_ADC_MULTI_MASTER_SLAVE (ADC_CDR_RDATA_SLV | ADC_CDR_RDATA_MST) /*!< In multimode, selection among several ADC instances: both ADC master and ADC slave */ 1559 /** 1560 * @} 1561 */ 1562 1563 1564 1565 /** @defgroup ADC_LL_EC_HW_DELAYS Definitions of ADC hardware constraints delays 1566 * @ingroup RTEMSBSPsARMSTM32H7 1567 * @note Only ADC peripheral HW delays are defined in ADC LL driver driver, 1568 * not timeout values. 1569 * For details on delays values, refer to descriptions in source code 1570 * above each literal definition. 1571 * @{ 1572 */ 1573 1574 /* Note: Only ADC peripheral HW delays are defined in ADC LL driver driver, */ 1575 /* not timeout values. */ 1576 /* Timeout values for ADC operations are dependent to device clock */ 1577 /* configuration (system clock versus ADC clock), */ 1578 /* and therefore must be defined in user application. */ 1579 /* Indications for estimation of ADC timeout delays, for this */ 1580 /* STM32 series: */ 1581 /* - ADC calibration time: maximum delay is 16384/fADC. */ 1582 /* (refer to device datasheet, parameter "tCAL") */ 1583 /* - ADC enable time: maximum delay is 1 conversion cycle. */ 1584 /* (refer to device datasheet, parameter "tSTAB") */ 1585 /* - ADC disable time: maximum delay should be a few ADC clock cycles */ 1586 /* - ADC stop conversion time: maximum delay should be a few ADC clock */ 1587 /* cycles */ 1588 /* - ADC conversion time: duration depending on ADC clock and ADC */ 1589 /* configuration. */ 1590 /* (refer to device reference manual, section "Timing") */ 1591 1592 /* Delay for ADC stabilization time (ADC voltage regulator start-up time) */ 1593 /* Delay set to maximum value (refer to device datasheet, */ 1594 /* parameter "tADCVREG_STUP"). */ 1595 /* Unit: us */ 1596 #define LL_ADC_DELAY_INTERNAL_REGUL_STAB_US ( 10UL) /*!< Delay for ADC stabilization time (ADC voltage regulator start-up time) */ 1597 1598 /* Delay for internal voltage reference stabilization time. */ 1599 /* Delay set to maximum value (refer to device datasheet, */ 1600 /* parameter "ts_vrefint"). */ 1601 /* Unit: us */ 1602 #define LL_ADC_DELAY_VREFINT_STAB_US (5UL) /*!< Delay for internal voltage reference stabilization time */ 1603 1604 /* Delay for temperature sensor stabilization time. */ 1605 /* Literal set to maximum value (refer to device datasheet, */ 1606 /* parameter "tSTART_RUN"). */ 1607 /* Unit: us */ 1608 #define LL_ADC_DELAY_TEMPSENSOR_STAB_US ( 26UL) /*!< Delay for temperature sensor stabilization time */ 1609 1610 /* Delay required between ADC end of calibration and ADC enable. */ 1611 /* Note: On this STM32 series, a minimum number of ADC clock cycles */ 1612 /* are required between ADC end of calibration and ADC enable. */ 1613 /* Wait time can be computed in user application by waiting for the */ 1614 /* equivalent number of CPU cycles, by taking into account */ 1615 /* ratio of CPU clock versus ADC clock prescalers. */ 1616 /* Unit: ADC clock cycles. */ 1617 #define LL_ADC_DELAY_CALIB_ENABLE_ADC_CYCLES ( 4UL) /*!< Delay required between ADC end of calibration and ADC enable */ 1618 1619 /* Fixed timeout value for ADC linearity word bit set/clear delay. */ 1620 /* Values defined to be higher than worst cases: low clock frequency, */ 1621 /* maximum prescalers. */ 1622 /* Ex of profile low frequency : f_ADC at 4,577 Khz (minimum value */ 1623 /* according to Data sheet), linearity set/clear bit delay MAX = 6 / f_ADC + 3 cycles AHB */ 1624 /* 6 / 4577 = 1,311ms */ 1625 /* At maximum CPU speed (400 MHz), this means */ 1626 /* 3.58 * 400 MHz = 524400 CPU cycles */ 1627 #define ADC_LINEARITY_BIT_TOGGLE_TIMEOUT (524400UL) /*!< ADC linearity set/clear bit delay */ 1628 1629 /** 1630 * @} 1631 */ 1632 1633 /** 1634 * @} 1635 */ 1636 1637 1638 /* Exported macro ------------------------------------------------------------*/ 1639 /** @defgroup ADC_LL_Exported_Macros ADC Exported Macros 1640 * @ingroup RTEMSBSPsARMSTM32H7 1641 * @{ 1642 */ 1643 1644 /** @defgroup ADC_LL_EM_WRITE_READ Common write and read registers Macros 1645 * @ingroup RTEMSBSPsARMSTM32H7 1646 * @{ 1647 */ 1648 1649 /** 1650 * @brief Write a value in ADC register 1651 * @param __INSTANCE__ ADC Instance 1652 * @param __REG__ Register to be written 1653 * @param __VALUE__ Value to be written in the register 1654 * @retval None 1655 */ 1656 #define LL_ADC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__)) 1657 1658 /** 1659 * @brief Read a value in ADC register 1660 * @param __INSTANCE__ ADC Instance 1661 * @param __REG__ Register to be read 1662 * @retval Register value 1663 */ 1664 #define LL_ADC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__) 1665 /** 1666 * @} 1667 */ 1668 1669 /** @defgroup ADC_LL_EM_HELPER_MACRO ADC helper macro 1670 * @ingroup RTEMSBSPsARMSTM32H7 1671 * @{ 1672 */ 1673 1674 #if defined(ADC_VER_V5_V90) 1675 /** 1676 * @brief Helper macro to convert the resolution defines to STM32H73x/2x ADC3 registers values 1677 * value corresponding to the ADC3 resolution according to the STM32H73x/2x RefMan. 1678 * @note The input can be a value from ADC3 resolution (12b, 10b, 8b,6b) 1679 * @param __ADC_RESOLUTION__ This parameter can be one of the following values: 1680 * @arg @ref LL_ADC_RESOLUTION_12B 1681 * @arg @ref LL_ADC_RESOLUTION_10B 1682 * @arg @ref LL_ADC_RESOLUTION_8B 1683 * @arg @ref LL_ADC_RESOLUTION_6B 1684 * @retval Returned value can be one of the following values: 1685 * @arg 0x00000000UL (value correspodning to ADC3 12 bits) 1686 * @arg ADC_CFGR_RES_0 = 0x00000004 (value corresponding to ADC3 10 bits) 1687 * @arg ADC_CFGR_RES_1 = 0x00000008 (value corresponding to ADC3 8 bits) 1688 * @arg 0x0000001C (value corresponding to ADC3 6 bits) 1689 * @note This helper macro is applicable for STM32H73x/2x devices only 1690 */ 1691 #define __LL_ADC12_RESOLUTION_TO_ADC3(__ADC_RESOLUTION__) \ 1692 ( \ 1693 ((__ADC_RESOLUTION__) == LL_ADC_RESOLUTION_12B) \ 1694 ?(0x00000000UL) \ 1695 : \ 1696 ((__ADC_RESOLUTION__) == LL_ADC_RESOLUTION_10B) \ 1697 ?(ADC_CFGR_RES_0) \ 1698 : \ 1699 ((__ADC_RESOLUTION__) == LL_ADC_RESOLUTION_8B) \ 1700 ?(ADC_CFGR_RES_1) \ 1701 : \ 1702 ((__ADC_RESOLUTION__) == LL_ADC_RESOLUTION_6B) \ 1703 ?((ADC_CFGR_RES_2|ADC_CFGR_RES_1 | ADC_CFGR_RES_0)) \ 1704 :(0x00000000UL) \ 1705 ) 1706 1707 #endif /* ADC_VER_V5_V90 */ 1708 1709 /** 1710 * @brief Helper macro to get ADC channel number in decimal format 1711 * from literals LL_ADC_CHANNEL_x. 1712 * @note Example: 1713 * __LL_ADC_CHANNEL_TO_DECIMAL_NB(LL_ADC_CHANNEL_4) 1714 * will return decimal number "4". 1715 * @note The input can be a value from functions where a channel 1716 * number is returned, either defined with number 1717 * or with bitfield (only one bit must be set). 1718 * @param __CHANNEL__ This parameter can be one of the following values: 1719 * @arg @ref LL_ADC_CHANNEL_0 (3) 1720 * @arg @ref LL_ADC_CHANNEL_1 (3) 1721 * @arg @ref LL_ADC_CHANNEL_2 (3) 1722 * @arg @ref LL_ADC_CHANNEL_3 (3) 1723 * @arg @ref LL_ADC_CHANNEL_4 (3) 1724 * @arg @ref LL_ADC_CHANNEL_5 (3) 1725 * @arg @ref LL_ADC_CHANNEL_6 1726 * @arg @ref LL_ADC_CHANNEL_7 1727 * @arg @ref LL_ADC_CHANNEL_8 1728 * @arg @ref LL_ADC_CHANNEL_9 1729 * @arg @ref LL_ADC_CHANNEL_10 1730 * @arg @ref LL_ADC_CHANNEL_11 1731 * @arg @ref LL_ADC_CHANNEL_12 1732 * @arg @ref LL_ADC_CHANNEL_13 1733 * @arg @ref LL_ADC_CHANNEL_14 1734 * @arg @ref LL_ADC_CHANNEL_15 1735 * @arg @ref LL_ADC_CHANNEL_16 1736 * @arg @ref LL_ADC_CHANNEL_17 1737 * @arg @ref LL_ADC_CHANNEL_18 1738 * @arg @ref LL_ADC_CHANNEL_19 1739 * @arg @ref LL_ADC_CHANNEL_VREFINT (1) 1740 * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1) 1741 * @arg @ref LL_ADC_CHANNEL_VBAT (1) 1742 * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC2 (2) 1743 * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC2 (2) 1744 * 1745 * (1) On STM32H7, parameter available only on ADC instance: ADC3.\n 1746 * (2) On STM32H7, parameter available only on ADC instance: ADC2.\n 1747 * (3) On STM32H7, fast channel (0.125 us for 14-bit resolution (ADC conversion rate up to 8 Ms/s)). 1748 * Other channels are slow channels (conversion rate: refer to reference manual). 1749 * @retval Value between Min_Data=0 and Max_Data=18 1750 */ 1751 #define __LL_ADC_CHANNEL_TO_DECIMAL_NB(__CHANNEL__) \ 1752 ((((__CHANNEL__) & ADC_CHANNEL_ID_BITFIELD_MASK) == 0UL) \ 1753 ? ( \ 1754 ((__CHANNEL__) & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS \ 1755 ) \ 1756 : \ 1757 ( \ 1758 (uint32_t)POSITION_VAL((__CHANNEL__)) \ 1759 ) \ 1760 ) 1761 1762 /** 1763 * @brief Helper macro to get ADC channel in literal format LL_ADC_CHANNEL_x 1764 * from number in decimal format. 1765 * @note Example: 1766 * __LL_ADC_DECIMAL_NB_TO_CHANNEL(4) 1767 * will return a data equivalent to "LL_ADC_CHANNEL_4". 1768 * @param __DECIMAL_NB__ Value between Min_Data=0 and Max_Data=18 1769 * @retval Returned value can be one of the following values: 1770 * @arg @ref LL_ADC_CHANNEL_0 (3) 1771 * @arg @ref LL_ADC_CHANNEL_1 (3) 1772 * @arg @ref LL_ADC_CHANNEL_2 (3) 1773 * @arg @ref LL_ADC_CHANNEL_3 (3) 1774 * @arg @ref LL_ADC_CHANNEL_4 (3) 1775 * @arg @ref LL_ADC_CHANNEL_5 (3) 1776 * @arg @ref LL_ADC_CHANNEL_6 1777 * @arg @ref LL_ADC_CHANNEL_7 1778 * @arg @ref LL_ADC_CHANNEL_8 1779 * @arg @ref LL_ADC_CHANNEL_9 1780 * @arg @ref LL_ADC_CHANNEL_10 1781 * @arg @ref LL_ADC_CHANNEL_11 1782 * @arg @ref LL_ADC_CHANNEL_12 1783 * @arg @ref LL_ADC_CHANNEL_13 1784 * @arg @ref LL_ADC_CHANNEL_14 1785 * @arg @ref LL_ADC_CHANNEL_15 1786 * @arg @ref LL_ADC_CHANNEL_16 1787 * @arg @ref LL_ADC_CHANNEL_17 1788 * @arg @ref LL_ADC_CHANNEL_18 1789 * @arg @ref LL_ADC_CHANNEL_19 1790 * @arg @ref LL_ADC_CHANNEL_VREFINT (1) 1791 * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1) 1792 * @arg @ref LL_ADC_CHANNEL_VBAT (1) 1793 * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC2 (2) 1794 * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC2 (2) 1795 * 1796 * (1) On STM32H7, parameter available only on ADC instance: ADC3.\n 1797 * (2) On STM32H7, parameter available only on ADC instance: ADC2.\n 1798 * (3) On STM32H7, fast channel (0.125 us for 14-bit resolution (ADC conversion rate up to 8 Ms/s)). 1799 * Other channels are slow channels (conversion rate: refer to reference manual).\n 1800 * (1, 2) For ADC channel read back from ADC register, 1801 * comparison with internal channel parameter to be done 1802 * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL(). 1803 */ 1804 #define __LL_ADC_DECIMAL_NB_TO_CHANNEL(__DECIMAL_NB__) \ 1805 (((__DECIMAL_NB__) <= 9UL) \ 1806 ? ( \ 1807 ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \ 1808 (ADC_AWD2CR_AWD2CH_0 << (__DECIMAL_NB__)) | \ 1809 (ADC_SMPR1_REGOFFSET | (((3UL * (__DECIMAL_NB__))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \ 1810 ) \ 1811 : \ 1812 ( \ 1813 ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \ 1814 (ADC_AWD2CR_AWD2CH_0 << (__DECIMAL_NB__)) | \ 1815 (ADC_SMPR2_REGOFFSET | (((3UL * ((__DECIMAL_NB__) - 10UL))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \ 1816 ) \ 1817 ) 1818 1819 /** 1820 * @brief Helper macro to determine whether the selected channel 1821 * corresponds to literal definitions of driver. 1822 * @note The different literal definitions of ADC channels are: 1823 * - ADC internal channel: 1824 * LL_ADC_CHANNEL_VREFINT, LL_ADC_CHANNEL_TEMPSENSOR, ... 1825 * - ADC external channel (channel connected to a GPIO pin): 1826 * LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ... 1827 * @note The channel parameter must be a value defined from literal 1828 * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT, 1829 * LL_ADC_CHANNEL_TEMPSENSOR, ...), 1830 * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...), 1831 * must not be a value from functions where a channel number is 1832 * returned from ADC registers, 1833 * because internal and external channels share the same channel 1834 * number in ADC registers. The differentiation is made only with 1835 * parameters definitions of driver. 1836 * @param __CHANNEL__ This parameter can be one of the following values: 1837 * @arg @ref LL_ADC_CHANNEL_0 (3) 1838 * @arg @ref LL_ADC_CHANNEL_1 (3) 1839 * @arg @ref LL_ADC_CHANNEL_2 (3) 1840 * @arg @ref LL_ADC_CHANNEL_3 (3) 1841 * @arg @ref LL_ADC_CHANNEL_4 (3) 1842 * @arg @ref LL_ADC_CHANNEL_5 (3) 1843 * @arg @ref LL_ADC_CHANNEL_6 1844 * @arg @ref LL_ADC_CHANNEL_7 1845 * @arg @ref LL_ADC_CHANNEL_8 1846 * @arg @ref LL_ADC_CHANNEL_9 1847 * @arg @ref LL_ADC_CHANNEL_10 1848 * @arg @ref LL_ADC_CHANNEL_11 1849 * @arg @ref LL_ADC_CHANNEL_12 1850 * @arg @ref LL_ADC_CHANNEL_13 1851 * @arg @ref LL_ADC_CHANNEL_14 1852 * @arg @ref LL_ADC_CHANNEL_15 1853 * @arg @ref LL_ADC_CHANNEL_16 1854 * @arg @ref LL_ADC_CHANNEL_17 1855 * @arg @ref LL_ADC_CHANNEL_18 1856 * @arg @ref LL_ADC_CHANNEL_19 1857 * @arg @ref LL_ADC_CHANNEL_VREFINT (1) 1858 * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1) 1859 * @arg @ref LL_ADC_CHANNEL_VBAT (1) 1860 * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC2 (2) 1861 * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC2 (2) 1862 * 1863 * (1) On STM32H7, parameter available only on ADC instance: ADC3.\n 1864 * (2) On STM32H7, parameter available only on ADC instance: ADC2.\n 1865 * (3) On STM32H7, fast channel (0.125 us for 14-bit resolution (ADC conversion rate up to 8 Ms/s)). 1866 * Other channels are slow channels (conversion rate: refer to reference manual). 1867 * @retval Value "0" if the channel corresponds to a parameter definition of a ADC external channel (channel connected to a GPIO pin). 1868 * Value "1" if the channel corresponds to a parameter definition of a ADC internal channel. 1869 */ 1870 #define __LL_ADC_IS_CHANNEL_INTERNAL(__CHANNEL__) \ 1871 (((__CHANNEL__) & ADC_CHANNEL_ID_INTERNAL_CH_MASK) != 0UL) 1872 1873 /** 1874 * @brief Helper macro to convert a channel defined from parameter 1875 * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT, 1876 * LL_ADC_CHANNEL_TEMPSENSOR, ...), 1877 * to its equivalent parameter definition of a ADC external channel 1878 * (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...). 1879 * @note The channel parameter can be, additionally to a value 1880 * defined from parameter definition of a ADC internal channel 1881 * (LL_ADC_CHANNEL_VREFINT, LL_ADC_CHANNEL_TEMPSENSOR, ...), 1882 * a value defined from parameter definition of 1883 * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...) 1884 * or a value from functions where a channel number is returned 1885 * from ADC registers. 1886 * @param __CHANNEL__ This parameter can be one of the following values: 1887 * @arg @ref LL_ADC_CHANNEL_0 (3) 1888 * @arg @ref LL_ADC_CHANNEL_1 (3) 1889 * @arg @ref LL_ADC_CHANNEL_2 (3) 1890 * @arg @ref LL_ADC_CHANNEL_3 (3) 1891 * @arg @ref LL_ADC_CHANNEL_4 (3) 1892 * @arg @ref LL_ADC_CHANNEL_5 (3) 1893 * @arg @ref LL_ADC_CHANNEL_6 1894 * @arg @ref LL_ADC_CHANNEL_7 1895 * @arg @ref LL_ADC_CHANNEL_8 1896 * @arg @ref LL_ADC_CHANNEL_9 1897 * @arg @ref LL_ADC_CHANNEL_10 1898 * @arg @ref LL_ADC_CHANNEL_11 1899 * @arg @ref LL_ADC_CHANNEL_12 1900 * @arg @ref LL_ADC_CHANNEL_13 1901 * @arg @ref LL_ADC_CHANNEL_14 1902 * @arg @ref LL_ADC_CHANNEL_15 1903 * @arg @ref LL_ADC_CHANNEL_16 1904 * @arg @ref LL_ADC_CHANNEL_17 1905 * @arg @ref LL_ADC_CHANNEL_18 1906 * @arg @ref LL_ADC_CHANNEL_19 1907 * @arg @ref LL_ADC_CHANNEL_VREFINT (1) 1908 * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1) 1909 * @arg @ref LL_ADC_CHANNEL_VBAT (1) 1910 * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC2 (2) 1911 * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC2 (2) 1912 * 1913 * (1) On STM32H7, parameter available only on ADC instance: ADC3.\n 1914 * (2) On STM32H7, parameter available only on ADC instance: ADC2.\n 1915 * (3) On STM32H7, fast channel (0.125 us for 14-bit resolution (ADC conversion rate up to 8 Ms/s)). 1916 * Other channels are slow channels (conversion rate: refer to reference manual). 1917 * @retval Returned value can be one of the following values: 1918 * @arg @ref LL_ADC_CHANNEL_0 1919 * @arg @ref LL_ADC_CHANNEL_1 1920 * @arg @ref LL_ADC_CHANNEL_2 1921 * @arg @ref LL_ADC_CHANNEL_3 1922 * @arg @ref LL_ADC_CHANNEL_4 1923 * @arg @ref LL_ADC_CHANNEL_5 1924 * @arg @ref LL_ADC_CHANNEL_6 1925 * @arg @ref LL_ADC_CHANNEL_7 1926 * @arg @ref LL_ADC_CHANNEL_8 1927 * @arg @ref LL_ADC_CHANNEL_9 1928 * @arg @ref LL_ADC_CHANNEL_10 1929 * @arg @ref LL_ADC_CHANNEL_11 1930 * @arg @ref LL_ADC_CHANNEL_12 1931 * @arg @ref LL_ADC_CHANNEL_13 1932 * @arg @ref LL_ADC_CHANNEL_14 1933 * @arg @ref LL_ADC_CHANNEL_15 1934 * @arg @ref LL_ADC_CHANNEL_16 1935 * @arg @ref LL_ADC_CHANNEL_17 1936 * @arg @ref LL_ADC_CHANNEL_18 1937 * @arg @ref LL_ADC_CHANNEL_19 1938 */ 1939 #define __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL(__CHANNEL__) \ 1940 ((__CHANNEL__) & ~ADC_CHANNEL_ID_INTERNAL_CH_MASK) 1941 1942 /** 1943 * @brief Helper macro to determine whether the internal channel 1944 * selected is available on the ADC instance selected. 1945 * @note The channel parameter must be a value defined from parameter 1946 * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT, 1947 * LL_ADC_CHANNEL_TEMPSENSOR, ...), 1948 * must not be a value defined from parameter definition of 1949 * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...) 1950 * or a value from functions where a channel number is 1951 * returned from ADC registers, 1952 * because internal and external channels share the same channel 1953 * number in ADC registers. The differentiation is made only with 1954 * parameters definitions of driver. 1955 * @param __ADC_INSTANCE__ ADC instance 1956 * @param __CHANNEL__ This parameter can be one of the following values: 1957 * @arg @ref LL_ADC_CHANNEL_VREFINT (1) 1958 * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1) 1959 * @arg @ref LL_ADC_CHANNEL_VBAT (1) 1960 * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC2 (2) 1961 * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC2 (2) 1962 * 1963 * (1) On STM32H7, parameter available only on ADC instance: ADC3.\n 1964 * (2) On STM32H7, parameter available only on ADC instance: ADC2. 1965 * @retval Value "0" if the internal channel selected is not available on the ADC instance selected. 1966 * Value "1" if the internal channel selected is available on the ADC instance selected. 1967 */ 1968 #if defined(ADC3) 1969 #define __LL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE(__ADC_INSTANCE__, __CHANNEL__) \ 1970 ((((__ADC_INSTANCE__) == ADC2) \ 1971 &&( \ 1972 ((__CHANNEL__) == LL_ADC_CHANNEL_DAC1CH1_ADC2) || \ 1973 ((__CHANNEL__) == LL_ADC_CHANNEL_DAC1CH2_ADC2) \ 1974 ) \ 1975 ) \ 1976 || \ 1977 (((__ADC_INSTANCE__) == ADC3) \ 1978 &&( \ 1979 ((__CHANNEL__) == LL_ADC_CHANNEL_TEMPSENSOR) || \ 1980 ((__CHANNEL__) == LL_ADC_CHANNEL_VBAT) || \ 1981 ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) \ 1982 ) \ 1983 ) \ 1984 ) 1985 #else 1986 #define __LL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE(__ADC_INSTANCE__, __CHANNEL__) \ 1987 ((((__ADC_INSTANCE__) == ADC2) \ 1988 &&( \ 1989 ((__CHANNEL__) == LL_ADC_CHANNEL_DAC1CH1_ADC2) || \ 1990 ((__CHANNEL__) == LL_ADC_CHANNEL_DAC1CH2_ADC2) || \ 1991 ((__CHANNEL__) == LL_ADC_CHANNEL_TEMPSENSOR) || \ 1992 ((__CHANNEL__) == LL_ADC_CHANNEL_VBAT) || \ 1993 ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) \ 1994 ) \ 1995 ) \ 1996 ) 1997 #endif 1998 1999 /** 2000 * @brief Helper macro to define ADC analog watchdog parameter: 2001 * define a single channel to monitor with analog watchdog 2002 * from sequencer channel and groups definition. 2003 * @note To be used with function @ref LL_ADC_SetAnalogWDMonitChannels(). 2004 * Example: 2005 * LL_ADC_SetAnalogWDMonitChannels( 2006 * ADC1, LL_ADC_AWD1, 2007 * __LL_ADC_ANALOGWD_CHANNEL_GROUP(LL_ADC_CHANNEL4, LL_ADC_GROUP_REGULAR)) 2008 * @param __CHANNEL__ This parameter can be one of the following values: 2009 * @arg @ref LL_ADC_CHANNEL_0 (3) 2010 * @arg @ref LL_ADC_CHANNEL_1 (3) 2011 * @arg @ref LL_ADC_CHANNEL_2 (3) 2012 * @arg @ref LL_ADC_CHANNEL_3 (3) 2013 * @arg @ref LL_ADC_CHANNEL_4 (3) 2014 * @arg @ref LL_ADC_CHANNEL_5 (3) 2015 * @arg @ref LL_ADC_CHANNEL_6 2016 * @arg @ref LL_ADC_CHANNEL_7 2017 * @arg @ref LL_ADC_CHANNEL_8 2018 * @arg @ref LL_ADC_CHANNEL_9 2019 * @arg @ref LL_ADC_CHANNEL_10 2020 * @arg @ref LL_ADC_CHANNEL_11 2021 * @arg @ref LL_ADC_CHANNEL_12 2022 * @arg @ref LL_ADC_CHANNEL_13 2023 * @arg @ref LL_ADC_CHANNEL_14 2024 * @arg @ref LL_ADC_CHANNEL_15 2025 * @arg @ref LL_ADC_CHANNEL_16 2026 * @arg @ref LL_ADC_CHANNEL_17 2027 * @arg @ref LL_ADC_CHANNEL_18 2028 * @arg @ref LL_ADC_CHANNEL_19 2029 * @arg @ref LL_ADC_CHANNEL_VREFINT (1) 2030 * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1) 2031 * @arg @ref LL_ADC_CHANNEL_VBAT (1) 2032 * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC2 (2) 2033 * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC2 (2) 2034 * 2035 * (1) On STM32H7, parameter available only on ADC instance: ADC3.\n 2036 * (2) On STM32H7, parameter available only on ADC instance: ADC2.\n 2037 * (3) On STM32H7, fast channel (0.125 us for 14-bit resolution (ADC conversion rate up to 8 Ms/s)). 2038 * Other channels are slow channels (conversion rate: refer to reference manual).\n 2039 * (1, 2) For ADC channel read back from ADC register, 2040 * comparison with internal channel parameter to be done 2041 * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL(). 2042 * @param __GROUP__ This parameter can be one of the following values: 2043 * @arg @ref LL_ADC_GROUP_REGULAR 2044 * @arg @ref LL_ADC_GROUP_INJECTED 2045 * @arg @ref LL_ADC_GROUP_REGULAR_INJECTED 2046 * @retval Returned value can be one of the following values: 2047 * @arg @ref LL_ADC_AWD_DISABLE 2048 * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG (0) 2049 * @arg @ref LL_ADC_AWD_ALL_CHANNELS_INJ (0) 2050 * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG_INJ 2051 * @arg @ref LL_ADC_AWD_CHANNEL_0_REG (0) 2052 * @arg @ref LL_ADC_AWD_CHANNEL_0_INJ (0) 2053 * @arg @ref LL_ADC_AWD_CHANNEL_0_REG_INJ 2054 * @arg @ref LL_ADC_AWD_CHANNEL_1_REG (0) 2055 * @arg @ref LL_ADC_AWD_CHANNEL_1_INJ (0) 2056 * @arg @ref LL_ADC_AWD_CHANNEL_1_REG_INJ 2057 * @arg @ref LL_ADC_AWD_CHANNEL_2_REG (0) 2058 * @arg @ref LL_ADC_AWD_CHANNEL_2_INJ (0) 2059 * @arg @ref LL_ADC_AWD_CHANNEL_2_REG_INJ 2060 * @arg @ref LL_ADC_AWD_CHANNEL_3_REG (0) 2061 * @arg @ref LL_ADC_AWD_CHANNEL_3_INJ (0) 2062 * @arg @ref LL_ADC_AWD_CHANNEL_3_REG_INJ 2063 * @arg @ref LL_ADC_AWD_CHANNEL_4_REG (0) 2064 * @arg @ref LL_ADC_AWD_CHANNEL_4_INJ (0) 2065 * @arg @ref LL_ADC_AWD_CHANNEL_4_REG_INJ 2066 * @arg @ref LL_ADC_AWD_CHANNEL_5_REG (0) 2067 * @arg @ref LL_ADC_AWD_CHANNEL_5_INJ (0) 2068 * @arg @ref LL_ADC_AWD_CHANNEL_5_REG_INJ 2069 * @arg @ref LL_ADC_AWD_CHANNEL_6_REG (0) 2070 * @arg @ref LL_ADC_AWD_CHANNEL_6_INJ (0) 2071 * @arg @ref LL_ADC_AWD_CHANNEL_6_REG_INJ 2072 * @arg @ref LL_ADC_AWD_CHANNEL_7_REG (0) 2073 * @arg @ref LL_ADC_AWD_CHANNEL_7_INJ (0) 2074 * @arg @ref LL_ADC_AWD_CHANNEL_7_REG_INJ 2075 * @arg @ref LL_ADC_AWD_CHANNEL_8_REG (0) 2076 * @arg @ref LL_ADC_AWD_CHANNEL_8_INJ (0) 2077 * @arg @ref LL_ADC_AWD_CHANNEL_8_REG_INJ 2078 * @arg @ref LL_ADC_AWD_CHANNEL_9_REG (0) 2079 * @arg @ref LL_ADC_AWD_CHANNEL_9_INJ (0) 2080 * @arg @ref LL_ADC_AWD_CHANNEL_9_REG_INJ 2081 * @arg @ref LL_ADC_AWD_CHANNEL_10_REG (0) 2082 * @arg @ref LL_ADC_AWD_CHANNEL_10_INJ (0) 2083 * @arg @ref LL_ADC_AWD_CHANNEL_10_REG_INJ 2084 * @arg @ref LL_ADC_AWD_CHANNEL_11_REG (0) 2085 * @arg @ref LL_ADC_AWD_CHANNEL_11_INJ (0) 2086 * @arg @ref LL_ADC_AWD_CHANNEL_11_REG_INJ 2087 * @arg @ref LL_ADC_AWD_CHANNEL_12_REG (0) 2088 * @arg @ref LL_ADC_AWD_CHANNEL_12_INJ (0) 2089 * @arg @ref LL_ADC_AWD_CHANNEL_12_REG_INJ 2090 * @arg @ref LL_ADC_AWD_CHANNEL_13_REG (0) 2091 * @arg @ref LL_ADC_AWD_CHANNEL_13_INJ (0) 2092 * @arg @ref LL_ADC_AWD_CHANNEL_13_REG_INJ 2093 * @arg @ref LL_ADC_AWD_CHANNEL_14_REG (0) 2094 * @arg @ref LL_ADC_AWD_CHANNEL_14_INJ (0) 2095 * @arg @ref LL_ADC_AWD_CHANNEL_14_REG_INJ 2096 * @arg @ref LL_ADC_AWD_CHANNEL_15_REG (0) 2097 * @arg @ref LL_ADC_AWD_CHANNEL_15_INJ (0) 2098 * @arg @ref LL_ADC_AWD_CHANNEL_15_REG_INJ 2099 * @arg @ref LL_ADC_AWD_CHANNEL_16_REG (0) 2100 * @arg @ref LL_ADC_AWD_CHANNEL_16_INJ (0) 2101 * @arg @ref LL_ADC_AWD_CHANNEL_16_REG_INJ 2102 * @arg @ref LL_ADC_AWD_CHANNEL_17_REG (0) 2103 * @arg @ref LL_ADC_AWD_CHANNEL_17_INJ (0) 2104 * @arg @ref LL_ADC_AWD_CHANNEL_17_REG_INJ 2105 * @arg @ref LL_ADC_AWD_CHANNEL_18_REG (0) 2106 * @arg @ref LL_ADC_AWD_CHANNEL_18_INJ (0) 2107 * @arg @ref LL_ADC_AWD_CHANNEL_18_REG_INJ 2108 * @arg @ref LL_ADC_AWD_CHANNEL_19_REG (0) 2109 * @arg @ref LL_ADC_AWD_CHANNEL_19_INJ (0) 2110 * @arg @ref LL_ADC_AWD_CHANNEL_19_REG_INJ 2111 * @arg @ref LL_ADC_AWD_CH_VREFINT_REG (0)(1) 2112 * @arg @ref LL_ADC_AWD_CH_VREFINT_INJ (0)(1) 2113 * @arg @ref LL_ADC_AWD_CH_VREFINT_REG_INJ (1) 2114 * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG (0)(1) 2115 * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_INJ (0)(1) 2116 * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG_INJ (1) 2117 * @arg @ref LL_ADC_AWD_CH_VBAT_REG (0)(1) 2118 * @arg @ref LL_ADC_AWD_CH_VBAT_INJ (0)(1) 2119 * @arg @ref LL_ADC_AWD_CH_VBAT_REG_INJ (1) 2120 * @arg @ref LL_ADC_AWD_CH_DAC1CH1_ADC2_REG (0)(2) 2121 * @arg @ref LL_ADC_AWD_CH_DAC1CH1_ADC2_INJ (0)(2) 2122 * @arg @ref LL_ADC_AWD_CH_DAC1CH1_ADC2_REG_INJ (2) 2123 * @arg @ref LL_ADC_AWD_CH_DAC1CH2_ADC2_REG (0)(2) 2124 * @arg @ref LL_ADC_AWD_CH_DAC1CH2_ADC2_INJ (0)(2) 2125 * @arg @ref LL_ADC_AWD_CH_DAC1CH2_ADC2_REG_INJ (2) 2126 * 2127 * (0) On STM32H7, parameter available only on analog watchdog number: AWD1.\n 2128 * (1) On STM32H7, parameter available only on ADC instance: ADC3.\n 2129 * (2) On STM32H7, parameter available only on ADC instance: ADC2. 2130 */ 2131 #define __LL_ADC_ANALOGWD_CHANNEL_GROUP(__CHANNEL__, __GROUP__) \ 2132 (((__GROUP__) == LL_ADC_GROUP_REGULAR) \ 2133 ? (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) \ 2134 : \ 2135 ((__GROUP__) == LL_ADC_GROUP_INJECTED) \ 2136 ? (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1SGL) \ 2137 : \ 2138 (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) \ 2139 ) 2140 2141 /** 2142 * @brief Helper macro to set the value of ADC analog watchdog threshold high 2143 * or low in function of ADC resolution, when ADC resolution is 2144 * different of 16 bits. 2145 * @note To be used with function @ref LL_ADC_SetAnalogWDThresholds(). 2146 * Example, with a ADC resolution of 8 bits, to set the value of 2147 * analog watchdog threshold high (on 18 bits): 2148 * LL_ADC_SetAnalogWDThresholds 2149 * (< ADCx param >, 2150 * __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION(LL_ADC_RESOLUTION_8B, <threshold_value_18_bits>) 2151 * ); 2152 * @param __ADC_RESOLUTION__ This parameter can be one of the following values: 2153 * @arg @ref LL_ADC_RESOLUTION_16B 2154 * @arg @ref LL_ADC_RESOLUTION_14B 2155 * @arg @ref LL_ADC_RESOLUTION_12B 2156 * @arg @ref LL_ADC_RESOLUTION_10B 2157 * @arg @ref LL_ADC_RESOLUTION_8B 2158 * @param __AWD_THRESHOLD__ Value between Min_Data=0x000000 and Max_Data=0xFFFFFF 2159 * @retval Value between Min_Data=0x000000 and Max_Data=0xFFFFFF 2160 */ 2161 #define __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION(__ADC_RESOLUTION__, __AWD_THRESHOLD__) \ 2162 ((__AWD_THRESHOLD__) << ((__ADC_RESOLUTION__) >> (ADC_CFGR_RES_BITOFFSET_POS - 1U ))) 2163 2164 /** 2165 * @brief Helper macro to get the value of ADC analog watchdog threshold high 2166 * or low in function of ADC resolution, when ADC resolution is 2167 * different of 16 bits. 2168 * @note To be used with function @ref LL_ADC_GetAnalogWDThresholds(). 2169 * Example, with a ADC resolution of 8 bits, to get the value of 2170 * analog watchdog threshold high (on 18 bits): 2171 * < threshold_value_18_bits > = __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION 2172 * (LL_ADC_RESOLUTION_8B, 2173 * LL_ADC_GetAnalogWDThresholds(<ADCx param>, LL_ADC_AWD_THRESHOLD_HIGH) 2174 * ); 2175 * @param __ADC_RESOLUTION__ This parameter can be one of the following values: 2176 * @arg @ref LL_ADC_RESOLUTION_16B 2177 * @arg @ref LL_ADC_RESOLUTION_14B 2178 * @arg @ref LL_ADC_RESOLUTION_12B 2179 * @arg @ref LL_ADC_RESOLUTION_10B 2180 * @arg @ref LL_ADC_RESOLUTION_8B 2181 * @param __AWD_THRESHOLD_16_BITS__ Value between Min_Data=0x000000 and Max_Data=0xFFFFFF 2182 * @retval Value between Min_Data=0x000000 and Max_Data=0xFFFFFF 2183 */ 2184 #define __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION(__ADC_RESOLUTION__, __AWD_THRESHOLD_16_BITS__) \ 2185 ((__AWD_THRESHOLD_16_BITS__) >> ((__ADC_RESOLUTION__) >> (ADC_CFGR_RES_BITOFFSET_POS - 1U ))) 2186 2187 /** 2188 * @brief Helper macro to set the ADC calibration value with both single ended 2189 * and differential modes calibration factors concatenated. 2190 * @note To be used with function @ref LL_ADC_SetCalibrationOffsetFactor(). 2191 * Example, to set calibration factors single ended to 0x55 2192 * and differential ended to 0x2A: 2193 * LL_ADC_SetCalibrationOffsetFactor( 2194 * ADC1, 2195 * __LL_ADC_CALIB_FACTOR_SINGLE_DIFF(0x55, 0x2A)) 2196 * @param __CALIB_FACTOR_SINGLE_ENDED__ Value between Min_Data=0x00 and Max_Data=0x7F 2197 * @param __CALIB_FACTOR_DIFFERENTIAL__ Value between Min_Data=0x00 and Max_Data=0x7F 2198 * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF 2199 */ 2200 #define __LL_ADC_CALIB_FACTOR_SINGLE_DIFF(__CALIB_FACTOR_SINGLE_ENDED__, __CALIB_FACTOR_DIFFERENTIAL__) \ 2201 (((__CALIB_FACTOR_DIFFERENTIAL__) << ADC_CALFACT_CALFACT_D_Pos) | (__CALIB_FACTOR_SINGLE_ENDED__)) 2202 2203 /** 2204 * @brief Helper macro to get the ADC multimode conversion data of ADC master 2205 * or ADC slave from raw value with both ADC conversion data concatenated. 2206 * @note This macro is intended to be used when multimode transfer by DMA 2207 * is enabled: refer to function @ref LL_ADC_SetMultiDMATransfer(). 2208 * In this case the transferred data need to processed with this macro 2209 * to separate the conversion data of ADC master and ADC slave. 2210 * @param __ADC_MULTI_MASTER_SLAVE__ This parameter can be one of the following values: 2211 * @arg @ref LL_ADC_MULTI_MASTER 2212 * @arg @ref LL_ADC_MULTI_SLAVE 2213 * @param __ADC_MULTI_CONV_DATA__ Value between Min_Data=0x000 and Max_Data=0xFFF 2214 * @retval Value between Min_Data=0x000 and Max_Data=0xFFF 2215 */ 2216 #define __LL_ADC_MULTI_CONV_DATA_MASTER_SLAVE(__ADC_MULTI_MASTER_SLAVE__, __ADC_MULTI_CONV_DATA__) \ 2217 (((__ADC_MULTI_CONV_DATA__) >> ((ADC_CDR_RDATA_SLV_Pos) & ~(__ADC_MULTI_MASTER_SLAVE__))) & ADC_CDR_RDATA_MST) 2218 2219 /** 2220 * @brief Helper macro to select, from a ADC instance, to which ADC instance 2221 * it has a dependence in multimode (ADC master of the corresponding 2222 * ADC common instance). 2223 * @note In case of device with multimode available and a mix of 2224 * ADC instances compliant and not compliant with multimode feature, 2225 * ADC instances not compliant with multimode feature are 2226 * considered as master instances (do not depend to 2227 * any other ADC instance). 2228 * @param __ADCx__ ADC instance 2229 * @retval __ADCx__ ADC instance master of the corresponding ADC common instance 2230 */ 2231 #define __LL_ADC_MULTI_INSTANCE_MASTER(__ADCx__) \ 2232 ( ( ((__ADCx__) == ADC2) \ 2233 )? \ 2234 (ADC1) \ 2235 : \ 2236 (__ADCx__) \ 2237 ) 2238 2239 /** 2240 * @brief Helper macro to select the ADC common instance 2241 * to which is belonging the selected ADC instance. 2242 * @note ADC common register instance can be used for: 2243 * - Set parameters common to several ADC instances 2244 * - Multimode (for devices with several ADC instances) 2245 * Refer to functions having argument "ADCxy_COMMON" as parameter. 2246 * @param __ADCx__ ADC instance 2247 * @retval ADC common register instance 2248 */ 2249 #if defined(ADC3_COMMON) 2250 #define __LL_ADC_COMMON_INSTANCE(__ADCx__) \ 2251 ((((__ADCx__) == ADC1) || ((__ADCx__) == ADC2)) \ 2252 ? ( \ 2253 (ADC12_COMMON) \ 2254 ) \ 2255 : \ 2256 ( \ 2257 (ADC3_COMMON) \ 2258 ) \ 2259 ) 2260 #else 2261 #define __LL_ADC_COMMON_INSTANCE(__ADCx__) (ADC12_COMMON) 2262 #endif 2263 2264 /** 2265 * @brief Helper macro to check if all ADC instances sharing the same 2266 * ADC common instance are disabled. 2267 * @note This check is required by functions with setting conditioned to 2268 * ADC state: 2269 * All ADC instances of the ADC common group must be disabled. 2270 * Refer to functions having argument "ADCxy_COMMON" as parameter. 2271 * @note On devices with only 1 ADC common instance, parameter of this macro 2272 * is useless and can be ignored (parameter kept for compatibility 2273 * with devices featuring several ADC common instances). 2274 * @param __ADCXY_COMMON__ ADC common instance 2275 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() ) 2276 * @retval Value "0" if all ADC instances sharing the same ADC common instance 2277 * are disabled. 2278 * Value "1" if at least one ADC instance sharing the same ADC common instance 2279 * is enabled. 2280 */ 2281 #if defined(ADC3_COMMON) 2282 #define __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(__ADCXY_COMMON__) \ 2283 (((__ADCXY_COMMON__) == ADC12_COMMON) \ 2284 ? ( \ 2285 (LL_ADC_IsEnabled(ADC1) | \ 2286 LL_ADC_IsEnabled(ADC2) ) \ 2287 ) \ 2288 : \ 2289 ( \ 2290 (LL_ADC_IsEnabled(ADC3)) \ 2291 ) \ 2292 ) 2293 #else 2294 #define __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(__ADCXY_COMMON__) \ 2295 (LL_ADC_IsEnabled(ADC1) | LL_ADC_IsEnabled(ADC2)) 2296 #endif 2297 2298 /** 2299 * @brief Helper macro to define the ADC conversion data full-scale digital 2300 * value corresponding to the selected ADC resolution. 2301 * @note ADC conversion data full-scale corresponds to voltage range 2302 * determined by analog voltage references Vref+ and Vref- 2303 * (refer to reference manual). 2304 * @param __ADC_RESOLUTION__ This parameter can be one of the following values: 2305 * @arg @ref LL_ADC_RESOLUTION_16B 2306 * @arg @ref LL_ADC_RESOLUTION_14B 2307 * @arg @ref LL_ADC_RESOLUTION_12B 2308 * @arg @ref LL_ADC_RESOLUTION_10B 2309 * @arg @ref LL_ADC_RESOLUTION_8B 2310 * @retval ADC conversion data full-scale digital value (unit: digital value of ADC conversion data) 2311 */ 2312 #define __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__) \ 2313 (0xFFFFUL >> ((__ADC_RESOLUTION__) >> (ADC_CFGR_RES_BITOFFSET_POS - 1UL))) 2314 2315 #if defined(ADC_VER_V5_V90) 2316 /** 2317 * @brief Helper macro to define the ADC conversion data full-scale digital 2318 * value corresponding to the selected ADC resolution. 2319 * @note ADC conversion data full-scale corresponds to voltage range 2320 * determined by analog voltage references Vref+ and Vref- 2321 * (refer to reference manual). 2322 * @param __ADC_RESOLUTION__ This parameter can be one of the following values: 2323 * @arg @ref LL_ADC_RESOLUTION_12B 2324 * @arg @ref LL_ADC_RESOLUTION_10B 2325 * @arg @ref LL_ADC_RESOLUTION_8B 2326 * @arg @ref LL_ADC_RESOLUTION_6B 2327 * @retval ADC conversion data equivalent voltage value (unit: digital value of ADC conversion bitfield) 2328 */ 2329 #define __LL_ADC3_DIGITAL_SCALE(__ADC_RESOLUTION__) \ 2330 (0xFFFUL >> ((__ADC_RESOLUTION__) >> (ADC_CFGR_RES_BITOFFSET_POS_ADC3 - 1UL))) 2331 #endif /* ADC_VER_V5_V90 */ 2332 /** 2333 * @brief Helper macro to convert the ADC conversion data from 2334 * a resolution to another resolution. 2335 * @param __DATA__ ADC conversion data to be converted 2336 * @param __ADC_RESOLUTION_CURRENT__ Resolution of the data to be converted 2337 * This parameter can be one of the following values: 2338 * @arg @ref LL_ADC_RESOLUTION_16B 2339 * @arg @ref LL_ADC_RESOLUTION_14B 2340 * @arg @ref LL_ADC_RESOLUTION_12B 2341 * @arg @ref LL_ADC_RESOLUTION_10B 2342 * @arg @ref LL_ADC_RESOLUTION_8B 2343 * @param __ADC_RESOLUTION_TARGET__ Resolution of the data after conversion 2344 * This parameter can be one of the following values: 2345 * @arg @ref LL_ADC_RESOLUTION_16B 2346 * @arg @ref LL_ADC_RESOLUTION_14B 2347 * @arg @ref LL_ADC_RESOLUTION_12B 2348 * @arg @ref LL_ADC_RESOLUTION_10B 2349 * @arg @ref LL_ADC_RESOLUTION_8B 2350 * @retval ADC conversion data to the requested resolution 2351 */ 2352 #if defined(ADC_VER_V5_X) || defined(ADC_VER_V5_V90) 2353 #define __LL_ADC_CONVERT_DATA_RESOLUTION(__DATA__,\ 2354 __ADC_RESOLUTION_CURRENT__,\ 2355 __ADC_RESOLUTION_TARGET__) \ 2356 ( (__ADC_RESOLUTION_CURRENT__ == LL_ADC_RESOLUTION_8B) \ 2357 ?( \ 2358 ((__DATA__) \ 2359 << (((__ADC_RESOLUTION_CURRENT__) & ~(ADC_CFGR_RES_1 | ADC_CFGR_RES_0) ) >> (ADC_CFGR_RES_BITOFFSET_POS - 1UL))) \ 2360 >> ((__ADC_RESOLUTION_TARGET__) >> (ADC_CFGR_RES_BITOFFSET_POS - 1UL)) \ 2361 ) \ 2362 : \ 2363 ( \ 2364 (__ADC_RESOLUTION_TARGET__ == LL_ADC_RESOLUTION_8B) \ 2365 ? ( \ 2366 ((__DATA__) \ 2367 << ((__ADC_RESOLUTION_CURRENT__) >> (ADC_CFGR_RES_BITOFFSET_POS - 1UL))) \ 2368 >> (((__ADC_RESOLUTION_TARGET__) & ~(ADC_CFGR_RES_1 | ADC_CFGR_RES_0) ) >> (ADC_CFGR_RES_BITOFFSET_POS - 1UL)) \ 2369 ) \ 2370 :\ 2371 (\ 2372 ((__DATA__) \ 2373 << ((__ADC_RESOLUTION_CURRENT__) >> (ADC_CFGR_RES_BITOFFSET_POS - 1UL))) \ 2374 >> ((__ADC_RESOLUTION_TARGET__) >> (ADC_CFGR_RES_BITOFFSET_POS - 1UL)) \ 2375 ) \ 2376 )\ 2377 ) 2378 2379 2380 #else /* defined(ADC_VER_V5_3) */ 2381 #define __LL_ADC_CONVERT_DATA_RESOLUTION(__DATA__,\ 2382 __ADC_RESOLUTION_CURRENT__,\ 2383 __ADC_RESOLUTION_TARGET__) \ 2384 ( (__ADC_RESOLUTION_CURRENT__ == LL_ADC_RESOLUTION_8B) \ 2385 ?( \ 2386 ((__DATA__) \ 2387 << (((__ADC_RESOLUTION_CURRENT__) & ~(ADC_CFGR_RES_1 | ADC_CFGR_RES_0) ) >> (ADC_CFGR_RES_BITOFFSET_POS - 1UL))) \ 2388 >> ((__ADC_RESOLUTION_TARGET__) >> (ADC_CFGR_RES_BITOFFSET_POS - 1UL)) \ 2389 ) \ 2390 : \ 2391 ( \ 2392 (__ADC_RESOLUTION_TARGET__ == LL_ADC_RESOLUTION_8B) \ 2393 ? ( \ 2394 ((__DATA__) \ 2395 << ((__ADC_RESOLUTION_CURRENT__) >> (ADC_CFGR_RES_BITOFFSET_POS - 1UL))) \ 2396 >> (((__ADC_RESOLUTION_TARGET__) & ~(ADC_CFGR_RES_1 | ADC_CFGR_RES_0) ) >> (ADC_CFGR_RES_BITOFFSET_POS - 1UL)) \ 2397 ) \ 2398 :\ 2399 (\ 2400 ((__DATA__) \ 2401 << ((__ADC_RESOLUTION_CURRENT__) >> (ADC_CFGR_RES_BITOFFSET_POS - 1UL))) \ 2402 >> ((__ADC_RESOLUTION_TARGET__) >> (ADC_CFGR_RES_BITOFFSET_POS - 1UL)) \ 2403 ) \ 2404 )\ 2405 ) 2406 2407 #endif 2408 2409 #if defined(ADC_VER_V5_V90) 2410 /** 2411 * @brief Helper macro to convert the ADC conversion data from 2412 * a resolution to another resolution. 2413 * @param __DATA__ ADC conversion data to be converted 2414 * @param __ADC_RESOLUTION_CURRENT__ Resolution of the data to be converted 2415 * This parameter can be one of the following values: 2416 * @arg @ref LL_ADC_RESOLUTION_12B 2417 * @arg @ref LL_ADC_RESOLUTION_10B 2418 * @arg @ref LL_ADC_RESOLUTION_8B 2419 * @arg @ref LL_ADC_RESOLUTION_6B 2420 * @param __ADC_RESOLUTION_TARGET__ Resolution of the data after conversion 2421 * This parameter can be one of the following values: 2422 * @arg @ref LL_ADC_RESOLUTION_12B 2423 * @arg @ref LL_ADC_RESOLUTION_10B 2424 * @arg @ref LL_ADC_RESOLUTION_8B 2425 * @arg @ref LL_ADC_RESOLUTION_6B 2426 * @retval ADC conversion data to the requested resolution 2427 */ 2428 #define __LL_ADC_CONVERT_DATA_RESOLUTION_ADC3(__DATA__,\ 2429 __ADC_RESOLUTION_CURRENT__,\ 2430 __ADC_RESOLUTION_TARGET__) \ 2431 (((__DATA__) \ 2432 << ((__ADC_RESOLUTION_CURRENT__) >> (ADC_CFGR_RES_BITOFFSET_POS_ADC3 - 1UL))) \ 2433 >> ((__ADC_RESOLUTION_TARGET__) >> (ADC_CFGR_RES_BITOFFSET_POS_ADC3 - 1UL)) \ 2434 ) 2435 #endif /* ADC_VER_V5_V90 */ 2436 /** 2437 * @brief Helper macro to calculate the voltage (unit: mVolt) 2438 * corresponding to a ADC conversion data (unit: digital value). 2439 * @note Analog reference voltage (Vref+) must be either known from 2440 * user board environment or can be calculated using ADC measurement 2441 * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE(). 2442 * @param __VREFANALOG_VOLTAGE__ Analog reference voltage (unit: mV) 2443 * @param __ADC_DATA__ ADC conversion data (resolution 16 bits) 2444 * (unit: digital value). 2445 * @param __ADC_RESOLUTION__ This parameter can be one of the following values: 2446 * @arg @ref LL_ADC_RESOLUTION_16B 2447 * @arg @ref LL_ADC_RESOLUTION_14B 2448 * @arg @ref LL_ADC_RESOLUTION_12B 2449 * @arg @ref LL_ADC_RESOLUTION_10B 2450 * @arg @ref LL_ADC_RESOLUTION_8B 2451 * @retval ADC conversion data equivalent voltage value (unit: mVolt) 2452 */ 2453 #define __LL_ADC_CALC_DATA_TO_VOLTAGE(__VREFANALOG_VOLTAGE__,\ 2454 __ADC_DATA__,\ 2455 __ADC_RESOLUTION__) \ 2456 ((__ADC_DATA__) * (__VREFANALOG_VOLTAGE__) \ 2457 / __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__) \ 2458 ) 2459 2460 /** 2461 * @brief Helper macro to calculate analog reference voltage (Vref+) 2462 * (unit: mVolt) from ADC conversion data of internal voltage 2463 * reference VrefInt. 2464 * @note Computation is using VrefInt calibration value 2465 * stored in system memory for each device during production. 2466 * @note This voltage depends on user board environment: voltage level 2467 * connected to pin Vref+. 2468 * On devices with small package, the pin Vref+ is not present 2469 * and internally bonded to pin Vdda. 2470 * @note On this STM32 series, calibration data of internal voltage reference 2471 * VrefInt corresponds to a resolution of 16 bits, 2472 * this is the recommended ADC resolution to convert voltage of 2473 * internal voltage reference VrefInt. 2474 * Otherwise, this macro performs the processing to scale 2475 * ADC conversion data to 16 bits. 2476 * @param __VREFINT_ADC_DATA__ ADC conversion data (resolution 16 bits) 2477 * of internal voltage reference VrefInt (unit: digital value). 2478 * @param __ADC_RESOLUTION__ This parameter can be one of the following values: 2479 * @arg @ref LL_ADC_RESOLUTION_16B 2480 * @arg @ref LL_ADC_RESOLUTION_14B 2481 * @arg @ref LL_ADC_RESOLUTION_12B 2482 * @arg @ref LL_ADC_RESOLUTION_10B 2483 * @arg @ref LL_ADC_RESOLUTION_8B 2484 * @retval Analog reference voltage (unit: mV) 2485 */ 2486 #define __LL_ADC_CALC_VREFANALOG_VOLTAGE(__VREFINT_ADC_DATA__,\ 2487 __ADC_RESOLUTION__) \ 2488 (((uint32_t)(*VREFINT_CAL_ADDR) * VREFINT_CAL_VREF) \ 2489 / __LL_ADC_CONVERT_DATA_RESOLUTION((__VREFINT_ADC_DATA__), \ 2490 (__ADC_RESOLUTION__), \ 2491 LL_ADC_RESOLUTION_16B) \ 2492 ) 2493 2494 /** 2495 * @brief Helper macro to calculate the temperature (unit: degree Celsius) 2496 * from ADC conversion data of internal temperature sensor. 2497 * @note Computation is using temperature sensor calibration values 2498 * stored in system memory for each device during production. 2499 * @note Calculation formula: 2500 * Temperature = ((TS_ADC_DATA - TS_CAL1) 2501 * * (TS_CAL2_TEMP - TS_CAL1_TEMP)) 2502 * / (TS_CAL2 - TS_CAL1) + TS_CAL1_TEMP 2503 * with TS_ADC_DATA = temperature sensor raw data measured by ADC 2504 * Avg_Slope = (TS_CAL2 - TS_CAL1) 2505 * / (TS_CAL2_TEMP - TS_CAL1_TEMP) 2506 * TS_CAL1 = equivalent TS_ADC_DATA at temperature 2507 * TEMP_DEGC_CAL1 (calibrated in factory) 2508 * TS_CAL2 = equivalent TS_ADC_DATA at temperature 2509 * TEMP_DEGC_CAL2 (calibrated in factory) 2510 * Caution: Calculation relevancy under reserve that calibration 2511 * parameters are correct (address and data). 2512 * To calculate temperature using temperature sensor 2513 * datasheet typical values (generic values less, therefore 2514 * less accurate than calibrated values), 2515 * use helper macro @ref __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS(). 2516 * @note As calculation input, the analog reference voltage (Vref+) must be 2517 * defined as it impacts the ADC LSB equivalent voltage. 2518 * @note Analog reference voltage (Vref+) must be either known from 2519 * user board environment or can be calculated using ADC measurement 2520 * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE(). 2521 * @note On this STM32 series, calibration data of temperature sensor 2522 * corresponds to a resolution of 16 bits, 2523 * this is the recommended ADC resolution to convert voltage of 2524 * temperature sensor. 2525 * Otherwise, this macro performs the processing to scale 2526 * ADC conversion data to 16 bits. 2527 * @param __VREFANALOG_VOLTAGE__ Analog reference voltage (unit: mV) 2528 * @param __TEMPSENSOR_ADC_DATA__ ADC conversion data of internal 2529 * temperature sensor (unit: digital value). 2530 * @param __ADC_RESOLUTION__ ADC resolution at which internal temperature 2531 * sensor voltage has been measured. 2532 * This parameter can be one of the following values: 2533 * @arg @ref LL_ADC_RESOLUTION_16B 2534 * @arg @ref LL_ADC_RESOLUTION_14B 2535 * @arg @ref LL_ADC_RESOLUTION_12B 2536 * @arg @ref LL_ADC_RESOLUTION_10B 2537 * @arg @ref LL_ADC_RESOLUTION_8B 2538 * @retval Temperature (unit: degree Celsius) 2539 */ 2540 #define __LL_ADC_CALC_TEMPERATURE(__VREFANALOG_VOLTAGE__,\ 2541 __TEMPSENSOR_ADC_DATA__,\ 2542 __ADC_RESOLUTION__) \ 2543 (((( ((int32_t)((__LL_ADC_CONVERT_DATA_RESOLUTION((__TEMPSENSOR_ADC_DATA__), \ 2544 (__ADC_RESOLUTION__), \ 2545 LL_ADC_RESOLUTION_16B) \ 2546 * (__VREFANALOG_VOLTAGE__)) \ 2547 / TEMPSENSOR_CAL_VREFANALOG) \ 2548 - (int32_t) *TEMPSENSOR_CAL1_ADDR) \ 2549 ) * (int32_t)(TEMPSENSOR_CAL2_TEMP - TEMPSENSOR_CAL1_TEMP) \ 2550 ) / (int32_t)((int32_t)*TEMPSENSOR_CAL2_ADDR - (int32_t)*TEMPSENSOR_CAL1_ADDR) \ 2551 ) + TEMPSENSOR_CAL1_TEMP \ 2552 ) 2553 2554 /** 2555 * @brief Helper macro to calculate the temperature (unit: degree Celsius) 2556 * from ADC conversion data of internal temperature sensor. 2557 * @note Computation is using temperature sensor typical values 2558 * (refer to device datasheet). 2559 * @note Calculation formula: 2560 * Temperature = (TS_TYP_CALx_VOLT(uV) - TS_ADC_DATA * Conversion_uV) 2561 * / Avg_Slope + CALx_TEMP 2562 * with TS_ADC_DATA = temperature sensor raw data measured by ADC 2563 * (unit: digital value) 2564 * Avg_Slope = temperature sensor slope 2565 * (unit: uV/Degree Celsius) 2566 * TS_TYP_CALx_VOLT = temperature sensor digital value at 2567 * temperature CALx_TEMP (unit: mV) 2568 * Caution: Calculation relevancy under reserve the temperature sensor 2569 * of the current device has characteristics in line with 2570 * datasheet typical values. 2571 * If temperature sensor calibration values are available on 2572 * on this device (presence of macro __LL_ADC_CALC_TEMPERATURE()), 2573 * temperature calculation will be more accurate using 2574 * helper macro @ref __LL_ADC_CALC_TEMPERATURE(). 2575 * @note As calculation input, the analog reference voltage (Vref+) must be 2576 * defined as it impacts the ADC LSB equivalent voltage. 2577 * @note Analog reference voltage (Vref+) must be either known from 2578 * user board environment or can be calculated using ADC measurement 2579 * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE(). 2580 * @note ADC measurement data must correspond to a resolution of 16 bits 2581 * (full scale digital value 4095). If not the case, the data must be 2582 * preliminarily rescaled to an equivalent resolution of 16 bits. 2583 * @param __TEMPSENSOR_TYP_AVGSLOPE__ Device datasheet data: Temperature sensor slope typical value (unit: uV/DegCelsius). 2584 * On STM32H7, refer to device datasheet parameter "Avg_Slope". 2585 * @param __TEMPSENSOR_TYP_CALX_V__ Device datasheet data: Temperature sensor voltage typical value (at temperature and Vref+ defined in parameters below) (unit: mV). 2586 * On STM32H7, refer to device datasheet parameter "V30" (corresponding to TS_CAL1). 2587 * @param __TEMPSENSOR_CALX_TEMP__ Device datasheet data: Temperature at which temperature sensor voltage (see parameter above) is corresponding (unit: mV) 2588 * @param __VREFANALOG_VOLTAGE__ Analog voltage reference (Vref+) voltage (unit: mV) 2589 * @param __TEMPSENSOR_ADC_DATA__ ADC conversion data of internal temperature sensor (unit: digital value). 2590 * @param __ADC_RESOLUTION__ ADC resolution at which internal temperature sensor voltage has been measured. 2591 * This parameter can be one of the following values: 2592 * @arg @ref LL_ADC_RESOLUTION_16B 2593 * @arg @ref LL_ADC_RESOLUTION_14B 2594 * @arg @ref LL_ADC_RESOLUTION_12B 2595 * @arg @ref LL_ADC_RESOLUTION_10B 2596 * @arg @ref LL_ADC_RESOLUTION_8B 2597 * @retval Temperature (unit: degree Celsius) 2598 */ 2599 #define __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS(__TEMPSENSOR_TYP_AVGSLOPE__,\ 2600 __TEMPSENSOR_TYP_CALX_V__,\ 2601 __TEMPSENSOR_CALX_TEMP__,\ 2602 __VREFANALOG_VOLTAGE__,\ 2603 __TEMPSENSOR_ADC_DATA__,\ 2604 __ADC_RESOLUTION__) \ 2605 ((( ( \ 2606 (int32_t)((((__TEMPSENSOR_ADC_DATA__) * (__VREFANALOG_VOLTAGE__)) \ 2607 / __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__)) \ 2608 * 1000UL) \ 2609 - \ 2610 (int32_t)(((__TEMPSENSOR_TYP_CALX_V__)) \ 2611 * 1000UL) \ 2612 ) \ 2613 ) / (int32_t)(__TEMPSENSOR_TYP_AVGSLOPE__) \ 2614 ) + (int32_t)(__TEMPSENSOR_CALX_TEMP__) \ 2615 ) 2616 2617 /** 2618 * @} 2619 */ 2620 2621 /** 2622 * @} 2623 */ 2624 2625 2626 /* Exported functions --------------------------------------------------------*/ 2627 /** @defgroup ADC_LL_Exported_Functions ADC Exported Functions 2628 * @ingroup RTEMSBSPsARMSTM32H7 2629 * @{ 2630 */ 2631 2632 /** @defgroup ADC_LL_EF_DMA_Management ADC DMA management 2633 * @ingroup RTEMSBSPsARMSTM32H7 2634 * @{ 2635 */ 2636 2637 /** 2638 * @brief Function to help to configure DMA transfer from ADC: retrieve the 2639 * ADC register address from ADC instance and a list of ADC registers 2640 * intended to be used (most commonly) with DMA transfer. 2641 * @note These ADC registers are data registers: 2642 * when ADC conversion data is available in ADC data registers, 2643 * ADC generates a DMA transfer request. 2644 * @note This macro is intended to be used with LL DMA driver, refer to 2645 * function "LL_DMA_ConfigAddresses()". 2646 * Example: 2647 * LL_DMA_ConfigAddresses(DMA1, 2648 * LL_DMA_CHANNEL_1, 2649 * LL_ADC_DMA_GetRegAddr(ADC1, LL_ADC_DMA_REG_REGULAR_DATA), 2650 * (uint32_t)&< array or variable >, 2651 * LL_DMA_DIRECTION_PERIPH_TO_MEMORY); 2652 * @note For devices with several ADC: in multimode, some devices 2653 * use a different data register outside of ADC instance scope 2654 * (common data register). This macro manages this register difference, 2655 * only ADC instance has to be set as parameter. 2656 * @rmtoll DR RDATA LL_ADC_DMA_GetRegAddr\n 2657 * CDR RDATA_MST LL_ADC_DMA_GetRegAddr\n 2658 * CDR RDATA_SLV LL_ADC_DMA_GetRegAddr 2659 * @param ADCx ADC instance 2660 * @param Register This parameter can be one of the following values: 2661 * @arg @ref LL_ADC_DMA_REG_REGULAR_DATA 2662 * @arg @ref LL_ADC_DMA_REG_REGULAR_DATA_MULTI (1) 2663 * 2664 * (1) Available on devices with several ADC instances. 2665 * @retval ADC register address 2666 */ 2667 __STATIC_INLINE uint32_t LL_ADC_DMA_GetRegAddr(ADC_TypeDef *ADCx, uint32_t Register) 2668 { 2669 uint32_t data_reg_addr; 2670 2671 if (Register == LL_ADC_DMA_REG_REGULAR_DATA) 2672 { 2673 /* Retrieve address of register DR */ 2674 data_reg_addr = (uint32_t) & (ADCx->DR); 2675 } 2676 else /* (Register == LL_ADC_DMA_REG_REGULAR_DATA_MULTI) */ 2677 { 2678 /* Retrieve address of register CDR */ 2679 data_reg_addr = (uint32_t) & ((__LL_ADC_COMMON_INSTANCE(ADCx))->CDR); 2680 } 2681 2682 return data_reg_addr; 2683 } 2684 2685 /** 2686 * @} 2687 */ 2688 2689 /** @defgroup ADC_LL_EF_Configuration_ADC_Common Configuration of ADC hierarchical scope: common to several ADC instances 2690 * @ingroup RTEMSBSPsARMSTM32H7 2691 * @{ 2692 */ 2693 2694 /** 2695 * @brief Set parameter common to several ADC: Clock source and prescaler. 2696 * @note On this STM32 series, if ADC group injected is used, some 2697 * clock ratio constraints between ADC clock and AHB clock 2698 * must be respected. 2699 * Refer to reference manual. 2700 * @note On this STM32 series, setting of this feature is conditioned to 2701 * ADC state: 2702 * All ADC instances of the ADC common group must be disabled. 2703 * This check can be done with function @ref LL_ADC_IsEnabled() for each 2704 * ADC instance or by using helper macro helper macro 2705 * @ref __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(). 2706 * @rmtoll CCR CKMODE LL_ADC_SetCommonClock\n 2707 * CCR PRESC LL_ADC_SetCommonClock 2708 * @param ADCxy_COMMON ADC common instance 2709 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() ) 2710 * @param CommonClock This parameter can be one of the following values: 2711 * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV1 2712 * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV2 2713 * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV4 2714 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV1 2715 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV2 2716 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV4 2717 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV6 2718 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV8 2719 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV10 2720 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV12 2721 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV16 2722 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV32 2723 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV64 2724 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV128 2725 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV256 2726 * @retval None 2727 */ 2728 __STATIC_INLINE void LL_ADC_SetCommonClock(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t CommonClock) 2729 { 2730 MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_CKMODE | ADC_CCR_PRESC, CommonClock); 2731 } 2732 2733 /** 2734 * @brief Get parameter common to several ADC: Clock source and prescaler. 2735 * @rmtoll CCR CKMODE LL_ADC_GetCommonClock\n 2736 * CCR PRESC LL_ADC_GetCommonClock 2737 * @param ADCxy_COMMON ADC common instance 2738 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() ) 2739 * @retval Returned value can be one of the following values: 2740 * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV1 2741 * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV2 2742 * @arg @ref LL_ADC_CLOCK_SYNC_PCLK_DIV4 2743 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV1 2744 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV2 2745 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV4 2746 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV6 2747 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV8 2748 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV10 2749 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV12 2750 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV16 2751 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV32 2752 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV64 2753 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV128 2754 * @arg @ref LL_ADC_CLOCK_ASYNC_DIV256 2755 */ 2756 __STATIC_INLINE uint32_t LL_ADC_GetCommonClock(ADC_Common_TypeDef *ADCxy_COMMON) 2757 { 2758 return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_CKMODE | ADC_CCR_PRESC)); 2759 } 2760 2761 /** 2762 * @brief Set parameter common to several ADC: measurement path to internal 2763 * channels (VrefInt, temperature sensor, ...). 2764 * @note One or several values can be selected. 2765 * Example: (LL_ADC_PATH_INTERNAL_VREFINT | 2766 * LL_ADC_PATH_INTERNAL_TEMPSENSOR) 2767 * @note Stabilization time of measurement path to internal channel: 2768 * After enabling internal paths, before starting ADC conversion, 2769 * a delay is required for internal voltage reference and 2770 * temperature sensor stabilization time. 2771 * Refer to device datasheet. 2772 * Refer to literal @ref LL_ADC_DELAY_VREFINT_STAB_US. 2773 * Refer to literal @ref LL_ADC_DELAY_TEMPSENSOR_STAB_US. 2774 * @note ADC internal channel sampling time constraint: 2775 * For ADC conversion of internal channels, 2776 * a sampling time minimum value is required. 2777 * Refer to device datasheet. 2778 * @note On this STM32 series, setting of this feature is conditioned to 2779 * ADC state: 2780 * All ADC instances of the ADC common group must be disabled. 2781 * This check can be done with function @ref LL_ADC_IsEnabled() for each 2782 * ADC instance or by using helper macro helper macro 2783 * @ref __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(). 2784 * @rmtoll CCR VREFEN LL_ADC_SetCommonPathInternalCh\n 2785 * CCR TSEN LL_ADC_SetCommonPathInternalCh\n 2786 * CCR VBATEN LL_ADC_SetCommonPathInternalCh 2787 * @param ADCxy_COMMON ADC common instance 2788 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() ) 2789 * @param PathInternal This parameter can be a combination of the following values: 2790 * @arg @ref LL_ADC_PATH_INTERNAL_NONE 2791 * @arg @ref LL_ADC_PATH_INTERNAL_VREFINT 2792 * @arg @ref LL_ADC_PATH_INTERNAL_TEMPSENSOR 2793 * @arg @ref LL_ADC_PATH_INTERNAL_VBAT 2794 * @retval None 2795 */ 2796 __STATIC_INLINE void LL_ADC_SetCommonPathInternalCh(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t PathInternal) 2797 { 2798 MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_VREFEN | ADC_CCR_TSEN | ADC_CCR_VBATEN, PathInternal); 2799 } 2800 2801 /** 2802 * @brief Get parameter common to several ADC: measurement path to internal 2803 * channels (VrefInt, temperature sensor, ...). 2804 * @note One or several values can be selected. 2805 * Example: (LL_ADC_PATH_INTERNAL_VREFINT | 2806 * LL_ADC_PATH_INTERNAL_TEMPSENSOR) 2807 * @rmtoll CCR VREFEN LL_ADC_GetCommonPathInternalCh\n 2808 * CCR TSEN LL_ADC_GetCommonPathInternalCh\n 2809 * CCR VBATEN LL_ADC_GetCommonPathInternalCh 2810 * @param ADCxy_COMMON ADC common instance 2811 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() ) 2812 * @retval Returned value can be a combination of the following values: 2813 * @arg @ref LL_ADC_PATH_INTERNAL_NONE 2814 * @arg @ref LL_ADC_PATH_INTERNAL_VREFINT 2815 * @arg @ref LL_ADC_PATH_INTERNAL_TEMPSENSOR 2816 * @arg @ref LL_ADC_PATH_INTERNAL_VBAT 2817 */ 2818 __STATIC_INLINE uint32_t LL_ADC_GetCommonPathInternalCh(ADC_Common_TypeDef *ADCxy_COMMON) 2819 { 2820 return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_VREFEN | ADC_CCR_TSEN | ADC_CCR_VBATEN)); 2821 } 2822 2823 /** 2824 * @brief Set parameter common to several ADC: measurement path to 2825 * internal channels (VrefInt, temperature sensor, ...). 2826 * Add paths to the current configuration. 2827 * @note One or several values can be selected. 2828 * Example: (LL_ADC_PATH_INTERNAL_VREFINT | 2829 * LL_ADC_PATH_INTERNAL_TEMPSENSOR) 2830 * @note Stabilization time of measurement path to internal channel: 2831 * After enabling internal paths, before starting ADC conversion, 2832 * a delay is required for internal voltage reference and 2833 * temperature sensor stabilization time. 2834 * Refer to device datasheet. 2835 * Refer to literal @ref LL_ADC_DELAY_VREFINT_STAB_US. 2836 * Refer to literal @ref LL_ADC_DELAY_TEMPSENSOR_STAB_US. 2837 * @note ADC internal channel sampling time constraint: 2838 * For ADC conversion of internal channels, 2839 * a sampling time minimum value is required. 2840 * Refer to device datasheet. 2841 * @rmtoll CCR VREFEN LL_ADC_SetCommonPathInternalChAdd\n 2842 * CCR TSEN LL_ADC_SetCommonPathInternalChAdd\n 2843 * CCR VBATEN LL_ADC_SetCommonPathInternalChAdd 2844 * @param ADCxy_COMMON ADC common instance 2845 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() ) 2846 * @param PathInternal This parameter can be a combination of the following values: 2847 * @arg @ref LL_ADC_PATH_INTERNAL_NONE 2848 * @arg @ref LL_ADC_PATH_INTERNAL_VREFINT 2849 * @arg @ref LL_ADC_PATH_INTERNAL_TEMPSENSOR 2850 * @arg @ref LL_ADC_PATH_INTERNAL_VBAT 2851 * @retval None 2852 */ 2853 __STATIC_INLINE void LL_ADC_SetCommonPathInternalChAdd(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t PathInternal) 2854 { 2855 SET_BIT(ADCxy_COMMON->CCR, PathInternal); 2856 } 2857 2858 /** 2859 * @brief Set parameter common to several ADC: measurement path to 2860 * internal channels (VrefInt, temperature sensor, ...). 2861 * Remove paths to the current configuration. 2862 * @note One or several values can be selected. 2863 * Example: (LL_ADC_PATH_INTERNAL_VREFINT | 2864 * LL_ADC_PATH_INTERNAL_TEMPSENSOR) 2865 * @rmtoll CCR VREFEN LL_ADC_SetCommonPathInternalChRem\n 2866 * CCR TSEN LL_ADC_SetCommonPathInternalChRem\n 2867 * CCR VBATEN LL_ADC_SetCommonPathInternalChRem 2868 * @param ADCxy_COMMON ADC common instance 2869 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() ) 2870 * @param PathInternal This parameter can be a combination of the following values: 2871 * @arg @ref LL_ADC_PATH_INTERNAL_NONE 2872 * @arg @ref LL_ADC_PATH_INTERNAL_VREFINT 2873 * @arg @ref LL_ADC_PATH_INTERNAL_TEMPSENSOR 2874 * @arg @ref LL_ADC_PATH_INTERNAL_VBAT 2875 * @retval None 2876 */ 2877 __STATIC_INLINE void LL_ADC_SetCommonPathInternalChRem(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t PathInternal) 2878 { 2879 CLEAR_BIT(ADCxy_COMMON->CCR, PathInternal); 2880 } 2881 2882 /** 2883 * @} 2884 */ 2885 2886 /** @defgroup ADC_LL_EF_Configuration_ADC_Instance Configuration of ADC hierarchical scope: ADC instance 2887 * @ingroup RTEMSBSPsARMSTM32H7 2888 * @{ 2889 */ 2890 2891 /** 2892 * @brief Set ADC calibration factor in the mode single-ended 2893 * or differential (for devices with differential mode available). 2894 * @note This function is intended to set calibration parameters 2895 * without having to perform a new calibration using 2896 * @ref LL_ADC_StartCalibration(). 2897 * @note For devices with differential mode available: 2898 * Calibration of offset is specific to each of 2899 * single-ended and differential modes 2900 * (calibration factor must be specified for each of these 2901 * differential modes, if used afterwards and if the application 2902 * requires their calibration). 2903 * Calibration of linearity is common to both 2904 * single-ended and differential modes 2905 * (calibration factor can be specified only once). 2906 * @note In case of setting calibration factors of both modes single ended 2907 * and differential (parameter LL_ADC_BOTH_SINGLE_DIFF_ENDED): 2908 * both calibration factors must be concatenated. 2909 * To perform this processing, use helper macro 2910 * @ref __LL_ADC_CALIB_FACTOR_SINGLE_DIFF(). 2911 * @note On this STM32 series, setting of this feature is conditioned to 2912 * ADC state: 2913 * ADC must be enabled, without calibration on going, without conversion 2914 * on going on group regular. 2915 * @rmtoll CALFACT CALFACT_S LL_ADC_SetCalibrationOffsetFactor\n 2916 * CALFACT CALFACT_D LL_ADC_SetCalibrationOffsetFactor 2917 * @param ADCx ADC instance 2918 * @param SingleDiff This parameter can be one of the following values: 2919 * @arg @ref LL_ADC_SINGLE_ENDED 2920 * @arg @ref LL_ADC_DIFFERENTIAL_ENDED 2921 * @arg @ref LL_ADC_BOTH_SINGLE_DIFF_ENDED 2922 * @param CalibrationFactor Value between Min_Data=0x00 and Max_Data=0x7F 2923 * @retval None 2924 */ 2925 __STATIC_INLINE void LL_ADC_SetCalibrationOffsetFactor(ADC_TypeDef *ADCx, uint32_t SingleDiff, uint32_t CalibrationFactor) 2926 { 2927 #if defined(ADC_VER_V5_V90) 2928 MODIFY_REG(ADCx->CALFACT_RES13, 2929 SingleDiff & ADC_SINGLEDIFF_CALIB_FACTOR_MASK, 2930 CalibrationFactor << (((SingleDiff & ADC_SINGLEDIFF_CALIB_F_BIT_D_MASK) >> ADC_SINGLEDIFF_CALIB_F_BIT_D_SHIFT4) & ~(SingleDiff & ADC_CALFACT_CALFACT_S))); 2931 #else 2932 MODIFY_REG(ADCx->CALFACT, 2933 SingleDiff & ADC_SINGLEDIFF_CALIB_FACTOR_MASK, 2934 CalibrationFactor << (((SingleDiff & ADC_SINGLEDIFF_CALIB_F_BIT_D_MASK) >> ADC_SINGLEDIFF_CALIB_F_BIT_D_SHIFT4) & ~(SingleDiff & ADC_CALFACT_CALFACT_S))); 2935 #endif /* ADC_VER_V5_V90 */ 2936 } 2937 2938 /** 2939 * @brief Get ADC calibration factor in the mode single-ended 2940 * or differential (for devices with differential mode available). 2941 * @note Calibration factors are set by hardware after performing 2942 * a calibration run using function @ref LL_ADC_StartCalibration(). 2943 * @note For devices with differential mode available: 2944 * Calibration of offset is specific to each of 2945 * single-ended and differential modes 2946 * Calibration of linearity is common to both 2947 * single-ended and differential modes 2948 * @rmtoll CALFACT CALFACT_S LL_ADC_GetCalibrationOffsetFactor\n 2949 * CALFACT CALFACT_D LL_ADC_GetCalibrationOffsetFactor 2950 * @param ADCx ADC instance 2951 * @param SingleDiff This parameter can be one of the following values: 2952 * @arg @ref LL_ADC_SINGLE_ENDED 2953 * @arg @ref LL_ADC_DIFFERENTIAL_ENDED 2954 * @retval Value between Min_Data=0x00 and Max_Data=0x7F 2955 */ 2956 __STATIC_INLINE uint32_t LL_ADC_GetCalibrationOffsetFactor(ADC_TypeDef *ADCx, uint32_t SingleDiff) 2957 { 2958 /* Retrieve bits with position in register depending on parameter */ 2959 /* "SingleDiff". */ 2960 /* Parameter used with mask "ADC_SINGLEDIFF_CALIB_FACTOR_MASK" because */ 2961 /* containing other bits reserved for other purpose. */ 2962 #if defined(ADC_VER_V5_V90) 2963 return (uint32_t)(READ_BIT(ADCx->CALFACT_RES13, (SingleDiff & ADC_SINGLEDIFF_CALIB_FACTOR_MASK)) >> ((SingleDiff & ADC_SINGLEDIFF_CALIB_F_BIT_D_MASK) >> ADC_SINGLEDIFF_CALIB_F_BIT_D_SHIFT4)); 2964 #else 2965 return (uint32_t)(READ_BIT(ADCx->CALFACT, (SingleDiff & ADC_SINGLEDIFF_CALIB_FACTOR_MASK)) >> ((SingleDiff & ADC_SINGLEDIFF_CALIB_F_BIT_D_MASK) >> ADC_SINGLEDIFF_CALIB_F_BIT_D_SHIFT4)); 2966 #endif /* ADC_VER_V5_V90 */ 2967 } 2968 2969 /** 2970 * @brief Set ADC Linear calibration factor in the mode single-ended. 2971 * @note This function is intended to set linear calibration parameters 2972 * without having to perform a new calibration using 2973 * @ref LL_ADC_StartCalibration(). 2974 * @note On this STM32 series, setting of this feature is conditioned to 2975 * ADC state: 2976 * ADC must be enabled, without calibration on going, without conversion 2977 * on going on group regular. 2978 * @rmtoll CALFACT2 LINCALFACT LL_ADC_SetCalibrationLinearFactor\n 2979 * CALFACT2 LINCALFACT LL_ADC_SetCalibrationLinearFactor 2980 * @param ADCx ADC instance 2981 * @param LinearityWord This parameter can be one of the following values: 2982 * @arg @ref LL_ADC_CALIB_LINEARITY_WORD1 2983 * @arg @ref LL_ADC_CALIB_LINEARITY_WORD2 2984 * @arg @ref LL_ADC_CALIB_LINEARITY_WORD3 2985 * @arg @ref LL_ADC_CALIB_LINEARITY_WORD4 2986 * @arg @ref LL_ADC_CALIB_LINEARITY_WORD5 2987 * @arg @ref LL_ADC_CALIB_LINEARITY_WORD6 2988 * @param CalibrationFactor Value between Min_Data=0x00 and Max_Data=0x3FFFFFFF 2989 * @retval None 2990 */ 2991 __STATIC_INLINE void LL_ADC_SetCalibrationLinearFactor(ADC_TypeDef *ADCx, uint32_t LinearityWord, uint32_t CalibrationFactor) 2992 { 2993 #if defined(ADC_VER_V5_V90) 2994 if (ADCx != ADC3) 2995 { 2996 uint32_t timeout_cpu_cycles = ADC_LINEARITY_BIT_TOGGLE_TIMEOUT; 2997 MODIFY_REG(ADCx->CALFACT2_RES14, ADC_CALFACT2_LINCALFACT, CalibrationFactor); 2998 MODIFY_REG(ADCx->CR, ADC_CR_ADCALLIN, LinearityWord); 2999 while ((READ_BIT(ADCx->CR, LinearityWord) == 0UL) && (timeout_cpu_cycles > 0UL)) 3000 { 3001 timeout_cpu_cycles--; 3002 } 3003 } 3004 #else 3005 uint32_t timeout_cpu_cycles = ADC_LINEARITY_BIT_TOGGLE_TIMEOUT; 3006 MODIFY_REG(ADCx->CALFACT2, ADC_CALFACT2_LINCALFACT, CalibrationFactor); 3007 MODIFY_REG(ADCx->CR, ADC_CR_ADCALLIN, LinearityWord); 3008 while ((READ_BIT(ADCx->CR, LinearityWord) == 0UL) && (timeout_cpu_cycles > 0UL)) 3009 { 3010 timeout_cpu_cycles--; 3011 } 3012 #endif /* ADC_VER_V5_V90 */ 3013 } 3014 3015 /** 3016 * @brief Get ADC Linear calibration factor in the mode single-ended. 3017 * @note Calibration factors are set by hardware after performing 3018 * a calibration run using function @ref LL_ADC_StartCalibration(). 3019 * @rmtoll CALFACT2 LINCALFACT LL_ADC_GetCalibrationLinearFactor\n 3020 * CALFACT2 LINCALFACT LL_ADC_GetCalibrationLinearFactor 3021 * @param ADCx ADC instance 3022 * @param LinearityWord This parameter can be one of the following values: 3023 * @arg @ref LL_ADC_CALIB_LINEARITY_WORD1 3024 * @arg @ref LL_ADC_CALIB_LINEARITY_WORD2 3025 * @arg @ref LL_ADC_CALIB_LINEARITY_WORD3 3026 * @arg @ref LL_ADC_CALIB_LINEARITY_WORD4 3027 * @arg @ref LL_ADC_CALIB_LINEARITY_WORD5 3028 * @arg @ref LL_ADC_CALIB_LINEARITY_WORD6 3029 * @retval Value between Min_Data=0x00 and Max_Data=0x3FFFFFFF 3030 */ 3031 __STATIC_INLINE uint32_t LL_ADC_GetCalibrationLinearFactor(ADC_TypeDef *ADCx, uint32_t LinearityWord) 3032 { 3033 uint32_t timeout_cpu_cycles = ADC_LINEARITY_BIT_TOGGLE_TIMEOUT; 3034 CLEAR_BIT(ADCx->CR, LinearityWord); 3035 while ((READ_BIT(ADCx->CR, LinearityWord) != 0UL) && (timeout_cpu_cycles > 0UL)) 3036 { 3037 timeout_cpu_cycles--; 3038 } 3039 #if defined(ADC_VER_V5_V90) 3040 return (uint32_t)(READ_BIT(ADCx->CALFACT2_RES14, ADC_CALFACT2_LINCALFACT)); 3041 #else 3042 return (uint32_t)(READ_BIT(ADCx->CALFACT2, ADC_CALFACT2_LINCALFACT)); 3043 #endif /* ADC_VER_V5_V90 */ 3044 } 3045 /** 3046 * @brief Set ADC resolution. 3047 * Refer to reference manual for alignments formats 3048 * dependencies to ADC resolutions. 3049 * @note On this STM32 series, setting of this feature is conditioned to 3050 * ADC state: 3051 * ADC must be disabled or enabled without conversion on going 3052 * on either groups regular or injected. 3053 * @rmtoll CFGR RES LL_ADC_SetResolution 3054 * @param ADCx ADC instance 3055 * @param Resolution This parameter can be one of the following values: 3056 * @arg @ref LL_ADC_RESOLUTION_16B 3057 * @arg @ref LL_ADC_RESOLUTION_14B 3058 * @arg @ref LL_ADC_RESOLUTION_12B 3059 * @arg @ref LL_ADC_RESOLUTION_10B 3060 * @arg @ref LL_ADC_RESOLUTION_8B 3061 * @retval None 3062 */ 3063 __STATIC_INLINE void LL_ADC_SetResolution(ADC_TypeDef *ADCx, uint32_t Resolution) 3064 { 3065 #if defined(ADC_VER_V5_3) 3066 3067 MODIFY_REG(ADCx->CFGR, ADC_CFGR_RES, Resolution); 3068 3069 #elif defined(ADC_VER_V5_V90) 3070 if (ADCx == ADC3) 3071 { 3072 MODIFY_REG(ADCx->CFGR, ADC3_CFGR_RES, ((__LL_ADC12_RESOLUTION_TO_ADC3(Resolution) & (ADC_CFGR_RES_1 | ADC_CFGR_RES_0)) << 1UL)); 3073 } 3074 else 3075 { 3076 if ((DBGMCU->IDCODE & 0x30000000UL) == 0x10000000UL) /* Rev.Y */ 3077 { 3078 MODIFY_REG(ADCx->CFGR, ADC_CFGR_RES, Resolution); 3079 } 3080 else /* Rev.V */ 3081 { 3082 if (LL_ADC_RESOLUTION_8B == Resolution) 3083 { 3084 MODIFY_REG(ADCx->CFGR, ADC_CFGR_RES, Resolution | 0x0000000CUL); 3085 } 3086 else 3087 { 3088 MODIFY_REG(ADCx->CFGR, ADC_CFGR_RES, Resolution); 3089 } 3090 } 3091 } 3092 #else /* ADC_VER_V5_V90 */ 3093 if ((DBGMCU->IDCODE & 0x30000000UL) == 0x10000000UL) /* Rev.Y */ 3094 { 3095 MODIFY_REG(ADCx->CFGR, ADC_CFGR_RES, Resolution); 3096 } 3097 else /* Rev.V */ 3098 { 3099 if (LL_ADC_RESOLUTION_8B == Resolution) 3100 { 3101 MODIFY_REG(ADCx->CFGR, ADC_CFGR_RES, Resolution | 0x0000000CUL); 3102 } 3103 else 3104 { 3105 MODIFY_REG(ADCx->CFGR, ADC_CFGR_RES, Resolution); 3106 } 3107 } 3108 3109 #endif /* ADC_VER_V5_X*/ 3110 } 3111 3112 /** 3113 * @brief Get ADC resolution. 3114 * Refer to reference manual for alignments formats 3115 * dependencies to ADC resolutions. 3116 * @rmtoll CFGR RES LL_ADC_GetResolution 3117 * @param ADCx ADC instance 3118 * @retval Returned value can be one of the following values: 3119 * @arg @ref LL_ADC_RESOLUTION_16B (1) 3120 * @arg @ref LL_ADC_RESOLUTION_14B 3121 * @arg @ref LL_ADC_RESOLUTION_12B 3122 * @arg @ref LL_ADC_RESOLUTION_10B 3123 * @arg @ref LL_ADC_RESOLUTION_8B 3124 * @arg @ref LL_ADC_RESOLUTION_6B (2) 3125 * (1): Specific to ADC instance: ADC1, ADC2 3126 * (2): Specific to ADC instance: ADC3 3127 */ 3128 __STATIC_INLINE uint32_t LL_ADC_GetResolution(ADC_TypeDef *ADCx) 3129 { 3130 #if defined (ADC_VER_V5_3) 3131 3132 return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_RES)); 3133 3134 #elif defined(ADC_VER_V5_V90) 3135 if (ADCx == ADC3) 3136 { 3137 return (uint32_t)(READ_BIT(ADCx->CFGR, ADC3_CFGR_RES)); 3138 } 3139 else 3140 { 3141 if ((uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_RES)) == 0x0000001CUL) 3142 { 3143 return (LL_ADC_RESOLUTION_8B); 3144 } 3145 else 3146 { 3147 return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_RES)); 3148 } 3149 } 3150 3151 #else /* ADC_VER_V5_V90 */ 3152 if ((DBGMCU->IDCODE & 0x30000000UL) == 0x10000000UL) /* Rev.Y */ 3153 { 3154 return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_RES)); 3155 } 3156 else /* Rev.V */ 3157 { 3158 if ((uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_RES)) == 0x0000001CUL) 3159 { 3160 return (LL_ADC_RESOLUTION_8B); 3161 } 3162 else 3163 { 3164 return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_RES)); 3165 } 3166 } 3167 3168 #endif /* ADC_VER_V5_X */ 3169 } 3170 3171 /** 3172 * @brief Set ADC low power mode. 3173 * @note Description of ADC low power modes: 3174 * - ADC low power mode "auto wait": Dynamic low power mode, 3175 * ADC conversions occurrences are limited to the minimum necessary 3176 * in order to reduce power consumption. 3177 * New ADC conversion starts only when the previous 3178 * unitary conversion data (for ADC group regular) 3179 * or previous sequence conversions data (for ADC group injected) 3180 * has been retrieved by user software. 3181 * In the meantime, ADC remains idle: does not performs any 3182 * other conversion. 3183 * This mode allows to automatically adapt the ADC conversions 3184 * triggers to the speed of the software that reads the data. 3185 * Moreover, this avoids risk of overrun for low frequency 3186 * applications. 3187 * How to use this low power mode: 3188 * - It is not recommended to use with interruption or DMA 3189 * since these modes have to clear immediately the EOC flag 3190 * (by CPU to free the IRQ pending event or by DMA). 3191 * Auto wait will work but fort a very short time, discarding 3192 * its intended benefit (except specific case of high load of CPU 3193 * or DMA transfers which can justify usage of auto wait). 3194 * - Do use with polling: 1. Start conversion, 3195 * 2. Later on, when conversion data is needed: poll for end of 3196 * conversion to ensure that conversion is completed and 3197 * retrieve ADC conversion data. This will trig another 3198 * ADC conversion start. 3199 * - ADC low power mode "auto power-off" (feature available on 3200 * this device if parameter LL_ADC_LP_AUTOPOWEROFF is available): 3201 * the ADC automatically powers-off after a conversion and 3202 * automatically wakes up when a new conversion is triggered 3203 * (with startup time between trigger and start of sampling). 3204 * This feature can be combined with low power mode "auto wait". 3205 * @note With ADC low power mode "auto wait", the ADC conversion data read 3206 * is corresponding to previous ADC conversion start, independently 3207 * of delay during which ADC was idle. 3208 * Therefore, the ADC conversion data may be outdated: does not 3209 * correspond to the current voltage level on the selected 3210 * ADC channel. 3211 * @note On this STM32 series, setting of this feature is conditioned to 3212 * ADC state: 3213 * ADC must be disabled or enabled without conversion on going 3214 * on either groups regular or injected. 3215 * @rmtoll CFGR AUTDLY LL_ADC_SetLowPowerMode 3216 * @param ADCx ADC instance 3217 * @param LowPowerMode This parameter can be one of the following values: 3218 * @arg @ref LL_ADC_LP_MODE_NONE 3219 * @arg @ref LL_ADC_LP_AUTOWAIT 3220 * @retval None 3221 */ 3222 __STATIC_INLINE void LL_ADC_SetLowPowerMode(ADC_TypeDef *ADCx, uint32_t LowPowerMode) 3223 { 3224 MODIFY_REG(ADCx->CFGR, ADC_CFGR_AUTDLY, LowPowerMode); 3225 } 3226 3227 /** 3228 * @brief Get ADC low power mode: 3229 * @note Description of ADC low power modes: 3230 * - ADC low power mode "auto wait": Dynamic low power mode, 3231 * ADC conversions occurrences are limited to the minimum necessary 3232 * in order to reduce power consumption. 3233 * New ADC conversion starts only when the previous 3234 * unitary conversion data (for ADC group regular) 3235 * or previous sequence conversions data (for ADC group injected) 3236 * has been retrieved by user software. 3237 * In the meantime, ADC remains idle: does not performs any 3238 * other conversion. 3239 * This mode allows to automatically adapt the ADC conversions 3240 * triggers to the speed of the software that reads the data. 3241 * Moreover, this avoids risk of overrun for low frequency 3242 * applications. 3243 * How to use this low power mode: 3244 * - It is not recommended to use with interruption or DMA 3245 * since these modes have to clear immediately the EOC flag 3246 * (by CPU to free the IRQ pending event or by DMA). 3247 * Auto wait will work but fort a very short time, discarding 3248 * its intended benefit (except specific case of high load of CPU 3249 * or DMA transfers which can justify usage of auto wait). 3250 * - Do use with polling: 1. Start conversion, 3251 * 2. Later on, when conversion data is needed: poll for end of 3252 * conversion to ensure that conversion is completed and 3253 * retrieve ADC conversion data. This will trig another 3254 * ADC conversion start. 3255 * - ADC low power mode "auto power-off" (feature available on 3256 * this device if parameter LL_ADC_LP_AUTOPOWEROFF is available): 3257 * the ADC automatically powers-off after a conversion and 3258 * automatically wakes up when a new conversion is triggered 3259 * (with startup time between trigger and start of sampling). 3260 * This feature can be combined with low power mode "auto wait". 3261 * @note With ADC low power mode "auto wait", the ADC conversion data read 3262 * is corresponding to previous ADC conversion start, independently 3263 * of delay during which ADC was idle. 3264 * Therefore, the ADC conversion data may be outdated: does not 3265 * correspond to the current voltage level on the selected 3266 * ADC channel. 3267 * @rmtoll CFGR AUTDLY LL_ADC_GetLowPowerMode 3268 * @param ADCx ADC instance 3269 * @retval Returned value can be one of the following values: 3270 * @arg @ref LL_ADC_LP_MODE_NONE 3271 * @arg @ref LL_ADC_LP_AUTOWAIT 3272 */ 3273 __STATIC_INLINE uint32_t LL_ADC_GetLowPowerMode(ADC_TypeDef *ADCx) 3274 { 3275 return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_AUTDLY)); 3276 } 3277 3278 /** 3279 * @brief Set ADC selected Channel. 3280 * @note This function set the pre-selection of channel configuration. 3281 * @note Caution: Channel selections is dependent to ADC instance and IP version: 3282 * For STM32H72x/3x This is applicable only for ADC1/ADC2 3283 * For Rest of STM32H7xxx This is applicable only all the ADCs instances. 3284 * 3285 * @param ADCx ADC instance 3286 * @param Channel This parameter can be one of the following values: 3287 * @arg @ref LL_ADC_CHANNEL_0 3288 * @arg @ref LL_ADC_CHANNEL_1 3289 * @arg @ref LL_ADC_CHANNEL_2 3290 * @arg @ref LL_ADC_CHANNEL_3 3291 * @arg @ref LL_ADC_CHANNEL_4 3292 * @arg @ref LL_ADC_CHANNEL_5 3293 * @arg @ref LL_ADC_CHANNEL_6 3294 * @arg @ref LL_ADC_CHANNEL_7 3295 * @arg @ref LL_ADC_CHANNEL_8 3296 * @arg @ref LL_ADC_CHANNEL_9 3297 * @arg @ref LL_ADC_CHANNEL_10 3298 * @arg @ref LL_ADC_CHANNEL_11 3299 * @arg @ref LL_ADC_CHANNEL_12 3300 * @arg @ref LL_ADC_CHANNEL_13 3301 * @arg @ref LL_ADC_CHANNEL_14 3302 * @arg @ref LL_ADC_CHANNEL_15 3303 * @arg @ref LL_ADC_CHANNEL_16 3304 * @arg @ref LL_ADC_CHANNEL_17 3305 * @arg @ref LL_ADC_CHANNEL_18 3306 * @arg @ref LL_ADC_CHANNEL_19 3307 * @retval None 3308 */ 3309 __STATIC_INLINE void LL_ADC_SetChannelPreselection(ADC_TypeDef *ADCx, uint32_t Channel) 3310 { 3311 #if defined(ADC_VER_V5_V90) 3312 if (ADCx != ADC3) 3313 { 3314 /* ADC channels preselection */ 3315 ADCx->PCSEL_RES0 |= (1UL << (__LL_ADC_CHANNEL_TO_DECIMAL_NB(Channel) & 0x1FUL)); 3316 } 3317 #else 3318 /* ADC channels preselection */ 3319 ADCx->PCSEL |= (1UL << (__LL_ADC_CHANNEL_TO_DECIMAL_NB(Channel) & 0x1FUL)); 3320 #endif /* ADC_VER_V5_V90 */ 3321 } 3322 3323 /** 3324 * @brief Gets ADC pre-selected Channel. 3325 * @note This function gets the pre-selected ADC channel. 3326 * @note Caution: Channel selections is dependent to ADC instance and IP version: 3327 * For STM32H72x/3x This is applicable only for ADC1/ADC2 3328 * For Rest of STM32H7xxx This is applicable on all the ADCs instances. 3329 * 3330 * @param ADCx ADC instance 3331 * @param Channel This parameter can be one of the following values: 3332 * @arg @ref LL_ADC_CHANNEL_0 3333 * @arg @ref LL_ADC_CHANNEL_1 3334 * @arg @ref LL_ADC_CHANNEL_2 3335 * @arg @ref LL_ADC_CHANNEL_3 3336 * @arg @ref LL_ADC_CHANNEL_4 3337 * @arg @ref LL_ADC_CHANNEL_5 3338 * @arg @ref LL_ADC_CHANNEL_6 3339 * @arg @ref LL_ADC_CHANNEL_7 3340 * @arg @ref LL_ADC_CHANNEL_8 3341 * @arg @ref LL_ADC_CHANNEL_9 3342 * @arg @ref LL_ADC_CHANNEL_10 3343 * @arg @ref LL_ADC_CHANNEL_11 3344 * @arg @ref LL_ADC_CHANNEL_12 3345 * @arg @ref LL_ADC_CHANNEL_13 3346 * @arg @ref LL_ADC_CHANNEL_14 3347 * @arg @ref LL_ADC_CHANNEL_15 3348 * @arg @ref LL_ADC_CHANNEL_16 3349 * @arg @ref LL_ADC_CHANNEL_17 3350 * @arg @ref LL_ADC_CHANNEL_18 3351 * @arg @ref LL_ADC_CHANNEL_19 3352 * @retval the preselection state of Channel (!= 0 : pre-selected, == 0 : not pre-selected) 3353 */ 3354 __STATIC_INLINE uint32_t LL_ADC_GetChannelPreselection(ADC_TypeDef *ADCx, uint32_t Channel) 3355 { 3356 #if defined(ADC_VER_V5_V90) 3357 if (ADCx != ADC3) 3358 { 3359 /* Gets preselected ADC channel */ 3360 return (uint32_t)(READ_BIT(ADCx->PCSEL_RES0, 1UL << (__LL_ADC_CHANNEL_TO_DECIMAL_NB(Channel) & 0x1FUL))); 3361 } 3362 else 3363 { 3364 return 0UL; 3365 } 3366 #else 3367 /* Gets preselected ADC channel */ 3368 return (uint32_t)(READ_BIT(ADCx->PCSEL, 1UL << (__LL_ADC_CHANNEL_TO_DECIMAL_NB(Channel) & 0x1FUL))); 3369 #endif /* ADC_VER_V5_V90 */ 3370 } 3371 3372 /** 3373 * @brief Set ADC selected offset number 1, 2, 3 or 4. 3374 * @note This function set the 2 items of offset configuration: 3375 * - ADC channel to which the offset programmed will be applied 3376 * (independently of channel mapped on ADC group regular 3377 * or group injected) 3378 * - Offset level (offset to be subtracted from the raw 3379 * converted data). 3380 * @note Caution: Offset format is dependent to ADC resolution: 3381 * offset has to be left-aligned on bit 15 (handling maximum ADC resolution 16 bit), 3382 * the LSB (right bits) are set to 0. 3383 * @note This function enables the offset, by default. It can be forced 3384 * to disable state using function LL_ADC_SetOffsetState(). 3385 * @note If a channel is mapped on several offsets numbers, only the offset 3386 * with the lowest value is considered for the subtraction. 3387 * @note On this STM32 series, setting of this feature is conditioned to 3388 * ADC state: 3389 * ADC must be disabled or enabled without conversion on going 3390 * on either groups regular or injected. 3391 * @note On STM32H7, some fast channels are available: fast analog inputs 3392 * coming from GPIO pads (ADC_IN0..5). 3393 * @rmtoll OFR1 OFFSET1_CH LL_ADC_SetOffset\n 3394 * OFR1 OFFSET1 LL_ADC_SetOffset\n 3395 * OFR1 OFFSET1_EN LL_ADC_SetOffset\n 3396 * OFR2 OFFSET2_CH LL_ADC_SetOffset\n 3397 * OFR2 OFFSET2 LL_ADC_SetOffset\n 3398 * OFR2 OFFSET2_EN LL_ADC_SetOffset\n 3399 * OFR3 OFFSET3_CH LL_ADC_SetOffset\n 3400 * OFR3 OFFSET3 LL_ADC_SetOffset\n 3401 * OFR3 OFFSET3_EN LL_ADC_SetOffset\n 3402 * OFR4 OFFSET4_CH LL_ADC_SetOffset\n 3403 * OFR4 OFFSET4 LL_ADC_SetOffset\n 3404 * OFR4 OFFSET4_EN LL_ADC_SetOffset 3405 * @param ADCx ADC instance 3406 * @param Offsety This parameter can be one of the following values: 3407 * @arg @ref LL_ADC_OFFSET_1 3408 * @arg @ref LL_ADC_OFFSET_2 3409 * @arg @ref LL_ADC_OFFSET_3 3410 * @arg @ref LL_ADC_OFFSET_4 3411 * @param Channel This parameter can be one of the following values: 3412 * @arg @ref LL_ADC_CHANNEL_0 (3) 3413 * @arg @ref LL_ADC_CHANNEL_1 (3) 3414 * @arg @ref LL_ADC_CHANNEL_2 (3) 3415 * @arg @ref LL_ADC_CHANNEL_3 (3) 3416 * @arg @ref LL_ADC_CHANNEL_4 (3) 3417 * @arg @ref LL_ADC_CHANNEL_5 (3) 3418 * @arg @ref LL_ADC_CHANNEL_6 3419 * @arg @ref LL_ADC_CHANNEL_7 3420 * @arg @ref LL_ADC_CHANNEL_8 3421 * @arg @ref LL_ADC_CHANNEL_9 3422 * @arg @ref LL_ADC_CHANNEL_10 3423 * @arg @ref LL_ADC_CHANNEL_11 3424 * @arg @ref LL_ADC_CHANNEL_12 3425 * @arg @ref LL_ADC_CHANNEL_13 3426 * @arg @ref LL_ADC_CHANNEL_14 3427 * @arg @ref LL_ADC_CHANNEL_15 3428 * @arg @ref LL_ADC_CHANNEL_16 3429 * @arg @ref LL_ADC_CHANNEL_17 3430 * @arg @ref LL_ADC_CHANNEL_18 3431 * @arg @ref LL_ADC_CHANNEL_19 3432 * @arg @ref LL_ADC_CHANNEL_VREFINT (1) 3433 * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1) 3434 * @arg @ref LL_ADC_CHANNEL_VBAT (1) 3435 * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC2 (2) 3436 * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC2 (2) 3437 * 3438 * (1) On STM32H7, parameter available only on ADC instance: ADC3.\n 3439 * (2) On STM32H7, parameter available only on ADC instance: ADC2.\n 3440 * (3) On STM32H7, fast channel (0.125 us for 14-bit resolution (ADC conversion rate up to 8 Ms/s)). 3441 * Other channels are slow channels (conversion rate: refer to reference manual). 3442 * @param OffsetLevel Value between Min_Data=0x000 and Max_Data=0x3FFFFFF 3443 * @retval None 3444 */ 3445 __STATIC_INLINE void LL_ADC_SetOffset(ADC_TypeDef *ADCx, uint32_t Offsety, uint32_t Channel, uint32_t OffsetLevel) 3446 { 3447 __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->OFR1, Offsety); 3448 #if defined(ADC_VER_V5_V90) 3449 if (ADCx == ADC3) 3450 { 3451 MODIFY_REG(*preg, 3452 ADC3_OFR1_OFFSET1_EN | ADC_OFR1_OFFSET1_CH | ADC_OFR1_OFFSET1, 3453 ADC3_OFR1_OFFSET1_EN | (Channel & ADC_CHANNEL_ID_NUMBER_MASK) | OffsetLevel); 3454 } 3455 else 3456 #endif /* ADC_VER_V5_V90 */ 3457 { 3458 MODIFY_REG(*preg, 3459 ADC_OFR1_OFFSET1_CH | ADC_OFR1_OFFSET1, 3460 (Channel & ADC_CHANNEL_ID_NUMBER_MASK) | OffsetLevel); 3461 } 3462 } 3463 3464 /** 3465 * @brief Get for the ADC selected offset number 1, 2, 3 or 4: 3466 * Channel to which the offset programmed will be applied 3467 * (independently of channel mapped on ADC group regular 3468 * or group injected) 3469 * @note Usage of the returned channel number: 3470 * - To reinject this channel into another function LL_ADC_xxx: 3471 * the returned channel number is only partly formatted on definition 3472 * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared 3473 * with parts of literals LL_ADC_CHANNEL_x or using 3474 * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB(). 3475 * Then the selected literal LL_ADC_CHANNEL_x can be used 3476 * as parameter for another function. 3477 * - To get the channel number in decimal format: 3478 * process the returned value with the helper macro 3479 * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB(). 3480 * @note On STM32H7, some fast channels are available: fast analog inputs 3481 * coming from GPIO pads (ADC_IN0..5). 3482 * @rmtoll OFR1 OFFSET1_CH LL_ADC_GetOffsetChannel\n 3483 * OFR2 OFFSET2_CH LL_ADC_GetOffsetChannel\n 3484 * OFR3 OFFSET3_CH LL_ADC_GetOffsetChannel\n 3485 * OFR4 OFFSET4_CH LL_ADC_GetOffsetChannel 3486 * @param ADCx ADC instance 3487 * @param Offsety This parameter can be one of the following values: 3488 * @arg @ref LL_ADC_OFFSET_1 3489 * @arg @ref LL_ADC_OFFSET_2 3490 * @arg @ref LL_ADC_OFFSET_3 3491 * @arg @ref LL_ADC_OFFSET_4 3492 * @retval Returned value can be one of the following values: 3493 * @arg @ref LL_ADC_CHANNEL_0 (3) 3494 * @arg @ref LL_ADC_CHANNEL_1 (3) 3495 * @arg @ref LL_ADC_CHANNEL_2 (3) 3496 * @arg @ref LL_ADC_CHANNEL_3 (3) 3497 * @arg @ref LL_ADC_CHANNEL_4 (3) 3498 * @arg @ref LL_ADC_CHANNEL_5 (3) 3499 * @arg @ref LL_ADC_CHANNEL_6 3500 * @arg @ref LL_ADC_CHANNEL_7 3501 * @arg @ref LL_ADC_CHANNEL_8 3502 * @arg @ref LL_ADC_CHANNEL_9 3503 * @arg @ref LL_ADC_CHANNEL_10 3504 * @arg @ref LL_ADC_CHANNEL_11 3505 * @arg @ref LL_ADC_CHANNEL_12 3506 * @arg @ref LL_ADC_CHANNEL_13 3507 * @arg @ref LL_ADC_CHANNEL_14 3508 * @arg @ref LL_ADC_CHANNEL_15 3509 * @arg @ref LL_ADC_CHANNEL_16 3510 * @arg @ref LL_ADC_CHANNEL_17 3511 * @arg @ref LL_ADC_CHANNEL_18 3512 * @arg @ref LL_ADC_CHANNEL_19 3513 * @arg @ref LL_ADC_CHANNEL_VREFINT (1) 3514 * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1) 3515 * @arg @ref LL_ADC_CHANNEL_VBAT (1) 3516 * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC2 (2) 3517 * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC2 (2) 3518 * 3519 * (1) On STM32H7, parameter available only on ADC instance: ADC3.\n 3520 * (2) On STM32H7, parameter available only on ADC instance: ADC2.\n 3521 * (3) On STM32H7, fast channel (0.125 us for 14-bit resolution (ADC conversion rate up to 8 Ms/s)). 3522 * Other channels are slow channels (conversion rate: refer to reference manual).\n 3523 * (1, 2) For ADC channel read back from ADC register, 3524 * comparison with internal channel parameter to be done 3525 * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL(). 3526 */ 3527 __STATIC_INLINE uint32_t LL_ADC_GetOffsetChannel(ADC_TypeDef *ADCx, uint32_t Offsety) 3528 { 3529 const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->OFR1, Offsety); 3530 3531 return (uint32_t) READ_BIT(*preg, ADC_OFR1_OFFSET1_CH); 3532 } 3533 3534 /** 3535 * @brief Get for the ADC selected offset number 1, 2, 3 or 4: 3536 * Offset level (offset to be subtracted from the raw 3537 * converted data). 3538 * @note Caution: Offset format is dependent to ADC resolution: 3539 * offset has to be left-aligned on bit 15 (handling maximum ADC resolution 16 bit), 3540 * the LSB (right bits) are set to 0. 3541 * @rmtoll OFR1 OFFSET1 LL_ADC_GetOffsetLevel\n 3542 * OFR2 OFFSET2 LL_ADC_GetOffsetLevel\n 3543 * OFR3 OFFSET3 LL_ADC_GetOffsetLevel\n 3544 * OFR4 OFFSET4 LL_ADC_GetOffsetLevel 3545 * @param ADCx ADC instance 3546 * @param Offsety This parameter can be one of the following values: 3547 * @arg @ref LL_ADC_OFFSET_1 3548 * @arg @ref LL_ADC_OFFSET_2 3549 * @arg @ref LL_ADC_OFFSET_3 3550 * @arg @ref LL_ADC_OFFSET_4 3551 * @retval Value between Min_Data=0x000 and Max_Data=0x3FFFFFF 3552 */ 3553 __STATIC_INLINE uint32_t LL_ADC_GetOffsetLevel(ADC_TypeDef *ADCx, uint32_t Offsety) 3554 { 3555 const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->OFR1, Offsety); 3556 3557 return (uint32_t) READ_BIT(*preg, ADC_OFR1_OFFSET1); 3558 } 3559 3560 3561 /** 3562 * @brief Set data right shift for the ADC selected offset number 1, 2, 3 or 4: 3563 * signed offset saturation if enabled or disabled. 3564 * @rmtoll CFGR2 RSHIFT LL_ADC_SetDataRightShift\n 3565 * @param ADCx ADC instance 3566 * @param Offsety This parameter can be one of the following values: 3567 * @arg @ref LL_ADC_OFFSET_1 3568 * @arg @ref LL_ADC_OFFSET_2 3569 * @arg @ref LL_ADC_OFFSET_3 3570 * @arg @ref LL_ADC_OFFSET_4 3571 * @param RigthShift This parameter can be one of the following values: 3572 * @arg @ref LL_ADC_OFFSET_RSHIFT_ENABLE 3573 * @arg @ref LL_ADC_OFFSET_RSHIFT_DISABLE 3574 * @retval Returned None 3575 */ 3576 __STATIC_INLINE void LL_ADC_SetDataRightShift(ADC_TypeDef *ADCx, uint32_t Offsety, uint32_t RigthShift) 3577 { 3578 MODIFY_REG(ADCx->CFGR2, (ADC_CFGR2_RSHIFT1 | ADC_CFGR2_RSHIFT2 | ADC_CFGR2_RSHIFT3 | ADC_CFGR2_RSHIFT4), RigthShift << (Offsety & 0x1FUL)); 3579 } 3580 3581 /** 3582 * @brief Get data right shift for the ADC selected offset number 1, 2, 3 or 4: 3583 * signed offset saturation if enabled or disabled. 3584 * @rmtoll CFGR2 RSHIFT LL_ADC_GetDataRightShift\n 3585 * @param ADCx ADC instance 3586 * @param Offsety This parameter can be one of the following values: 3587 * @arg @ref LL_ADC_OFFSET_1 3588 * @arg @ref LL_ADC_OFFSET_2 3589 * @arg @ref LL_ADC_OFFSET_3 3590 * @arg @ref LL_ADC_OFFSET_4 3591 * @retval Returned value can be one of the following values: 3592 * @arg @ref LL_ADC_OFFSET_RSHIFT_ENABLE 3593 * @arg @ref LL_ADC_OFFSET_RSHIFT_DISABLE 3594 */ 3595 __STATIC_INLINE uint32_t LL_ADC_GetDataRightShift(ADC_TypeDef *ADCx, uint32_t Offsety) 3596 { 3597 return (uint32_t)((READ_BIT(ADCx->CFGR2, (ADC_CFGR2_RSHIFT1 << (Offsety & 0x1FUL)))) >> (Offsety & 0x1FUL)); 3598 } 3599 3600 /** 3601 * @brief Set signed saturation for the ADC selected offset number 1, 2, 3 or 4: 3602 * signed offset saturation if enabled or disabled. 3603 * @rmtoll OFR1 SSATE LL_ADC_SetOffsetSignedSaturation\n 3604 * OFR2 SSATE LL_ADC_SetOffsetSignedSaturation\n 3605 * OFR3 SSATE LL_ADC_SetOffsetSignedSaturation\n 3606 * OFR4 SSATE LL_ADC_SetOffsetSignedSaturation 3607 * @param ADCx ADC instance 3608 * @param Offsety This parameter can be one of the following values: 3609 * @arg @ref LL_ADC_OFFSET_1 3610 * @arg @ref LL_ADC_OFFSET_2 3611 * @arg @ref LL_ADC_OFFSET_3 3612 * @arg @ref LL_ADC_OFFSET_4 3613 * @param OffsetSignedSaturation This parameter can be one of the following values: 3614 * @arg @ref LL_ADC_OFFSET_SIGNED_SATURATION_ENABLE 3615 * @arg @ref LL_ADC_OFFSET_SIGNED_SATURATION_DISABLE 3616 * @retval Returned None 3617 */ 3618 __STATIC_INLINE void LL_ADC_SetOffsetSignedSaturation(ADC_TypeDef *ADCx, uint32_t Offsety, uint32_t OffsetSignedSaturation) 3619 { 3620 #if defined(ADC_VER_V5_V90) 3621 if (ADCx == ADC3) 3622 { 3623 /* Function not available on this instance */ 3624 } 3625 else 3626 #endif /* ADC_VER_V5_V90 */ 3627 { 3628 __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->OFR1, Offsety); 3629 MODIFY_REG(*preg, ADC_OFR1_SSATE, OffsetSignedSaturation); 3630 } 3631 } 3632 3633 /** 3634 * @brief Get signed saturation for the ADC selected offset number 1, 2, 3 or 4: 3635 * signed offset saturation if enabled or disabled. 3636 * @rmtoll OFR1 SSATE LL_ADC_GetOffsetSignedSaturation\n 3637 * OFR2 SSATE LL_ADC_GetOffsetSignedSaturation\n 3638 * OFR3 SSATE LL_ADC_GetOffsetSignedSaturation\n 3639 * OFR4 SSATE LL_ADC_GetOffsetSignedSaturation 3640 * @param ADCx ADC instance 3641 * @param Offsety This parameter can be one of the following values: 3642 * @arg @ref LL_ADC_OFFSET_1 3643 * @arg @ref LL_ADC_OFFSET_2 3644 * @arg @ref LL_ADC_OFFSET_3 3645 * @arg @ref LL_ADC_OFFSET_4 3646 * @retval Returned value can be one of the following values: 3647 * @arg @ref LL_ADC_OFFSET_SIGNED_SATURATION_ENABLE 3648 * @arg @ref LL_ADC_OFFSET_SIGNED_SATURATION_DISABLE 3649 */ 3650 __STATIC_INLINE uint32_t LL_ADC_GetOffsetSignedSaturation(ADC_TypeDef *ADCx, uint32_t Offsety) 3651 { 3652 #if defined(ADC_VER_V5_V90) 3653 if (ADCx == ADC3) 3654 { 3655 /* Function not available on this instance */ 3656 return 0UL; 3657 } 3658 else 3659 #endif /* ADC_VER_V5_V90 */ 3660 { 3661 const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->OFR1, Offsety); 3662 return (uint32_t) READ_BIT(*preg, ADC_OFR1_SSATE); 3663 } 3664 } 3665 3666 #if defined(ADC_VER_V5_V90) 3667 /** 3668 * @brief Set for the ADC selected offset number 1, 2, 3 or 4: 3669 * choose offset saturation mode. 3670 * @note On this STM32 series, setting of this feature is conditioned to 3671 * ADC state: 3672 * ADC must be disabled or enabled without conversion on going 3673 * on either groups regular or injected. 3674 * @rmtoll OFR1 SATEN LL_ADC_SetOffsetSaturation\n 3675 * OFR2 SATEN LL_ADC_SetOffsetSaturation\n 3676 * OFR3 SATEN LL_ADC_SetOffsetSaturation\n 3677 * OFR4 SATEN LL_ADC_SetOffsetSaturation 3678 * @param ADCx ADC instance 3679 * @param Offsety This parameter can be one of the following values: 3680 * @arg @ref LL_ADC_OFFSET_1 3681 * @arg @ref LL_ADC_OFFSET_2 3682 * @arg @ref LL_ADC_OFFSET_3 3683 * @arg @ref LL_ADC_OFFSET_4 3684 * @param OffsetSaturation This parameter can be one of the following values: 3685 * @arg @ref LL_ADC_OFFSET_SATURATION_ENABLE 3686 * @arg @ref LL_ADC_OFFSET_SATURATION_DISABLE 3687 * @retval None 3688 */ 3689 __STATIC_INLINE void LL_ADC_SetOffsetSaturation(ADC_TypeDef *ADCx, uint32_t Offsety, uint32_t OffsetSaturation) 3690 { 3691 if (ADCx == ADC3) 3692 { 3693 __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->OFR1, Offsety); 3694 3695 MODIFY_REG(*preg, 3696 ADC3_OFR1_SATEN, 3697 OffsetSaturation); 3698 } 3699 } 3700 3701 /** 3702 * @brief Get for the ADC selected offset number 1, 2, 3 or 4: 3703 * offset saturation if enabled or disabled. 3704 * @rmtoll OFR1 SATEN LL_ADC_GetOffsetSaturation\n 3705 * OFR2 SATEN LL_ADC_GetOffsetSaturation\n 3706 * OFR3 SATEN LL_ADC_GetOffsetSaturation\n 3707 * OFR4 SATEN LL_ADC_GetOffsetSaturation 3708 * @param ADCx ADC instance 3709 * @param Offsety This parameter can be one of the following values: 3710 * @arg @ref LL_ADC_OFFSET_1 3711 * @arg @ref LL_ADC_OFFSET_2 3712 * @arg @ref LL_ADC_OFFSET_3 3713 * @arg @ref LL_ADC_OFFSET_4 3714 * @retval Returned value can be one of the following values: 3715 * @arg @ref LL_ADC_OFFSET_SATURATION_ENABLE 3716 * @arg @ref LL_ADC_OFFSET_SATURATION_DISABLE 3717 */ 3718 __STATIC_INLINE uint32_t LL_ADC_GetOffsetSaturation(ADC_TypeDef *ADCx, uint32_t Offsety) 3719 { 3720 if (ADCx == ADC3) 3721 { 3722 const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->OFR1, Offsety); 3723 3724 return (uint32_t) READ_BIT(*preg, ADC3_OFR1_SATEN); 3725 }else 3726 { 3727 return 0UL; 3728 } 3729 } 3730 3731 /** 3732 * @brief Set for the ADC selected offset number 1, 2, 3 or 4: 3733 * choose offset sign. 3734 * @note On this STM32 series, setting of this feature is conditioned to 3735 * ADC state: 3736 * ADC must be disabled or enabled without conversion on going 3737 * on either groups regular or injected. 3738 * @rmtoll OFR1 OFFSETPOS LL_ADC_SetOffsetSign\n 3739 * OFR2 OFFSETPOS LL_ADC_SetOffsetSign\n 3740 * OFR3 OFFSETPOS LL_ADC_SetOffsetSign\n 3741 * OFR4 OFFSETPOS LL_ADC_SetOffsetSign 3742 * @param ADCx ADC instance 3743 * @param Offsety This parameter can be one of the following values: 3744 * @arg @ref LL_ADC_OFFSET_1 3745 * @arg @ref LL_ADC_OFFSET_2 3746 * @arg @ref LL_ADC_OFFSET_3 3747 * @arg @ref LL_ADC_OFFSET_4 3748 * @param OffsetSign This parameter can be one of the following values: 3749 * @arg @ref LL_ADC_OFFSET_SIGN_NEGATIVE 3750 * @arg @ref LL_ADC_OFFSET_SIGN_POSITIVE 3751 * @retval None 3752 */ 3753 __STATIC_INLINE void LL_ADC_SetOffsetSign(ADC_TypeDef *ADCx, uint32_t Offsety, uint32_t OffsetSign) 3754 { 3755 if (ADCx == ADC3) 3756 { 3757 __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->OFR1, Offsety); 3758 3759 MODIFY_REG(*preg, 3760 ADC3_OFR1_OFFSETPOS, 3761 OffsetSign); 3762 } 3763 } 3764 3765 /** 3766 * @brief Get for the ADC selected offset number 1, 2, 3 or 4: 3767 * offset sign if positive or negative. 3768 * @rmtoll OFR1 OFFSETPOS LL_ADC_GetOffsetSign\n 3769 * OFR2 OFFSETPOS LL_ADC_GetOffsetSign\n 3770 * OFR3 OFFSETPOS LL_ADC_GetOffsetSign\n 3771 * OFR4 OFFSETPOS LL_ADC_GetOffsetSign 3772 * @param ADCx ADC instance 3773 * @param Offsety This parameter can be one of the following values: 3774 * @arg @ref LL_ADC_OFFSET_1 3775 * @arg @ref LL_ADC_OFFSET_2 3776 * @arg @ref LL_ADC_OFFSET_3 3777 * @arg @ref LL_ADC_OFFSET_4 3778 * @retval Returned value can be one of the following values: 3779 * @arg @ref LL_ADC_OFFSET_SIGN_NEGATIVE 3780 * @arg @ref LL_ADC_OFFSET_SIGN_POSITIVE 3781 */ 3782 __STATIC_INLINE uint32_t LL_ADC_GetOffsetSign(ADC_TypeDef *ADCx, uint32_t Offsety) 3783 { 3784 if (ADCx == ADC3) 3785 { 3786 const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->OFR1, Offsety); 3787 3788 return (uint32_t) READ_BIT(*preg, ADC3_OFR1_OFFSETPOS); 3789 } 3790 else 3791 { 3792 return 0UL; 3793 } 3794 } 3795 3796 /** 3797 * @brief Set for the ADC selected offset number 1, 2, 3 or 4: 3798 * force offset state disable or enable 3799 * without modifying offset channel or offset value. 3800 * @note This function should be needed only in case of offset to be 3801 * enabled-disabled dynamically, and should not be needed in other cases: 3802 * function LL_ADC_SetOffset() automatically enables the offset. 3803 * @note On this STM32 series, setting of this feature is conditioned to 3804 * ADC state: 3805 * ADC must be disabled or enabled without conversion on going 3806 * on either groups regular or injected. 3807 * @rmtoll OFR1 OFFSET1_EN LL_ADC_SetOffsetState\n 3808 * OFR2 OFFSET2_EN LL_ADC_SetOffsetState\n 3809 * OFR3 OFFSET3_EN LL_ADC_SetOffsetState\n 3810 * OFR4 OFFSET4_EN LL_ADC_SetOffsetState 3811 * @param ADCx ADC instance 3812 * @param Offsety This parameter can be one of the following values: 3813 * @arg @ref LL_ADC_OFFSET_1 3814 * @arg @ref LL_ADC_OFFSET_2 3815 * @arg @ref LL_ADC_OFFSET_3 3816 * @arg @ref LL_ADC_OFFSET_4 3817 * @param OffsetState This parameter can be one of the following values: 3818 * @arg @ref LL_ADC_OFFSET_DISABLE 3819 * @arg @ref LL_ADC_OFFSET_ENABLE 3820 * @retval None 3821 */ 3822 __STATIC_INLINE void LL_ADC_SetOffsetState(ADC_TypeDef *ADCx, uint32_t Offsety, uint32_t OffsetState) 3823 { 3824 __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->OFR1, Offsety); 3825 if (ADCx == ADC3) 3826 { 3827 MODIFY_REG(*preg, 3828 ADC3_OFR1_OFFSET1_EN, 3829 OffsetState); 3830 } 3831 else 3832 { 3833 MODIFY_REG(*preg, 3834 ADC_OFR1_SSATE, 3835 OffsetState); 3836 } 3837 } 3838 3839 /** 3840 * @brief Get for the ADC selected offset number 1, 2, 3 or 4: 3841 * offset state disabled or enabled. 3842 * @rmtoll OFR1 OFFSET1_EN LL_ADC_GetOffsetState\n 3843 * OFR2 OFFSET2_EN LL_ADC_GetOffsetState\n 3844 * OFR3 OFFSET3_EN LL_ADC_GetOffsetState\n 3845 * OFR4 OFFSET4_EN LL_ADC_GetOffsetState 3846 * @param ADCx ADC instance 3847 * @param Offsety This parameter can be one of the following values: 3848 * @arg @ref LL_ADC_OFFSET_1 3849 * @arg @ref LL_ADC_OFFSET_2 3850 * @arg @ref LL_ADC_OFFSET_3 3851 * @arg @ref LL_ADC_OFFSET_4 3852 * @retval Returned value can be one of the following values: 3853 * @arg @ref LL_ADC_OFFSET_DISABLE 3854 * @arg @ref LL_ADC_OFFSET_ENABLE 3855 */ 3856 __STATIC_INLINE uint32_t LL_ADC_GetOffsetState(ADC_TypeDef *ADCx, uint32_t Offsety) 3857 { 3858 const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->OFR1, Offsety); 3859 if (ADCx == ADC3) 3860 { 3861 return (uint32_t) READ_BIT(*preg, ADC3_OFR1_OFFSET1_EN); 3862 } 3863 else 3864 { 3865 return (uint32_t) READ_BIT(*preg, ADC_OFR1_SSATE); 3866 } 3867 } 3868 3869 #endif /* ADC_VER_V5_V90 */ 3870 3871 /** 3872 * @} 3873 */ 3874 3875 /** @defgroup ADC_LL_EF_Configuration_ADC_Group_Regular Configuration of ADC hierarchical scope: group regular 3876 * @ingroup RTEMSBSPsARMSTM32H7 3877 * @{ 3878 */ 3879 3880 /** 3881 * @brief Set ADC group regular conversion trigger source: 3882 * internal (SW start) or from external peripheral (timer event, 3883 * external interrupt line). 3884 * @note On this STM32 series, setting trigger source to external trigger 3885 * also set trigger polarity to rising edge 3886 * (default setting for compatibility with some ADC on other 3887 * STM32 families having this setting set by HW default value). 3888 * In case of need to modify trigger edge, use 3889 * function @ref LL_ADC_REG_SetTriggerEdge(). 3890 * @note Availability of parameters of trigger sources from timer 3891 * depends on timers availability on the selected device. 3892 * @note On this STM32 series, setting of this feature is conditioned to 3893 * ADC state: 3894 * ADC must be disabled or enabled without conversion on going 3895 * on group regular. 3896 * @rmtoll CFGR EXTSEL LL_ADC_REG_SetTriggerSource\n 3897 * CFGR EXTEN LL_ADC_REG_SetTriggerSource 3898 * @param ADCx ADC instance 3899 * @param TriggerSource This parameter can be one of the following values: 3900 * @arg @ref LL_ADC_REG_TRIG_SOFTWARE 3901 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH1 3902 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH2 3903 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH3 3904 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH2 3905 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_TRGO 3906 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_CH4 3907 * @arg @ref LL_ADC_REG_TRIG_EXT_EXTI_LINE11 3908 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_TRGO 3909 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_TRGO2 3910 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_TRGO 3911 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_TRGO2 3912 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_TRGO 3913 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_TRGO 3914 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM6_TRGO 3915 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM15_TRGO 3916 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_CH4 3917 * @arg @ref LL_ADC_REG_TRIG_EXT_HRTIM_TRG1 3918 * @arg @ref LL_ADC_REG_TRIG_EXT_HRTIM_TRG3 3919 * @arg @ref LL_ADC_REG_TRIG_EXT_LPTIM1_OUT 3920 * @arg @ref LL_ADC_REG_TRIG_EXT_LPTIM2_OUT 3921 * @arg @ref LL_ADC_REG_TRIG_EXT_LPTIM3_OUT 3922 * @retval None 3923 */ 3924 __STATIC_INLINE void LL_ADC_REG_SetTriggerSource(ADC_TypeDef *ADCx, uint32_t TriggerSource) 3925 { 3926 MODIFY_REG(ADCx->CFGR, ADC_CFGR_EXTEN | ADC_CFGR_EXTSEL, TriggerSource); 3927 } 3928 3929 /** 3930 * @brief Get ADC group regular conversion trigger source: 3931 * internal (SW start) or from external peripheral (timer event, 3932 * external interrupt line). 3933 * @note To determine whether group regular trigger source is 3934 * internal (SW start) or external, without detail 3935 * of which peripheral is selected as external trigger, 3936 * (equivalent to 3937 * "if(LL_ADC_REG_GetTriggerSource(ADC1) == LL_ADC_REG_TRIG_SOFTWARE)") 3938 * use function @ref LL_ADC_REG_IsTriggerSourceSWStart. 3939 * @note Availability of parameters of trigger sources from timer 3940 * depends on timers availability on the selected device. 3941 * @rmtoll CFGR EXTSEL LL_ADC_REG_GetTriggerSource\n 3942 * CFGR EXTEN LL_ADC_REG_GetTriggerSource 3943 * @param ADCx ADC instance 3944 * @retval Returned value can be one of the following values: 3945 * @arg @ref LL_ADC_REG_TRIG_SOFTWARE 3946 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH1 3947 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH2 3948 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_CH3 3949 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH2 3950 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_TRGO 3951 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_CH4 3952 * @arg @ref LL_ADC_REG_TRIG_EXT_EXTI_LINE11 3953 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_TRGO 3954 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM8_TRGO2 3955 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_TRGO 3956 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM1_TRGO2 3957 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_TRGO 3958 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_TRGO 3959 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM6_TRGO 3960 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM15_TRGO 3961 * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_CH4 3962 * @arg @ref LL_ADC_REG_TRIG_EXT_HRTIM_TRG1 3963 * @arg @ref LL_ADC_REG_TRIG_EXT_HRTIM_TRG3 3964 * @arg @ref LL_ADC_REG_TRIG_EXT_LPTIM1_OUT 3965 * @arg @ref LL_ADC_REG_TRIG_EXT_LPTIM2_OUT 3966 * @arg @ref LL_ADC_REG_TRIG_EXT_LPTIM3_OUT 3967 */ 3968 __STATIC_INLINE uint32_t LL_ADC_REG_GetTriggerSource(ADC_TypeDef *ADCx) 3969 { 3970 __IO uint32_t TriggerSource = READ_BIT(ADCx->CFGR, ADC_CFGR_EXTSEL | ADC_CFGR_EXTEN); 3971 3972 /* Value for shift of {0; 4; 8; 12} depending on value of bitfield */ 3973 /* corresponding to ADC_CFGR_EXTEN {0; 1; 2; 3}. */ 3974 uint32_t ShiftExten = ((TriggerSource & ADC_CFGR_EXTEN) >> (ADC_REG_TRIG_EXTEN_BITOFFSET_POS - 2UL)); 3975 3976 /* Set bitfield corresponding to ADC_CFGR_EXTEN and ADC_CFGR_EXTSEL */ 3977 /* to match with triggers literals definition. */ 3978 return ((TriggerSource 3979 & (ADC_REG_TRIG_SOURCE_MASK >> ShiftExten) & ADC_CFGR_EXTSEL) 3980 | ((ADC_REG_TRIG_EDGE_MASK >> ShiftExten) & ADC_CFGR_EXTEN) 3981 ); 3982 } 3983 3984 /** 3985 * @brief Get ADC group regular conversion trigger source internal (SW start) 3986 * or external. 3987 * @note In case of group regular trigger source set to external trigger, 3988 * to determine which peripheral is selected as external trigger, 3989 * use function @ref LL_ADC_REG_GetTriggerSource(). 3990 * @rmtoll CFGR EXTEN LL_ADC_REG_IsTriggerSourceSWStart 3991 * @param ADCx ADC instance 3992 * @retval Value "0" if trigger source external trigger 3993 * Value "1" if trigger source SW start. 3994 */ 3995 __STATIC_INLINE uint32_t LL_ADC_REG_IsTriggerSourceSWStart(ADC_TypeDef *ADCx) 3996 { 3997 return ((READ_BIT(ADCx->CFGR, ADC_CFGR_EXTEN) == (LL_ADC_REG_TRIG_SOFTWARE & ADC_CFGR_EXTEN)) ? 1UL : 0UL); 3998 } 3999 4000 /** 4001 * @brief Set ADC group regular conversion trigger polarity. 4002 * @note Applicable only for trigger source set to external trigger. 4003 * @note On this STM32 series, setting of this feature is conditioned to 4004 * ADC state: 4005 * ADC must be disabled or enabled without conversion on going 4006 * on group regular. 4007 * @rmtoll CFGR EXTEN LL_ADC_REG_SetTriggerEdge 4008 * @param ADCx ADC instance 4009 * @param ExternalTriggerEdge This parameter can be one of the following values: 4010 * @arg @ref LL_ADC_REG_TRIG_EXT_RISING 4011 * @arg @ref LL_ADC_REG_TRIG_EXT_FALLING 4012 * @arg @ref LL_ADC_REG_TRIG_EXT_RISINGFALLING 4013 * @retval None 4014 */ 4015 __STATIC_INLINE void LL_ADC_REG_SetTriggerEdge(ADC_TypeDef *ADCx, uint32_t ExternalTriggerEdge) 4016 { 4017 MODIFY_REG(ADCx->CFGR, ADC_CFGR_EXTEN, ExternalTriggerEdge); 4018 } 4019 4020 /** 4021 * @brief Get ADC group regular conversion trigger polarity. 4022 * @note Applicable only for trigger source set to external trigger. 4023 * @rmtoll CFGR EXTEN LL_ADC_REG_GetTriggerEdge 4024 * @param ADCx ADC instance 4025 * @retval Returned value can be one of the following values: 4026 * @arg @ref LL_ADC_REG_TRIG_EXT_RISING 4027 * @arg @ref LL_ADC_REG_TRIG_EXT_FALLING 4028 * @arg @ref LL_ADC_REG_TRIG_EXT_RISINGFALLING 4029 */ 4030 __STATIC_INLINE uint32_t LL_ADC_REG_GetTriggerEdge(ADC_TypeDef *ADCx) 4031 { 4032 return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_EXTEN)); 4033 } 4034 4035 #if defined(ADC_VER_V5_V90) 4036 /** 4037 * @brief Set ADC sampling mode. 4038 * @note This function set the ADC conversion sampling mode 4039 * @note This mode applies to regular group only. 4040 * @note Set sampling mode is applied to all conversion of regular group. 4041 * @note On this STM32 series, setting of this feature is conditioned to 4042 * ADC state: 4043 * ADC must be disabled or enabled without conversion on going 4044 * on group regular. 4045 * @rmtoll CFGR2 BULB LL_ADC_REG_SetSamplingMode\n 4046 * CFGR2 SMPTRIG LL_ADC_REG_SetSamplingMode 4047 * @param ADCx ADC instance 4048 * @param SamplingMode This parameter can be one of the following values: 4049 * @arg @ref LL_ADC_REG_SAMPLING_MODE_NORMAL 4050 * @arg @ref LL_ADC_REG_SAMPLING_MODE_BULB 4051 * @arg @ref LL_ADC_REG_SAMPLING_MODE_TRIGGER_CONTROLED 4052 * @retval None 4053 */ 4054 __STATIC_INLINE void LL_ADC_REG_SetSamplingMode(ADC_TypeDef *ADCx, uint32_t SamplingMode) 4055 { 4056 if (ADCx != ADC3) 4057 { 4058 /* Function not available on this instance */ 4059 } 4060 else 4061 { 4062 MODIFY_REG(ADCx->CFGR2, ADC3_CFGR2_BULB | ADC3_CFGR2_SMPTRIG, SamplingMode); 4063 } 4064 } 4065 #endif /* ADC_VER_V5_V90 */ 4066 4067 /** 4068 * @brief Set ADC group regular sequencer length and scan direction. 4069 * @note Description of ADC group regular sequencer features: 4070 * - For devices with sequencer fully configurable 4071 * (function "LL_ADC_REG_SetSequencerRanks()" available): 4072 * sequencer length and each rank affectation to a channel 4073 * are configurable. 4074 * This function performs configuration of: 4075 * - Sequence length: Number of ranks in the scan sequence. 4076 * - Sequence direction: Unless specified in parameters, sequencer 4077 * scan direction is forward (from rank 1 to rank n). 4078 * Sequencer ranks are selected using 4079 * function "LL_ADC_REG_SetSequencerRanks()". 4080 * - For devices with sequencer not fully configurable 4081 * (function "LL_ADC_REG_SetSequencerChannels()" available): 4082 * sequencer length and each rank affectation to a channel 4083 * are defined by channel number. 4084 * This function performs configuration of: 4085 * - Sequence length: Number of ranks in the scan sequence is 4086 * defined by number of channels set in the sequence, 4087 * rank of each channel is fixed by channel HW number. 4088 * (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...). 4089 * - Sequence direction: Unless specified in parameters, sequencer 4090 * scan direction is forward (from lowest channel number to 4091 * highest channel number). 4092 * Sequencer ranks are selected using 4093 * function "LL_ADC_REG_SetSequencerChannels()". 4094 * @note Sequencer disabled is equivalent to sequencer of 1 rank: 4095 * ADC conversion on only 1 channel. 4096 * @note On this STM32 series, setting of this feature is conditioned to 4097 * ADC state: 4098 * ADC must be disabled or enabled without conversion on going 4099 * on group regular. 4100 * @rmtoll SQR1 L LL_ADC_REG_SetSequencerLength 4101 * @param ADCx ADC instance 4102 * @param SequencerNbRanks This parameter can be one of the following values: 4103 * @arg @ref LL_ADC_REG_SEQ_SCAN_DISABLE 4104 * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS 4105 * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS 4106 * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_4RANKS 4107 * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS 4108 * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS 4109 * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_7RANKS 4110 * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_8RANKS 4111 * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS 4112 * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_10RANKS 4113 * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_11RANKS 4114 * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_12RANKS 4115 * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_13RANKS 4116 * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_14RANKS 4117 * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_15RANKS 4118 * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_16RANKS 4119 * @retval None 4120 */ 4121 __STATIC_INLINE void LL_ADC_REG_SetSequencerLength(ADC_TypeDef *ADCx, uint32_t SequencerNbRanks) 4122 { 4123 MODIFY_REG(ADCx->SQR1, ADC_SQR1_L, SequencerNbRanks); 4124 } 4125 4126 /** 4127 * @brief Get ADC group regular sequencer length and scan direction. 4128 * @note Description of ADC group regular sequencer features: 4129 * - For devices with sequencer fully configurable 4130 * (function "LL_ADC_REG_SetSequencerRanks()" available): 4131 * sequencer length and each rank affectation to a channel 4132 * are configurable. 4133 * This function retrieves: 4134 * - Sequence length: Number of ranks in the scan sequence. 4135 * - Sequence direction: Unless specified in parameters, sequencer 4136 * scan direction is forward (from rank 1 to rank n). 4137 * Sequencer ranks are selected using 4138 * function "LL_ADC_REG_SetSequencerRanks()". 4139 * - For devices with sequencer not fully configurable 4140 * (function "LL_ADC_REG_SetSequencerChannels()" available): 4141 * sequencer length and each rank affectation to a channel 4142 * are defined by channel number. 4143 * This function retrieves: 4144 * - Sequence length: Number of ranks in the scan sequence is 4145 * defined by number of channels set in the sequence, 4146 * rank of each channel is fixed by channel HW number. 4147 * (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...). 4148 * - Sequence direction: Unless specified in parameters, sequencer 4149 * scan direction is forward (from lowest channel number to 4150 * highest channel number). 4151 * Sequencer ranks are selected using 4152 * function "LL_ADC_REG_SetSequencerChannels()". 4153 * @note Sequencer disabled is equivalent to sequencer of 1 rank: 4154 * ADC conversion on only 1 channel. 4155 * @rmtoll SQR1 L LL_ADC_REG_GetSequencerLength 4156 * @param ADCx ADC instance 4157 * @retval Returned value can be one of the following values: 4158 * @arg @ref LL_ADC_REG_SEQ_SCAN_DISABLE 4159 * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS 4160 * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS 4161 * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_4RANKS 4162 * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS 4163 * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS 4164 * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_7RANKS 4165 * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_8RANKS 4166 * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS 4167 * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_10RANKS 4168 * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_11RANKS 4169 * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_12RANKS 4170 * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_13RANKS 4171 * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_14RANKS 4172 * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_15RANKS 4173 * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_16RANKS 4174 */ 4175 __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerLength(ADC_TypeDef *ADCx) 4176 { 4177 return (uint32_t)(READ_BIT(ADCx->SQR1, ADC_SQR1_L)); 4178 } 4179 4180 /** 4181 * @brief Set ADC group regular sequencer discontinuous mode: 4182 * sequence subdivided and scan conversions interrupted every selected 4183 * number of ranks. 4184 * @note It is not possible to enable both ADC group regular 4185 * continuous mode and sequencer discontinuous mode. 4186 * @note It is not possible to enable both ADC auto-injected mode 4187 * and ADC group regular sequencer discontinuous mode. 4188 * @note On this STM32 series, setting of this feature is conditioned to 4189 * ADC state: 4190 * ADC must be disabled or enabled without conversion on going 4191 * on group regular. 4192 * @rmtoll CFGR DISCEN LL_ADC_REG_SetSequencerDiscont\n 4193 * CFGR DISCNUM LL_ADC_REG_SetSequencerDiscont 4194 * @param ADCx ADC instance 4195 * @param SeqDiscont This parameter can be one of the following values: 4196 * @arg @ref LL_ADC_REG_SEQ_DISCONT_DISABLE 4197 * @arg @ref LL_ADC_REG_SEQ_DISCONT_1RANK 4198 * @arg @ref LL_ADC_REG_SEQ_DISCONT_2RANKS 4199 * @arg @ref LL_ADC_REG_SEQ_DISCONT_3RANKS 4200 * @arg @ref LL_ADC_REG_SEQ_DISCONT_4RANKS 4201 * @arg @ref LL_ADC_REG_SEQ_DISCONT_5RANKS 4202 * @arg @ref LL_ADC_REG_SEQ_DISCONT_6RANKS 4203 * @arg @ref LL_ADC_REG_SEQ_DISCONT_7RANKS 4204 * @arg @ref LL_ADC_REG_SEQ_DISCONT_8RANKS 4205 * @retval None 4206 */ 4207 __STATIC_INLINE void LL_ADC_REG_SetSequencerDiscont(ADC_TypeDef *ADCx, uint32_t SeqDiscont) 4208 { 4209 MODIFY_REG(ADCx->CFGR, ADC_CFGR_DISCEN | ADC_CFGR_DISCNUM, SeqDiscont); 4210 } 4211 4212 /** 4213 * @brief Get ADC group regular sequencer discontinuous mode: 4214 * sequence subdivided and scan conversions interrupted every selected 4215 * number of ranks. 4216 * @rmtoll CFGR DISCEN LL_ADC_REG_GetSequencerDiscont\n 4217 * CFGR DISCNUM LL_ADC_REG_GetSequencerDiscont 4218 * @param ADCx ADC instance 4219 * @retval Returned value can be one of the following values: 4220 * @arg @ref LL_ADC_REG_SEQ_DISCONT_DISABLE 4221 * @arg @ref LL_ADC_REG_SEQ_DISCONT_1RANK 4222 * @arg @ref LL_ADC_REG_SEQ_DISCONT_2RANKS 4223 * @arg @ref LL_ADC_REG_SEQ_DISCONT_3RANKS 4224 * @arg @ref LL_ADC_REG_SEQ_DISCONT_4RANKS 4225 * @arg @ref LL_ADC_REG_SEQ_DISCONT_5RANKS 4226 * @arg @ref LL_ADC_REG_SEQ_DISCONT_6RANKS 4227 * @arg @ref LL_ADC_REG_SEQ_DISCONT_7RANKS 4228 * @arg @ref LL_ADC_REG_SEQ_DISCONT_8RANKS 4229 */ 4230 __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerDiscont(ADC_TypeDef *ADCx) 4231 { 4232 return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_DISCEN | ADC_CFGR_DISCNUM)); 4233 } 4234 4235 /** 4236 * @brief Set ADC group regular sequence: channel on the selected 4237 * scan sequence rank. 4238 * @note This function performs configuration of: 4239 * - Channels ordering into each rank of scan sequence: 4240 * whatever channel can be placed into whatever rank. 4241 * @note On this STM32 series, ADC group regular sequencer is 4242 * fully configurable: sequencer length and each rank 4243 * affectation to a channel are configurable. 4244 * Refer to description of function @ref LL_ADC_REG_SetSequencerLength(). 4245 * @note Depending on devices and packages, some channels may not be available. 4246 * Refer to device datasheet for channels availability. 4247 * @note On this STM32 series, to measure internal channels (VrefInt, 4248 * TempSensor, ...), measurement paths to internal channels must be 4249 * enabled separately. 4250 * This can be done using function @ref LL_ADC_SetCommonPathInternalCh(). 4251 * @note On this STM32 series, setting of this feature is conditioned to 4252 * ADC state: 4253 * ADC must be disabled or enabled without conversion on going 4254 * on group regular. 4255 * @rmtoll SQR1 SQ1 LL_ADC_REG_SetSequencerRanks\n 4256 * SQR1 SQ2 LL_ADC_REG_SetSequencerRanks\n 4257 * SQR1 SQ3 LL_ADC_REG_SetSequencerRanks\n 4258 * SQR1 SQ4 LL_ADC_REG_SetSequencerRanks\n 4259 * SQR2 SQ5 LL_ADC_REG_SetSequencerRanks\n 4260 * SQR2 SQ6 LL_ADC_REG_SetSequencerRanks\n 4261 * SQR2 SQ7 LL_ADC_REG_SetSequencerRanks\n 4262 * SQR2 SQ8 LL_ADC_REG_SetSequencerRanks\n 4263 * SQR2 SQ9 LL_ADC_REG_SetSequencerRanks\n 4264 * SQR3 SQ10 LL_ADC_REG_SetSequencerRanks\n 4265 * SQR3 SQ11 LL_ADC_REG_SetSequencerRanks\n 4266 * SQR3 SQ12 LL_ADC_REG_SetSequencerRanks\n 4267 * SQR3 SQ13 LL_ADC_REG_SetSequencerRanks\n 4268 * SQR3 SQ14 LL_ADC_REG_SetSequencerRanks\n 4269 * SQR4 SQ15 LL_ADC_REG_SetSequencerRanks\n 4270 * SQR4 SQ16 LL_ADC_REG_SetSequencerRanks 4271 * @param ADCx ADC instance 4272 * @param Rank This parameter can be one of the following values: 4273 * @arg @ref LL_ADC_REG_RANK_1 4274 * @arg @ref LL_ADC_REG_RANK_2 4275 * @arg @ref LL_ADC_REG_RANK_3 4276 * @arg @ref LL_ADC_REG_RANK_4 4277 * @arg @ref LL_ADC_REG_RANK_5 4278 * @arg @ref LL_ADC_REG_RANK_6 4279 * @arg @ref LL_ADC_REG_RANK_7 4280 * @arg @ref LL_ADC_REG_RANK_8 4281 * @arg @ref LL_ADC_REG_RANK_9 4282 * @arg @ref LL_ADC_REG_RANK_10 4283 * @arg @ref LL_ADC_REG_RANK_11 4284 * @arg @ref LL_ADC_REG_RANK_12 4285 * @arg @ref LL_ADC_REG_RANK_13 4286 * @arg @ref LL_ADC_REG_RANK_14 4287 * @arg @ref LL_ADC_REG_RANK_15 4288 * @arg @ref LL_ADC_REG_RANK_16 4289 * @param Channel This parameter can be one of the following values: 4290 * @arg @ref LL_ADC_CHANNEL_0 (3) 4291 * @arg @ref LL_ADC_CHANNEL_1 (3) 4292 * @arg @ref LL_ADC_CHANNEL_2 (3) 4293 * @arg @ref LL_ADC_CHANNEL_3 (3) 4294 * @arg @ref LL_ADC_CHANNEL_4 (3) 4295 * @arg @ref LL_ADC_CHANNEL_5 (3) 4296 * @arg @ref LL_ADC_CHANNEL_6 4297 * @arg @ref LL_ADC_CHANNEL_7 4298 * @arg @ref LL_ADC_CHANNEL_8 4299 * @arg @ref LL_ADC_CHANNEL_9 4300 * @arg @ref LL_ADC_CHANNEL_10 4301 * @arg @ref LL_ADC_CHANNEL_11 4302 * @arg @ref LL_ADC_CHANNEL_12 4303 * @arg @ref LL_ADC_CHANNEL_13 4304 * @arg @ref LL_ADC_CHANNEL_14 4305 * @arg @ref LL_ADC_CHANNEL_15 4306 * @arg @ref LL_ADC_CHANNEL_16 4307 * @arg @ref LL_ADC_CHANNEL_17 4308 * @arg @ref LL_ADC_CHANNEL_18 4309 * @arg @ref LL_ADC_CHANNEL_19 4310 * @arg @ref LL_ADC_CHANNEL_VREFINT (1) 4311 * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1) 4312 * @arg @ref LL_ADC_CHANNEL_VBAT (1) 4313 * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC2 (2) 4314 * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC2 (2) 4315 * 4316 * (1) On STM32H7, parameter available only on ADC instance: ADC3.\n 4317 * (2) On STM32H7, parameter available only on ADC instance: ADC2.\n 4318 * (3) On STM32H7, fast channel (0.125 us for 14-bit resolution (ADC conversion rate up to 8 Ms/s)). 4319 * Other channels are slow channels (conversion rate: refer to reference manual). 4320 * @retval None 4321 */ 4322 __STATIC_INLINE void LL_ADC_REG_SetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank, uint32_t Channel) 4323 { 4324 /* Set bits with content of parameter "Channel" with bits position */ 4325 /* in register and register position depending on parameter "Rank". */ 4326 /* Parameters "Rank" and "Channel" are used with masks because containing */ 4327 /* other bits reserved for other purpose. */ 4328 __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SQR1, ((Rank & ADC_REG_SQRX_REGOFFSET_MASK) >> ADC_SQRX_REGOFFSET_POS)); 4329 4330 MODIFY_REG(*preg, 4331 ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0 << (Rank & ADC_REG_RANK_ID_SQRX_MASK), 4332 ((Channel & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) << (Rank & ADC_REG_RANK_ID_SQRX_MASK)); 4333 } 4334 4335 /** 4336 * @brief Get ADC group regular sequence: channel on the selected 4337 * scan sequence rank. 4338 * @note On this STM32 series, ADC group regular sequencer is 4339 * fully configurable: sequencer length and each rank 4340 * affectation to a channel are configurable. 4341 * Refer to description of function @ref LL_ADC_REG_SetSequencerLength(). 4342 * @note Depending on devices and packages, some channels may not be available. 4343 * Refer to device datasheet for channels availability. 4344 * @note Usage of the returned channel number: 4345 * - To reinject this channel into another function LL_ADC_xxx: 4346 * the returned channel number is only partly formatted on definition 4347 * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared 4348 * with parts of literals LL_ADC_CHANNEL_x or using 4349 * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB(). 4350 * Then the selected literal LL_ADC_CHANNEL_x can be used 4351 * as parameter for another function. 4352 * - To get the channel number in decimal format: 4353 * process the returned value with the helper macro 4354 * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB(). 4355 * @rmtoll SQR1 SQ1 LL_ADC_REG_GetSequencerRanks\n 4356 * SQR1 SQ2 LL_ADC_REG_GetSequencerRanks\n 4357 * SQR1 SQ3 LL_ADC_REG_GetSequencerRanks\n 4358 * SQR1 SQ4 LL_ADC_REG_GetSequencerRanks\n 4359 * SQR2 SQ5 LL_ADC_REG_GetSequencerRanks\n 4360 * SQR2 SQ6 LL_ADC_REG_GetSequencerRanks\n 4361 * SQR2 SQ7 LL_ADC_REG_GetSequencerRanks\n 4362 * SQR2 SQ8 LL_ADC_REG_GetSequencerRanks\n 4363 * SQR2 SQ9 LL_ADC_REG_GetSequencerRanks\n 4364 * SQR3 SQ10 LL_ADC_REG_GetSequencerRanks\n 4365 * SQR3 SQ11 LL_ADC_REG_GetSequencerRanks\n 4366 * SQR3 SQ12 LL_ADC_REG_GetSequencerRanks\n 4367 * SQR3 SQ13 LL_ADC_REG_GetSequencerRanks\n 4368 * SQR3 SQ14 LL_ADC_REG_GetSequencerRanks\n 4369 * SQR4 SQ15 LL_ADC_REG_GetSequencerRanks\n 4370 * SQR4 SQ16 LL_ADC_REG_GetSequencerRanks 4371 * @param ADCx ADC instance 4372 * @param Rank This parameter can be one of the following values: 4373 * @arg @ref LL_ADC_REG_RANK_1 4374 * @arg @ref LL_ADC_REG_RANK_2 4375 * @arg @ref LL_ADC_REG_RANK_3 4376 * @arg @ref LL_ADC_REG_RANK_4 4377 * @arg @ref LL_ADC_REG_RANK_5 4378 * @arg @ref LL_ADC_REG_RANK_6 4379 * @arg @ref LL_ADC_REG_RANK_7 4380 * @arg @ref LL_ADC_REG_RANK_8 4381 * @arg @ref LL_ADC_REG_RANK_9 4382 * @arg @ref LL_ADC_REG_RANK_10 4383 * @arg @ref LL_ADC_REG_RANK_11 4384 * @arg @ref LL_ADC_REG_RANK_12 4385 * @arg @ref LL_ADC_REG_RANK_13 4386 * @arg @ref LL_ADC_REG_RANK_14 4387 * @arg @ref LL_ADC_REG_RANK_15 4388 * @arg @ref LL_ADC_REG_RANK_16 4389 * @retval Returned value can be one of the following values: 4390 * @arg @ref LL_ADC_CHANNEL_0 (3) 4391 * @arg @ref LL_ADC_CHANNEL_1 (3) 4392 * @arg @ref LL_ADC_CHANNEL_2 (3) 4393 * @arg @ref LL_ADC_CHANNEL_3 (3) 4394 * @arg @ref LL_ADC_CHANNEL_4 (3) 4395 * @arg @ref LL_ADC_CHANNEL_5 (3) 4396 * @arg @ref LL_ADC_CHANNEL_6 4397 * @arg @ref LL_ADC_CHANNEL_7 4398 * @arg @ref LL_ADC_CHANNEL_8 4399 * @arg @ref LL_ADC_CHANNEL_9 4400 * @arg @ref LL_ADC_CHANNEL_10 4401 * @arg @ref LL_ADC_CHANNEL_11 4402 * @arg @ref LL_ADC_CHANNEL_12 4403 * @arg @ref LL_ADC_CHANNEL_13 4404 * @arg @ref LL_ADC_CHANNEL_14 4405 * @arg @ref LL_ADC_CHANNEL_15 4406 * @arg @ref LL_ADC_CHANNEL_16 4407 * @arg @ref LL_ADC_CHANNEL_17 4408 * @arg @ref LL_ADC_CHANNEL_18 4409 * @arg @ref LL_ADC_CHANNEL_19 4410 * @arg @ref LL_ADC_CHANNEL_VREFINT (1) 4411 * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1) 4412 * @arg @ref LL_ADC_CHANNEL_VBAT (1) 4413 * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC2 (2) 4414 * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC2 (2) 4415 * 4416 * (1) On STM32H7, parameter available only on ADC instance: ADC3.\n 4417 * (2) On STM32H7, parameter available only on ADC instance: ADC2.\n 4418 * (3) On STM32H7, fast channel (0.125 us for 14-bit resolution (ADC conversion rate up to 8 Ms/s)). 4419 * Other channels are slow channels (conversion rate: refer to reference manual).\n 4420 * (1, 2) For ADC channel read back from ADC register, 4421 * comparison with internal channel parameter to be done 4422 * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL(). 4423 */ 4424 __STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank) 4425 { 4426 const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SQR1, ((Rank & ADC_REG_SQRX_REGOFFSET_MASK) >> ADC_SQRX_REGOFFSET_POS)); 4427 4428 return (uint32_t)((READ_BIT(*preg, 4429 ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0 << (Rank & ADC_REG_RANK_ID_SQRX_MASK)) 4430 >> (Rank & ADC_REG_RANK_ID_SQRX_MASK)) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS 4431 ); 4432 } 4433 4434 /** 4435 * @brief Set ADC continuous conversion mode on ADC group regular. 4436 * @note Description of ADC continuous conversion mode: 4437 * - single mode: one conversion per trigger 4438 * - continuous mode: after the first trigger, following 4439 * conversions launched successively automatically. 4440 * @note It is not possible to enable both ADC group regular 4441 * continuous mode and sequencer discontinuous mode. 4442 * @note On this STM32 series, setting of this feature is conditioned to 4443 * ADC state: 4444 * ADC must be disabled or enabled without conversion on going 4445 * on group regular. 4446 * @rmtoll CFGR CONT LL_ADC_REG_SetContinuousMode 4447 * @param ADCx ADC instance 4448 * @param Continuous This parameter can be one of the following values: 4449 * @arg @ref LL_ADC_REG_CONV_SINGLE 4450 * @arg @ref LL_ADC_REG_CONV_CONTINUOUS 4451 * @retval None 4452 */ 4453 __STATIC_INLINE void LL_ADC_REG_SetContinuousMode(ADC_TypeDef *ADCx, uint32_t Continuous) 4454 { 4455 MODIFY_REG(ADCx->CFGR, ADC_CFGR_CONT, Continuous); 4456 } 4457 4458 /** 4459 * @brief Get ADC continuous conversion mode on ADC group regular. 4460 * @note Description of ADC continuous conversion mode: 4461 * - single mode: one conversion per trigger 4462 * - continuous mode: after the first trigger, following 4463 * conversions launched successively automatically. 4464 * @rmtoll CFGR CONT LL_ADC_REG_GetContinuousMode 4465 * @param ADCx ADC instance 4466 * @retval Returned value can be one of the following values: 4467 * @arg @ref LL_ADC_REG_CONV_SINGLE 4468 * @arg @ref LL_ADC_REG_CONV_CONTINUOUS 4469 */ 4470 __STATIC_INLINE uint32_t LL_ADC_REG_GetContinuousMode(ADC_TypeDef *ADCx) 4471 { 4472 return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_CONT)); 4473 } 4474 /** 4475 * @brief Set ADC data transfer mode 4476 * @note Conversion data can be either: 4477 * - Available in Data Register 4478 * - Transferred by DMA in one shot mode 4479 * - Transferred by DMA in circular mode 4480 * - Transferred to DFSDM data register 4481 * @rmtoll CFGR DMNGT LL_ADC_REG_SetDataTransferMode 4482 * @param ADCx ADC instance 4483 * @param DataTransferMode Select Data Management configuration 4484 * @retval None 4485 */ 4486 __STATIC_INLINE void LL_ADC_REG_SetDataTransferMode(ADC_TypeDef *ADCx, uint32_t DataTransferMode) 4487 { 4488 MODIFY_REG(ADCx->CFGR, ADC_CFGR_DMNGT, DataTransferMode); 4489 } 4490 4491 #if defined(ADC_VER_V5_V90) 4492 /** 4493 * @brief Enable DMA requests for ADC3. 4494 * @rmtoll CFGR DMAEN LL_ADC_REG_SetDMATransfer\n 4495 * @param ADCx ADC instance 4496 * @retval None 4497 */ 4498 __STATIC_INLINE void LL_ADC_EnableDMAReq (ADC_TypeDef *ADCx) 4499 { 4500 SET_BIT(ADCx->CFGR, ADC3_CFGR_DMAEN); 4501 } 4502 4503 __STATIC_INLINE void LL_ADC_DisableDMAReq(ADC_TypeDef *ADCx) 4504 { 4505 CLEAR_BIT (ADCx->CFGR, ADC3_CFGR_DMAEN); 4506 } 4507 4508 __STATIC_INLINE uint32_t LL_ADC_IsEnabledDMAReq (ADC_TypeDef *ADCx) 4509 { 4510 return ((READ_BIT(ADCx->CFGR, ADC3_CFGR_DMAEN) == (ADC3_CFGR_DMAEN)) ? 1UL : 0UL); 4511 } 4512 /** 4513 * @brief Set ADC group regular conversion data transfer: no transfer or 4514 * transfer by DMA, and DMA requests mode. 4515 * @note If transfer by DMA selected, specifies the DMA requests 4516 * mode: 4517 * - Limited mode (One shot mode): DMA transfer requests are stopped 4518 * when number of DMA data transfers (number of 4519 * ADC conversions) is reached. 4520 * This ADC mode is intended to be used with DMA mode non-circular. 4521 * - Unlimited mode: DMA transfer requests are unlimited, 4522 * whatever number of DMA data transfers (number of 4523 * ADC conversions). 4524 * This ADC mode is intended to be used with DMA mode circular. 4525 * @note If ADC DMA requests mode is set to unlimited and DMA is set to 4526 * mode non-circular: 4527 * when DMA transfers size will be reached, DMA will stop transfers of 4528 * ADC conversions data ADC will raise an overrun error 4529 * (overrun flag and interruption if enabled). 4530 * @note For devices with several ADC instances: ADC multimode DMA 4531 * settings are available using function @ref LL_ADC_SetMultiDMATransfer(). 4532 * @note To configure DMA source address (peripheral address), 4533 * use function @ref LL_ADC_DMA_GetRegAddr(). 4534 * @note On this STM32 series, setting of this feature is conditioned to 4535 * ADC state: 4536 * ADC must be disabled or enabled without conversion on going 4537 * on either groups regular or injected. 4538 * @rmtoll CFGR DMAEN LL_ADC_REG_SetDMATransferMode\n 4539 * CFGR DMACFG LL_ADC_REG_SetDMATransferMode 4540 * @param ADCx ADC instance 4541 * @param DMATransfer This parameter can be one of the following values: 4542 * @arg @ref LL_ADC3_REG_DMA_TRANSFER_NONE 4543 * @arg @ref LL_ADC3_REG_DMA_TRANSFER_LIMITED 4544 * @arg @ref LL_ADC3_REG_DMA_TRANSFER_UNLIMITED 4545 * @retval None 4546 */ 4547 __STATIC_INLINE void LL_ADC_REG_SetDMATransferMode(ADC_TypeDef *ADCx, uint32_t DMATransfer) 4548 { 4549 if (ADCx == ADC3) 4550 { 4551 MODIFY_REG(ADCx->CFGR, ADC3_CFGR_DMAEN | ADC3_CFGR_DMACFG, DMATransfer); 4552 } 4553 } 4554 4555 /** 4556 * @brief Get ADC group regular conversion data transfer: no transfer or 4557 * transfer by DMA, and DMA requests mode. 4558 * @note If transfer by DMA selected, specifies the DMA requests 4559 * mode: 4560 * - Limited mode (One shot mode): DMA transfer requests are stopped 4561 * when number of DMA data transfers (number of 4562 * ADC conversions) is reached. 4563 * This ADC mode is intended to be used with DMA mode non-circular. 4564 * - Unlimited mode: DMA transfer requests are unlimited, 4565 * whatever number of DMA data transfers (number of 4566 * ADC conversions). 4567 * This ADC mode is intended to be used with DMA mode circular. 4568 * @note If ADC DMA requests mode is set to unlimited and DMA is set to 4569 * mode non-circular: 4570 * when DMA transfers size will be reached, DMA will stop transfers of 4571 * ADC conversions data ADC will raise an overrun error 4572 * (overrun flag and interruption if enabled). 4573 * @note For devices with several ADC instances: ADC multimode DMA 4574 * settings are available using function @ref LL_ADC_GetMultiDMATransfer(). 4575 * @note To configure DMA source address (peripheral address), 4576 * use function @ref LL_ADC_DMA_GetRegAddr(). 4577 * @rmtoll CFGR DMAEN LL_ADC_REG_GetDMATransfer\n 4578 * CFGR DMACFG LL_ADC_REG_GetDMATransfer 4579 * @param ADCx ADC instance 4580 * @retval Returned value can be one of the following values: 4581 * @arg @ref LL_ADC3_REG_DMA_TRANSFER_NONE 4582 * @arg @ref LL_ADC3_REG_DMA_TRANSFER_LIMITED 4583 * @arg @ref LL_ADC3_REG_DMA_TRANSFER_UNLIMITED 4584 */ 4585 __STATIC_INLINE uint32_t LL_ADC_REG_GetDMATransferMode(ADC_TypeDef *ADCx) 4586 { 4587 if (ADCx == ADC3) 4588 { 4589 return (uint32_t)(READ_BIT(ADCx->CFGR, ADC3_CFGR_DMAEN | ADC3_CFGR_DMACFG)); 4590 } 4591 else 4592 { 4593 return 0UL; 4594 } 4595 } 4596 4597 #endif /* ADC_VER_V5_V90 */ 4598 4599 /** 4600 * @brief Get ADC data transfer mode 4601 * @note Conversion data can be either: 4602 * - Available in Data Register 4603 * - Transferred by DMA in one shot mode 4604 * - Transferred by DMA in circular mode 4605 * - Transferred to DFSDM data register 4606 * @rmtoll CFGR DMNGT LL_ADC_REG_GetDataTransferMode 4607 * @param ADCx ADC instance 4608 * @retval Returned value can be one of the following values: 4609 * @arg @ref LL_ADC_REG_DR_TRANSFER 4610 * @arg @ref LL_ADC_REG_DMA_TRANSFER_LIMITED 4611 * @arg @ref LL_ADC_REG_DMA_TRANSFER_UNLIMITED 4612 * @arg @ref LL_ADC_REG_DFSDM_TRANSFER 4613 */ 4614 __STATIC_INLINE uint32_t LL_ADC_REG_GetDataTransferMode(ADC_TypeDef *ADCx) 4615 { 4616 return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_DMNGT)); 4617 } 4618 4619 4620 /** 4621 * @brief Set ADC group regular behavior in case of overrun: 4622 * data preserved or overwritten. 4623 * @note Compatibility with devices without feature overrun: 4624 * other devices without this feature have a behavior 4625 * equivalent to data overwritten. 4626 * The default setting of overrun is data preserved. 4627 * Therefore, for compatibility with all devices, parameter 4628 * overrun should be set to data overwritten. 4629 * @note On this STM32 series, setting of this feature is conditioned to 4630 * ADC state: 4631 * ADC must be disabled or enabled without conversion on going 4632 * on group regular. 4633 * @rmtoll CFGR OVRMOD LL_ADC_REG_SetOverrun 4634 * @param ADCx ADC instance 4635 * @param Overrun This parameter can be one of the following values: 4636 * @arg @ref LL_ADC_REG_OVR_DATA_PRESERVED 4637 * @arg @ref LL_ADC_REG_OVR_DATA_OVERWRITTEN 4638 * @retval None 4639 */ 4640 __STATIC_INLINE void LL_ADC_REG_SetOverrun(ADC_TypeDef *ADCx, uint32_t Overrun) 4641 { 4642 MODIFY_REG(ADCx->CFGR, ADC_CFGR_OVRMOD, Overrun); 4643 } 4644 4645 /** 4646 * @brief Get ADC group regular behavior in case of overrun: 4647 * data preserved or overwritten. 4648 * @rmtoll CFGR OVRMOD LL_ADC_REG_GetOverrun 4649 * @param ADCx ADC instance 4650 * @retval Returned value can be one of the following values: 4651 * @arg @ref LL_ADC_REG_OVR_DATA_PRESERVED 4652 * @arg @ref LL_ADC_REG_OVR_DATA_OVERWRITTEN 4653 */ 4654 __STATIC_INLINE uint32_t LL_ADC_REG_GetOverrun(ADC_TypeDef *ADCx) 4655 { 4656 return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_OVRMOD)); 4657 } 4658 4659 /** 4660 * @} 4661 */ 4662 4663 /** @defgroup ADC_LL_EF_Configuration_ADC_Group_Injected Configuration of ADC hierarchical scope: group injected 4664 * @ingroup RTEMSBSPsARMSTM32H7 4665 * @{ 4666 */ 4667 4668 /** 4669 * @brief Set ADC group injected conversion trigger source: 4670 * internal (SW start) or from external peripheral (timer event, 4671 * external interrupt line). 4672 * @note On this STM32 series, setting trigger source to external trigger 4673 * also set trigger polarity to rising edge 4674 * (default setting for compatibility with some ADC on other 4675 * STM32 families having this setting set by HW default value). 4676 * In case of need to modify trigger edge, use 4677 * function @ref LL_ADC_INJ_SetTriggerEdge(). 4678 * @note Availability of parameters of trigger sources from timer 4679 * depends on timers availability on the selected device. 4680 * @note On this STM32 series, setting of this feature is conditioned to 4681 * ADC state: 4682 * ADC must not be disabled. Can be enabled with or without conversion 4683 * on going on either groups regular or injected. 4684 * @rmtoll JSQR JEXTSEL LL_ADC_INJ_SetTriggerSource\n 4685 * JSQR JEXTEN LL_ADC_INJ_SetTriggerSource 4686 * @param ADCx ADC instance 4687 * @param TriggerSource This parameter can be one of the following values: 4688 * @arg @ref LL_ADC_INJ_TRIG_SOFTWARE 4689 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_TRGO 4690 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_CH4 4691 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO 4692 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_CH1 4693 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH4 4694 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO 4695 * @arg @ref LL_ADC_INJ_TRIG_EXT_EXTI_LINE15 4696 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_CH4 4697 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_TRGO2 4698 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_TRGO 4699 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_TRGO2 4700 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH3 4701 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_TRGO 4702 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH1 4703 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM6_TRGO 4704 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM15_TRGO 4705 * @arg @ref LL_ADC_INJ_TRIG_EXT_HRTIM_TRG2 4706 * @arg @ref LL_ADC_INJ_TRIG_EXT_HRTIM_TRG4 4707 * @arg @ref LL_ADC_INJ_TRIG_EXT_LPTIM1_OUT 4708 * @arg @ref LL_ADC_INJ_TRIG_EXT_LPTIM2_OUT 4709 * @arg @ref LL_ADC_INJ_TRIG_EXT_LPTIM3_OUT 4710 * @retval None 4711 */ 4712 __STATIC_INLINE void LL_ADC_INJ_SetTriggerSource(ADC_TypeDef *ADCx, uint32_t TriggerSource) 4713 { 4714 MODIFY_REG(ADCx->JSQR, ADC_JSQR_JEXTSEL | ADC_JSQR_JEXTEN, TriggerSource); 4715 } 4716 4717 /** 4718 * @brief Get ADC group injected conversion trigger source: 4719 * internal (SW start) or from external peripheral (timer event, 4720 * external interrupt line). 4721 * @note To determine whether group injected trigger source is 4722 * internal (SW start) or external, without detail 4723 * of which peripheral is selected as external trigger, 4724 * (equivalent to 4725 * "if(LL_ADC_INJ_GetTriggerSource(ADC1) == LL_ADC_INJ_TRIG_SOFTWARE)") 4726 * use function @ref LL_ADC_INJ_IsTriggerSourceSWStart. 4727 * @note Availability of parameters of trigger sources from timer 4728 * depends on timers availability on the selected device. 4729 * @rmtoll JSQR JEXTSEL LL_ADC_INJ_GetTriggerSource\n 4730 * JSQR JEXTEN LL_ADC_INJ_GetTriggerSource 4731 * @param ADCx ADC instance 4732 * @retval Returned value can be one of the following values: 4733 * @arg @ref LL_ADC_INJ_TRIG_SOFTWARE 4734 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_TRGO 4735 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_CH4 4736 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO 4737 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_CH1 4738 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH4 4739 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO 4740 * @arg @ref LL_ADC_INJ_TRIG_EXT_EXTI_LINE15 4741 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_CH4 4742 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_TRGO2 4743 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_TRGO 4744 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_TRGO2 4745 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH3 4746 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_TRGO 4747 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH1 4748 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM6_TRGO 4749 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM15_TRGO 4750 * @arg @ref LL_ADC_INJ_TRIG_EXT_HRTIM_TRG2 4751 * @arg @ref LL_ADC_INJ_TRIG_EXT_HRTIM_TRG4 4752 * @arg @ref LL_ADC_INJ_TRIG_EXT_LPTIM1_OUT 4753 * @arg @ref LL_ADC_INJ_TRIG_EXT_LPTIM2_OUT 4754 * @arg @ref LL_ADC_INJ_TRIG_EXT_LPTIM3_OUT 4755 */ 4756 __STATIC_INLINE uint32_t LL_ADC_INJ_GetTriggerSource(ADC_TypeDef *ADCx) 4757 { 4758 __IO uint32_t TriggerSource = READ_BIT(ADCx->JSQR, ADC_JSQR_JEXTSEL | ADC_JSQR_JEXTEN); 4759 4760 /* Value for shift of {0; 4; 8; 12} depending on value of bitfield */ 4761 /* corresponding to ADC_JSQR_JEXTEN {0; 1; 2; 3}. */ 4762 uint32_t ShiftJexten = ((TriggerSource & ADC_JSQR_JEXTEN) >> (ADC_INJ_TRIG_EXTEN_BITOFFSET_POS - 2UL)); 4763 4764 /* Set bitfield corresponding to ADC_JSQR_JEXTEN and ADC_JSQR_JEXTSEL */ 4765 /* to match with triggers literals definition. */ 4766 return ((TriggerSource 4767 & (ADC_INJ_TRIG_SOURCE_MASK >> ShiftJexten) & ADC_JSQR_JEXTSEL) 4768 | ((ADC_INJ_TRIG_EDGE_MASK >> ShiftJexten) & ADC_JSQR_JEXTEN) 4769 ); 4770 } 4771 4772 /** 4773 * @brief Get ADC group injected conversion trigger source internal (SW start) 4774 or external 4775 * @note In case of group injected trigger source set to external trigger, 4776 * to determine which peripheral is selected as external trigger, 4777 * use function @ref LL_ADC_INJ_GetTriggerSource. 4778 * @rmtoll JSQR JEXTEN LL_ADC_INJ_IsTriggerSourceSWStart 4779 * @param ADCx ADC instance 4780 * @retval Value "0" if trigger source external trigger 4781 * Value "1" if trigger source SW start. 4782 */ 4783 __STATIC_INLINE uint32_t LL_ADC_INJ_IsTriggerSourceSWStart(ADC_TypeDef *ADCx) 4784 { 4785 return ((READ_BIT(ADCx->JSQR, ADC_JSQR_JEXTEN) == (LL_ADC_INJ_TRIG_SOFTWARE & ADC_JSQR_JEXTEN)) ? 1UL : 0UL); 4786 } 4787 4788 /** 4789 * @brief Set ADC group injected conversion trigger polarity. 4790 * Applicable only for trigger source set to external trigger. 4791 * @note On this STM32 series, setting of this feature is conditioned to 4792 * ADC state: 4793 * ADC must not be disabled. Can be enabled with or without conversion 4794 * on going on either groups regular or injected. 4795 * @rmtoll JSQR JEXTEN LL_ADC_INJ_SetTriggerEdge 4796 * @param ADCx ADC instance 4797 * @param ExternalTriggerEdge This parameter can be one of the following values: 4798 * @arg @ref LL_ADC_INJ_TRIG_EXT_RISING 4799 * @arg @ref LL_ADC_INJ_TRIG_EXT_FALLING 4800 * @arg @ref LL_ADC_INJ_TRIG_EXT_RISINGFALLING 4801 * @retval None 4802 */ 4803 __STATIC_INLINE void LL_ADC_INJ_SetTriggerEdge(ADC_TypeDef *ADCx, uint32_t ExternalTriggerEdge) 4804 { 4805 MODIFY_REG(ADCx->JSQR, ADC_JSQR_JEXTEN, ExternalTriggerEdge); 4806 } 4807 4808 /** 4809 * @brief Get ADC group injected conversion trigger polarity. 4810 * Applicable only for trigger source set to external trigger. 4811 * @rmtoll JSQR JEXTEN LL_ADC_INJ_GetTriggerEdge 4812 * @param ADCx ADC instance 4813 * @retval Returned value can be one of the following values: 4814 * @arg @ref LL_ADC_INJ_TRIG_EXT_RISING 4815 * @arg @ref LL_ADC_INJ_TRIG_EXT_FALLING 4816 * @arg @ref LL_ADC_INJ_TRIG_EXT_RISINGFALLING 4817 */ 4818 __STATIC_INLINE uint32_t LL_ADC_INJ_GetTriggerEdge(ADC_TypeDef *ADCx) 4819 { 4820 return (uint32_t)(READ_BIT(ADCx->JSQR, ADC_JSQR_JEXTEN)); 4821 } 4822 4823 /** 4824 * @brief Set ADC group injected sequencer length and scan direction. 4825 * @note This function performs configuration of: 4826 * - Sequence length: Number of ranks in the scan sequence. 4827 * - Sequence direction: Unless specified in parameters, sequencer 4828 * scan direction is forward (from rank 1 to rank n). 4829 * @note Sequencer disabled is equivalent to sequencer of 1 rank: 4830 * ADC conversion on only 1 channel. 4831 * @note On this STM32 series, setting of this feature is conditioned to 4832 * ADC state: 4833 * ADC must not be disabled. Can be enabled with or without conversion 4834 * on going on either groups regular or injected. 4835 * @rmtoll JSQR JL LL_ADC_INJ_SetSequencerLength 4836 * @param ADCx ADC instance 4837 * @param SequencerNbRanks This parameter can be one of the following values: 4838 * @arg @ref LL_ADC_INJ_SEQ_SCAN_DISABLE 4839 * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS 4840 * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS 4841 * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS 4842 * @retval None 4843 */ 4844 __STATIC_INLINE void LL_ADC_INJ_SetSequencerLength(ADC_TypeDef *ADCx, uint32_t SequencerNbRanks) 4845 { 4846 MODIFY_REG(ADCx->JSQR, ADC_JSQR_JL, SequencerNbRanks); 4847 } 4848 4849 /** 4850 * @brief Get ADC group injected sequencer length and scan direction. 4851 * @note This function retrieves: 4852 * - Sequence length: Number of ranks in the scan sequence. 4853 * - Sequence direction: Unless specified in parameters, sequencer 4854 * scan direction is forward (from rank 1 to rank n). 4855 * @note Sequencer disabled is equivalent to sequencer of 1 rank: 4856 * ADC conversion on only 1 channel. 4857 * @rmtoll JSQR JL LL_ADC_INJ_GetSequencerLength 4858 * @param ADCx ADC instance 4859 * @retval Returned value can be one of the following values: 4860 * @arg @ref LL_ADC_INJ_SEQ_SCAN_DISABLE 4861 * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS 4862 * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS 4863 * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS 4864 */ 4865 __STATIC_INLINE uint32_t LL_ADC_INJ_GetSequencerLength(ADC_TypeDef *ADCx) 4866 { 4867 return (uint32_t)(READ_BIT(ADCx->JSQR, ADC_JSQR_JL)); 4868 } 4869 4870 /** 4871 * @brief Set ADC group injected sequencer discontinuous mode: 4872 * sequence subdivided and scan conversions interrupted every selected 4873 * number of ranks. 4874 * @note It is not possible to enable both ADC group injected 4875 * auto-injected mode and sequencer discontinuous mode. 4876 * @rmtoll CFGR JDISCEN LL_ADC_INJ_SetSequencerDiscont 4877 * @param ADCx ADC instance 4878 * @param SeqDiscont This parameter can be one of the following values: 4879 * @arg @ref LL_ADC_INJ_SEQ_DISCONT_DISABLE 4880 * @arg @ref LL_ADC_INJ_SEQ_DISCONT_1RANK 4881 * @retval None 4882 */ 4883 __STATIC_INLINE void LL_ADC_INJ_SetSequencerDiscont(ADC_TypeDef *ADCx, uint32_t SeqDiscont) 4884 { 4885 MODIFY_REG(ADCx->CFGR, ADC_CFGR_JDISCEN, SeqDiscont); 4886 } 4887 4888 /** 4889 * @brief Get ADC group injected sequencer discontinuous mode: 4890 * sequence subdivided and scan conversions interrupted every selected 4891 * number of ranks. 4892 * @rmtoll CFGR JDISCEN LL_ADC_INJ_GetSequencerDiscont 4893 * @param ADCx ADC instance 4894 * @retval Returned value can be one of the following values: 4895 * @arg @ref LL_ADC_INJ_SEQ_DISCONT_DISABLE 4896 * @arg @ref LL_ADC_INJ_SEQ_DISCONT_1RANK 4897 */ 4898 __STATIC_INLINE uint32_t LL_ADC_INJ_GetSequencerDiscont(ADC_TypeDef *ADCx) 4899 { 4900 return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_JDISCEN)); 4901 } 4902 4903 /** 4904 * @brief Set ADC group injected sequence: channel on the selected 4905 * sequence rank. 4906 * @note Depending on devices and packages, some channels may not be available. 4907 * Refer to device datasheet for channels availability. 4908 * @note On this STM32 series, to measure internal channels (VrefInt, 4909 * TempSensor, ...), measurement paths to internal channels must be 4910 * enabled separately. 4911 * This can be done using function @ref LL_ADC_SetCommonPathInternalCh(). 4912 * @note On STM32H7, some fast channels are available: fast analog inputs 4913 * coming from GPIO pads (ADC_IN0..5). 4914 * @note On this STM32 series, setting of this feature is conditioned to 4915 * ADC state: 4916 * ADC must not be disabled. Can be enabled with or without conversion 4917 * on going on either groups regular or injected. 4918 * @rmtoll JSQR JSQ1 LL_ADC_INJ_SetSequencerRanks\n 4919 * JSQR JSQ2 LL_ADC_INJ_SetSequencerRanks\n 4920 * JSQR JSQ3 LL_ADC_INJ_SetSequencerRanks\n 4921 * JSQR JSQ4 LL_ADC_INJ_SetSequencerRanks 4922 * @param ADCx ADC instance 4923 * @param Rank This parameter can be one of the following values: 4924 * @arg @ref LL_ADC_INJ_RANK_1 4925 * @arg @ref LL_ADC_INJ_RANK_2 4926 * @arg @ref LL_ADC_INJ_RANK_3 4927 * @arg @ref LL_ADC_INJ_RANK_4 4928 * @param Channel This parameter can be one of the following values: 4929 * @arg @ref LL_ADC_CHANNEL_0 (3) 4930 * @arg @ref LL_ADC_CHANNEL_1 (3) 4931 * @arg @ref LL_ADC_CHANNEL_2 (3) 4932 * @arg @ref LL_ADC_CHANNEL_3 (3) 4933 * @arg @ref LL_ADC_CHANNEL_4 (3) 4934 * @arg @ref LL_ADC_CHANNEL_5 (3) 4935 * @arg @ref LL_ADC_CHANNEL_6 4936 * @arg @ref LL_ADC_CHANNEL_7 4937 * @arg @ref LL_ADC_CHANNEL_8 4938 * @arg @ref LL_ADC_CHANNEL_9 4939 * @arg @ref LL_ADC_CHANNEL_10 4940 * @arg @ref LL_ADC_CHANNEL_11 4941 * @arg @ref LL_ADC_CHANNEL_12 4942 * @arg @ref LL_ADC_CHANNEL_13 4943 * @arg @ref LL_ADC_CHANNEL_14 4944 * @arg @ref LL_ADC_CHANNEL_15 4945 * @arg @ref LL_ADC_CHANNEL_16 4946 * @arg @ref LL_ADC_CHANNEL_17 4947 * @arg @ref LL_ADC_CHANNEL_18 4948 * @arg @ref LL_ADC_CHANNEL_19 4949 * @arg @ref LL_ADC_CHANNEL_VREFINT (1) 4950 * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1) 4951 * @arg @ref LL_ADC_CHANNEL_VBAT (1) 4952 * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC2 (2) 4953 * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC2 (2) 4954 * 4955 * (1) On STM32H7, parameter available only on ADC instance: ADC3.\n 4956 * (2) On STM32H7, parameter available only on ADC instance: ADC2.\n 4957 * (3) On STM32H7, fast channel (0.125 us for 14-bit resolution (ADC conversion rate up to 8 Ms/s)). 4958 * Other channels are slow channels (conversion rate: refer to reference manual). 4959 * @retval None 4960 */ 4961 __STATIC_INLINE void LL_ADC_INJ_SetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank, uint32_t Channel) 4962 { 4963 /* Set bits with content of parameter "Channel" with bits position */ 4964 /* in register depending on parameter "Rank". */ 4965 /* Parameters "Rank" and "Channel" are used with masks because containing */ 4966 /* other bits reserved for other purpose. */ 4967 MODIFY_REG(ADCx->JSQR, 4968 (ADC_CHANNEL_ID_NUMBER_MASK >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) << (Rank & ADC_INJ_RANK_ID_JSQR_MASK), 4969 ((Channel & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) << (Rank & ADC_INJ_RANK_ID_JSQR_MASK)); 4970 } 4971 4972 /** 4973 * @brief Get ADC group injected sequence: channel on the selected 4974 * sequence rank. 4975 * @note Depending on devices and packages, some channels may not be available. 4976 * Refer to device datasheet for channels availability. 4977 * @note Usage of the returned channel number: 4978 * - To reinject this channel into another function LL_ADC_xxx: 4979 * the returned channel number is only partly formatted on definition 4980 * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared 4981 * with parts of literals LL_ADC_CHANNEL_x or using 4982 * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB(). 4983 * Then the selected literal LL_ADC_CHANNEL_x can be used 4984 * as parameter for another function. 4985 * - To get the channel number in decimal format: 4986 * process the returned value with the helper macro 4987 * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB(). 4988 * @rmtoll JSQR JSQ1 LL_ADC_INJ_GetSequencerRanks\n 4989 * JSQR JSQ2 LL_ADC_INJ_GetSequencerRanks\n 4990 * JSQR JSQ3 LL_ADC_INJ_GetSequencerRanks\n 4991 * JSQR JSQ4 LL_ADC_INJ_GetSequencerRanks 4992 * @param ADCx ADC instance 4993 * @param Rank This parameter can be one of the following values: 4994 * @arg @ref LL_ADC_INJ_RANK_1 4995 * @arg @ref LL_ADC_INJ_RANK_2 4996 * @arg @ref LL_ADC_INJ_RANK_3 4997 * @arg @ref LL_ADC_INJ_RANK_4 4998 * @retval Returned value can be one of the following values: 4999 * @arg @ref LL_ADC_CHANNEL_0 (3) 5000 * @arg @ref LL_ADC_CHANNEL_1 (3) 5001 * @arg @ref LL_ADC_CHANNEL_2 (3) 5002 * @arg @ref LL_ADC_CHANNEL_3 (3) 5003 * @arg @ref LL_ADC_CHANNEL_4 (3) 5004 * @arg @ref LL_ADC_CHANNEL_5 (3) 5005 * @arg @ref LL_ADC_CHANNEL_6 5006 * @arg @ref LL_ADC_CHANNEL_7 5007 * @arg @ref LL_ADC_CHANNEL_8 5008 * @arg @ref LL_ADC_CHANNEL_9 5009 * @arg @ref LL_ADC_CHANNEL_10 5010 * @arg @ref LL_ADC_CHANNEL_11 5011 * @arg @ref LL_ADC_CHANNEL_12 5012 * @arg @ref LL_ADC_CHANNEL_13 5013 * @arg @ref LL_ADC_CHANNEL_14 5014 * @arg @ref LL_ADC_CHANNEL_15 5015 * @arg @ref LL_ADC_CHANNEL_16 5016 * @arg @ref LL_ADC_CHANNEL_17 5017 * @arg @ref LL_ADC_CHANNEL_18 5018 * @arg @ref LL_ADC_CHANNEL_19 5019 * @arg @ref LL_ADC_CHANNEL_VREFINT (1) 5020 * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1) 5021 * @arg @ref LL_ADC_CHANNEL_VBAT (1) 5022 * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC2 (2) 5023 * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC2 (2) 5024 * 5025 * (1) On STM32H7, parameter available only on ADC instance: ADC3.\n 5026 * (2) On STM32H7, parameter available only on ADC instance: ADC2.\n 5027 * (3) On STM32H7, fast channel (0.125 us for 14-bit resolution (ADC conversion rate up to 8 Ms/s)). 5028 * Other channels are slow channels (conversion rate: refer to reference manual).\n 5029 * (1, 2) For ADC channel read back from ADC register, 5030 * comparison with internal channel parameter to be done 5031 * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL(). 5032 */ 5033 __STATIC_INLINE uint32_t LL_ADC_INJ_GetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank) 5034 { 5035 return (uint32_t)((READ_BIT(ADCx->JSQR, 5036 (ADC_CHANNEL_ID_NUMBER_MASK >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) << (Rank & ADC_INJ_RANK_ID_JSQR_MASK)) 5037 >> (Rank & ADC_INJ_RANK_ID_JSQR_MASK)) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS 5038 ); 5039 } 5040 5041 /** 5042 * @brief Set ADC group injected conversion trigger: 5043 * independent or from ADC group regular. 5044 * @note This mode can be used to extend number of data registers 5045 * updated after one ADC conversion trigger and with data 5046 * permanently kept (not erased by successive conversions of scan of 5047 * ADC sequencer ranks), up to 5 data registers: 5048 * 1 data register on ADC group regular, 4 data registers 5049 * on ADC group injected. 5050 * @note If ADC group injected injected trigger source is set to an 5051 * external trigger, this feature must be must be set to 5052 * independent trigger. 5053 * ADC group injected automatic trigger is compliant only with 5054 * group injected trigger source set to SW start, without any 5055 * further action on ADC group injected conversion start or stop: 5056 * in this case, ADC group injected is controlled only 5057 * from ADC group regular. 5058 * @note It is not possible to enable both ADC group injected 5059 * auto-injected mode and sequencer discontinuous mode. 5060 * @note On this STM32 series, setting of this feature is conditioned to 5061 * ADC state: 5062 * ADC must be disabled or enabled without conversion on going 5063 * on either groups regular or injected. 5064 * @rmtoll CFGR JAUTO LL_ADC_INJ_SetTrigAuto 5065 * @param ADCx ADC instance 5066 * @param TrigAuto This parameter can be one of the following values: 5067 * @arg @ref LL_ADC_INJ_TRIG_INDEPENDENT 5068 * @arg @ref LL_ADC_INJ_TRIG_FROM_GRP_REGULAR 5069 * @retval None 5070 */ 5071 __STATIC_INLINE void LL_ADC_INJ_SetTrigAuto(ADC_TypeDef *ADCx, uint32_t TrigAuto) 5072 { 5073 MODIFY_REG(ADCx->CFGR, ADC_CFGR_JAUTO, TrigAuto); 5074 } 5075 5076 /** 5077 * @brief Get ADC group injected conversion trigger: 5078 * independent or from ADC group regular. 5079 * @rmtoll CFGR JAUTO LL_ADC_INJ_GetTrigAuto 5080 * @param ADCx ADC instance 5081 * @retval Returned value can be one of the following values: 5082 * @arg @ref LL_ADC_INJ_TRIG_INDEPENDENT 5083 * @arg @ref LL_ADC_INJ_TRIG_FROM_GRP_REGULAR 5084 */ 5085 __STATIC_INLINE uint32_t LL_ADC_INJ_GetTrigAuto(ADC_TypeDef *ADCx) 5086 { 5087 return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_JAUTO)); 5088 } 5089 5090 /** 5091 * @brief Set ADC group injected contexts queue mode. 5092 * @note A context is a setting of group injected sequencer: 5093 * - group injected trigger 5094 * - sequencer length 5095 * - sequencer ranks 5096 * If contexts queue is disabled: 5097 * - only 1 sequence can be configured 5098 * and is active perpetually. 5099 * If contexts queue is enabled: 5100 * - up to 2 contexts can be queued 5101 * and are checked in and out as a FIFO stack (first-in, first-out). 5102 * - If a new context is set when queues is full, error is triggered 5103 * by interruption "Injected Queue Overflow". 5104 * - Two behaviors are possible when all contexts have been processed: 5105 * the contexts queue can maintain the last context active perpetually 5106 * or can be empty and injected group triggers are disabled. 5107 * - Triggers can be only external (not internal SW start) 5108 * - Caution: The sequence must be fully configured in one time 5109 * (one write of register JSQR makes a check-in of a new context 5110 * into the queue). 5111 * Therefore functions to set separately injected trigger and 5112 * sequencer channels cannot be used, register JSQR must be set 5113 * using function @ref LL_ADC_INJ_ConfigQueueContext(). 5114 * @note This parameter can be modified only when no conversion is on going 5115 * on either groups regular or injected. 5116 * @note A modification of the context mode (bit JQDIS) causes the contexts 5117 * queue to be flushed and the register JSQR is cleared. 5118 * @note On this STM32 series, setting of this feature is conditioned to 5119 * ADC state: 5120 * ADC must be disabled or enabled without conversion on going 5121 * on either groups regular or injected. 5122 * @rmtoll CFGR JQM LL_ADC_INJ_SetQueueMode\n 5123 * CFGR JQDIS LL_ADC_INJ_SetQueueMode 5124 * @param ADCx ADC instance 5125 * @param QueueMode This parameter can be one of the following values: 5126 * @arg @ref LL_ADC_INJ_QUEUE_DISABLE 5127 * @arg @ref LL_ADC_INJ_QUEUE_2CONTEXTS_LAST_ACTIVE 5128 * @arg @ref LL_ADC_INJ_QUEUE_2CONTEXTS_END_EMPTY 5129 * @retval None 5130 */ 5131 __STATIC_INLINE void LL_ADC_INJ_SetQueueMode(ADC_TypeDef *ADCx, uint32_t QueueMode) 5132 { 5133 MODIFY_REG(ADCx->CFGR, ADC_CFGR_JQM | ADC_CFGR_JQDIS, QueueMode); 5134 } 5135 5136 /** 5137 * @brief Get ADC group injected context queue mode. 5138 * @rmtoll CFGR JQM LL_ADC_INJ_GetQueueMode\n 5139 * CFGR JQDIS LL_ADC_INJ_GetQueueMode 5140 * @param ADCx ADC instance 5141 * @retval Returned value can be one of the following values: 5142 * @arg @ref LL_ADC_INJ_QUEUE_DISABLE 5143 * @arg @ref LL_ADC_INJ_QUEUE_2CONTEXTS_LAST_ACTIVE 5144 * @arg @ref LL_ADC_INJ_QUEUE_2CONTEXTS_END_EMPTY 5145 */ 5146 __STATIC_INLINE uint32_t LL_ADC_INJ_GetQueueMode(ADC_TypeDef *ADCx) 5147 { 5148 return (uint32_t)(READ_BIT(ADCx->CFGR, ADC_CFGR_JQM | ADC_CFGR_JQDIS)); 5149 } 5150 5151 /** 5152 * @brief Set one context on ADC group injected that will be checked in 5153 * contexts queue. 5154 * @note A context is a setting of group injected sequencer: 5155 * - group injected trigger 5156 * - sequencer length 5157 * - sequencer ranks 5158 * This function is intended to be used when contexts queue is enabled, 5159 * because the sequence must be fully configured in one time 5160 * (functions to set separately injected trigger and sequencer channels 5161 * cannot be used): 5162 * Refer to function @ref LL_ADC_INJ_SetQueueMode(). 5163 * @note In the contexts queue, only the active context can be read. 5164 * The parameters of this function can be read using functions: 5165 * @arg @ref LL_ADC_INJ_GetTriggerSource() 5166 * @arg @ref LL_ADC_INJ_GetTriggerEdge() 5167 * @arg @ref LL_ADC_INJ_GetSequencerRanks() 5168 * @note On this STM32 series, to measure internal channels (VrefInt, 5169 * TempSensor, ...), measurement paths to internal channels must be 5170 * enabled separately. 5171 * This can be done using function @ref LL_ADC_SetCommonPathInternalCh(). 5172 * @note On STM32H7, some fast channels are available: fast analog inputs 5173 * coming from GPIO pads (ADC_IN0..5). 5174 * @note On this STM32 series, setting of this feature is conditioned to 5175 * ADC state: 5176 * ADC must not be disabled. Can be enabled with or without conversion 5177 * on going on either groups regular or injected. 5178 * @rmtoll JSQR JEXTSEL LL_ADC_INJ_ConfigQueueContext\n 5179 * JSQR JEXTEN LL_ADC_INJ_ConfigQueueContext\n 5180 * JSQR JL LL_ADC_INJ_ConfigQueueContext\n 5181 * JSQR JSQ1 LL_ADC_INJ_ConfigQueueContext\n 5182 * JSQR JSQ2 LL_ADC_INJ_ConfigQueueContext\n 5183 * JSQR JSQ3 LL_ADC_INJ_ConfigQueueContext\n 5184 * JSQR JSQ4 LL_ADC_INJ_ConfigQueueContext 5185 * @param ADCx ADC instance 5186 * @param TriggerSource This parameter can be one of the following values: 5187 * @arg @ref LL_ADC_INJ_TRIG_SOFTWARE 5188 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_TRGO 5189 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_CH4 5190 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO 5191 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_CH1 5192 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH4 5193 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO 5194 * @arg @ref LL_ADC_INJ_TRIG_EXT_EXTI_LINE15 5195 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_CH4 5196 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM1_TRGO2 5197 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_TRGO 5198 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM8_TRGO2 5199 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH3 5200 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_TRGO 5201 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH1 5202 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM6_TRGO 5203 * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM15_TRGO 5204 * @arg @ref LL_ADC_INJ_TRIG_EXT_HRTIM_TRG2 5205 * @arg @ref LL_ADC_INJ_TRIG_EXT_HRTIM_TRG4 5206 * @arg @ref LL_ADC_INJ_TRIG_EXT_LPTIM1_OUT 5207 * @arg @ref LL_ADC_INJ_TRIG_EXT_LPTIM2_OUT 5208 * @arg @ref LL_ADC_INJ_TRIG_EXT_LPTIM3_OUT 5209 * @param ExternalTriggerEdge This parameter can be one of the following values: 5210 * @arg @ref LL_ADC_INJ_TRIG_EXT_RISING 5211 * @arg @ref LL_ADC_INJ_TRIG_EXT_FALLING 5212 * @arg @ref LL_ADC_INJ_TRIG_EXT_RISINGFALLING 5213 * 5214 * Note: This parameter is discarded in case of SW start: 5215 * parameter "TriggerSource" set to "LL_ADC_INJ_TRIG_SOFTWARE". 5216 * @param SequencerNbRanks This parameter can be one of the following values: 5217 * @arg @ref LL_ADC_INJ_SEQ_SCAN_DISABLE 5218 * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS 5219 * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS 5220 * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS 5221 * @param Rank1_Channel This parameter can be one of the following values: 5222 * @arg @ref LL_ADC_CHANNEL_0 (3) 5223 * @arg @ref LL_ADC_CHANNEL_1 (3) 5224 * @arg @ref LL_ADC_CHANNEL_2 (3) 5225 * @arg @ref LL_ADC_CHANNEL_3 (3) 5226 * @arg @ref LL_ADC_CHANNEL_4 (3) 5227 * @arg @ref LL_ADC_CHANNEL_5 (3) 5228 * @arg @ref LL_ADC_CHANNEL_6 5229 * @arg @ref LL_ADC_CHANNEL_7 5230 * @arg @ref LL_ADC_CHANNEL_8 5231 * @arg @ref LL_ADC_CHANNEL_9 5232 * @arg @ref LL_ADC_CHANNEL_10 5233 * @arg @ref LL_ADC_CHANNEL_11 5234 * @arg @ref LL_ADC_CHANNEL_12 5235 * @arg @ref LL_ADC_CHANNEL_13 5236 * @arg @ref LL_ADC_CHANNEL_14 5237 * @arg @ref LL_ADC_CHANNEL_15 5238 * @arg @ref LL_ADC_CHANNEL_16 5239 * @arg @ref LL_ADC_CHANNEL_17 5240 * @arg @ref LL_ADC_CHANNEL_18 5241 * @arg @ref LL_ADC_CHANNEL_19 5242 * @arg @ref LL_ADC_CHANNEL_VREFINT (1) 5243 * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1) 5244 * @arg @ref LL_ADC_CHANNEL_VBAT (1) 5245 * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC2 (2) 5246 * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC2 (2) 5247 * 5248 * (1) On STM32H7, parameter available only on ADC instance: ADC3.\n 5249 * (2) On STM32H7, parameter available only on ADC instance: ADC2.\n 5250 * (3) On STM32H7, fast channel (0.125 us for 14-bit resolution (ADC conversion rate up to 8 Ms/s)). 5251 * Other channels are slow channels (conversion rate: refer to reference manual). 5252 * @param Rank2_Channel This parameter can be one of the following values: 5253 * @arg @ref LL_ADC_CHANNEL_0 (3) 5254 * @arg @ref LL_ADC_CHANNEL_1 (3) 5255 * @arg @ref LL_ADC_CHANNEL_2 (3) 5256 * @arg @ref LL_ADC_CHANNEL_3 (3) 5257 * @arg @ref LL_ADC_CHANNEL_4 (3) 5258 * @arg @ref LL_ADC_CHANNEL_5 (3) 5259 * @arg @ref LL_ADC_CHANNEL_6 5260 * @arg @ref LL_ADC_CHANNEL_7 5261 * @arg @ref LL_ADC_CHANNEL_8 5262 * @arg @ref LL_ADC_CHANNEL_9 5263 * @arg @ref LL_ADC_CHANNEL_10 5264 * @arg @ref LL_ADC_CHANNEL_11 5265 * @arg @ref LL_ADC_CHANNEL_12 5266 * @arg @ref LL_ADC_CHANNEL_13 5267 * @arg @ref LL_ADC_CHANNEL_14 5268 * @arg @ref LL_ADC_CHANNEL_15 5269 * @arg @ref LL_ADC_CHANNEL_16 5270 * @arg @ref LL_ADC_CHANNEL_17 5271 * @arg @ref LL_ADC_CHANNEL_18 5272 * @arg @ref LL_ADC_CHANNEL_19 5273 * @arg @ref LL_ADC_CHANNEL_VREFINT (1) 5274 * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1) 5275 * @arg @ref LL_ADC_CHANNEL_VBAT (1) 5276 * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC2 (2) 5277 * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC2 (2) 5278 * 5279 * (1) On STM32H7, parameter available only on ADC instance: ADC3.\n 5280 * (2) On STM32H7, parameter available only on ADC instance: ADC2.\n 5281 * (3) On STM32H7, fast channel (0.125 us for 14-bit resolution (ADC conversion rate up to 8 Ms/s)). 5282 * Other channels are slow channels (conversion rate: refer to reference manual). 5283 * @param Rank3_Channel This parameter can be one of the following values: 5284 * @arg @ref LL_ADC_CHANNEL_0 (3) 5285 * @arg @ref LL_ADC_CHANNEL_1 (3) 5286 * @arg @ref LL_ADC_CHANNEL_2 (3) 5287 * @arg @ref LL_ADC_CHANNEL_3 (3) 5288 * @arg @ref LL_ADC_CHANNEL_4 (3) 5289 * @arg @ref LL_ADC_CHANNEL_5 (3) 5290 * @arg @ref LL_ADC_CHANNEL_6 5291 * @arg @ref LL_ADC_CHANNEL_7 5292 * @arg @ref LL_ADC_CHANNEL_8 5293 * @arg @ref LL_ADC_CHANNEL_9 5294 * @arg @ref LL_ADC_CHANNEL_10 5295 * @arg @ref LL_ADC_CHANNEL_11 5296 * @arg @ref LL_ADC_CHANNEL_12 5297 * @arg @ref LL_ADC_CHANNEL_13 5298 * @arg @ref LL_ADC_CHANNEL_14 5299 * @arg @ref LL_ADC_CHANNEL_15 5300 * @arg @ref LL_ADC_CHANNEL_16 5301 * @arg @ref LL_ADC_CHANNEL_17 5302 * @arg @ref LL_ADC_CHANNEL_18 5303 * @arg @ref LL_ADC_CHANNEL_19 5304 * @arg @ref LL_ADC_CHANNEL_VREFINT (1) 5305 * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1) 5306 * @arg @ref LL_ADC_CHANNEL_VBAT (1) 5307 * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC2 (2) 5308 * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC2 (2) 5309 * 5310 * (1) On STM32H7, parameter available only on ADC instance: ADC3.\n 5311 * (2) On STM32H7, parameter available only on ADC instance: ADC2.\n 5312 * (3) On STM32H7, fast channel (0.125 us for 14-bit resolution (ADC conversion rate up to 8 Ms/s)). 5313 * Other channels are slow channels (conversion rate: refer to reference manual). 5314 * @param Rank4_Channel This parameter can be one of the following values: 5315 * @arg @ref LL_ADC_CHANNEL_0 (3) 5316 * @arg @ref LL_ADC_CHANNEL_1 (3) 5317 * @arg @ref LL_ADC_CHANNEL_2 (3) 5318 * @arg @ref LL_ADC_CHANNEL_3 (3) 5319 * @arg @ref LL_ADC_CHANNEL_4 (3) 5320 * @arg @ref LL_ADC_CHANNEL_5 (3) 5321 * @arg @ref LL_ADC_CHANNEL_6 5322 * @arg @ref LL_ADC_CHANNEL_7 5323 * @arg @ref LL_ADC_CHANNEL_8 5324 * @arg @ref LL_ADC_CHANNEL_9 5325 * @arg @ref LL_ADC_CHANNEL_10 5326 * @arg @ref LL_ADC_CHANNEL_11 5327 * @arg @ref LL_ADC_CHANNEL_12 5328 * @arg @ref LL_ADC_CHANNEL_13 5329 * @arg @ref LL_ADC_CHANNEL_14 5330 * @arg @ref LL_ADC_CHANNEL_15 5331 * @arg @ref LL_ADC_CHANNEL_16 5332 * @arg @ref LL_ADC_CHANNEL_17 5333 * @arg @ref LL_ADC_CHANNEL_18 5334 * @arg @ref LL_ADC_CHANNEL_19 5335 * @arg @ref LL_ADC_CHANNEL_VREFINT (1) 5336 * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1) 5337 * @arg @ref LL_ADC_CHANNEL_VBAT (1) 5338 * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC2 (2) 5339 * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC2 (2) 5340 * 5341 * (1) On STM32H7, parameter available only on ADC instance: ADC3.\n 5342 * (2) On STM32H7, parameter available only on ADC instance: ADC2.\n 5343 * (3) On STM32H7, fast channel (0.125 us for 14-bit resolution (ADC conversion rate up to 8 Ms/s)). 5344 * Other channels are slow channels (conversion rate: refer to reference manual). 5345 * @retval None 5346 */ 5347 __STATIC_INLINE void LL_ADC_INJ_ConfigQueueContext(ADC_TypeDef *ADCx, 5348 uint32_t TriggerSource, 5349 uint32_t ExternalTriggerEdge, 5350 uint32_t SequencerNbRanks, 5351 uint32_t Rank1_Channel, 5352 uint32_t Rank2_Channel, 5353 uint32_t Rank3_Channel, 5354 uint32_t Rank4_Channel) 5355 { 5356 /* Set bits with content of parameter "Rankx_Channel" with bits position */ 5357 /* in register depending on literal "LL_ADC_INJ_RANK_x". */ 5358 /* Parameters "Rankx_Channel" and "LL_ADC_INJ_RANK_x" are used with masks */ 5359 /* because containing other bits reserved for other purpose. */ 5360 /* If parameter "TriggerSource" is set to SW start, then parameter */ 5361 /* "ExternalTriggerEdge" is discarded. */ 5362 uint32_t is_trigger_not_sw = (uint32_t)((TriggerSource != LL_ADC_INJ_TRIG_SOFTWARE) ? 1UL : 0UL); 5363 MODIFY_REG(ADCx->JSQR, 5364 ADC_JSQR_JEXTSEL | 5365 ADC_JSQR_JEXTEN | 5366 ADC_JSQR_JSQ4 | 5367 ADC_JSQR_JSQ3 | 5368 ADC_JSQR_JSQ2 | 5369 ADC_JSQR_JSQ1 | 5370 ADC_JSQR_JL, 5371 (TriggerSource & ADC_JSQR_JEXTSEL) | 5372 (ExternalTriggerEdge * (is_trigger_not_sw)) | 5373 (((Rank4_Channel & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) << (LL_ADC_INJ_RANK_4 & ADC_INJ_RANK_ID_JSQR_MASK)) | 5374 (((Rank3_Channel & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) << (LL_ADC_INJ_RANK_3 & ADC_INJ_RANK_ID_JSQR_MASK)) | 5375 (((Rank2_Channel & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) << (LL_ADC_INJ_RANK_2 & ADC_INJ_RANK_ID_JSQR_MASK)) | 5376 (((Rank1_Channel & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) << (LL_ADC_INJ_RANK_1 & ADC_INJ_RANK_ID_JSQR_MASK)) | 5377 SequencerNbRanks 5378 ); 5379 } 5380 5381 /** 5382 * @} 5383 */ 5384 5385 /** @defgroup ADC_LL_EF_Configuration_Channels Configuration of ADC hierarchical scope: channels 5386 * @ingroup RTEMSBSPsARMSTM32H7 5387 * @{ 5388 */ 5389 5390 /** 5391 * @brief Set sampling time of the selected ADC channel 5392 * Unit: ADC clock cycles. 5393 * @note On this device, sampling time is on channel scope: independently 5394 * of channel mapped on ADC group regular or injected. 5395 * @note In case of internal channel (VrefInt, TempSensor, ...) to be 5396 * converted: 5397 * sampling time constraints must be respected (sampling time can be 5398 * adjusted in function of ADC clock frequency and sampling time 5399 * setting). 5400 * Refer to device datasheet for timings values (parameters TS_vrefint, 5401 * TS_temp, ...). 5402 * @note Conversion time is the addition of sampling time and processing time. 5403 * On this STM32 series, ADC processing time is: 5404 * - 12.5 ADC clock cycles at ADC resolution 12 bits 5405 * - 10.5 ADC clock cycles at ADC resolution 10 bits 5406 * - 8.5 ADC clock cycles at ADC resolution 8 bits 5407 * - 6.5 ADC clock cycles at ADC resolution 6 bits 5408 * @note In case of ADC conversion of internal channel (VrefInt, 5409 * temperature sensor, ...), a sampling time minimum value 5410 * is required. 5411 * Refer to device datasheet. 5412 * @note On this STM32 series, setting of this feature is conditioned to 5413 * ADC state: 5414 * ADC must be disabled or enabled without conversion on going 5415 * on either groups regular or injected. 5416 * @rmtoll SMPR1 SMP0 LL_ADC_SetChannelSamplingTime\n 5417 * SMPR1 SMP1 LL_ADC_SetChannelSamplingTime\n 5418 * SMPR1 SMP2 LL_ADC_SetChannelSamplingTime\n 5419 * SMPR1 SMP3 LL_ADC_SetChannelSamplingTime\n 5420 * SMPR1 SMP4 LL_ADC_SetChannelSamplingTime\n 5421 * SMPR1 SMP5 LL_ADC_SetChannelSamplingTime\n 5422 * SMPR1 SMP6 LL_ADC_SetChannelSamplingTime\n 5423 * SMPR1 SMP7 LL_ADC_SetChannelSamplingTime\n 5424 * SMPR1 SMP8 LL_ADC_SetChannelSamplingTime\n 5425 * SMPR1 SMP9 LL_ADC_SetChannelSamplingTime\n 5426 * SMPR2 SMP10 LL_ADC_SetChannelSamplingTime\n 5427 * SMPR2 SMP11 LL_ADC_SetChannelSamplingTime\n 5428 * SMPR2 SMP12 LL_ADC_SetChannelSamplingTime\n 5429 * SMPR2 SMP13 LL_ADC_SetChannelSamplingTime\n 5430 * SMPR2 SMP14 LL_ADC_SetChannelSamplingTime\n 5431 * SMPR2 SMP15 LL_ADC_SetChannelSamplingTime\n 5432 * SMPR2 SMP16 LL_ADC_SetChannelSamplingTime\n 5433 * SMPR2 SMP17 LL_ADC_SetChannelSamplingTime\n 5434 * SMPR2 SMP18 LL_ADC_SetChannelSamplingTime 5435 * @param ADCx ADC instance 5436 * @param Channel This parameter can be one of the following values: 5437 * @arg @ref LL_ADC_CHANNEL_0 (3) 5438 * @arg @ref LL_ADC_CHANNEL_1 (3) 5439 * @arg @ref LL_ADC_CHANNEL_2 (3) 5440 * @arg @ref LL_ADC_CHANNEL_3 (3) 5441 * @arg @ref LL_ADC_CHANNEL_4 (3) 5442 * @arg @ref LL_ADC_CHANNEL_5 (3) 5443 * @arg @ref LL_ADC_CHANNEL_6 5444 * @arg @ref LL_ADC_CHANNEL_7 5445 * @arg @ref LL_ADC_CHANNEL_8 5446 * @arg @ref LL_ADC_CHANNEL_9 5447 * @arg @ref LL_ADC_CHANNEL_10 5448 * @arg @ref LL_ADC_CHANNEL_11 5449 * @arg @ref LL_ADC_CHANNEL_12 5450 * @arg @ref LL_ADC_CHANNEL_13 5451 * @arg @ref LL_ADC_CHANNEL_14 5452 * @arg @ref LL_ADC_CHANNEL_15 5453 * @arg @ref LL_ADC_CHANNEL_16 5454 * @arg @ref LL_ADC_CHANNEL_17 5455 * @arg @ref LL_ADC_CHANNEL_18 5456 * @arg @ref LL_ADC_CHANNEL_19 5457 * @arg @ref LL_ADC_CHANNEL_VREFINT (1) 5458 * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1) 5459 * @arg @ref LL_ADC_CHANNEL_VBAT (1) 5460 * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC2 (2) 5461 * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC2 (2) 5462 * 5463 * (1) On STM32H7, parameter available only on ADC instance: ADC3.\n 5464 * (2) On STM32H7, parameter available only on ADC instance: ADC2.\n 5465 * (3) On STM32H7, fast channel (0.125 us for 14-bit resolution (ADC conversion rate up to 8 Ms/s)). 5466 * Other channels are slow channels (conversion rate: refer to reference manual). 5467 * @param SamplingTime This parameter can be one of the following values: 5468 * @arg @ref LL_ADC_SAMPLINGTIME_1CYCLE_5 5469 * @arg @ref LL_ADC_SAMPLINGTIME_2CYCLES_5 5470 * @arg @ref LL_ADC_SAMPLINGTIME_8CYCLES_5 5471 * @arg @ref LL_ADC_SAMPLINGTIME_16CYCLES_5 5472 * @arg @ref LL_ADC_SAMPLINGTIME_32CYCLES_5 5473 * @arg @ref LL_ADC_SAMPLINGTIME_64CYCLES_5 5474 * @arg @ref LL_ADC_SAMPLINGTIME_387CYCLES_5 5475 * @arg @ref LL_ADC_SAMPLINGTIME_810CYCLES_5 5476 * @retval None 5477 */ 5478 __STATIC_INLINE void LL_ADC_SetChannelSamplingTime(ADC_TypeDef *ADCx, uint32_t Channel, uint32_t SamplingTime) 5479 { 5480 /* Set bits with content of parameter "SamplingTime" with bits position */ 5481 /* in register and register position depending on parameter "Channel". */ 5482 /* Parameter "Channel" is used with masks because containing */ 5483 /* other bits reserved for other purpose. */ 5484 __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SMPR1, ((Channel & ADC_CHANNEL_SMPRX_REGOFFSET_MASK) >> ADC_SMPRX_REGOFFSET_POS)); 5485 5486 MODIFY_REG(*preg, 5487 ADC_SMPR1_SMP0 << ((Channel & ADC_CHANNEL_SMPx_BITOFFSET_MASK) >> ADC_CHANNEL_SMPx_BITOFFSET_POS), 5488 SamplingTime << ((Channel & ADC_CHANNEL_SMPx_BITOFFSET_MASK) >> ADC_CHANNEL_SMPx_BITOFFSET_POS)); 5489 } 5490 5491 /** 5492 * @brief Get sampling time of the selected ADC channel 5493 * Unit: ADC clock cycles. 5494 * @note On this device, sampling time is on channel scope: independently 5495 * of channel mapped on ADC group regular or injected. 5496 * @note Conversion time is the addition of sampling time and processing time. 5497 * On this STM32 series, ADC processing time is: 5498 * - 12.5 ADC clock cycles at ADC resolution 12 bits 5499 * - 10.5 ADC clock cycles at ADC resolution 10 bits 5500 * - 8.5 ADC clock cycles at ADC resolution 8 bits 5501 * - 6.5 ADC clock cycles at ADC resolution 6 bits 5502 * @rmtoll SMPR1 SMP0 LL_ADC_GetChannelSamplingTime\n 5503 * SMPR1 SMP1 LL_ADC_GetChannelSamplingTime\n 5504 * SMPR1 SMP2 LL_ADC_GetChannelSamplingTime\n 5505 * SMPR1 SMP3 LL_ADC_GetChannelSamplingTime\n 5506 * SMPR1 SMP4 LL_ADC_GetChannelSamplingTime\n 5507 * SMPR1 SMP5 LL_ADC_GetChannelSamplingTime\n 5508 * SMPR1 SMP6 LL_ADC_GetChannelSamplingTime\n 5509 * SMPR1 SMP7 LL_ADC_GetChannelSamplingTime\n 5510 * SMPR1 SMP8 LL_ADC_GetChannelSamplingTime\n 5511 * SMPR1 SMP9 LL_ADC_GetChannelSamplingTime\n 5512 * SMPR2 SMP10 LL_ADC_GetChannelSamplingTime\n 5513 * SMPR2 SMP11 LL_ADC_GetChannelSamplingTime\n 5514 * SMPR2 SMP12 LL_ADC_GetChannelSamplingTime\n 5515 * SMPR2 SMP13 LL_ADC_GetChannelSamplingTime\n 5516 * SMPR2 SMP14 LL_ADC_GetChannelSamplingTime\n 5517 * SMPR2 SMP15 LL_ADC_GetChannelSamplingTime\n 5518 * SMPR2 SMP16 LL_ADC_GetChannelSamplingTime\n 5519 * SMPR2 SMP17 LL_ADC_GetChannelSamplingTime\n 5520 * SMPR2 SMP18 LL_ADC_GetChannelSamplingTime 5521 * @param ADCx ADC instance 5522 * @param Channel This parameter can be one of the following values: 5523 * @arg @ref LL_ADC_CHANNEL_0 (3) 5524 * @arg @ref LL_ADC_CHANNEL_1 (3) 5525 * @arg @ref LL_ADC_CHANNEL_2 (3) 5526 * @arg @ref LL_ADC_CHANNEL_3 (3) 5527 * @arg @ref LL_ADC_CHANNEL_4 (3) 5528 * @arg @ref LL_ADC_CHANNEL_5 (3) 5529 * @arg @ref LL_ADC_CHANNEL_6 5530 * @arg @ref LL_ADC_CHANNEL_7 5531 * @arg @ref LL_ADC_CHANNEL_8 5532 * @arg @ref LL_ADC_CHANNEL_9 5533 * @arg @ref LL_ADC_CHANNEL_10 5534 * @arg @ref LL_ADC_CHANNEL_11 5535 * @arg @ref LL_ADC_CHANNEL_12 5536 * @arg @ref LL_ADC_CHANNEL_13 5537 * @arg @ref LL_ADC_CHANNEL_14 5538 * @arg @ref LL_ADC_CHANNEL_15 5539 * @arg @ref LL_ADC_CHANNEL_16 5540 * @arg @ref LL_ADC_CHANNEL_17 5541 * @arg @ref LL_ADC_CHANNEL_18 5542 * @arg @ref LL_ADC_CHANNEL_19 5543 * @arg @ref LL_ADC_CHANNEL_VREFINT (1) 5544 * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (1) 5545 * @arg @ref LL_ADC_CHANNEL_VBAT (1) 5546 * @arg @ref LL_ADC_CHANNEL_DAC1CH1_ADC2 (2) 5547 * @arg @ref LL_ADC_CHANNEL_DAC1CH2_ADC2 (2) 5548 * 5549 * (1) On STM32H7, parameter available only on ADC instance: ADC3.\n 5550 * (2) On STM32H7, parameter available only on ADC instance: ADC2.\n 5551 * (3) On STM32H7, fast channel (0.125 us for 14-bit resolution (ADC conversion rate up to 8 Ms/s)). 5552 * Other channels are slow channels (conversion rate: refer to reference manual). 5553 * @retval Returned value can be one of the following values: 5554 * @arg @ref LL_ADC_SAMPLINGTIME_1CYCLE_5 5555 * @arg @ref LL_ADC_SAMPLINGTIME_2CYCLES_5 5556 * @arg @ref LL_ADC_SAMPLINGTIME_8CYCLES_5 5557 * @arg @ref LL_ADC_SAMPLINGTIME_16CYCLES_5 5558 * @arg @ref LL_ADC_SAMPLINGTIME_32CYCLES_5 5559 * @arg @ref LL_ADC_SAMPLINGTIME_64CYCLES_5 5560 * @arg @ref LL_ADC_SAMPLINGTIME_387CYCLES_5 5561 * @arg @ref LL_ADC_SAMPLINGTIME_810CYCLES_5 5562 */ 5563 __STATIC_INLINE uint32_t LL_ADC_GetChannelSamplingTime(ADC_TypeDef *ADCx, uint32_t Channel) 5564 { 5565 const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SMPR1, ((Channel & ADC_CHANNEL_SMPRX_REGOFFSET_MASK) >> ADC_SMPRX_REGOFFSET_POS)); 5566 5567 return (uint32_t)(READ_BIT(*preg, 5568 ADC_SMPR1_SMP0 << ((Channel & ADC_CHANNEL_SMPx_BITOFFSET_MASK) >> ADC_CHANNEL_SMPx_BITOFFSET_POS)) 5569 >> ((Channel & ADC_CHANNEL_SMPx_BITOFFSET_MASK) >> ADC_CHANNEL_SMPx_BITOFFSET_POS) 5570 ); 5571 } 5572 5573 /** 5574 * @brief Set mode single-ended or differential input of the selected 5575 * ADC channel. 5576 * @note Channel ending is on channel scope: independently of channel mapped 5577 * on ADC group regular or injected. 5578 * In differential mode: Differential measurement is carried out 5579 * between the selected channel 'i' (positive input) and 5580 * channel 'i+1' (negative input). Only channel 'i' has to be 5581 * configured, channel 'i+1' is configured automatically. 5582 * @note Refer to Reference Manual to ensure the selected channel is 5583 * available in differential mode. 5584 * For example, internal channels (VrefInt, TempSensor, ...) are 5585 * not available in differential mode. 5586 * @note When configuring a channel 'i' in differential mode, 5587 * the channel 'i+1' is not usable separately. 5588 * @note On STM32H7, some channels are internally fixed to single-ended inputs 5589 * configuration: 5590 * - ADC1: Channels 0, 6, 7, 8, 9, 13, 14, 15, 17, and 19 5591 * - ADC2: Channels 0, 6, 7, 8, 9, 13, 14, 15 and 19 5592 * - ADC3: Channels 0, 6, 7, 8, 9, 12, 16, 17, and 19 5593 * @note For ADC channels configured in differential mode, both inputs 5594 * should be biased at (Vref+)/2 +/-200mV. 5595 * (Vref+ is the analog voltage reference) 5596 * @note On this STM32 series, setting of this feature is conditioned to 5597 * ADC state: 5598 * ADC must be ADC disabled. 5599 * @note One or several values can be selected. 5600 * Example: (LL_ADC_CHANNEL_4 | LL_ADC_CHANNEL_12 | ...) 5601 * @rmtoll DIFSEL DIFSEL LL_ADC_SetChannelSingleDiff 5602 * @param ADCx ADC instance 5603 * @param Channel This parameter can be one of the following values: 5604 * @arg @ref LL_ADC_CHANNEL_1 5605 * @arg @ref LL_ADC_CHANNEL_2 5606 * @arg @ref LL_ADC_CHANNEL_3 5607 * @arg @ref LL_ADC_CHANNEL_4 5608 * @arg @ref LL_ADC_CHANNEL_5 5609 * @arg @ref LL_ADC_CHANNEL_10 5610 * @arg @ref LL_ADC_CHANNEL_11 5611 * @arg @ref LL_ADC_CHANNEL_12 5612 * @arg @ref LL_ADC_CHANNEL_13 5613 * @arg @ref LL_ADC_CHANNEL_14 5614 * @arg @ref LL_ADC_CHANNEL_15 5615 * @arg @ref LL_ADC_CHANNEL_16 5616 * @arg @ref LL_ADC_CHANNEL_17 5617 * @arg @ref LL_ADC_CHANNEL_18 5618 * @arg @ref LL_ADC_CHANNEL_19 5619 * @param SingleDiff This parameter can be a combination of the following values: 5620 * @arg @ref LL_ADC_SINGLE_ENDED 5621 * @arg @ref LL_ADC_DIFFERENTIAL_ENDED 5622 * @retval None 5623 */ 5624 __STATIC_INLINE void LL_ADC_SetChannelSingleDiff(ADC_TypeDef *ADCx, uint32_t Channel, uint32_t SingleDiff) 5625 { 5626 #if defined(ADC_VER_V5_V90) 5627 /* Bits of channels in single or differential mode are set only for */ 5628 /* differential mode (for single mode, mask of bits allowed to be set is */ 5629 /* shifted out of range of bits of channels in single or differential mode. */ 5630 if (ADCx == ADC3) 5631 { 5632 MODIFY_REG(ADCx->LTR2_DIFSEL, 5633 Channel & ADC_SINGLEDIFF_CHANNEL_MASK, 5634 (Channel & ADC_SINGLEDIFF_CHANNEL_MASK) & (ADC_DIFSEL_DIFSEL >> (SingleDiff & ADC_SINGLEDIFF_CHANNEL_SHIFT_MASK))); 5635 } 5636 else 5637 { 5638 MODIFY_REG(ADCx->DIFSEL_RES12, 5639 Channel & ADC_SINGLEDIFF_CHANNEL_MASK, 5640 (Channel & ADC_SINGLEDIFF_CHANNEL_MASK) & (ADC_DIFSEL_DIFSEL >> (SingleDiff & ADC_SINGLEDIFF_CHANNEL_SHIFT_MASK))); 5641 } 5642 #else /* ADC_VER_V5_V90 */ 5643 /* Bits of channels in single or differential mode are set only for */ 5644 /* differential mode (for single mode, mask of bits allowed to be set is */ 5645 /* shifted out of range of bits of channels in single or differential mode. */ 5646 MODIFY_REG(ADCx->DIFSEL, 5647 Channel & ADC_SINGLEDIFF_CHANNEL_MASK, 5648 (Channel & ADC_SINGLEDIFF_CHANNEL_MASK) & (ADC_DIFSEL_DIFSEL >> (SingleDiff & ADC_SINGLEDIFF_CHANNEL_SHIFT_MASK))); 5649 #endif /* ADC_VER_V5_V90 */ 5650 } 5651 5652 /** 5653 * @brief Get mode single-ended or differential input of the selected 5654 * ADC channel. 5655 * @note When configuring a channel 'i' in differential mode, 5656 * the channel 'i+1' is not usable separately. 5657 * Therefore, to ensure a channel is configured in single-ended mode, 5658 * the configuration of channel itself and the channel 'i-1' must be 5659 * read back (to ensure that the selected channel channel has not been 5660 * configured in differential mode by the previous channel). 5661 * @note Refer to Reference Manual to ensure the selected channel is 5662 * available in differential mode. 5663 * For example, internal channels (VrefInt, TempSensor, ...) are 5664 * not available in differential mode. 5665 * @note When configuring a channel 'i' in differential mode, 5666 * the channel 'i+1' is not usable separately. 5667 * @note On STM32H7, some channels are internally fixed to single-ended inputs 5668 * configuration: 5669 * - ADC1: Channels 0, 6, 7, 8, 9, 13, 14, 15, 17, and 19 5670 * - ADC2: Channels 0, 6, 7, 8, 9, 13, 14, 15 and 19 5671 * - ADC3: Channels 0, 6, 7, 8, 9, 12, 16, 17, and 19 5672 * @note One or several values can be selected. In this case, the value 5673 * returned is null if all channels are in single ended-mode. 5674 * Example: (LL_ADC_CHANNEL_4 | LL_ADC_CHANNEL_12 | ...) 5675 * @rmtoll DIFSEL DIFSEL LL_ADC_GetChannelSingleDiff 5676 * @param ADCx ADC instance 5677 * @param Channel This parameter can be a combination of the following values: 5678 * @arg @ref LL_ADC_CHANNEL_1 5679 * @arg @ref LL_ADC_CHANNEL_2 5680 * @arg @ref LL_ADC_CHANNEL_3 5681 * @arg @ref LL_ADC_CHANNEL_4 5682 * @arg @ref LL_ADC_CHANNEL_5 5683 * @arg @ref LL_ADC_CHANNEL_10 5684 * @arg @ref LL_ADC_CHANNEL_11 5685 * @arg @ref LL_ADC_CHANNEL_12 5686 * @arg @ref LL_ADC_CHANNEL_13 5687 * @arg @ref LL_ADC_CHANNEL_14 5688 * @arg @ref LL_ADC_CHANNEL_15 5689 * @arg @ref LL_ADC_CHANNEL_16 5690 * @arg @ref LL_ADC_CHANNEL_17 5691 * @arg @ref LL_ADC_CHANNEL_18 5692 * @arg @ref LL_ADC_CHANNEL_19 5693 * @retval 0: channel in single-ended mode, else: channel in differential mode 5694 */ 5695 __STATIC_INLINE uint32_t LL_ADC_GetChannelSingleDiff(ADC_TypeDef *ADCx, uint32_t Channel) 5696 { 5697 #if defined(ADC_VER_V5_V90) 5698 return (uint32_t)(READ_BIT(ADCx->DIFSEL_RES12, (Channel & ADC_SINGLEDIFF_CHANNEL_MASK))); 5699 #else 5700 return (uint32_t)(READ_BIT(ADCx->DIFSEL, (Channel & ADC_SINGLEDIFF_CHANNEL_MASK))); 5701 #endif /* ADC_VER_V5_V90 */ 5702 } 5703 5704 /** 5705 * @} 5706 */ 5707 5708 /** @defgroup ADC_LL_EF_Configuration_ADC_AnalogWatchdog Configuration of ADC transversal scope: analog watchdog 5709 * @ingroup RTEMSBSPsARMSTM32H7 5710 * @{ 5711 */ 5712 5713 /** 5714 * @brief Set ADC analog watchdog monitored channels: 5715 * a single channel, multiple channels or all channels, 5716 * on ADC groups regular and-or injected. 5717 * @note Once monitored channels are selected, analog watchdog 5718 * is enabled. 5719 * @note In case of need to define a single channel to monitor 5720 * with analog watchdog from sequencer channel definition, 5721 * use helper macro @ref __LL_ADC_ANALOGWD_CHANNEL_GROUP(). 5722 * @note On this STM32 series, there are 2 kinds of analog watchdog 5723 * instance: 5724 * - AWD standard (instance AWD1): 5725 * - channels monitored: can monitor 1 channel or all channels. 5726 * - groups monitored: ADC groups regular and-or injected. 5727 * - resolution: resolution is not limited (corresponds to 5728 * ADC resolution configured). 5729 * - AWD flexible (instances AWD2, AWD3): 5730 * - channels monitored: flexible on channels monitored, selection is 5731 * channel wise, from from 1 to all channels. 5732 * Specificity of this analog watchdog: Multiple channels can 5733 * be selected. For example: 5734 * (LL_ADC_AWD_CHANNEL4_REG_INJ | LL_ADC_AWD_CHANNEL5_REG_INJ | ...) 5735 * - groups monitored: not selection possible (monitoring on both 5736 * groups regular and injected). 5737 * Channels selected are monitored on groups regular and injected: 5738 * LL_ADC_AWD_CHANNELxx_REG_INJ (do not use parameters 5739 * LL_ADC_AWD_CHANNELxx_REG and LL_ADC_AWD_CHANNELxx_INJ) 5740 * - resolution: resolution is limited to 8 bits: if ADC resolution is 5741 * 12 bits the 4 LSB are ignored, if ADC resolution is 10 bits 5742 * the 2 LSB are ignored. 5743 * @note On this STM32 series, setting of this feature is conditioned to 5744 * ADC state: 5745 * ADC must be disabled or enabled without conversion on going 5746 * on either groups regular or injected. 5747 * @rmtoll CFGR AWD1CH LL_ADC_SetAnalogWDMonitChannels\n 5748 * CFGR AWD1SGL LL_ADC_SetAnalogWDMonitChannels\n 5749 * CFGR AWD1EN LL_ADC_SetAnalogWDMonitChannels\n 5750 * CFGR JAWD1EN LL_ADC_SetAnalogWDMonitChannels\n 5751 * AWD2CR AWD2CH LL_ADC_SetAnalogWDMonitChannels\n 5752 * AWD3CR AWD3CH LL_ADC_SetAnalogWDMonitChannels 5753 * @param ADCx ADC instance 5754 * @param AWDy This parameter can be one of the following values: 5755 * @arg @ref LL_ADC_AWD1 5756 * @arg @ref LL_ADC_AWD2 5757 * @arg @ref LL_ADC_AWD3 5758 * @param AWDChannelGroup This parameter can be one of the following values: 5759 * @arg @ref LL_ADC_AWD_DISABLE 5760 * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG (0) 5761 * @arg @ref LL_ADC_AWD_ALL_CHANNELS_INJ (0) 5762 * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG_INJ 5763 * @arg @ref LL_ADC_AWD_CHANNEL_0_REG (0) 5764 * @arg @ref LL_ADC_AWD_CHANNEL_0_INJ (0) 5765 * @arg @ref LL_ADC_AWD_CHANNEL_0_REG_INJ 5766 * @arg @ref LL_ADC_AWD_CHANNEL_1_REG (0) 5767 * @arg @ref LL_ADC_AWD_CHANNEL_1_INJ (0) 5768 * @arg @ref LL_ADC_AWD_CHANNEL_1_REG_INJ 5769 * @arg @ref LL_ADC_AWD_CHANNEL_2_REG (0) 5770 * @arg @ref LL_ADC_AWD_CHANNEL_2_INJ (0) 5771 * @arg @ref LL_ADC_AWD_CHANNEL_2_REG_INJ 5772 * @arg @ref LL_ADC_AWD_CHANNEL_3_REG (0) 5773 * @arg @ref LL_ADC_AWD_CHANNEL_3_INJ (0) 5774 * @arg @ref LL_ADC_AWD_CHANNEL_3_REG_INJ 5775 * @arg @ref LL_ADC_AWD_CHANNEL_4_REG (0) 5776 * @arg @ref LL_ADC_AWD_CHANNEL_4_INJ (0) 5777 * @arg @ref LL_ADC_AWD_CHANNEL_4_REG_INJ 5778 * @arg @ref LL_ADC_AWD_CHANNEL_5_REG (0) 5779 * @arg @ref LL_ADC_AWD_CHANNEL_5_INJ (0) 5780 * @arg @ref LL_ADC_AWD_CHANNEL_5_REG_INJ 5781 * @arg @ref LL_ADC_AWD_CHANNEL_6_REG (0) 5782 * @arg @ref LL_ADC_AWD_CHANNEL_6_INJ (0) 5783 * @arg @ref LL_ADC_AWD_CHANNEL_6_REG_INJ 5784 * @arg @ref LL_ADC_AWD_CHANNEL_7_REG (0) 5785 * @arg @ref LL_ADC_AWD_CHANNEL_7_INJ (0) 5786 * @arg @ref LL_ADC_AWD_CHANNEL_7_REG_INJ 5787 * @arg @ref LL_ADC_AWD_CHANNEL_8_REG (0) 5788 * @arg @ref LL_ADC_AWD_CHANNEL_8_INJ (0) 5789 * @arg @ref LL_ADC_AWD_CHANNEL_8_REG_INJ 5790 * @arg @ref LL_ADC_AWD_CHANNEL_9_REG (0) 5791 * @arg @ref LL_ADC_AWD_CHANNEL_9_INJ (0) 5792 * @arg @ref LL_ADC_AWD_CHANNEL_9_REG_INJ 5793 * @arg @ref LL_ADC_AWD_CHANNEL_10_REG (0) 5794 * @arg @ref LL_ADC_AWD_CHANNEL_10_INJ (0) 5795 * @arg @ref LL_ADC_AWD_CHANNEL_10_REG_INJ 5796 * @arg @ref LL_ADC_AWD_CHANNEL_11_REG (0) 5797 * @arg @ref LL_ADC_AWD_CHANNEL_11_INJ (0) 5798 * @arg @ref LL_ADC_AWD_CHANNEL_11_REG_INJ 5799 * @arg @ref LL_ADC_AWD_CHANNEL_12_REG (0) 5800 * @arg @ref LL_ADC_AWD_CHANNEL_12_INJ (0) 5801 * @arg @ref LL_ADC_AWD_CHANNEL_12_REG_INJ 5802 * @arg @ref LL_ADC_AWD_CHANNEL_13_REG (0) 5803 * @arg @ref LL_ADC_AWD_CHANNEL_13_INJ (0) 5804 * @arg @ref LL_ADC_AWD_CHANNEL_13_REG_INJ 5805 * @arg @ref LL_ADC_AWD_CHANNEL_14_REG (0) 5806 * @arg @ref LL_ADC_AWD_CHANNEL_14_INJ (0) 5807 * @arg @ref LL_ADC_AWD_CHANNEL_14_REG_INJ 5808 * @arg @ref LL_ADC_AWD_CHANNEL_15_REG (0) 5809 * @arg @ref LL_ADC_AWD_CHANNEL_15_INJ (0) 5810 * @arg @ref LL_ADC_AWD_CHANNEL_15_REG_INJ 5811 * @arg @ref LL_ADC_AWD_CHANNEL_16_REG (0) 5812 * @arg @ref LL_ADC_AWD_CHANNEL_16_INJ (0) 5813 * @arg @ref LL_ADC_AWD_CHANNEL_16_REG_INJ 5814 * @arg @ref LL_ADC_AWD_CHANNEL_17_REG (0) 5815 * @arg @ref LL_ADC_AWD_CHANNEL_17_INJ (0) 5816 * @arg @ref LL_ADC_AWD_CHANNEL_17_REG_INJ 5817 * @arg @ref LL_ADC_AWD_CHANNEL_18_REG (0) 5818 * @arg @ref LL_ADC_AWD_CHANNEL_18_INJ (0) 5819 * @arg @ref LL_ADC_AWD_CHANNEL_18_REG_INJ 5820 * @arg @ref LL_ADC_AWD_CHANNEL_19_REG (0) 5821 * @arg @ref LL_ADC_AWD_CHANNEL_19_INJ (0) 5822 * @arg @ref LL_ADC_AWD_CHANNEL_19_REG_INJ 5823 * @arg @ref LL_ADC_AWD_CH_VREFINT_REG (0)(1) 5824 * @arg @ref LL_ADC_AWD_CH_VREFINT_INJ (0)(1) 5825 * @arg @ref LL_ADC_AWD_CH_VREFINT_REG_INJ (1) 5826 * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG (0)(1) 5827 * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_INJ (0)(1) 5828 * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG_INJ (1) 5829 * @arg @ref LL_ADC_AWD_CH_VBAT_REG (0)(1) 5830 * @arg @ref LL_ADC_AWD_CH_VBAT_INJ (0)(1) 5831 * @arg @ref LL_ADC_AWD_CH_VBAT_REG_INJ (1) 5832 * @arg @ref LL_ADC_AWD_CH_DAC1CH1_ADC2_REG (0)(2) 5833 * @arg @ref LL_ADC_AWD_CH_DAC1CH1_ADC2_INJ (0)(2) 5834 * @arg @ref LL_ADC_AWD_CH_DAC1CH1_ADC2_REG_INJ (2) 5835 * @arg @ref LL_ADC_AWD_CH_DAC1CH2_ADC2_REG (0)(2) 5836 * @arg @ref LL_ADC_AWD_CH_DAC1CH2_ADC2_INJ (0)(2) 5837 * @arg @ref LL_ADC_AWD_CH_DAC1CH2_ADC2_REG_INJ (2) 5838 * 5839 * (0) On STM32H7, parameter available only on analog watchdog number: AWD1.\n 5840 * (1) On STM32H7, parameter available only on ADC instance: ADC3.\n 5841 * (2) On STM32H7, parameter available only on ADC instance: ADC2. 5842 * @retval None 5843 */ 5844 __STATIC_INLINE void LL_ADC_SetAnalogWDMonitChannels(ADC_TypeDef *ADCx, uint32_t AWDy, uint32_t AWDChannelGroup) 5845 { 5846 /* Set bits with content of parameter "AWDChannelGroup" with bits position */ 5847 /* in register and register position depending on parameter "AWDy". */ 5848 /* Parameters "AWDChannelGroup" and "AWDy" are used with masks because */ 5849 /* containing other bits reserved for other purpose. */ 5850 __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->CFGR, ((AWDy & ADC_AWD_CRX_REGOFFSET_MASK) >> ADC_AWD_CRX_REGOFFSET_POS) 5851 + ((AWDy & ADC_AWD_CR12_REGOFFSETGAP_MASK) * ADC_AWD_CR12_REGOFFSETGAP_VAL)); 5852 5853 MODIFY_REG(*preg, 5854 (AWDy & ADC_AWD_CR_ALL_CHANNEL_MASK), 5855 AWDChannelGroup & AWDy); 5856 } 5857 5858 /** 5859 * @brief Get ADC analog watchdog monitored channel. 5860 * @note Usage of the returned channel number: 5861 * - To reinject this channel into another function LL_ADC_xxx: 5862 * the returned channel number is only partly formatted on definition 5863 * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared 5864 * with parts of literals LL_ADC_CHANNEL_x or using 5865 * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB(). 5866 * Then the selected literal LL_ADC_CHANNEL_x can be used 5867 * as parameter for another function. 5868 * - To get the channel number in decimal format: 5869 * process the returned value with the helper macro 5870 * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB(). 5871 * Applicable only when the analog watchdog is set to monitor 5872 * one channel. 5873 * @note On this STM32 series, there are 2 kinds of analog watchdog 5874 * instance: 5875 * - AWD standard (instance AWD1): 5876 * - channels monitored: can monitor 1 channel or all channels. 5877 * - groups monitored: ADC groups regular and-or injected. 5878 * - resolution: resolution is not limited (corresponds to 5879 * ADC resolution configured). 5880 * - AWD flexible (instances AWD2, AWD3): 5881 * - channels monitored: flexible on channels monitored, selection is 5882 * channel wise, from from 1 to all channels. 5883 * Specificity of this analog watchdog: Multiple channels can 5884 * be selected. For example: 5885 * (LL_ADC_AWD_CHANNEL4_REG_INJ | LL_ADC_AWD_CHANNEL5_REG_INJ | ...) 5886 * - groups monitored: not selection possible (monitoring on both 5887 * groups regular and injected). 5888 * Channels selected are monitored on groups regular and injected: 5889 * LL_ADC_AWD_CHANNELxx_REG_INJ (do not use parameters 5890 * LL_ADC_AWD_CHANNELxx_REG and LL_ADC_AWD_CHANNELxx_INJ) 5891 * - resolution: resolution is limited to 8 bits: if ADC resolution is 5892 * 12 bits the 4 LSB are ignored, if ADC resolution is 10 bits 5893 * the 2 LSB are ignored. 5894 * @note On this STM32 series, setting of this feature is conditioned to 5895 * ADC state: 5896 * ADC must be disabled or enabled without conversion on going 5897 * on either groups regular or injected. 5898 * @rmtoll CFGR AWD1CH LL_ADC_GetAnalogWDMonitChannels\n 5899 * CFGR AWD1SGL LL_ADC_GetAnalogWDMonitChannels\n 5900 * CFGR AWD1EN LL_ADC_GetAnalogWDMonitChannels\n 5901 * CFGR JAWD1EN LL_ADC_GetAnalogWDMonitChannels\n 5902 * AWD2CR AWD2CH LL_ADC_GetAnalogWDMonitChannels\n 5903 * AWD3CR AWD3CH LL_ADC_GetAnalogWDMonitChannels 5904 * @param ADCx ADC instance 5905 * @param AWDy This parameter can be one of the following values: 5906 * @arg @ref LL_ADC_AWD1 5907 * @arg @ref LL_ADC_AWD2 (1) 5908 * @arg @ref LL_ADC_AWD3 (1) 5909 * 5910 * (1) On this AWD number, monitored channel can be retrieved 5911 * if only 1 channel is programmed (or none or all channels). 5912 * This function cannot retrieve monitored channel if 5913 * multiple channels are programmed simultaneously 5914 * by bitfield. 5915 * @retval Returned value can be one of the following values: 5916 * @arg @ref LL_ADC_AWD_DISABLE 5917 * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG (0) 5918 * @arg @ref LL_ADC_AWD_ALL_CHANNELS_INJ (0) 5919 * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG_INJ 5920 * @arg @ref LL_ADC_AWD_CHANNEL_0_REG (0) 5921 * @arg @ref LL_ADC_AWD_CHANNEL_0_INJ (0) 5922 * @arg @ref LL_ADC_AWD_CHANNEL_0_REG_INJ 5923 * @arg @ref LL_ADC_AWD_CHANNEL_1_REG (0) 5924 * @arg @ref LL_ADC_AWD_CHANNEL_1_INJ (0) 5925 * @arg @ref LL_ADC_AWD_CHANNEL_1_REG_INJ 5926 * @arg @ref LL_ADC_AWD_CHANNEL_2_REG (0) 5927 * @arg @ref LL_ADC_AWD_CHANNEL_2_INJ (0) 5928 * @arg @ref LL_ADC_AWD_CHANNEL_2_REG_INJ 5929 * @arg @ref LL_ADC_AWD_CHANNEL_3_REG (0) 5930 * @arg @ref LL_ADC_AWD_CHANNEL_3_INJ (0) 5931 * @arg @ref LL_ADC_AWD_CHANNEL_3_REG_INJ 5932 * @arg @ref LL_ADC_AWD_CHANNEL_4_REG (0) 5933 * @arg @ref LL_ADC_AWD_CHANNEL_4_INJ (0) 5934 * @arg @ref LL_ADC_AWD_CHANNEL_4_REG_INJ 5935 * @arg @ref LL_ADC_AWD_CHANNEL_5_REG (0) 5936 * @arg @ref LL_ADC_AWD_CHANNEL_5_INJ (0) 5937 * @arg @ref LL_ADC_AWD_CHANNEL_5_REG_INJ 5938 * @arg @ref LL_ADC_AWD_CHANNEL_6_REG (0) 5939 * @arg @ref LL_ADC_AWD_CHANNEL_6_INJ (0) 5940 * @arg @ref LL_ADC_AWD_CHANNEL_6_REG_INJ 5941 * @arg @ref LL_ADC_AWD_CHANNEL_7_REG (0) 5942 * @arg @ref LL_ADC_AWD_CHANNEL_7_INJ (0) 5943 * @arg @ref LL_ADC_AWD_CHANNEL_7_REG_INJ 5944 * @arg @ref LL_ADC_AWD_CHANNEL_8_REG (0) 5945 * @arg @ref LL_ADC_AWD_CHANNEL_8_INJ (0) 5946 * @arg @ref LL_ADC_AWD_CHANNEL_8_REG_INJ 5947 * @arg @ref LL_ADC_AWD_CHANNEL_9_REG (0) 5948 * @arg @ref LL_ADC_AWD_CHANNEL_9_INJ (0) 5949 * @arg @ref LL_ADC_AWD_CHANNEL_9_REG_INJ 5950 * @arg @ref LL_ADC_AWD_CHANNEL_10_REG (0) 5951 * @arg @ref LL_ADC_AWD_CHANNEL_10_INJ (0) 5952 * @arg @ref LL_ADC_AWD_CHANNEL_10_REG_INJ 5953 * @arg @ref LL_ADC_AWD_CHANNEL_11_REG (0) 5954 * @arg @ref LL_ADC_AWD_CHANNEL_11_INJ (0) 5955 * @arg @ref LL_ADC_AWD_CHANNEL_11_REG_INJ 5956 * @arg @ref LL_ADC_AWD_CHANNEL_12_REG (0) 5957 * @arg @ref LL_ADC_AWD_CHANNEL_12_INJ (0) 5958 * @arg @ref LL_ADC_AWD_CHANNEL_12_REG_INJ 5959 * @arg @ref LL_ADC_AWD_CHANNEL_13_REG (0) 5960 * @arg @ref LL_ADC_AWD_CHANNEL_13_INJ (0) 5961 * @arg @ref LL_ADC_AWD_CHANNEL_13_REG_INJ 5962 * @arg @ref LL_ADC_AWD_CHANNEL_14_REG (0) 5963 * @arg @ref LL_ADC_AWD_CHANNEL_14_INJ (0) 5964 * @arg @ref LL_ADC_AWD_CHANNEL_14_REG_INJ 5965 * @arg @ref LL_ADC_AWD_CHANNEL_15_REG (0) 5966 * @arg @ref LL_ADC_AWD_CHANNEL_15_INJ (0) 5967 * @arg @ref LL_ADC_AWD_CHANNEL_15_REG_INJ 5968 * @arg @ref LL_ADC_AWD_CHANNEL_16_REG (0) 5969 * @arg @ref LL_ADC_AWD_CHANNEL_16_INJ (0) 5970 * @arg @ref LL_ADC_AWD_CHANNEL_16_REG_INJ 5971 * @arg @ref LL_ADC_AWD_CHANNEL_17_REG (0) 5972 * @arg @ref LL_ADC_AWD_CHANNEL_17_INJ (0) 5973 * @arg @ref LL_ADC_AWD_CHANNEL_17_REG_INJ 5974 * @arg @ref LL_ADC_AWD_CHANNEL_18_REG (0) 5975 * @arg @ref LL_ADC_AWD_CHANNEL_18_INJ (0) 5976 * @arg @ref LL_ADC_AWD_CHANNEL_18_REG_INJ 5977 * @arg @ref LL_ADC_AWD_CHANNEL_19_REG (0) 5978 * @arg @ref LL_ADC_AWD_CHANNEL_19_INJ (0) 5979 * @arg @ref LL_ADC_AWD_CHANNEL_19_REG_INJ 5980 * 5981 * (0) On STM32H7, parameter available only on analog watchdog number: AWD1. 5982 */ 5983 __STATIC_INLINE uint32_t LL_ADC_GetAnalogWDMonitChannels(ADC_TypeDef *ADCx, uint32_t AWDy) 5984 { 5985 const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->CFGR, ((AWDy & ADC_AWD_CRX_REGOFFSET_MASK) >> ADC_AWD_CRX_REGOFFSET_POS) 5986 + ((AWDy & ADC_AWD_CR12_REGOFFSETGAP_MASK) * ADC_AWD_CR12_REGOFFSETGAP_VAL)); 5987 5988 uint32_t AnalogWDMonitChannels = (READ_BIT(*preg, AWDy) & AWDy & ADC_AWD_CR_ALL_CHANNEL_MASK); 5989 5990 /* If "AnalogWDMonitChannels" == 0, then the selected AWD is disabled */ 5991 /* (parameter value LL_ADC_AWD_DISABLE). */ 5992 /* Else, the selected AWD is enabled and is monitoring a group of channels */ 5993 /* or a single channel. */ 5994 if (AnalogWDMonitChannels != 0UL) 5995 { 5996 if (AWDy == LL_ADC_AWD1) 5997 { 5998 if ((AnalogWDMonitChannels & ADC_CFGR_AWD1SGL) == 0UL) 5999 { 6000 /* AWD monitoring a group of channels */ 6001 AnalogWDMonitChannels = ((AnalogWDMonitChannels 6002 | (ADC_AWD_CR23_CHANNEL_MASK) 6003 ) 6004 & (~(ADC_CFGR_AWD1CH)) 6005 ); 6006 } 6007 else 6008 { 6009 /* AWD monitoring a single channel */ 6010 AnalogWDMonitChannels = (AnalogWDMonitChannels 6011 | (ADC_AWD2CR_AWD2CH_0 << (AnalogWDMonitChannels >> ADC_CFGR_AWD1CH_Pos)) 6012 ); 6013 } 6014 } 6015 else 6016 { 6017 if ((AnalogWDMonitChannels & ADC_AWD_CR23_CHANNEL_MASK) == ADC_AWD_CR23_CHANNEL_MASK) 6018 { 6019 /* AWD monitoring a group of channels */ 6020 AnalogWDMonitChannels = (ADC_AWD_CR23_CHANNEL_MASK 6021 | ((ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN)) 6022 ); 6023 } 6024 else 6025 { 6026 /* AWD monitoring a single channel */ 6027 /* AWD monitoring a group of channels */ 6028 AnalogWDMonitChannels = (AnalogWDMonitChannels 6029 | (ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL) 6030 | (__LL_ADC_CHANNEL_TO_DECIMAL_NB(AnalogWDMonitChannels) << ADC_CFGR_AWD1CH_Pos) 6031 ); 6032 } 6033 } 6034 } 6035 6036 return AnalogWDMonitChannels; 6037 } 6038 6039 /** 6040 * @brief Set ADC analog watchdog threshold value of threshold 6041 * high or low. 6042 * @note In case of ADC resolution different of 12 bits, 6043 * analog watchdog thresholds data require a specific shift. 6044 * Use helper macro @ref __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION(). 6045 * @note On this STM32 series, there are 2 kinds of analog watchdog 6046 * instance: 6047 * - AWD standard (instance AWD1): 6048 * - channels monitored: can monitor 1 channel or all channels. 6049 * - groups monitored: ADC groups regular and-or injected. 6050 * - resolution: resolution is not limited (corresponds to 6051 * ADC resolution configured). 6052 * - AWD flexible (instances AWD2, AWD3): 6053 * - channels monitored: flexible on channels monitored, selection is 6054 * channel wise, from from 1 to all channels. 6055 * Specificity of this analog watchdog: Multiple channels can 6056 * be selected. For example: 6057 * (LL_ADC_AWD_CHANNEL4_REG_INJ | LL_ADC_AWD_CHANNEL5_REG_INJ | ...) 6058 * - groups monitored: not selection possible (monitoring on both 6059 * groups regular and injected). 6060 * Channels selected are monitored on groups regular and injected: 6061 * LL_ADC_AWD_CHANNELxx_REG_INJ (do not use parameters 6062 * LL_ADC_AWD_CHANNELxx_REG and LL_ADC_AWD_CHANNELxx_INJ) 6063 * - resolution: resolution is limited to 8 bits: if ADC resolution is 6064 * 12 bits the 4 LSB are ignored, if ADC resolution is 10 bits 6065 * the 2 LSB are ignored. 6066 * @note If ADC oversampling is enabled, ADC analog watchdog thresholds are 6067 * impacted: the comparison of analog watchdog thresholds is done 6068 * on oversampling intermediate computation (after ratio, before shift 6069 * application): intermediate register bitfield [32:7] 6070 * (26 most significant bits). 6071 * @note On this STM32 series, setting of this feature is conditioned to 6072 * ADC state: 6073 * ADC must be disabled or enabled without conversion on going 6074 * on either ADC groups regular or injected. 6075 * @rmtoll TR1 HT1 LL_ADC_SetAnalogWDThresholds\n 6076 * TR2 HT2 LL_ADC_SetAnalogWDThresholds\n 6077 * TR3 HT3 LL_ADC_SetAnalogWDThresholds\n 6078 * TR1 LT1 LL_ADC_SetAnalogWDThresholds\n 6079 * TR2 LT2 LL_ADC_SetAnalogWDThresholds\n 6080 * TR3 LT3 LL_ADC_SetAnalogWDThresholds 6081 * @param ADCx ADC instance 6082 * @param AWDy This parameter can be one of the following values: 6083 * @arg @ref LL_ADC_AWD1 6084 * @arg @ref LL_ADC_AWD2 6085 * @arg @ref LL_ADC_AWD3 6086 * @param AWDThresholdsHighLow This parameter can be one of the following values: 6087 * @arg @ref LL_ADC_AWD_THRESHOLD_HIGH 6088 * @arg @ref LL_ADC_AWD_THRESHOLD_LOW 6089 * @param AWDThresholdValue Value between Min_Data=0x000 and Max_Data=0xFFF 6090 * @retval None 6091 */ 6092 __STATIC_INLINE void LL_ADC_SetAnalogWDThresholds(ADC_TypeDef *ADCx, uint32_t AWDy, uint32_t AWDThresholdsHighLow, uint32_t AWDThresholdValue) 6093 { 6094 #if defined(ADC_VER_V5_V90) 6095 if (ADCx == ADC3) 6096 { 6097 /* Set bits with content of parameter "AWDThresholdValue" with bits */ 6098 /* position in register and register position depending on parameters */ 6099 /* "AWDThresholdsHighLow" and "AWDy". */ 6100 /* Parameters "AWDy" and "AWDThresholdValue" are used with masks because */ 6101 /* containing other bits reserved for other purpose. */ 6102 __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->LTR1_TR1, ((AWDy & ADC_AWD_TRX_REGOFFSET_MASK) >> ADC_AWD_TRX_REGOFFSET_POS)); 6103 6104 MODIFY_REG(*preg, 6105 (ADC3_TR1_LT1 << (AWDThresholdsHighLow * ADC3_TR1_HT1_Pos)), 6106 AWDThresholdValue << (((AWDThresholdsHighLow * ADC3_TR1_HT1) & ADC_AWD_TRX_BIT_HIGH_MASK) >> ADC_AWD_TRX_BIT_HIGH_SHIFT4)); 6107 } 6108 else 6109 { 6110 /* Set bits with content of parameter "AWDThresholdValue" with bits */ 6111 /* position in register and register position depending on parameters */ 6112 /* "AWDThresholdsHighLow" and "AWDy". */ 6113 /* Parameters "AWDy" and "AWDThresholdValue" are used with masks because */ 6114 /* containing other bits reserved for other purpose. */ 6115 __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->LTR1_TR1, (((AWDy & ADC_AWD_TRX_REGOFFSET_MASK) >> ADC_AWD_TRX_REGOFFSET_POS) * 2UL) 6116 + ((AWDy & ADC_AWD_TR12_REGOFFSETGAP_MASK) * ADC_AWD_TR12_REGOFFSETGAP_VAL) 6117 + (AWDThresholdsHighLow)); 6118 6119 MODIFY_REG(*preg, ADC_LTR_LT, AWDThresholdValue); 6120 } 6121 #else 6122 /* Set bits with content of parameter "AWDThresholdValue" with bits */ 6123 /* position in register and register position depending on parameters */ 6124 /* "AWDThresholdsHighLow" and "AWDy". */ 6125 /* Parameters "AWDy" and "AWDThresholdValue" are used with masks because */ 6126 /* containing other bits reserved for other purpose. */ 6127 __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->LTR1, (((AWDy & ADC_AWD_TRX_REGOFFSET_MASK) >> ADC_AWD_TRX_REGOFFSET_POS) * 2UL) 6128 + ((AWDy & ADC_AWD_TR12_REGOFFSETGAP_MASK) * ADC_AWD_TR12_REGOFFSETGAP_VAL) 6129 + (AWDThresholdsHighLow)); 6130 6131 MODIFY_REG(*preg, ADC_LTR_LT, AWDThresholdValue); 6132 #endif /* ADC_VER_V5_V90 */ 6133 } 6134 6135 /** 6136 * @brief Get ADC analog watchdog threshold value of threshold high, 6137 * threshold low or raw data with ADC thresholds high and low 6138 * concatenated. 6139 * @note In case of ADC resolution different of 12 bits, 6140 * analog watchdog thresholds data require a specific shift. 6141 * Use helper macro @ref __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION(). 6142 * @rmtoll TR1 HT1 LL_ADC_GetAnalogWDThresholds\n 6143 * TR2 HT2 LL_ADC_GetAnalogWDThresholds\n 6144 * TR3 HT3 LL_ADC_GetAnalogWDThresholds\n 6145 * TR1 LT1 LL_ADC_GetAnalogWDThresholds\n 6146 * TR2 LT2 LL_ADC_GetAnalogWDThresholds\n 6147 * TR3 LT3 LL_ADC_GetAnalogWDThresholds 6148 * @param ADCx ADC instance 6149 * @param AWDy This parameter can be one of the following values: 6150 * @arg @ref LL_ADC_AWD1 6151 * @arg @ref LL_ADC_AWD2 6152 * @arg @ref LL_ADC_AWD3 6153 * @param AWDThresholdsHighLow This parameter can be one of the following values: 6154 * @arg @ref LL_ADC_AWD_THRESHOLD_HIGH 6155 * @arg @ref LL_ADC_AWD_THRESHOLD_LOW 6156 * @retval Value between Min_Data=0x000 and Max_Data=0x3FFFFFF 6157 */ 6158 __STATIC_INLINE uint32_t LL_ADC_GetAnalogWDThresholds(ADC_TypeDef *ADCx, uint32_t AWDy, uint32_t AWDThresholdsHighLow) 6159 { 6160 #if defined(ADC_VER_V5_V90) 6161 if (ADCx == ADC3) 6162 { 6163 const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->LTR1_TR1, 6164 ((AWDy & ADC_AWD_TRX_REGOFFSET_MASK) >> ADC_AWD_TRX_REGOFFSET_POS)); 6165 6166 return (uint32_t)(READ_BIT(*preg, 6167 (ADC3_TR1_LT1 << (AWDThresholdsHighLow * ADC3_TR1_HT1_Pos))) 6168 >> (((AWDThresholdsHighLow & ADC_AWD_TRX_BIT_HIGH_MASK) >> ADC_AWD_TRX_BIT_HIGH_SHIFT4) 6169 & ~(AWDThresholdsHighLow & ADC3_TR1_LT1))); 6170 } 6171 else 6172 { 6173 const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->LTR1_TR1, (((AWDy & ADC_AWD_TRX_REGOFFSET_MASK) >> ADC_AWD_TRX_REGOFFSET_POS) * 2UL) 6174 + ((AWDy & ADC_AWD_TR12_REGOFFSETGAP_MASK) * ADC_AWD_TR12_REGOFFSETGAP_VAL) 6175 + (AWDThresholdsHighLow)); 6176 6177 return (uint32_t)(READ_BIT(*preg, ADC_LTR_LT)); 6178 } 6179 #else 6180 const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->LTR1, (((AWDy & ADC_AWD_TRX_REGOFFSET_MASK) >> ADC_AWD_TRX_REGOFFSET_POS) * 2UL) 6181 + ((AWDy & ADC_AWD_TR12_REGOFFSETGAP_MASK) * ADC_AWD_TR12_REGOFFSETGAP_VAL) 6182 + (AWDThresholdsHighLow)); 6183 6184 return (uint32_t)(READ_BIT(*preg, ADC_LTR_LT)); 6185 #endif /* ADC_VER_V5_V90 */ 6186 } 6187 6188 #if defined(ADC_VER_V5_V90) 6189 6190 /** 6191 * @brief Set ADC analog watchdog thresholds value of both thresholds 6192 * high and low. Applicable for devices STM32H72xx and STM32H73xx. 6193 * @note If value of only one threshold high or low must be set, 6194 * use function @ref LL_ADC_SetAnalogWDThresholds(). 6195 * @note In case of ADC resolution different of 12 bits, 6196 * analog watchdog thresholds data require a specific shift. 6197 * Use helper macro @ref __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION(). 6198 * @note On this STM32 series, there are 2 kinds of analog watchdog 6199 * instance: 6200 * - AWD standard (instance AWD1): 6201 * - channels monitored: can monitor 1 channel or all channels. 6202 * - groups monitored: ADC groups regular and-or injected. 6203 * - resolution: resolution is not limited (corresponds to 6204 * ADC resolution configured). 6205 * - AWD flexible (instances AWD2, AWD3): 6206 * - channels monitored: flexible on channels monitored, selection is 6207 * channel wise, from from 1 to all channels. 6208 * Specificity of this analog watchdog: Multiple channels can 6209 * be selected. For example: 6210 * (LL_ADC_AWD_CHANNEL4_REG_INJ | LL_ADC_AWD_CHANNEL5_REG_INJ | ...) 6211 * - groups monitored: not selection possible (monitoring on both 6212 * groups regular and injected). 6213 * Channels selected are monitored on groups regular and injected: 6214 * LL_ADC_AWD_CHANNELxx_REG_INJ (do not use parameters 6215 * LL_ADC_AWD_CHANNELxx_REG and LL_ADC_AWD_CHANNELxx_INJ) 6216 * - resolution: resolution is limited to 8 bits: if ADC resolution is 6217 * 12 bits the 4 LSB are ignored, if ADC resolution is 10 bits 6218 * the 2 LSB are ignored. 6219 * @rmtoll TR1 HT1 LL_ADC_ConfigAnalogWDThresholds\n 6220 * TR2 HT2 LL_ADC_ConfigAnalogWDThresholds\n 6221 * TR3 HT3 LL_ADC_ConfigAnalogWDThresholds\n 6222 * TR1 LT1 LL_ADC_ConfigAnalogWDThresholds\n 6223 * TR2 LT2 LL_ADC_ConfigAnalogWDThresholds\n 6224 * TR3 LT3 LL_ADC_ConfigAnalogWDThresholds 6225 * @param ADCx ADC instance 6226 * @param AWDy This parameter can be one of the following values: 6227 * @arg @ref LL_ADC_AWD1 6228 * @arg @ref LL_ADC_AWD2 6229 * @arg @ref LL_ADC_AWD3 6230 * @param AWDThresholdHighValue Value between Min_Data=0x000 and Max_Data=0xFFF 6231 * @param AWDThresholdLowValue Value between Min_Data=0x000 and Max_Data=0xFFF 6232 * @retval None 6233 */ 6234 __STATIC_INLINE void LL_ADC_ConfigAnalogWDThresholds(ADC_TypeDef *ADCx, uint32_t AWDy, uint32_t AWDThresholdHighValue, uint32_t AWDThresholdLowValue) 6235 { 6236 /* Set bits with content of parameter "AWDThresholdxxxValue" with bits */ 6237 /* position in register and register position depending on parameter */ 6238 /* "AWDy". */ 6239 /* Parameters "AWDy" and "AWDThresholdxxxValue" are used with masks because */ 6240 /* containing other bits reserved for other purpose. */ 6241 if (ADCx == ADC3) 6242 { 6243 __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->LTR1_TR1, 6244 ((AWDy & ADC_AWD_TRX_REGOFFSET_MASK) >> ADC_AWD_TRX_REGOFFSET_POS)); 6245 6246 MODIFY_REG(*preg, 6247 ADC3_TR1_HT1 | ADC3_TR1_LT1, 6248 (AWDThresholdHighValue << ADC3_TR1_HT1_Pos) | AWDThresholdLowValue); 6249 } 6250 else 6251 { 6252 __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->LTR1_TR1, (((AWDy & ADC_AWD_TRX_REGOFFSET_MASK) >> ADC_AWD_TRX_REGOFFSET_POS) * 2UL) 6253 + ((AWDy & ADC_AWD_TR12_REGOFFSETGAP_MASK) * ADC_AWD_TR12_REGOFFSETGAP_VAL) 6254 + (LL_ADC_AWD_THRESHOLD_LOW)); 6255 __IO uint32_t *preg2 = __ADC_PTR_REG_OFFSET(ADCx->LTR1_TR1, (((AWDy & ADC_AWD_TRX_REGOFFSET_MASK) >> ADC_AWD_TRX_REGOFFSET_POS) * 2UL) 6256 + ((AWDy & ADC_AWD_TR12_REGOFFSETGAP_MASK) * ADC_AWD_TR12_REGOFFSETGAP_VAL) 6257 + (LL_ADC_AWD_THRESHOLD_HIGH)); 6258 6259 MODIFY_REG(*preg, ADC_LTR_LT, AWDThresholdLowValue); 6260 MODIFY_REG(*preg2, ADC_HTR_HT, AWDThresholdHighValue); 6261 } 6262 } 6263 6264 6265 /** 6266 * @brief Set ADC analog watchdog filtering configuration 6267 * @note On this STM32 series, setting of this feature is conditioned to 6268 * ADC state: 6269 * ADC must be disabled or enabled without conversion on going 6270 * on either groups regular or injected. 6271 * Applicable on ADC3 of devices STM32H72xx and STM32H73xx. 6272 * @note On this STM32 series, this feature is only available on first 6273 * analog watchdog (AWD1) 6274 * @rmtoll TR1 AWDFILT LL_ADC_SetAWDFilteringConfiguration 6275 * @param ADCx ADC instance 6276 * @param AWDy This parameter can be one of the following values: 6277 * @arg @ref LL_ADC_AWD1 6278 * @param FilteringConfig This parameter can be one of the following values: 6279 * @arg @ref LL_ADC_AWD_FILTERING_NONE 6280 * @arg @ref LL_ADC_AWD_FILTERING_2SAMPLES 6281 * @arg @ref LL_ADC_AWD_FILTERING_3SAMPLES 6282 * @arg @ref LL_ADC_AWD_FILTERING_4SAMPLES 6283 * @arg @ref LL_ADC_AWD_FILTERING_5SAMPLES 6284 * @arg @ref LL_ADC_AWD_FILTERING_6SAMPLES 6285 * @arg @ref LL_ADC_AWD_FILTERING_7SAMPLES 6286 * @arg @ref LL_ADC_AWD_FILTERING_8SAMPLES 6287 * @retval None 6288 */ 6289 __STATIC_INLINE void LL_ADC_SetAWDFilteringConfiguration(ADC_TypeDef *ADCx, uint32_t AWDy, uint32_t FilteringConfig) 6290 { 6291 if (ADCx == ADC3) 6292 { 6293 /* Prevent unused argument(s) compilation warning */ 6294 (void)(AWDy); 6295 MODIFY_REG(ADCx->LTR1_TR1, ADC3_TR1_AWDFILT, FilteringConfig); 6296 } 6297 } 6298 6299 /** 6300 * @brief Get ADC analog watchdog filtering configuration 6301 * @note On this STM32 series, this feature is only available on first 6302 * analog watchdog (AWD1) 6303 * Applicable on ADC3 of devices STM32H72xx and STM32H73xx. 6304 * @rmtoll TR1 AWDFILT LL_ADC_GetAWDFilteringConfiguration 6305 * @param ADCx ADC instance 6306 * @param AWDy This parameter can be one of the following values: 6307 * @arg @ref LL_ADC_AWD1 6308 * @retval Returned value can be: 6309 * @arg @ref LL_ADC_AWD_FILTERING_NONE 6310 * @arg @ref LL_ADC_AWD_FILTERING_2SAMPLES 6311 * @arg @ref LL_ADC_AWD_FILTERING_3SAMPLES 6312 * @arg @ref LL_ADC_AWD_FILTERING_4SAMPLES 6313 * @arg @ref LL_ADC_AWD_FILTERING_5SAMPLES 6314 * @arg @ref LL_ADC_AWD_FILTERING_6SAMPLES 6315 * @arg @ref LL_ADC_AWD_FILTERING_7SAMPLES 6316 * @arg @ref LL_ADC_AWD_FILTERING_8SAMPLES 6317 */ 6318 __STATIC_INLINE uint32_t LL_ADC_GetAWDFilteringConfiguration(ADC_TypeDef *ADCx, uint32_t AWDy) 6319 { 6320 if (ADCx == ADC3) 6321 { 6322 /* Prevent unused argument(s) compilation warning */ 6323 (void)(AWDy); 6324 return (uint32_t)(READ_BIT(ADCx->LTR1_TR1, ADC3_TR1_AWDFILT)); 6325 } 6326 else 6327 { 6328 /* Function not available on this instance, return 0 */ 6329 return 0UL; 6330 } 6331 } 6332 #endif /* ADC_VER_V5_V90 */ 6333 /** 6334 * @} 6335 */ 6336 6337 /** @defgroup ADC_LL_EF_Configuration_ADC_oversampling Configuration of ADC transversal scope: oversampling 6338 * @ingroup RTEMSBSPsARMSTM32H7 6339 * @{ 6340 */ 6341 6342 /** 6343 * @brief Set ADC oversampling scope: ADC groups regular and-or injected 6344 * (availability of ADC group injected depends on STM32 families). 6345 * @note If both groups regular and injected are selected, 6346 * specify behavior of ADC group injected interrupting 6347 * group regular: when ADC group injected is triggered, 6348 * the oversampling on ADC group regular is either 6349 * temporary stopped and continued, or resumed from start 6350 * (oversampler buffer reset). 6351 * @note On this STM32 series, setting of this feature is conditioned to 6352 * ADC state: 6353 * ADC must be disabled or enabled without conversion on going 6354 * on either groups regular or injected. 6355 * @rmtoll CFGR2 ROVSE LL_ADC_SetOverSamplingScope\n 6356 * CFGR2 JOVSE LL_ADC_SetOverSamplingScope\n 6357 * CFGR2 ROVSM LL_ADC_SetOverSamplingScope 6358 * @param ADCx ADC instance 6359 * @param OvsScope This parameter can be one of the following values: 6360 * @arg @ref LL_ADC_OVS_DISABLE 6361 * @arg @ref LL_ADC_OVS_GRP_REGULAR_CONTINUED 6362 * @arg @ref LL_ADC_OVS_GRP_REGULAR_RESUMED 6363 * @arg @ref LL_ADC_OVS_GRP_INJECTED 6364 * @arg @ref LL_ADC_OVS_GRP_INJ_REG_RESUMED 6365 * @retval None 6366 */ 6367 __STATIC_INLINE void LL_ADC_SetOverSamplingScope(ADC_TypeDef *ADCx, uint32_t OvsScope) 6368 { 6369 MODIFY_REG(ADCx->CFGR2, ADC_CFGR2_ROVSE | ADC_CFGR2_JOVSE | ADC_CFGR2_ROVSM, OvsScope); 6370 } 6371 6372 /** 6373 * @brief Get ADC oversampling scope: ADC groups regular and-or injected 6374 * (availability of ADC group injected depends on STM32 families). 6375 * @note If both groups regular and injected are selected, 6376 * specify behavior of ADC group injected interrupting 6377 * group regular: when ADC group injected is triggered, 6378 * the oversampling on ADC group regular is either 6379 * temporary stopped and continued, or resumed from start 6380 * (oversampler buffer reset). 6381 * @rmtoll CFGR2 ROVSE LL_ADC_GetOverSamplingScope\n 6382 * CFGR2 JOVSE LL_ADC_GetOverSamplingScope\n 6383 * CFGR2 ROVSM LL_ADC_GetOverSamplingScope 6384 * @param ADCx ADC instance 6385 * @retval Returned value can be one of the following values: 6386 * @arg @ref LL_ADC_OVS_DISABLE 6387 * @arg @ref LL_ADC_OVS_GRP_REGULAR_CONTINUED 6388 * @arg @ref LL_ADC_OVS_GRP_REGULAR_RESUMED 6389 * @arg @ref LL_ADC_OVS_GRP_INJECTED 6390 * @arg @ref LL_ADC_OVS_GRP_INJ_REG_RESUMED 6391 */ 6392 __STATIC_INLINE uint32_t LL_ADC_GetOverSamplingScope(ADC_TypeDef *ADCx) 6393 { 6394 return (uint32_t)(READ_BIT(ADCx->CFGR2, ADC_CFGR2_ROVSE | ADC_CFGR2_JOVSE | ADC_CFGR2_ROVSM)); 6395 } 6396 6397 /** 6398 * @brief Set ADC oversampling discontinuous mode (triggered mode) 6399 * on the selected ADC group. 6400 * @note Number of oversampled conversions are done either in: 6401 * - continuous mode (all conversions of oversampling ratio 6402 * are done from 1 trigger) 6403 * - discontinuous mode (each conversion of oversampling ratio 6404 * needs a trigger) 6405 * @note On this STM32 series, setting of this feature is conditioned to 6406 * ADC state: 6407 * ADC must be disabled or enabled without conversion on going 6408 * on group regular. 6409 * @note On this STM32 series, oversampling discontinuous mode 6410 * (triggered mode) can be used only when oversampling is 6411 * set on group regular only and in resumed mode. 6412 * @rmtoll CFGR2 TROVS LL_ADC_SetOverSamplingDiscont 6413 * @param ADCx ADC instance 6414 * @param OverSamplingDiscont This parameter can be one of the following values: 6415 * @arg @ref LL_ADC_OVS_REG_CONT 6416 * @arg @ref LL_ADC_OVS_REG_DISCONT 6417 * @retval None 6418 */ 6419 __STATIC_INLINE void LL_ADC_SetOverSamplingDiscont(ADC_TypeDef *ADCx, uint32_t OverSamplingDiscont) 6420 { 6421 MODIFY_REG(ADCx->CFGR2, ADC_CFGR2_TROVS, OverSamplingDiscont); 6422 } 6423 6424 /** 6425 * @brief Get ADC oversampling discontinuous mode (triggered mode) 6426 * on the selected ADC group. 6427 * @note Number of oversampled conversions are done either in: 6428 * - continuous mode (all conversions of oversampling ratio 6429 * are done from 1 trigger) 6430 * - discontinuous mode (each conversion of oversampling ratio 6431 * needs a trigger) 6432 * @rmtoll CFGR2 TROVS LL_ADC_GetOverSamplingDiscont 6433 * @param ADCx ADC instance 6434 * @retval Returned value can be one of the following values: 6435 * @arg @ref LL_ADC_OVS_REG_CONT 6436 * @arg @ref LL_ADC_OVS_REG_DISCONT 6437 */ 6438 __STATIC_INLINE uint32_t LL_ADC_GetOverSamplingDiscont(ADC_TypeDef *ADCx) 6439 { 6440 return (uint32_t)(READ_BIT(ADCx->CFGR2, ADC_CFGR2_TROVS)); 6441 } 6442 6443 /** 6444 * @brief Set ADC oversampling 6445 * (impacting both ADC groups regular and injected) 6446 * @note This function set the 2 items of oversampling configuration: 6447 * - ratio 6448 * - shift 6449 * @note On this STM32 series, setting of this feature is conditioned to 6450 * ADC state: 6451 * ADC must be disabled or enabled without conversion on going 6452 * on either groups regular or injected. 6453 * @rmtoll CFGR2 OVSS LL_ADC_ConfigOverSamplingRatioShift\n 6454 * CFGR2 OVSR LL_ADC_ConfigOverSamplingRatioShift 6455 * @param ADCx ADC instance 6456 * @param Ratio This parameter can be in the range from 1 to 1024. 6457 * In the case of ADC3 can be one of the following values: 6458 * @arg @ref LL_ADC_OVS_RATIO_2 6459 * @arg @ref LL_ADC_OVS_RATIO_4 6460 * @arg @ref LL_ADC_OVS_RATIO_8 6461 * @arg @ref LL_ADC_OVS_RATIO_16 6462 * @arg @ref LL_ADC_OVS_RATIO_32 6463 * @arg @ref LL_ADC_OVS_RATIO_64 6464 * @arg @ref LL_ADC_OVS_RATIO_128 6465 * @arg @ref LL_ADC_OVS_RATIO_256 6466 * @param Shift This parameter can be one of the following values: 6467 * @arg @ref LL_ADC_OVS_SHIFT_NONE 6468 * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_1 6469 * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_2 6470 * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_3 6471 * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_4 6472 * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_5 6473 * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_6 6474 * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_7 6475 * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_8 6476 * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_9 6477 * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_10 6478 * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_11 6479 * @retval None 6480 */ 6481 __STATIC_INLINE void LL_ADC_ConfigOverSamplingRatioShift(ADC_TypeDef *ADCx, uint32_t Ratio, uint32_t Shift) 6482 { 6483 #if defined(ADC_VER_V5_V90) 6484 if(ADCx==ADC3) 6485 { 6486 MODIFY_REG(ADCx->CFGR2, (ADC_CFGR2_OVSS | ADC3_CFGR2_OVSR), (Shift | Ratio)); 6487 } 6488 else 6489 { 6490 MODIFY_REG(ADCx->CFGR2, (ADC_CFGR2_OVSS | ADC_CFGR2_OVSR), (Shift | (((Ratio - 1UL) << ADC_CFGR2_OVSR_Pos)))); 6491 } 6492 #else 6493 6494 MODIFY_REG(ADCx->CFGR2, (ADC_CFGR2_OVSS | ADC_CFGR2_OVSR), (Shift | (((Ratio - 1UL) << ADC_CFGR2_OVSR_Pos)))); 6495 6496 #endif /* ADC_VER_V5_V90 */ 6497 } 6498 6499 /** 6500 * @brief Get ADC oversampling ratio 6501 * (impacting both ADC groups regular and injected) 6502 * @rmtoll CFGR2 OVSR LL_ADC_GetOverSamplingRatio 6503 * @param ADCx ADC instance 6504 * @retval Ratio This parameter can be in the from 1 to 1024. 6505 * In the case of ADC3 can be one of the following values: 6506 * @arg @ref LL_ADC_OVS_RATIO_2 6507 * @arg @ref LL_ADC_OVS_RATIO_4 6508 * @arg @ref LL_ADC_OVS_RATIO_8 6509 * @arg @ref LL_ADC_OVS_RATIO_16 6510 * @arg @ref LL_ADC_OVS_RATIO_32 6511 * @arg @ref LL_ADC_OVS_RATIO_64 6512 * @arg @ref LL_ADC_OVS_RATIO_128 6513 * @arg @ref LL_ADC_OVS_RATIO_256 6514 */ 6515 __STATIC_INLINE uint32_t LL_ADC_GetOverSamplingRatio(ADC_TypeDef *ADCx) 6516 { 6517 #if defined(ADC_VER_V5_V90) 6518 if(ADCx==ADC3) 6519 { 6520 return (uint32_t)(READ_BIT(ADCx->CFGR2, ADC3_CFGR2_OVSR)); 6521 } 6522 else 6523 { 6524 return (((uint32_t)(READ_BIT(ADCx->CFGR2, ADC_CFGR2_OVSR)) + (1UL << ADC_CFGR2_OVSR_Pos)) >> ADC_CFGR2_OVSR_Pos); 6525 } 6526 #else 6527 6528 return (((uint32_t)(READ_BIT(ADCx->CFGR2, ADC_CFGR2_OVSR)) + (1UL << ADC_CFGR2_OVSR_Pos)) >> ADC_CFGR2_OVSR_Pos); 6529 6530 #endif /* ADC_VER_V5_V90 */ 6531 } 6532 6533 /** 6534 * @brief Get ADC oversampling shift 6535 * (impacting both ADC groups regular and injected) 6536 * @rmtoll CFGR2 OVSS LL_ADC_GetOverSamplingShift 6537 * @param ADCx ADC instance 6538 * @retval Shift This parameter can be one of the following values: 6539 * @arg @ref LL_ADC_OVS_SHIFT_NONE 6540 * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_1 6541 * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_2 6542 * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_3 6543 * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_4 6544 * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_5 6545 * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_6 6546 * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_7 6547 * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_8 6548 * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_9 6549 * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_10 6550 * @arg @ref LL_ADC_OVS_SHIFT_RIGHT_11 6551 */ 6552 __STATIC_INLINE uint32_t LL_ADC_GetOverSamplingShift(ADC_TypeDef *ADCx) 6553 { 6554 return (uint32_t)(READ_BIT(ADCx->CFGR2, ADC_CFGR2_OVSS)); 6555 } 6556 6557 /** 6558 * @} 6559 */ 6560 6561 /** @defgroup ADC_LL_EF_Configuration_ADC_Multimode Configuration of ADC hierarchical scope: multimode 6562 * @ingroup RTEMSBSPsARMSTM32H7 6563 * @{ 6564 */ 6565 /** 6566 * @brief Set ADC boost mode. 6567 * @note On this STM32 series, setting of this feature is conditioned to 6568 * ADC state: 6569 * ADC boost must be configured, without calibration on going, without conversion 6570 * on going on group regular. 6571 * @rmtoll CR BOOST LL_ADC_SetBoostMode 6572 * @param ADCx ADC instance 6573 * @param BoostMode This parameter can be one of the following values: 6574 * @arg @ref LL_ADC_BOOST_MODE_6MHZ25 6575 * @arg @ref LL_ADC_BOOST_MODE_12MHZ5 6576 * @arg @ref LL_ADC_BOOST_MODE_20MHZ 6577 * @arg @ref LL_ADC_BOOST_MODE_25MHZ 6578 * @arg @ref LL_ADC_BOOST_MODE_50MHZ 6579 * @retval None 6580 */ 6581 __STATIC_INLINE void LL_ADC_SetBoostMode(ADC_TypeDef *ADCx, uint32_t BoostMode) 6582 { 6583 #if defined(ADC_VER_V5_V90) 6584 if (ADCx != ADC3) 6585 { 6586 MODIFY_REG(ADCx->CR, ADC_CR_BOOST, (BoostMode & ADC_CR_BOOST)); 6587 } 6588 #else /* ADC_VER_V5_V90 */ 6589 if ((DBGMCU->IDCODE & 0x30000000UL) == 0x10000000UL) /* Cut 1.x */ 6590 { 6591 MODIFY_REG(ADCx->CR, ADC_CR_BOOST_0, (BoostMode >> 2UL)); 6592 } 6593 else /* Cut 2.x */ 6594 { 6595 MODIFY_REG(ADCx->CR, ADC_CR_BOOST, (BoostMode & ADC_CR_BOOST)); 6596 } 6597 #endif /* ADC_VER_V5_V90 */ 6598 } 6599 6600 6601 /** 6602 * @brief Get ADC boost mode. 6603 * @note On this STM32 series, setting of this feature is conditioned to 6604 * ADC state: 6605 * ADC boost must be configured, without calibration on going, without conversion 6606 * on going on group regular. 6607 * @rmtoll CR BOOST LL_ADC_GetBoostMode 6608 * @param ADCx ADC instance 6609 * @retval 0: Boost disabled 1: Boost enabled 6610 */ 6611 __STATIC_INLINE uint32_t LL_ADC_GetBoostMode(ADC_TypeDef *ADCx) 6612 { 6613 if ((DBGMCU->IDCODE & 0x30000000UL) == 0x10000000UL) /* Cut 1.x */ 6614 { 6615 return (uint32_t)READ_BIT(ADCx->CR, ADC_CR_BOOST_0); 6616 } 6617 else /* Cut 2.x */ 6618 { 6619 return ((READ_BIT(ADCx->CR, ADC_CR_BOOST) == (ADC_CR_BOOST)) ? 1UL : 0UL); 6620 } 6621 } 6622 6623 /** 6624 * @brief Set ADC multimode configuration to operate in independent mode 6625 * or multimode (for devices with several ADC instances). 6626 * @note If multimode configuration: the selected ADC instance is 6627 * either master or slave depending on hardware. 6628 * Refer to reference manual. 6629 * @note On this STM32 series, setting of this feature is conditioned to 6630 * ADC state: 6631 * All ADC instances of the ADC common group must be disabled. 6632 * This check can be done with function @ref LL_ADC_IsEnabled() for each 6633 * ADC instance or by using helper macro 6634 * @ref __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(). 6635 * @rmtoll CCR DUAL LL_ADC_SetMultimode 6636 * @param ADCxy_COMMON ADC common instance 6637 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() ) 6638 * @param Multimode This parameter can be one of the following values: 6639 * @arg @ref LL_ADC_MULTI_INDEPENDENT 6640 * @arg @ref LL_ADC_MULTI_DUAL_REG_SIMULT 6641 * @arg @ref LL_ADC_MULTI_DUAL_REG_INTERL 6642 * @arg @ref LL_ADC_MULTI_DUAL_INJ_SIMULT 6643 * @arg @ref LL_ADC_MULTI_DUAL_INJ_ALTERN 6644 * @arg @ref LL_ADC_MULTI_DUAL_REG_SIM_INJ_SIM 6645 * @arg @ref LL_ADC_MULTI_DUAL_REG_SIM_INJ_ALT 6646 * @arg @ref LL_ADC_MULTI_DUAL_REG_INT_INJ_SIM 6647 * @retval None 6648 */ 6649 __STATIC_INLINE void LL_ADC_SetMultimode(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t Multimode) 6650 { 6651 MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_DUAL, Multimode); 6652 } 6653 6654 /** 6655 * @brief Get ADC multimode configuration to operate in independent mode 6656 * or multimode (for devices with several ADC instances). 6657 * @note If multimode configuration: the selected ADC instance is 6658 * either master or slave depending on hardware. 6659 * Refer to reference manual. 6660 * @rmtoll CCR DUAL LL_ADC_GetMultimode 6661 * @param ADCxy_COMMON ADC common instance 6662 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() ) 6663 * @retval Returned value can be one of the following values: 6664 * @arg @ref LL_ADC_MULTI_INDEPENDENT 6665 * @arg @ref LL_ADC_MULTI_DUAL_REG_SIMULT 6666 * @arg @ref LL_ADC_MULTI_DUAL_REG_INTERL 6667 * @arg @ref LL_ADC_MULTI_DUAL_INJ_SIMULT 6668 * @arg @ref LL_ADC_MULTI_DUAL_INJ_ALTERN 6669 * @arg @ref LL_ADC_MULTI_DUAL_REG_SIM_INJ_SIM 6670 * @arg @ref LL_ADC_MULTI_DUAL_REG_SIM_INJ_ALT 6671 * @arg @ref LL_ADC_MULTI_DUAL_REG_INT_INJ_SIM 6672 */ 6673 __STATIC_INLINE uint32_t LL_ADC_GetMultimode(ADC_Common_TypeDef *ADCxy_COMMON) 6674 { 6675 return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_DUAL)); 6676 } 6677 6678 /** 6679 * @brief Set ADC multimode conversion data transfer: no transfer 6680 * or transfer by DMA. 6681 * @note If ADC multimode transfer by DMA is not selected: 6682 * each ADC uses its own DMA channel, with its individual 6683 * DMA transfer settings. 6684 * If ADC multimode transfer by DMA is selected: 6685 * One DMA channel is used for both ADC (DMA of ADC master) 6686 * Specifies the DMA requests mode: 6687 * - Limited mode (One shot mode): DMA transfer requests are stopped 6688 * when number of DMA data transfers (number of 6689 * ADC conversions) is reached. 6690 * This ADC mode is intended to be used with DMA mode non-circular. 6691 * - Unlimited mode: DMA transfer requests are unlimited, 6692 * whatever number of DMA data transfers (number of 6693 * ADC conversions). 6694 * This ADC mode is intended to be used with DMA mode circular. 6695 * @note If ADC DMA requests mode is set to unlimited and DMA is set to 6696 * mode non-circular: 6697 * when DMA transfers size will be reached, DMA will stop transfers of 6698 * ADC conversions data ADC will raise an overrun error 6699 * (overrun flag and interruption if enabled). 6700 * @note How to retrieve multimode conversion data: 6701 * Whatever multimode transfer by DMA setting: using function 6702 * @ref LL_ADC_REG_ReadMultiConversionData32(). 6703 * If ADC multimode transfer by DMA is selected: conversion data 6704 * is a raw data with ADC master and slave concatenated. 6705 * A macro is available to get the conversion data of 6706 * ADC master or ADC slave: see helper macro 6707 * @ref __LL_ADC_MULTI_CONV_DATA_MASTER_SLAVE(). 6708 * @note On this STM32 series, setting of this feature is conditioned to 6709 * ADC state: 6710 * All ADC instances of the ADC common group must be disabled 6711 * or enabled without conversion on going on group regular. 6712 * @rmtoll CCR DAMDF LL_ADC_GetMultiDMATransfer\n 6713 * @param ADCxy_COMMON ADC common instance 6714 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() ) 6715 * @param MultiDMATransfer This parameter can be one of the following values: 6716 * @arg @ref LL_ADC_MULTI_REG_DMA_EACH_ADC 6717 * @arg @ref LL_ADC_MULTI_REG_DMA_RES_32_10B 6718 * @arg @ref LL_ADC_MULTI_REG_DMA_RES_8B 6719 * @retval None 6720 */ 6721 __STATIC_INLINE void LL_ADC_SetMultiDMATransfer(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t MultiDMATransfer) 6722 { 6723 MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_DAMDF, MultiDMATransfer); 6724 } 6725 6726 /** 6727 * @brief Get ADC multimode conversion data transfer: no transfer 6728 * or transfer by DMA. 6729 * @note If ADC multimode transfer by DMA is not selected: 6730 * each ADC uses its own DMA channel, with its individual 6731 * DMA transfer settings. 6732 * If ADC multimode transfer by DMA is selected: 6733 * One DMA channel is used for both ADC (DMA of ADC master) 6734 * Specifies the DMA requests mode: 6735 * - Limited mode (One shot mode): DMA transfer requests are stopped 6736 * when number of DMA data transfers (number of 6737 * ADC conversions) is reached. 6738 * This ADC mode is intended to be used with DMA mode non-circular. 6739 * - Unlimited mode: DMA transfer requests are unlimited, 6740 * whatever number of DMA data transfers (number of 6741 * ADC conversions). 6742 * This ADC mode is intended to be used with DMA mode circular. 6743 * @note If ADC DMA requests mode is set to unlimited and DMA is set to 6744 * mode non-circular: 6745 * when DMA transfers size will be reached, DMA will stop transfers of 6746 * ADC conversions data ADC will raise an overrun error 6747 * (overrun flag and interruption if enabled). 6748 * @note How to retrieve multimode conversion data: 6749 * Whatever multimode transfer by DMA setting: using function 6750 * @ref LL_ADC_REG_ReadMultiConversionData32(). 6751 * If ADC multimode transfer by DMA is selected: conversion data 6752 * is a raw data with ADC master and slave concatenated. 6753 * A macro is available to get the conversion data of 6754 * ADC master or ADC slave: see helper macro 6755 * @ref __LL_ADC_MULTI_CONV_DATA_MASTER_SLAVE(). 6756 * @rmtoll CCR DAMDF LL_ADC_GetMultiDMATransfer\n 6757 * @param ADCxy_COMMON ADC common instance 6758 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() ) 6759 * @retval Returned value can be one of the following values: 6760 * @arg @ref LL_ADC_MULTI_REG_DMA_EACH_ADC 6761 * @arg @ref LL_ADC_MULTI_REG_DMA_RES_32_10B 6762 * @arg @ref LL_ADC_MULTI_REG_DMA_RES_8B 6763 */ 6764 __STATIC_INLINE uint32_t LL_ADC_GetMultiDMATransfer(ADC_Common_TypeDef *ADCxy_COMMON) 6765 { 6766 return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_DAMDF)); 6767 } 6768 6769 /** 6770 * @brief Set ADC multimode delay between 2 sampling phases. 6771 * @note The sampling delay range depends on ADC resolution: 6772 * - ADC resolution 12 bits can have maximum delay of 12 cycles. 6773 * - ADC resolution 10 bits can have maximum delay of 10 cycles. 6774 * - ADC resolution 8 bits can have maximum delay of 8 cycles. 6775 * - ADC resolution 6 bits can have maximum delay of 6 cycles. 6776 * @note On this STM32 series, setting of this feature is conditioned to 6777 * ADC state: 6778 * All ADC instances of the ADC common group must be disabled. 6779 * This check can be done with function @ref LL_ADC_IsEnabled() for each 6780 * ADC instance or by using helper macro helper macro 6781 * @ref __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(). 6782 * @rmtoll CCR DELAY LL_ADC_SetMultiTwoSamplingDelay 6783 * @param ADCxy_COMMON ADC common instance 6784 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() ) 6785 * @param MultiTwoSamplingDelay This parameter can be one of the following values: 6786 * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_1CYCLE_5 6787 * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_2CYCLES_5 6788 * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_3CYCLES_5 6789 * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_4CYCLES_5 (1) 6790 * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_4CYCLES_5_8_BITS 6791 * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_5CYCLES_5 (2) 6792 * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_5CYCLES_5_10_BITS 6793 * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_6CYCLES (3) 6794 * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_6CYCLES_5 (4) 6795 * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_6CYCLES_5_12_BITS 6796 * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_7CYCLES_5 (5) 6797 * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_8CYCLES (6) 6798 * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_9CYCLES (7) 6799 * 6800 * (1) Parameter available only if ADC resolution is 16, 14, 12 or 10 bits. 6801 * (2) Parameter available only if ADC resolution is 16, 14 or 12 bits. 6802 * (3) Parameter available only if ADC resolution is 10 or 8 bits. 6803 * (4) Parameter available only if ADC resolution is 16 or 14 bits. 6804 * (5) Parameter available only if ADC resolution is 16 bits. 6805 * (6) Parameter available only if ADC resolution is 12 bits. 6806 * (7) Parameter available only if ADC resolution is 16 or 14 bits. 6807 * @retval None 6808 */ 6809 __STATIC_INLINE void LL_ADC_SetMultiTwoSamplingDelay(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t MultiTwoSamplingDelay) 6810 { 6811 MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_DELAY, MultiTwoSamplingDelay); 6812 } 6813 6814 /** 6815 * @brief Get ADC multimode delay between 2 sampling phases. 6816 * @rmtoll CCR DELAY LL_ADC_GetMultiTwoSamplingDelay 6817 * @param ADCxy_COMMON ADC common instance 6818 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() ) 6819 * @retval Returned value can be one of the following values: 6820 * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_1CYCLE_5 6821 * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_2CYCLES_5 6822 * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_3CYCLES_5 6823 * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_4CYCLES_5 (1) 6824 * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_4CYCLES_5_8_BITS 6825 * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_5CYCLES_5 (2) 6826 * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_5CYCLES_5_10_BITS 6827 * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_6CYCLES (3) 6828 * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_6CYCLES_5 (4) 6829 * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_6CYCLES_5_12_BITS 6830 * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_7CYCLES_5 (5) 6831 * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_8CYCLES (6) 6832 * @arg @ref LL_ADC_MULTI_TWOSMP_DELAY_9CYCLES (7) 6833 * 6834 * (1) Parameter available only if ADC resolution is 16, 14, 12 or 10 bits. 6835 * (2) Parameter available only if ADC resolution is 16, 14 or 12 bits. 6836 * (3) Parameter available only if ADC resolution is 10 or 8 bits. 6837 * (4) Parameter available only if ADC resolution is 16 or 14 bits. 6838 * (5) Parameter available only if ADC resolution is 16 bits. 6839 * (6) Parameter available only if ADC resolution is 12 bits. 6840 * (7) Parameter available only if ADC resolution is 16 or 14 bits. 6841 */ 6842 __STATIC_INLINE uint32_t LL_ADC_GetMultiTwoSamplingDelay(ADC_Common_TypeDef *ADCxy_COMMON) 6843 { 6844 return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_DELAY)); 6845 } 6846 6847 /** 6848 * @} 6849 */ 6850 /** @defgroup ADC_LL_EF_Operation_ADC_Instance Operation on ADC hierarchical scope: ADC instance 6851 * @ingroup RTEMSBSPsARMSTM32H7 6852 * @{ 6853 */ 6854 6855 /** 6856 * @brief Put ADC instance in deep power down state. 6857 * @note In case of ADC calibration necessary: When ADC is in deep-power-down 6858 * state, the internal analog calibration is lost. After exiting from 6859 * deep power down, calibration must be relaunched or calibration factor 6860 * (preliminarily saved) must be set back into calibration register. 6861 * @note On this STM32 series, setting of this feature is conditioned to 6862 * ADC state: 6863 * ADC must be ADC disabled. 6864 * @rmtoll CR DEEPPWD LL_ADC_EnableDeepPowerDown 6865 * @param ADCx ADC instance 6866 * @retval None 6867 */ 6868 __STATIC_INLINE void LL_ADC_EnableDeepPowerDown(ADC_TypeDef *ADCx) 6869 { 6870 /* Note: Write register with some additional bits forced to state reset */ 6871 /* instead of modifying only the selected bit for this function, */ 6872 /* to not interfere with bits with HW property "rs". */ 6873 MODIFY_REG(ADCx->CR, 6874 ADC_CR_BITS_PROPERTY_RS, 6875 ADC_CR_DEEPPWD); 6876 } 6877 6878 /** 6879 * @brief Disable ADC deep power down mode. 6880 * @note In case of ADC calibration necessary: When ADC is in deep-power-down 6881 * state, the internal analog calibration is lost. After exiting from 6882 * deep power down, calibration must be relaunched or calibration factor 6883 * (preliminarily saved) must be set back into calibration register. 6884 * @note On this STM32 series, setting of this feature is conditioned to 6885 * ADC state: 6886 * ADC must be ADC disabled. 6887 * @rmtoll CR DEEPPWD LL_ADC_DisableDeepPowerDown 6888 * @param ADCx ADC instance 6889 * @retval None 6890 */ 6891 __STATIC_INLINE void LL_ADC_DisableDeepPowerDown(ADC_TypeDef *ADCx) 6892 { 6893 /* Note: Write register with some additional bits forced to state reset */ 6894 /* instead of modifying only the selected bit for this function, */ 6895 /* to not interfere with bits with HW property "rs". */ 6896 CLEAR_BIT(ADCx->CR, (ADC_CR_DEEPPWD | ADC_CR_BITS_PROPERTY_RS)); 6897 } 6898 6899 /** 6900 * @brief Get the selected ADC instance deep power down state. 6901 * @rmtoll CR DEEPPWD LL_ADC_IsDeepPowerDownEnabled 6902 * @param ADCx ADC instance 6903 * @retval 0: deep power down is disabled, 1: deep power down is enabled. 6904 */ 6905 __STATIC_INLINE uint32_t LL_ADC_IsDeepPowerDownEnabled(ADC_TypeDef *ADCx) 6906 { 6907 return ((READ_BIT(ADCx->CR, ADC_CR_DEEPPWD) == (ADC_CR_DEEPPWD)) ? 1UL : 0UL); 6908 } 6909 6910 /** 6911 * @brief Enable ADC instance internal voltage regulator. 6912 * @note On this STM32 series, after ADC internal voltage regulator enable, 6913 * a delay for ADC internal voltage regulator stabilization 6914 * is required before performing a ADC calibration or ADC enable. 6915 * Refer to device datasheet, parameter tADCVREG_STUP. 6916 * Refer to literal @ref LL_ADC_DELAY_INTERNAL_REGUL_STAB_US. 6917 * @note On this STM32 series, setting of this feature is conditioned to 6918 * ADC state: 6919 * ADC must be ADC disabled. 6920 * @rmtoll CR ADVREGEN LL_ADC_EnableInternalRegulator 6921 * @param ADCx ADC instance 6922 * @retval None 6923 */ 6924 __STATIC_INLINE void LL_ADC_EnableInternalRegulator(ADC_TypeDef *ADCx) 6925 { 6926 /* Note: Write register with some additional bits forced to state reset */ 6927 /* instead of modifying only the selected bit for this function, */ 6928 /* to not interfere with bits with HW property "rs". */ 6929 MODIFY_REG(ADCx->CR, 6930 ADC_CR_BITS_PROPERTY_RS, 6931 ADC_CR_ADVREGEN); 6932 } 6933 6934 /** 6935 * @brief Disable ADC internal voltage regulator. 6936 * @note On this STM32 series, setting of this feature is conditioned to 6937 * ADC state: 6938 * ADC must be ADC disabled. 6939 * @rmtoll CR ADVREGEN LL_ADC_DisableInternalRegulator 6940 * @param ADCx ADC instance 6941 * @retval None 6942 */ 6943 __STATIC_INLINE void LL_ADC_DisableInternalRegulator(ADC_TypeDef *ADCx) 6944 { 6945 CLEAR_BIT(ADCx->CR, (ADC_CR_ADVREGEN | ADC_CR_BITS_PROPERTY_RS)); 6946 } 6947 6948 /** 6949 * @brief Get the selected ADC instance internal voltage regulator state. 6950 * @rmtoll CR ADVREGEN LL_ADC_IsInternalRegulatorEnabled 6951 * @param ADCx ADC instance 6952 * @retval 0: internal regulator is disabled, 1: internal regulator is enabled. 6953 */ 6954 __STATIC_INLINE uint32_t LL_ADC_IsInternalRegulatorEnabled(ADC_TypeDef *ADCx) 6955 { 6956 return ((READ_BIT(ADCx->CR, ADC_CR_ADVREGEN) == (ADC_CR_ADVREGEN)) ? 1UL : 0UL); 6957 } 6958 6959 /** 6960 * @brief Enable the selected ADC instance. 6961 * @note On this STM32 series, after ADC enable, a delay for 6962 * ADC internal analog stabilization is required before performing a 6963 * ADC conversion start. 6964 * Refer to device datasheet, parameter tSTAB. 6965 * @note On this STM32 series, flag LL_ADC_FLAG_ADRDY is raised when the ADC 6966 * is enabled and when conversion clock is active. 6967 * (not only core clock: this ADC has a dual clock domain) 6968 * @note On this STM32 series, setting of this feature is conditioned to 6969 * ADC state: 6970 * ADC must be ADC disabled and ADC internal voltage regulator enabled. 6971 * @rmtoll CR ADEN LL_ADC_Enable 6972 * @param ADCx ADC instance 6973 * @retval None 6974 */ 6975 __STATIC_INLINE void LL_ADC_Enable(ADC_TypeDef *ADCx) 6976 { 6977 /* Note: Write register with some additional bits forced to state reset */ 6978 /* instead of modifying only the selected bit for this function, */ 6979 /* to not interfere with bits with HW property "rs". */ 6980 MODIFY_REG(ADCx->CR, 6981 ADC_CR_BITS_PROPERTY_RS, 6982 ADC_CR_ADEN); 6983 } 6984 6985 /** 6986 * @brief Disable the selected ADC instance. 6987 * @note On this STM32 series, setting of this feature is conditioned to 6988 * ADC state: 6989 * ADC must be not disabled. Must be enabled without conversion on going 6990 * on either groups regular or injected. 6991 * @rmtoll CR ADDIS LL_ADC_Disable 6992 * @param ADCx ADC instance 6993 * @retval None 6994 */ 6995 __STATIC_INLINE void LL_ADC_Disable(ADC_TypeDef *ADCx) 6996 { 6997 /* Note: Write register with some additional bits forced to state reset */ 6998 /* instead of modifying only the selected bit for this function, */ 6999 /* to not interfere with bits with HW property "rs". */ 7000 MODIFY_REG(ADCx->CR, 7001 ADC_CR_BITS_PROPERTY_RS, 7002 ADC_CR_ADDIS); 7003 } 7004 7005 /** 7006 * @brief Get the selected ADC instance enable state. 7007 * @note On this STM32 series, flag LL_ADC_FLAG_ADRDY is raised when the ADC 7008 * is enabled and when conversion clock is active. 7009 * (not only core clock: this ADC has a dual clock domain) 7010 * @rmtoll CR ADEN LL_ADC_IsEnabled 7011 * @param ADCx ADC instance 7012 * @retval 0: ADC is disabled, 1: ADC is enabled. 7013 */ 7014 __STATIC_INLINE uint32_t LL_ADC_IsEnabled(ADC_TypeDef *ADCx) 7015 { 7016 return ((READ_BIT(ADCx->CR, ADC_CR_ADEN) == (ADC_CR_ADEN)) ? 1UL : 0UL); 7017 } 7018 7019 /** 7020 * @brief Get the selected ADC instance disable state. 7021 * @rmtoll CR ADDIS LL_ADC_IsDisableOngoing 7022 * @param ADCx ADC instance 7023 * @retval 0: no ADC disable command on going. 7024 */ 7025 __STATIC_INLINE uint32_t LL_ADC_IsDisableOngoing(ADC_TypeDef *ADCx) 7026 { 7027 return ((READ_BIT(ADCx->CR, ADC_CR_ADDIS) == (ADC_CR_ADDIS)) ? 1UL : 0UL); 7028 } 7029 7030 /** 7031 * @brief Start ADC calibration in the mode single-ended 7032 * or differential (for devices with differential mode available). 7033 * @note On this STM32 series, a minimum number of ADC clock cycles 7034 * are required between ADC end of calibration and ADC enable. 7035 * Refer to literal @ref LL_ADC_DELAY_CALIB_ENABLE_ADC_CYCLES. 7036 * @note Calibration duration: 7037 * - Calibration of offset: 520 ADC clock cycles 7038 * - Calibration of linearity: 131072 ADC clock cycles 7039 * @note For devices with differential mode available: 7040 * Calibration of offset is specific to each of 7041 * single-ended and differential modes 7042 * (calibration run must be performed for each of these 7043 * differential modes, if used afterwards and if the application 7044 * requires their calibration). 7045 * Calibration of linearity is common to both 7046 * single-ended and differential modes 7047 * (calibration run can be performed only once). 7048 * @note On this STM32 series, setting of this feature is conditioned to 7049 * ADC state: 7050 * ADC must be ADC disabled. 7051 * @rmtoll CR ADCAL LL_ADC_StartCalibration\n 7052 * CR ADCALDIF LL_ADC_StartCalibration\n 7053 * CR ADCALLIN LL_ADC_StartCalibration 7054 * @param ADCx ADC instance 7055 * @param CalibrationMode This parameter can be one of the following values: 7056 * @arg @ref LL_ADC_CALIB_OFFSET 7057 * @arg @ref LL_ADC_CALIB_OFFSET_LINEARITY 7058 * @param SingleDiff This parameter can be one of the following values: 7059 * @arg @ref LL_ADC_SINGLE_ENDED 7060 * @arg @ref LL_ADC_DIFFERENTIAL_ENDED 7061 * @retval None 7062 */ 7063 __STATIC_INLINE void LL_ADC_StartCalibration(ADC_TypeDef *ADCx, uint32_t CalibrationMode, uint32_t SingleDiff) 7064 { 7065 /* Note: Write register with some additional bits forced to state reset */ 7066 /* instead of modifying only the selected bit for this function, */ 7067 /* to not interfere with bits with HW property "rs". */ 7068 MODIFY_REG(ADCx->CR, 7069 ADC_CR_ADCALLIN | ADC_CR_ADCALDIF | ADC_CR_BITS_PROPERTY_RS, 7070 ADC_CR_ADCAL | (CalibrationMode & ADC_CALIB_MODE_MASK) | (SingleDiff & ADC_SINGLEDIFF_CALIB_START_MASK)); 7071 } 7072 7073 /** 7074 * @brief Get ADC calibration state. 7075 * @rmtoll CR ADCAL LL_ADC_IsCalibrationOnGoing 7076 * @param ADCx ADC instance 7077 * @retval 0: calibration complete, 1: calibration in progress. 7078 */ 7079 __STATIC_INLINE uint32_t LL_ADC_IsCalibrationOnGoing(ADC_TypeDef *ADCx) 7080 { 7081 return ((READ_BIT(ADCx->CR, ADC_CR_ADCAL) == (ADC_CR_ADCAL)) ? 1UL : 0UL); 7082 } 7083 7084 /** 7085 * @} 7086 */ 7087 7088 /** @defgroup ADC_LL_EF_Operation_ADC_Group_Regular Operation on ADC hierarchical scope: group regular 7089 * @ingroup RTEMSBSPsARMSTM32H7 7090 * @{ 7091 */ 7092 7093 /** 7094 * @brief Start ADC group regular conversion. 7095 * @note On this STM32 series, this function is relevant for both 7096 * internal trigger (SW start) and external trigger: 7097 * - If ADC trigger has been set to software start, ADC conversion 7098 * starts immediately. 7099 * - If ADC trigger has been set to external trigger, ADC conversion 7100 * will start at next trigger event (on the selected trigger edge) 7101 * following the ADC start conversion command. 7102 * @note On this STM32 series, setting of this feature is conditioned to 7103 * ADC state: 7104 * ADC must be enabled without conversion on going on group regular, 7105 * without conversion stop command on going on group regular, 7106 * without ADC disable command on going. 7107 * @rmtoll CR ADSTART LL_ADC_REG_StartConversion 7108 * @param ADCx ADC instance 7109 * @retval None 7110 */ 7111 __STATIC_INLINE void LL_ADC_REG_StartConversion(ADC_TypeDef *ADCx) 7112 { 7113 /* Note: Write register with some additional bits forced to state reset */ 7114 /* instead of modifying only the selected bit for this function, */ 7115 /* to not interfere with bits with HW property "rs". */ 7116 MODIFY_REG(ADCx->CR, 7117 ADC_CR_BITS_PROPERTY_RS, 7118 ADC_CR_ADSTART); 7119 } 7120 7121 /** 7122 * @brief Stop ADC group regular conversion. 7123 * @note On this STM32 series, setting of this feature is conditioned to 7124 * ADC state: 7125 * ADC must be enabled with conversion on going on group regular, 7126 * without ADC disable command on going. 7127 * @rmtoll CR ADSTP LL_ADC_REG_StopConversion 7128 * @param ADCx ADC instance 7129 * @retval None 7130 */ 7131 __STATIC_INLINE void LL_ADC_REG_StopConversion(ADC_TypeDef *ADCx) 7132 { 7133 /* Note: Write register with some additional bits forced to state reset */ 7134 /* instead of modifying only the selected bit for this function, */ 7135 /* to not interfere with bits with HW property "rs". */ 7136 MODIFY_REG(ADCx->CR, 7137 ADC_CR_BITS_PROPERTY_RS, 7138 ADC_CR_ADSTP); 7139 } 7140 7141 /** 7142 * @brief Get ADC group regular conversion state. 7143 * @rmtoll CR ADSTART LL_ADC_REG_IsConversionOngoing 7144 * @param ADCx ADC instance 7145 * @retval 0: no conversion is on going on ADC group regular. 7146 */ 7147 __STATIC_INLINE uint32_t LL_ADC_REG_IsConversionOngoing(ADC_TypeDef *ADCx) 7148 { 7149 return ((READ_BIT(ADCx->CR, ADC_CR_ADSTART) == (ADC_CR_ADSTART)) ? 1UL : 0UL); 7150 } 7151 7152 /** 7153 * @brief Get ADC group regular command of conversion stop state 7154 * @rmtoll CR ADSTP LL_ADC_REG_IsStopConversionOngoing 7155 * @param ADCx ADC instance 7156 * @retval 0: no command of conversion stop is on going on ADC group regular. 7157 */ 7158 __STATIC_INLINE uint32_t LL_ADC_REG_IsStopConversionOngoing(ADC_TypeDef *ADCx) 7159 { 7160 return ((READ_BIT(ADCx->CR, ADC_CR_ADSTP) == (ADC_CR_ADSTP)) ? 1UL : 0UL); 7161 } 7162 7163 /** 7164 * @brief Get ADC group regular conversion data, range fit for 7165 * all ADC configurations: all ADC resolutions and 7166 * all oversampling increased data width (for devices 7167 * with feature oversampling). 7168 * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData32 7169 * @param ADCx ADC instance 7170 * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF 7171 */ 7172 __STATIC_INLINE uint32_t LL_ADC_REG_ReadConversionData32(ADC_TypeDef *ADCx) 7173 { 7174 return (uint32_t)(READ_BIT(ADCx->DR, ADC_DR_RDATA)); 7175 } 7176 7177 /** 7178 * @brief Get ADC group regular conversion data, range fit for 7179 * ADC resolution 16 bits. 7180 * @note For devices with feature oversampling: Oversampling 7181 * can increase data width, function for extended range 7182 * may be needed: @ref LL_ADC_REG_ReadConversionData32. 7183 * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData16 7184 * @param ADCx ADC instance 7185 * @retval Value between Min_Data=0x00 and Max_Data=0xFFFF 7186 */ 7187 __STATIC_INLINE uint16_t LL_ADC_REG_ReadConversionData16(ADC_TypeDef *ADCx) 7188 { 7189 return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_RDATA)); 7190 } 7191 7192 /** 7193 * @brief Get ADC group regular conversion data, range fit for 7194 * ADC resolution 14 bits. 7195 * @note For devices with feature oversampling: Oversampling 7196 * can increase data width, function for extended range 7197 * may be needed: @ref LL_ADC_REG_ReadConversionData32. 7198 * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData14 7199 * @param ADCx ADC instance 7200 * @retval Value between Min_Data=0x00 and Max_Data=0x3FF 7201 */ 7202 __STATIC_INLINE uint16_t LL_ADC_REG_ReadConversionData14(ADC_TypeDef *ADCx) 7203 { 7204 return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_RDATA)); 7205 } 7206 7207 /** 7208 * @brief Get ADC group regular conversion data, range fit for 7209 * ADC resolution 12 bits. 7210 * @note For devices with feature oversampling: Oversampling 7211 * can increase data width, function for extended range 7212 * may be needed: @ref LL_ADC_REG_ReadConversionData32. 7213 * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData12 7214 * @param ADCx ADC instance 7215 * @retval Value between Min_Data=0x000 and Max_Data=0xFFF 7216 */ 7217 __STATIC_INLINE uint16_t LL_ADC_REG_ReadConversionData12(ADC_TypeDef *ADCx) 7218 { 7219 return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_RDATA)); 7220 } 7221 7222 /** 7223 * @brief Get ADC group regular conversion data, range fit for 7224 * ADC resolution 10 bits. 7225 * @note For devices with feature oversampling: Oversampling 7226 * can increase data width, function for extended range 7227 * may be needed: @ref LL_ADC_REG_ReadConversionData32. 7228 * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData10 7229 * @param ADCx ADC instance 7230 * @retval Value between Min_Data=0x000 and Max_Data=0x3FF 7231 */ 7232 __STATIC_INLINE uint16_t LL_ADC_REG_ReadConversionData10(ADC_TypeDef *ADCx) 7233 { 7234 return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_RDATA)); 7235 } 7236 7237 /** 7238 * @brief Get ADC group regular conversion data, range fit for 7239 * ADC resolution 8 bits. 7240 * @note For devices with feature oversampling: Oversampling 7241 * can increase data width, function for extended range 7242 * may be needed: @ref LL_ADC_REG_ReadConversionData32. 7243 * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData8 7244 * @param ADCx ADC instance 7245 * @retval Value between Min_Data=0x00 and Max_Data=0xFF 7246 */ 7247 __STATIC_INLINE uint8_t LL_ADC_REG_ReadConversionData8(ADC_TypeDef *ADCx) 7248 { 7249 return (uint8_t)(READ_BIT(ADCx->DR, ADC_DR_RDATA)); 7250 } 7251 /** 7252 * @brief Get ADC multimode conversion data of ADC master, ADC slave 7253 * or raw data with ADC master and slave concatenated. 7254 * @note If raw data with ADC master and slave concatenated is retrieved, 7255 * a macro is available to get the conversion data of 7256 * ADC master or ADC slave: see helper macro 7257 * @ref __LL_ADC_MULTI_CONV_DATA_MASTER_SLAVE(). 7258 * (however this macro is mainly intended for multimode 7259 * transfer by DMA, because this function can do the same 7260 * by getting multimode conversion data of ADC master or ADC slave 7261 * separately). 7262 * @rmtoll CDR RDATA_MST LL_ADC_REG_ReadMultiConversionData32\n 7263 * CDR RDATA_SLV LL_ADC_REG_ReadMultiConversionData32 7264 * @param ADCxy_COMMON ADC common instance 7265 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() ) 7266 * @param ConversionData This parameter can be one of the following values: 7267 * @arg @ref LL_ADC_MULTI_MASTER 7268 * @arg @ref LL_ADC_MULTI_SLAVE 7269 * @arg @ref LL_ADC_MULTI_MASTER_SLAVE 7270 * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF 7271 */ 7272 __STATIC_INLINE uint32_t LL_ADC_REG_ReadMultiConversionData32(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t ConversionData) 7273 { 7274 return (uint32_t)(READ_BIT(ADCxy_COMMON->CDR, 7275 ConversionData) 7276 >> (POSITION_VAL(ConversionData) & 0x1FUL) 7277 ); 7278 } 7279 7280 /** 7281 * @} 7282 */ 7283 7284 /** @defgroup ADC_LL_EF_Operation_ADC_Group_Injected Operation on ADC hierarchical scope: group injected 7285 * @ingroup RTEMSBSPsARMSTM32H7 7286 * @{ 7287 */ 7288 7289 /** 7290 * @brief Start ADC group injected conversion. 7291 * @note On this STM32 series, this function is relevant for both 7292 * internal trigger (SW start) and external trigger: 7293 * - If ADC trigger has been set to software start, ADC conversion 7294 * starts immediately. 7295 * - If ADC trigger has been set to external trigger, ADC conversion 7296 * will start at next trigger event (on the selected trigger edge) 7297 * following the ADC start conversion command. 7298 * @note On this STM32 series, setting of this feature is conditioned to 7299 * ADC state: 7300 * ADC must be enabled without conversion on going on group injected, 7301 * without conversion stop command on going on group injected, 7302 * without ADC disable command on going. 7303 * @rmtoll CR JADSTART LL_ADC_INJ_StartConversion 7304 * @param ADCx ADC instance 7305 * @retval None 7306 */ 7307 __STATIC_INLINE void LL_ADC_INJ_StartConversion(ADC_TypeDef *ADCx) 7308 { 7309 /* Note: Write register with some additional bits forced to state reset */ 7310 /* instead of modifying only the selected bit for this function, */ 7311 /* to not interfere with bits with HW property "rs". */ 7312 MODIFY_REG(ADCx->CR, 7313 ADC_CR_BITS_PROPERTY_RS, 7314 ADC_CR_JADSTART); 7315 } 7316 7317 /** 7318 * @brief Stop ADC group injected conversion. 7319 * @note On this STM32 series, setting of this feature is conditioned to 7320 * ADC state: 7321 * ADC must be enabled with conversion on going on group injected, 7322 * without ADC disable command on going. 7323 * @rmtoll CR JADSTP LL_ADC_INJ_StopConversion 7324 * @param ADCx ADC instance 7325 * @retval None 7326 */ 7327 __STATIC_INLINE void LL_ADC_INJ_StopConversion(ADC_TypeDef *ADCx) 7328 { 7329 /* Note: Write register with some additional bits forced to state reset */ 7330 /* instead of modifying only the selected bit for this function, */ 7331 /* to not interfere with bits with HW property "rs". */ 7332 MODIFY_REG(ADCx->CR, 7333 ADC_CR_BITS_PROPERTY_RS, 7334 ADC_CR_JADSTP); 7335 } 7336 7337 /** 7338 * @brief Get ADC group injected conversion state. 7339 * @rmtoll CR JADSTART LL_ADC_INJ_IsConversionOngoing 7340 * @param ADCx ADC instance 7341 * @retval 0: no conversion is on going on ADC group injected. 7342 */ 7343 __STATIC_INLINE uint32_t LL_ADC_INJ_IsConversionOngoing(ADC_TypeDef *ADCx) 7344 { 7345 return ((READ_BIT(ADCx->CR, ADC_CR_JADSTART) == (ADC_CR_JADSTART)) ? 1UL : 0UL); 7346 } 7347 7348 /** 7349 * @brief Get ADC group injected command of conversion stop state 7350 * @rmtoll CR JADSTP LL_ADC_INJ_IsStopConversionOngoing 7351 * @param ADCx ADC instance 7352 * @retval 0: no command of conversion stop is on going on ADC group injected. 7353 */ 7354 __STATIC_INLINE uint32_t LL_ADC_INJ_IsStopConversionOngoing(ADC_TypeDef *ADCx) 7355 { 7356 return ((READ_BIT(ADCx->CR, ADC_CR_JADSTP) == (ADC_CR_JADSTP)) ? 1UL : 0UL); 7357 } 7358 7359 /** 7360 * @brief Get ADC group injected conversion data, range fit for 7361 * all ADC configurations: all ADC resolutions and 7362 * all oversampling increased data width (for devices 7363 * with feature oversampling). 7364 * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData32\n 7365 * JDR2 JDATA LL_ADC_INJ_ReadConversionData32\n 7366 * JDR3 JDATA LL_ADC_INJ_ReadConversionData32\n 7367 * JDR4 JDATA LL_ADC_INJ_ReadConversionData32 7368 * @param ADCx ADC instance 7369 * @param Rank This parameter can be one of the following values: 7370 * @arg @ref LL_ADC_INJ_RANK_1 7371 * @arg @ref LL_ADC_INJ_RANK_2 7372 * @arg @ref LL_ADC_INJ_RANK_3 7373 * @arg @ref LL_ADC_INJ_RANK_4 7374 * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF 7375 */ 7376 __STATIC_INLINE uint32_t LL_ADC_INJ_ReadConversionData32(ADC_TypeDef *ADCx, uint32_t Rank) 7377 { 7378 const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, ((Rank & ADC_INJ_JDRX_REGOFFSET_MASK) >> ADC_JDRX_REGOFFSET_POS)); 7379 7380 return (uint32_t)(READ_BIT(*preg, 7381 ADC_JDR1_JDATA) 7382 ); 7383 } 7384 7385 /** 7386 * @brief Get ADC group injected conversion data, range fit for 7387 * ADC resolution 16 bits. 7388 * @note For devices with feature oversampling: Oversampling 7389 * can increase data width, function for extended range 7390 * may be needed: @ref LL_ADC_INJ_ReadConversionData32. 7391 * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData16\n 7392 * JDR2 JDATA LL_ADC_INJ_ReadConversionData16\n 7393 * JDR3 JDATA LL_ADC_INJ_ReadConversionData16\n 7394 * JDR4 JDATA LL_ADC_INJ_ReadConversionData16 7395 * @param ADCx ADC instance 7396 * @param Rank This parameter can be one of the following values: 7397 * @arg @ref LL_ADC_INJ_RANK_1 7398 * @arg @ref LL_ADC_INJ_RANK_2 7399 * @arg @ref LL_ADC_INJ_RANK_3 7400 * @arg @ref LL_ADC_INJ_RANK_4 7401 * @retval Value between Min_Data=0x000 and Max_Data=0xFFFF 7402 */ 7403 __STATIC_INLINE uint16_t LL_ADC_INJ_ReadConversionData16(ADC_TypeDef *ADCx, uint32_t Rank) 7404 { 7405 const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, ((Rank & ADC_INJ_JDRX_REGOFFSET_MASK) >> ADC_JDRX_REGOFFSET_POS)); 7406 7407 return (uint16_t)(READ_BIT(*preg, 7408 ADC_JDR1_JDATA) 7409 ); 7410 } 7411 7412 /** 7413 * @brief Get ADC group injected conversion data, range fit for 7414 * ADC resolution 14 bits. 7415 * @note For devices with feature oversampling: Oversampling 7416 * can increase data width, function for extended range 7417 * may be needed: @ref LL_ADC_INJ_ReadConversionData32. 7418 * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData14\n 7419 * JDR2 JDATA LL_ADC_INJ_ReadConversionData14\n 7420 * JDR3 JDATA LL_ADC_INJ_ReadConversionData14\n 7421 * JDR4 JDATA LL_ADC_INJ_ReadConversionData14 7422 * @param ADCx ADC instance 7423 * @param Rank This parameter can be one of the following values: 7424 * @arg @ref LL_ADC_INJ_RANK_1 7425 * @arg @ref LL_ADC_INJ_RANK_2 7426 * @arg @ref LL_ADC_INJ_RANK_3 7427 * @arg @ref LL_ADC_INJ_RANK_4 7428 * @retval Value between Min_Data=0x000 and Max_Data=0x3FFF 7429 */ 7430 __STATIC_INLINE uint16_t LL_ADC_INJ_ReadConversionData14(ADC_TypeDef *ADCx, uint32_t Rank) 7431 { 7432 const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, ((Rank & ADC_INJ_JDRX_REGOFFSET_MASK) >> ADC_JDRX_REGOFFSET_POS)); 7433 7434 return (uint16_t)(READ_BIT(*preg, 7435 ADC_JDR1_JDATA) 7436 ); 7437 } 7438 7439 /** 7440 * @brief Get ADC group injected conversion data, range fit for 7441 * ADC resolution 12 bits. 7442 * @note For devices with feature oversampling: Oversampling 7443 * can increase data width, function for extended range 7444 * may be needed: @ref LL_ADC_INJ_ReadConversionData32. 7445 * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData12\n 7446 * JDR2 JDATA LL_ADC_INJ_ReadConversionData12\n 7447 * JDR3 JDATA LL_ADC_INJ_ReadConversionData12\n 7448 * JDR4 JDATA LL_ADC_INJ_ReadConversionData12 7449 * @param ADCx ADC instance 7450 * @param Rank This parameter can be one of the following values: 7451 * @arg @ref LL_ADC_INJ_RANK_1 7452 * @arg @ref LL_ADC_INJ_RANK_2 7453 * @arg @ref LL_ADC_INJ_RANK_3 7454 * @arg @ref LL_ADC_INJ_RANK_4 7455 * @retval Value between Min_Data=0x000 and Max_Data=0xFFF 7456 */ 7457 __STATIC_INLINE uint16_t LL_ADC_INJ_ReadConversionData12(ADC_TypeDef *ADCx, uint32_t Rank) 7458 { 7459 const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, ((Rank & ADC_INJ_JDRX_REGOFFSET_MASK) >> ADC_JDRX_REGOFFSET_POS)); 7460 7461 return (uint16_t)(READ_BIT(*preg, 7462 ADC_JDR1_JDATA) 7463 ); 7464 } 7465 7466 /** 7467 * @brief Get ADC group injected conversion data, range fit for 7468 * ADC resolution 10 bits. 7469 * @note For devices with feature oversampling: Oversampling 7470 * can increase data width, function for extended range 7471 * may be needed: @ref LL_ADC_INJ_ReadConversionData32. 7472 * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData10\n 7473 * JDR2 JDATA LL_ADC_INJ_ReadConversionData10\n 7474 * JDR3 JDATA LL_ADC_INJ_ReadConversionData10\n 7475 * JDR4 JDATA LL_ADC_INJ_ReadConversionData10 7476 * @param ADCx ADC instance 7477 * @param Rank This parameter can be one of the following values: 7478 * @arg @ref LL_ADC_INJ_RANK_1 7479 * @arg @ref LL_ADC_INJ_RANK_2 7480 * @arg @ref LL_ADC_INJ_RANK_3 7481 * @arg @ref LL_ADC_INJ_RANK_4 7482 * @retval Value between Min_Data=0x000 and Max_Data=0x3FF 7483 */ 7484 __STATIC_INLINE uint16_t LL_ADC_INJ_ReadConversionData10(ADC_TypeDef *ADCx, uint32_t Rank) 7485 { 7486 const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, ((Rank & ADC_INJ_JDRX_REGOFFSET_MASK) >> ADC_JDRX_REGOFFSET_POS)); 7487 7488 return (uint16_t)(READ_BIT(*preg, 7489 ADC_JDR1_JDATA) 7490 ); 7491 } 7492 7493 /** 7494 * @brief Get ADC group injected conversion data, range fit for 7495 * ADC resolution 8 bits. 7496 * @note For devices with feature oversampling: Oversampling 7497 * can increase data width, function for extended range 7498 * may be needed: @ref LL_ADC_INJ_ReadConversionData32. 7499 * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData8\n 7500 * JDR2 JDATA LL_ADC_INJ_ReadConversionData8\n 7501 * JDR3 JDATA LL_ADC_INJ_ReadConversionData8\n 7502 * JDR4 JDATA LL_ADC_INJ_ReadConversionData8 7503 * @param ADCx ADC instance 7504 * @param Rank This parameter can be one of the following values: 7505 * @arg @ref LL_ADC_INJ_RANK_1 7506 * @arg @ref LL_ADC_INJ_RANK_2 7507 * @arg @ref LL_ADC_INJ_RANK_3 7508 * @arg @ref LL_ADC_INJ_RANK_4 7509 * @retval Value between Min_Data=0x00 and Max_Data=0xFF 7510 */ 7511 __STATIC_INLINE uint8_t LL_ADC_INJ_ReadConversionData8(ADC_TypeDef *ADCx, uint32_t Rank) 7512 { 7513 const __IO uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, ((Rank & ADC_INJ_JDRX_REGOFFSET_MASK) >> ADC_JDRX_REGOFFSET_POS)); 7514 7515 return (uint8_t)(READ_BIT(*preg, 7516 ADC_JDR1_JDATA) 7517 ); 7518 } 7519 7520 /** 7521 * @} 7522 */ 7523 7524 /** @defgroup ADC_LL_EF_FLAG_Management ADC flag management 7525 * @ingroup RTEMSBSPsARMSTM32H7 7526 * @{ 7527 */ 7528 7529 /** 7530 * @brief Get flag ADC ready. 7531 * @note On this STM32 series, flag LL_ADC_FLAG_ADRDY is raised when the ADC 7532 * is enabled and when conversion clock is active. 7533 * (not only core clock: this ADC has a dual clock domain) 7534 * @rmtoll ISR ADRDY LL_ADC_IsActiveFlag_ADRDY 7535 * @param ADCx ADC instance 7536 * @retval State of bit (1 or 0). 7537 */ 7538 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_ADRDY(ADC_TypeDef *ADCx) 7539 { 7540 return ((READ_BIT(ADCx->ISR, LL_ADC_FLAG_ADRDY) == (LL_ADC_FLAG_ADRDY)) ? 1UL : 0UL); 7541 } 7542 7543 /** 7544 * @brief Get flag ADC group regular end of unitary conversion. 7545 * @rmtoll ISR EOC LL_ADC_IsActiveFlag_EOC 7546 * @param ADCx ADC instance 7547 * @retval State of bit (1 or 0). 7548 */ 7549 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_EOC(ADC_TypeDef *ADCx) 7550 { 7551 return ((READ_BIT(ADCx->ISR, ADC_ISR_EOC) == (ADC_ISR_EOC)) ? 1UL : 0UL); 7552 } 7553 7554 /** 7555 * @brief Get flag ADC group regular end of sequence conversions. 7556 * @rmtoll ISR EOS LL_ADC_IsActiveFlag_EOS 7557 * @param ADCx ADC instance 7558 * @retval State of bit (1 or 0). 7559 */ 7560 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_EOS(ADC_TypeDef *ADCx) 7561 { 7562 return ((READ_BIT(ADCx->ISR, LL_ADC_FLAG_EOS) == (LL_ADC_FLAG_EOS)) ? 1UL : 0UL); 7563 } 7564 7565 /** 7566 * @brief Get flag ADC group regular overrun. 7567 * @rmtoll ISR OVR LL_ADC_IsActiveFlag_OVR 7568 * @param ADCx ADC instance 7569 * @retval State of bit (1 or 0). 7570 */ 7571 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_OVR(ADC_TypeDef *ADCx) 7572 { 7573 return ((READ_BIT(ADCx->ISR, LL_ADC_FLAG_OVR) == (LL_ADC_FLAG_OVR)) ? 1UL : 0UL); 7574 } 7575 7576 /** 7577 * @brief Get flag ADC group regular end of sampling phase. 7578 * @rmtoll ISR EOSMP LL_ADC_IsActiveFlag_EOSMP 7579 * @param ADCx ADC instance 7580 * @retval State of bit (1 or 0). 7581 */ 7582 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_EOSMP(ADC_TypeDef *ADCx) 7583 { 7584 return ((READ_BIT(ADCx->ISR, LL_ADC_FLAG_EOSMP) == (LL_ADC_FLAG_EOSMP)) ? 1UL : 0UL); 7585 } 7586 7587 /** 7588 * @brief Get flag ADC group injected end of unitary conversion. 7589 * @rmtoll ISR JEOC LL_ADC_IsActiveFlag_JEOC 7590 * @param ADCx ADC instance 7591 * @retval State of bit (1 or 0). 7592 */ 7593 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_JEOC(ADC_TypeDef *ADCx) 7594 { 7595 return ((READ_BIT(ADCx->ISR, LL_ADC_FLAG_JEOC) == (LL_ADC_FLAG_JEOC)) ? 1UL : 0UL); 7596 } 7597 7598 /** 7599 * @brief Get flag ADC group injected end of sequence conversions. 7600 * @rmtoll ISR JEOS LL_ADC_IsActiveFlag_JEOS 7601 * @param ADCx ADC instance 7602 * @retval State of bit (1 or 0). 7603 */ 7604 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_JEOS(ADC_TypeDef *ADCx) 7605 { 7606 return ((READ_BIT(ADCx->ISR, LL_ADC_FLAG_JEOS) == (LL_ADC_FLAG_JEOS)) ? 1UL : 0UL); 7607 } 7608 7609 /** 7610 * @brief Get flag ADC group injected contexts queue overflow. 7611 * @rmtoll ISR JQOVF LL_ADC_IsActiveFlag_JQOVF 7612 * @param ADCx ADC instance 7613 * @retval State of bit (1 or 0). 7614 */ 7615 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_JQOVF(ADC_TypeDef *ADCx) 7616 { 7617 return ((READ_BIT(ADCx->ISR, LL_ADC_FLAG_JQOVF) == (LL_ADC_FLAG_JQOVF)) ? 1UL : 0UL); 7618 } 7619 7620 /** 7621 * @brief Get flag ADC LDO output voltage ready bit. 7622 * @rmtoll ISR LDORDY LL_ADC_IsActiveFlag_LDORDY 7623 * @param ADCx ADC instance 7624 * @retval State of bit (1 or 0). 7625 */ 7626 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_LDORDY(ADC_TypeDef *ADCx) 7627 { 7628 return ((READ_BIT(ADCx->ISR, LL_ADC_FLAG_LDORDY) == (LL_ADC_FLAG_LDORDY)) ? 1UL : 0UL); 7629 } 7630 7631 /** 7632 * @brief Get flag ADC analog watchdog 1 flag 7633 * @rmtoll ISR AWD1 LL_ADC_IsActiveFlag_AWD1 7634 * @param ADCx ADC instance 7635 * @retval State of bit (1 or 0). 7636 */ 7637 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_AWD1(ADC_TypeDef *ADCx) 7638 { 7639 return ((READ_BIT(ADCx->ISR, LL_ADC_FLAG_AWD1) == (LL_ADC_FLAG_AWD1)) ? 1UL : 0UL); 7640 } 7641 7642 /** 7643 * @brief Get flag ADC analog watchdog 2. 7644 * @rmtoll ISR AWD2 LL_ADC_IsActiveFlag_AWD2 7645 * @param ADCx ADC instance 7646 * @retval State of bit (1 or 0). 7647 */ 7648 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_AWD2(ADC_TypeDef *ADCx) 7649 { 7650 return ((READ_BIT(ADCx->ISR, LL_ADC_FLAG_AWD2) == (LL_ADC_FLAG_AWD2)) ? 1UL : 0UL); 7651 } 7652 7653 /** 7654 * @brief Get flag ADC analog watchdog 3. 7655 * @rmtoll ISR AWD3 LL_ADC_IsActiveFlag_AWD3 7656 * @param ADCx ADC instance 7657 * @retval State of bit (1 or 0). 7658 */ 7659 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_AWD3(ADC_TypeDef *ADCx) 7660 { 7661 return ((READ_BIT(ADCx->ISR, LL_ADC_FLAG_AWD3) == (LL_ADC_FLAG_AWD3)) ? 1UL : 0UL); 7662 } 7663 7664 /** 7665 * @brief Clear flag ADC ready. 7666 * @note On this STM32 series, flag LL_ADC_FLAG_ADRDY is raised when the ADC 7667 * is enabled and when conversion clock is active. 7668 * (not only core clock: this ADC has a dual clock domain) 7669 * @rmtoll ISR ADRDY LL_ADC_ClearFlag_ADRDY 7670 * @param ADCx ADC instance 7671 * @retval None 7672 */ 7673 __STATIC_INLINE void LL_ADC_ClearFlag_ADRDY(ADC_TypeDef *ADCx) 7674 { 7675 WRITE_REG(ADCx->ISR, LL_ADC_FLAG_ADRDY); 7676 } 7677 7678 /** 7679 * @brief Clear flag ADC group regular end of unitary conversion. 7680 * @rmtoll ISR EOC LL_ADC_ClearFlag_EOC 7681 * @param ADCx ADC instance 7682 * @retval None 7683 */ 7684 __STATIC_INLINE void LL_ADC_ClearFlag_EOC(ADC_TypeDef *ADCx) 7685 { 7686 WRITE_REG(ADCx->ISR, LL_ADC_FLAG_EOC); 7687 } 7688 7689 /** 7690 * @brief Clear flag ADC group regular end of sequence conversions. 7691 * @rmtoll ISR EOS LL_ADC_ClearFlag_EOS 7692 * @param ADCx ADC instance 7693 * @retval None 7694 */ 7695 __STATIC_INLINE void LL_ADC_ClearFlag_EOS(ADC_TypeDef *ADCx) 7696 { 7697 WRITE_REG(ADCx->ISR, LL_ADC_FLAG_EOS); 7698 } 7699 7700 /** 7701 * @brief Clear flag ADC group regular overrun. 7702 * @rmtoll ISR OVR LL_ADC_ClearFlag_OVR 7703 * @param ADCx ADC instance 7704 * @retval None 7705 */ 7706 __STATIC_INLINE void LL_ADC_ClearFlag_OVR(ADC_TypeDef *ADCx) 7707 { 7708 WRITE_REG(ADCx->ISR, LL_ADC_FLAG_OVR); 7709 } 7710 7711 /** 7712 * @brief Clear flag ADC group regular end of sampling phase. 7713 * @rmtoll ISR EOSMP LL_ADC_ClearFlag_EOSMP 7714 * @param ADCx ADC instance 7715 * @retval None 7716 */ 7717 __STATIC_INLINE void LL_ADC_ClearFlag_EOSMP(ADC_TypeDef *ADCx) 7718 { 7719 WRITE_REG(ADCx->ISR, LL_ADC_FLAG_EOSMP); 7720 } 7721 7722 /** 7723 * @brief Clear flag ADC group injected end of unitary conversion. 7724 * @rmtoll ISR JEOC LL_ADC_ClearFlag_JEOC 7725 * @param ADCx ADC instance 7726 * @retval None 7727 */ 7728 __STATIC_INLINE void LL_ADC_ClearFlag_JEOC(ADC_TypeDef *ADCx) 7729 { 7730 WRITE_REG(ADCx->ISR, LL_ADC_FLAG_JEOC); 7731 } 7732 7733 /** 7734 * @brief Clear flag ADC group injected end of sequence conversions. 7735 * @rmtoll ISR JEOS LL_ADC_ClearFlag_JEOS 7736 * @param ADCx ADC instance 7737 * @retval None 7738 */ 7739 __STATIC_INLINE void LL_ADC_ClearFlag_JEOS(ADC_TypeDef *ADCx) 7740 { 7741 WRITE_REG(ADCx->ISR, LL_ADC_FLAG_JEOS); 7742 } 7743 7744 /** 7745 * @brief Clear flag ADC group injected contexts queue overflow. 7746 * @rmtoll ISR JQOVF LL_ADC_ClearFlag_JQOVF 7747 * @param ADCx ADC instance 7748 * @retval None 7749 */ 7750 __STATIC_INLINE void LL_ADC_ClearFlag_JQOVF(ADC_TypeDef *ADCx) 7751 { 7752 WRITE_REG(ADCx->ISR, LL_ADC_FLAG_JQOVF); 7753 } 7754 7755 /** 7756 * @brief Clear flag ADC analog watchdog 1. 7757 * @rmtoll ISR AWD1 LL_ADC_ClearFlag_AWD1 7758 * @param ADCx ADC instance 7759 * @retval None 7760 */ 7761 __STATIC_INLINE void LL_ADC_ClearFlag_AWD1(ADC_TypeDef *ADCx) 7762 { 7763 WRITE_REG(ADCx->ISR, LL_ADC_FLAG_AWD1); 7764 } 7765 7766 /** 7767 * @brief Clear flag ADC analog watchdog 2. 7768 * @rmtoll ISR AWD2 LL_ADC_ClearFlag_AWD2 7769 * @param ADCx ADC instance 7770 * @retval None 7771 */ 7772 __STATIC_INLINE void LL_ADC_ClearFlag_AWD2(ADC_TypeDef *ADCx) 7773 { 7774 WRITE_REG(ADCx->ISR, LL_ADC_FLAG_AWD2); 7775 } 7776 7777 /** 7778 * @brief Clear flag ADC analog watchdog 3. 7779 * @rmtoll ISR AWD3 LL_ADC_ClearFlag_AWD3 7780 * @param ADCx ADC instance 7781 * @retval None 7782 */ 7783 __STATIC_INLINE void LL_ADC_ClearFlag_AWD3(ADC_TypeDef *ADCx) 7784 { 7785 WRITE_REG(ADCx->ISR, LL_ADC_FLAG_AWD3); 7786 } 7787 7788 /** 7789 * @brief Get flag multimode ADC ready of the ADC master. 7790 * @rmtoll CSR ADRDY_MST LL_ADC_IsActiveFlag_MST_ADRDY 7791 * @param ADCxy_COMMON ADC common instance 7792 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() ) 7793 * @retval State of bit (1 or 0). 7794 */ 7795 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_ADRDY(ADC_Common_TypeDef *ADCxy_COMMON) 7796 { 7797 return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_ADRDY_MST) == (LL_ADC_FLAG_ADRDY_MST)) ? 1UL : 0UL); 7798 } 7799 7800 /** 7801 * @brief Get flag multimode ADC ready of the ADC slave. 7802 * @rmtoll CSR ADRDY_SLV LL_ADC_IsActiveFlag_SLV_ADRDY 7803 * @param ADCxy_COMMON ADC common instance 7804 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() ) 7805 * @retval State of bit (1 or 0). 7806 */ 7807 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_ADRDY(ADC_Common_TypeDef *ADCxy_COMMON) 7808 { 7809 return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_ADRDY_SLV) == (LL_ADC_FLAG_ADRDY_SLV)) ? 1UL : 0UL); 7810 } 7811 7812 /** 7813 * @brief Get flag multimode ADC group regular end of unitary conversion of the ADC master. 7814 * @rmtoll CSR EOC_MST LL_ADC_IsActiveFlag_MST_EOC 7815 * @param ADCxy_COMMON ADC common instance 7816 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() ) 7817 * @retval State of bit (1 or 0). 7818 */ 7819 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_EOC(ADC_Common_TypeDef *ADCxy_COMMON) 7820 { 7821 return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_EOC_SLV) == (LL_ADC_FLAG_EOC_SLV)) ? 1UL : 0UL); 7822 } 7823 7824 /** 7825 * @brief Get flag multimode ADC group regular end of unitary conversion of the ADC slave. 7826 * @rmtoll CSR EOC_SLV LL_ADC_IsActiveFlag_SLV_EOC 7827 * @param ADCxy_COMMON ADC common instance 7828 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() ) 7829 * @retval State of bit (1 or 0). 7830 */ 7831 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_EOC(ADC_Common_TypeDef *ADCxy_COMMON) 7832 { 7833 return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_EOC_SLV) == (LL_ADC_FLAG_EOC_SLV)) ? 1UL : 0UL); 7834 } 7835 7836 /** 7837 * @brief Get flag multimode ADC group regular end of sequence conversions of the ADC master. 7838 * @rmtoll CSR EOS_MST LL_ADC_IsActiveFlag_MST_EOS 7839 * @param ADCxy_COMMON ADC common instance 7840 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() ) 7841 * @retval State of bit (1 or 0). 7842 */ 7843 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_EOS(ADC_Common_TypeDef *ADCxy_COMMON) 7844 { 7845 return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_EOS_MST) == (LL_ADC_FLAG_EOS_MST)) ? 1UL : 0UL); 7846 } 7847 7848 /** 7849 * @brief Get flag multimode ADC group regular end of sequence conversions of the ADC slave. 7850 * @rmtoll CSR EOS_SLV LL_ADC_IsActiveFlag_SLV_EOS 7851 * @param ADCxy_COMMON ADC common instance 7852 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() ) 7853 * @retval State of bit (1 or 0). 7854 */ 7855 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_EOS(ADC_Common_TypeDef *ADCxy_COMMON) 7856 { 7857 return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_EOS_SLV) == (LL_ADC_FLAG_EOS_SLV)) ? 1UL : 0UL); 7858 } 7859 7860 /** 7861 * @brief Get flag multimode ADC group regular overrun of the ADC master. 7862 * @rmtoll CSR OVR_MST LL_ADC_IsActiveFlag_MST_OVR 7863 * @param ADCxy_COMMON ADC common instance 7864 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() ) 7865 * @retval State of bit (1 or 0). 7866 */ 7867 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_OVR(ADC_Common_TypeDef *ADCxy_COMMON) 7868 { 7869 return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_OVR_MST) == (LL_ADC_FLAG_OVR_MST)) ? 1UL : 0UL); 7870 } 7871 7872 /** 7873 * @brief Get flag multimode ADC group regular overrun of the ADC slave. 7874 * @rmtoll CSR OVR_SLV LL_ADC_IsActiveFlag_SLV_OVR 7875 * @param ADCxy_COMMON ADC common instance 7876 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() ) 7877 * @retval State of bit (1 or 0). 7878 */ 7879 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_OVR(ADC_Common_TypeDef *ADCxy_COMMON) 7880 { 7881 return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_OVR_SLV) == (LL_ADC_FLAG_OVR_SLV)) ? 1UL : 0UL); 7882 } 7883 7884 /** 7885 * @brief Get flag multimode ADC group regular end of sampling of the ADC master. 7886 * @rmtoll CSR EOSMP_MST LL_ADC_IsActiveFlag_MST_EOSMP 7887 * @param ADCxy_COMMON ADC common instance 7888 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() ) 7889 * @retval State of bit (1 or 0). 7890 */ 7891 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_EOSMP(ADC_Common_TypeDef *ADCxy_COMMON) 7892 { 7893 return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_EOSMP_MST) == (LL_ADC_FLAG_EOSMP_MST)) ? 1UL : 0UL); 7894 } 7895 7896 /** 7897 * @brief Get flag multimode ADC group regular end of sampling of the ADC slave. 7898 * @rmtoll CSR EOSMP_SLV LL_ADC_IsActiveFlag_SLV_EOSMP 7899 * @param ADCxy_COMMON ADC common instance 7900 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() ) 7901 * @retval State of bit (1 or 0). 7902 */ 7903 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_EOSMP(ADC_Common_TypeDef *ADCxy_COMMON) 7904 { 7905 return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_EOSMP_SLV) == (LL_ADC_FLAG_EOSMP_SLV)) ? 1UL : 0UL); 7906 } 7907 7908 /** 7909 * @brief Get flag multimode ADC group injected end of unitary conversion of the ADC master. 7910 * @rmtoll CSR JEOC_MST LL_ADC_IsActiveFlag_MST_JEOC 7911 * @param ADCxy_COMMON ADC common instance 7912 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() ) 7913 * @retval State of bit (1 or 0). 7914 */ 7915 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_JEOC(ADC_Common_TypeDef *ADCxy_COMMON) 7916 { 7917 return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_JEOC_MST) == (LL_ADC_FLAG_JEOC_MST)) ? 1UL : 0UL); 7918 } 7919 7920 /** 7921 * @brief Get flag multimode ADC group injected end of unitary conversion of the ADC slave. 7922 * @rmtoll CSR JEOC_SLV LL_ADC_IsActiveFlag_SLV_JEOC 7923 * @param ADCxy_COMMON ADC common instance 7924 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() ) 7925 * @retval State of bit (1 or 0). 7926 */ 7927 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_JEOC(ADC_Common_TypeDef *ADCxy_COMMON) 7928 { 7929 return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_JEOC_SLV) == (LL_ADC_FLAG_JEOC_SLV)) ? 1UL : 0UL); 7930 } 7931 7932 /** 7933 * @brief Get flag multimode ADC group injected end of sequence conversions of the ADC master. 7934 * @rmtoll CSR JEOS_MST LL_ADC_IsActiveFlag_MST_JEOS 7935 * @param ADCxy_COMMON ADC common instance 7936 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() ) 7937 * @retval State of bit (1 or 0). 7938 */ 7939 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_JEOS(ADC_Common_TypeDef *ADCxy_COMMON) 7940 { 7941 return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_JEOS_MST) == (LL_ADC_FLAG_JEOS_MST)) ? 1UL : 0UL); 7942 } 7943 7944 /** 7945 * @brief Get flag multimode ADC group injected end of sequence conversions of the ADC slave. 7946 * @rmtoll CSR JEOS_SLV LL_ADC_IsActiveFlag_SLV_JEOS 7947 * @param ADCxy_COMMON ADC common instance 7948 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() ) 7949 * @retval State of bit (1 or 0). 7950 */ 7951 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_JEOS(ADC_Common_TypeDef *ADCxy_COMMON) 7952 { 7953 return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_JEOS_SLV) == (LL_ADC_FLAG_JEOS_SLV)) ? 1UL : 0UL); 7954 } 7955 7956 /** 7957 * @brief Get flag multimode ADC group injected context queue overflow of the ADC master. 7958 * @rmtoll CSR JQOVF_MST LL_ADC_IsActiveFlag_MST_JQOVF 7959 * @param ADCxy_COMMON ADC common instance 7960 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() ) 7961 * @retval State of bit (1 or 0). 7962 */ 7963 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_JQOVF(ADC_Common_TypeDef *ADCxy_COMMON) 7964 { 7965 return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_JQOVF_MST) == (LL_ADC_FLAG_JQOVF_MST)) ? 1UL : 0UL); 7966 } 7967 7968 /** 7969 * @brief Get flag multimode ADC group injected context queue overflow of the ADC slave. 7970 * @rmtoll CSR JQOVF_SLV LL_ADC_IsActiveFlag_SLV_JQOVF 7971 * @param ADCxy_COMMON ADC common instance 7972 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() ) 7973 * @retval State of bit (1 or 0). 7974 */ 7975 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_JQOVF(ADC_Common_TypeDef *ADCxy_COMMON) 7976 { 7977 return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_JQOVF_SLV) == (LL_ADC_FLAG_JQOVF_SLV)) ? 1UL : 0UL); 7978 } 7979 7980 /** 7981 * @brief Get flag multimode ADC analog watchdog 1 of the ADC master. 7982 * @rmtoll CSR AWD1_MST LL_ADC_IsActiveFlag_MST_AWD1 7983 * @param ADCxy_COMMON ADC common instance 7984 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() ) 7985 * @retval State of bit (1 or 0). 7986 */ 7987 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_AWD1(ADC_Common_TypeDef *ADCxy_COMMON) 7988 { 7989 return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_AWD1_MST) == (LL_ADC_FLAG_AWD1_MST)) ? 1UL : 0UL); 7990 } 7991 7992 /** 7993 * @brief Get flag multimode analog watchdog 1 of the ADC slave. 7994 * @rmtoll CSR AWD1_SLV LL_ADC_IsActiveFlag_SLV_AWD1 7995 * @param ADCxy_COMMON ADC common instance 7996 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() ) 7997 * @retval State of bit (1 or 0). 7998 */ 7999 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_AWD1(ADC_Common_TypeDef *ADCxy_COMMON) 8000 { 8001 return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_AWD1_SLV) == (LL_ADC_FLAG_AWD1_SLV)) ? 1UL : 0UL); 8002 } 8003 8004 /** 8005 * @brief Get flag multimode ADC analog watchdog 2 of the ADC master. 8006 * @rmtoll CSR AWD2_MST LL_ADC_IsActiveFlag_MST_AWD2 8007 * @param ADCxy_COMMON ADC common instance 8008 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() ) 8009 * @retval State of bit (1 or 0). 8010 */ 8011 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_AWD2(ADC_Common_TypeDef *ADCxy_COMMON) 8012 { 8013 return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_AWD2_MST) == (LL_ADC_FLAG_AWD2_MST)) ? 1UL : 0UL); 8014 } 8015 8016 /** 8017 * @brief Get flag multimode ADC analog watchdog 2 of the ADC slave. 8018 * @rmtoll CSR AWD2_SLV LL_ADC_IsActiveFlag_SLV_AWD2 8019 * @param ADCxy_COMMON ADC common instance 8020 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() ) 8021 * @retval State of bit (1 or 0). 8022 */ 8023 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_AWD2(ADC_Common_TypeDef *ADCxy_COMMON) 8024 { 8025 return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_AWD2_SLV) == (LL_ADC_FLAG_AWD2_SLV)) ? 1UL : 0UL); 8026 } 8027 8028 /** 8029 * @brief Get flag multimode ADC analog watchdog 3 of the ADC master. 8030 * @rmtoll CSR AWD3_MST LL_ADC_IsActiveFlag_MST_AWD3 8031 * @param ADCxy_COMMON ADC common instance 8032 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() ) 8033 * @retval State of bit (1 or 0). 8034 */ 8035 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_MST_AWD3(ADC_Common_TypeDef *ADCxy_COMMON) 8036 { 8037 return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_AWD3_MST) == (LL_ADC_FLAG_AWD3_MST)) ? 1UL : 0UL); 8038 } 8039 8040 /** 8041 * @brief Get flag multimode ADC analog watchdog 3 of the ADC slave. 8042 * @rmtoll CSR AWD3_SLV LL_ADC_IsActiveFlag_SLV_AWD3 8043 * @param ADCxy_COMMON ADC common instance 8044 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() ) 8045 * @retval State of bit (1 or 0). 8046 */ 8047 __STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_SLV_AWD3(ADC_Common_TypeDef *ADCxy_COMMON) 8048 { 8049 return ((READ_BIT(ADCxy_COMMON->CSR, LL_ADC_FLAG_AWD3_SLV) == (LL_ADC_FLAG_AWD3_SLV)) ? 1UL : 0UL); 8050 } 8051 8052 /** 8053 * @} 8054 */ 8055 8056 /** @defgroup ADC_LL_EF_IT_Management ADC IT management 8057 * @ingroup RTEMSBSPsARMSTM32H7 8058 * @{ 8059 */ 8060 8061 /** 8062 * @brief Enable ADC ready. 8063 * @rmtoll IER ADRDYIE LL_ADC_EnableIT_ADRDY 8064 * @param ADCx ADC instance 8065 * @retval None 8066 */ 8067 __STATIC_INLINE void LL_ADC_EnableIT_ADRDY(ADC_TypeDef *ADCx) 8068 { 8069 SET_BIT(ADCx->IER, LL_ADC_IT_ADRDY); 8070 } 8071 8072 /** 8073 * @brief Enable interruption ADC group regular end of unitary conversion. 8074 * @rmtoll IER EOCIE LL_ADC_EnableIT_EOC 8075 * @param ADCx ADC instance 8076 * @retval None 8077 */ 8078 __STATIC_INLINE void LL_ADC_EnableIT_EOC(ADC_TypeDef *ADCx) 8079 { 8080 SET_BIT(ADCx->IER, LL_ADC_IT_EOC); 8081 } 8082 8083 /** 8084 * @brief Enable interruption ADC group regular end of sequence conversions. 8085 * @rmtoll IER EOSIE LL_ADC_EnableIT_EOS 8086 * @param ADCx ADC instance 8087 * @retval None 8088 */ 8089 __STATIC_INLINE void LL_ADC_EnableIT_EOS(ADC_TypeDef *ADCx) 8090 { 8091 SET_BIT(ADCx->IER, LL_ADC_IT_EOS); 8092 } 8093 8094 /** 8095 * @brief Enable ADC group regular interruption overrun. 8096 * @rmtoll IER OVRIE LL_ADC_EnableIT_OVR 8097 * @param ADCx ADC instance 8098 * @retval None 8099 */ 8100 __STATIC_INLINE void LL_ADC_EnableIT_OVR(ADC_TypeDef *ADCx) 8101 { 8102 SET_BIT(ADCx->IER, LL_ADC_IT_OVR); 8103 } 8104 8105 /** 8106 * @brief Enable interruption ADC group regular end of sampling. 8107 * @rmtoll IER EOSMPIE LL_ADC_EnableIT_EOSMP 8108 * @param ADCx ADC instance 8109 * @retval None 8110 */ 8111 __STATIC_INLINE void LL_ADC_EnableIT_EOSMP(ADC_TypeDef *ADCx) 8112 { 8113 SET_BIT(ADCx->IER, LL_ADC_IT_EOSMP); 8114 } 8115 8116 /** 8117 * @brief Enable interruption ADC group injected end of unitary conversion. 8118 * @rmtoll IER JEOCIE LL_ADC_EnableIT_JEOC 8119 * @param ADCx ADC instance 8120 * @retval None 8121 */ 8122 __STATIC_INLINE void LL_ADC_EnableIT_JEOC(ADC_TypeDef *ADCx) 8123 { 8124 SET_BIT(ADCx->IER, LL_ADC_IT_JEOC); 8125 } 8126 8127 /** 8128 * @brief Enable interruption ADC group injected end of sequence conversions. 8129 * @rmtoll IER JEOSIE LL_ADC_EnableIT_JEOS 8130 * @param ADCx ADC instance 8131 * @retval None 8132 */ 8133 __STATIC_INLINE void LL_ADC_EnableIT_JEOS(ADC_TypeDef *ADCx) 8134 { 8135 SET_BIT(ADCx->IER, LL_ADC_IT_JEOS); 8136 } 8137 8138 /** 8139 * @brief Enable interruption ADC group injected context queue overflow. 8140 * @rmtoll IER JQOVFIE LL_ADC_EnableIT_JQOVF 8141 * @param ADCx ADC instance 8142 * @retval None 8143 */ 8144 __STATIC_INLINE void LL_ADC_EnableIT_JQOVF(ADC_TypeDef *ADCx) 8145 { 8146 SET_BIT(ADCx->IER, LL_ADC_IT_JQOVF); 8147 } 8148 8149 /** 8150 * @brief Enable interruption ADC analog watchdog 1. 8151 * @rmtoll IER AWD1IE LL_ADC_EnableIT_AWD1 8152 * @param ADCx ADC instance 8153 * @retval None 8154 */ 8155 __STATIC_INLINE void LL_ADC_EnableIT_AWD1(ADC_TypeDef *ADCx) 8156 { 8157 SET_BIT(ADCx->IER, LL_ADC_IT_AWD1); 8158 } 8159 8160 /** 8161 * @brief Enable interruption ADC analog watchdog 2. 8162 * @rmtoll IER AWD2IE LL_ADC_EnableIT_AWD2 8163 * @param ADCx ADC instance 8164 * @retval None 8165 */ 8166 __STATIC_INLINE void LL_ADC_EnableIT_AWD2(ADC_TypeDef *ADCx) 8167 { 8168 SET_BIT(ADCx->IER, LL_ADC_IT_AWD2); 8169 } 8170 8171 /** 8172 * @brief Enable interruption ADC analog watchdog 3. 8173 * @rmtoll IER AWD3IE LL_ADC_EnableIT_AWD3 8174 * @param ADCx ADC instance 8175 * @retval None 8176 */ 8177 __STATIC_INLINE void LL_ADC_EnableIT_AWD3(ADC_TypeDef *ADCx) 8178 { 8179 SET_BIT(ADCx->IER, LL_ADC_IT_AWD3); 8180 } 8181 8182 /** 8183 * @brief Disable interruption ADC ready. 8184 * @rmtoll IER ADRDYIE LL_ADC_DisableIT_ADRDY 8185 * @param ADCx ADC instance 8186 * @retval None 8187 */ 8188 __STATIC_INLINE void LL_ADC_DisableIT_ADRDY(ADC_TypeDef *ADCx) 8189 { 8190 CLEAR_BIT(ADCx->IER, LL_ADC_IT_ADRDY); 8191 } 8192 8193 /** 8194 * @brief Disable interruption ADC group regular end of unitary conversion. 8195 * @rmtoll IER EOCIE LL_ADC_DisableIT_EOC 8196 * @param ADCx ADC instance 8197 * @retval None 8198 */ 8199 __STATIC_INLINE void LL_ADC_DisableIT_EOC(ADC_TypeDef *ADCx) 8200 { 8201 CLEAR_BIT(ADCx->IER, LL_ADC_IT_EOC); 8202 } 8203 8204 /** 8205 * @brief Disable interruption ADC group regular end of sequence conversions. 8206 * @rmtoll IER EOSIE LL_ADC_DisableIT_EOS 8207 * @param ADCx ADC instance 8208 * @retval None 8209 */ 8210 __STATIC_INLINE void LL_ADC_DisableIT_EOS(ADC_TypeDef *ADCx) 8211 { 8212 CLEAR_BIT(ADCx->IER, LL_ADC_IT_EOS); 8213 } 8214 8215 /** 8216 * @brief Disable interruption ADC group regular overrun. 8217 * @rmtoll IER OVRIE LL_ADC_DisableIT_OVR 8218 * @param ADCx ADC instance 8219 * @retval None 8220 */ 8221 __STATIC_INLINE void LL_ADC_DisableIT_OVR(ADC_TypeDef *ADCx) 8222 { 8223 CLEAR_BIT(ADCx->IER, LL_ADC_IT_OVR); 8224 } 8225 8226 /** 8227 * @brief Disable interruption ADC group regular end of sampling. 8228 * @rmtoll IER EOSMPIE LL_ADC_DisableIT_EOSMP 8229 * @param ADCx ADC instance 8230 * @retval None 8231 */ 8232 __STATIC_INLINE void LL_ADC_DisableIT_EOSMP(ADC_TypeDef *ADCx) 8233 { 8234 CLEAR_BIT(ADCx->IER, LL_ADC_IT_EOSMP); 8235 } 8236 8237 /** 8238 * @brief Disable interruption ADC group regular end of unitary conversion. 8239 * @rmtoll IER JEOCIE LL_ADC_DisableIT_JEOC 8240 * @param ADCx ADC instance 8241 * @retval None 8242 */ 8243 __STATIC_INLINE void LL_ADC_DisableIT_JEOC(ADC_TypeDef *ADCx) 8244 { 8245 CLEAR_BIT(ADCx->IER, LL_ADC_IT_JEOC); 8246 } 8247 8248 /** 8249 * @brief Disable interruption ADC group injected end of sequence conversions. 8250 * @rmtoll IER JEOSIE LL_ADC_DisableIT_JEOS 8251 * @param ADCx ADC instance 8252 * @retval None 8253 */ 8254 __STATIC_INLINE void LL_ADC_DisableIT_JEOS(ADC_TypeDef *ADCx) 8255 { 8256 CLEAR_BIT(ADCx->IER, LL_ADC_IT_JEOS); 8257 } 8258 8259 /** 8260 * @brief Disable interruption ADC group injected context queue overflow. 8261 * @rmtoll IER JQOVFIE LL_ADC_DisableIT_JQOVF 8262 * @param ADCx ADC instance 8263 * @retval None 8264 */ 8265 __STATIC_INLINE void LL_ADC_DisableIT_JQOVF(ADC_TypeDef *ADCx) 8266 { 8267 CLEAR_BIT(ADCx->IER, LL_ADC_IT_JQOVF); 8268 } 8269 8270 /** 8271 * @brief Disable interruption ADC analog watchdog 1. 8272 * @rmtoll IER AWD1IE LL_ADC_DisableIT_AWD1 8273 * @param ADCx ADC instance 8274 * @retval None 8275 */ 8276 __STATIC_INLINE void LL_ADC_DisableIT_AWD1(ADC_TypeDef *ADCx) 8277 { 8278 CLEAR_BIT(ADCx->IER, LL_ADC_IT_AWD1); 8279 } 8280 8281 /** 8282 * @brief Disable interruption ADC analog watchdog 2. 8283 * @rmtoll IER AWD2IE LL_ADC_DisableIT_AWD2 8284 * @param ADCx ADC instance 8285 * @retval None 8286 */ 8287 __STATIC_INLINE void LL_ADC_DisableIT_AWD2(ADC_TypeDef *ADCx) 8288 { 8289 CLEAR_BIT(ADCx->IER, LL_ADC_IT_AWD2); 8290 } 8291 8292 /** 8293 * @brief Disable interruption ADC analog watchdog 3. 8294 * @rmtoll IER AWD3IE LL_ADC_DisableIT_AWD3 8295 * @param ADCx ADC instance 8296 * @retval None 8297 */ 8298 __STATIC_INLINE void LL_ADC_DisableIT_AWD3(ADC_TypeDef *ADCx) 8299 { 8300 CLEAR_BIT(ADCx->IER, LL_ADC_IT_AWD3); 8301 } 8302 8303 /** 8304 * @brief Get state of interruption ADC ready 8305 * (0: interrupt disabled, 1: interrupt enabled). 8306 * @rmtoll IER ADRDYIE LL_ADC_IsEnabledIT_ADRDY 8307 * @param ADCx ADC instance 8308 * @retval State of bit (1 or 0). 8309 */ 8310 __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_ADRDY(ADC_TypeDef *ADCx) 8311 { 8312 return ((READ_BIT(ADCx->IER, LL_ADC_IT_ADRDY) == (LL_ADC_IT_ADRDY)) ? 1UL : 0UL); 8313 } 8314 8315 /** 8316 * @brief Get state of interruption ADC group regular end of unitary conversion 8317 * (0: interrupt disabled, 1: interrupt enabled). 8318 * @rmtoll IER EOCIE LL_ADC_IsEnabledIT_EOC 8319 * @param ADCx ADC instance 8320 * @retval State of bit (1 or 0). 8321 */ 8322 __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_EOC(ADC_TypeDef *ADCx) 8323 { 8324 return ((READ_BIT(ADCx->IER, LL_ADC_IT_EOC) == (LL_ADC_IT_EOC)) ? 1UL : 0UL); 8325 } 8326 8327 /** 8328 * @brief Get state of interruption ADC group regular end of sequence conversions 8329 * (0: interrupt disabled, 1: interrupt enabled). 8330 * @rmtoll IER EOSIE LL_ADC_IsEnabledIT_EOS 8331 * @param ADCx ADC instance 8332 * @retval State of bit (1 or 0). 8333 */ 8334 __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_EOS(ADC_TypeDef *ADCx) 8335 { 8336 return ((READ_BIT(ADCx->IER, LL_ADC_IT_EOS) == (LL_ADC_IT_EOS)) ? 1UL : 0UL); 8337 } 8338 8339 /** 8340 * @brief Get state of interruption ADC group regular overrun 8341 * (0: interrupt disabled, 1: interrupt enabled). 8342 * @rmtoll IER OVRIE LL_ADC_IsEnabledIT_OVR 8343 * @param ADCx ADC instance 8344 * @retval State of bit (1 or 0). 8345 */ 8346 __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_OVR(ADC_TypeDef *ADCx) 8347 { 8348 return ((READ_BIT(ADCx->IER, LL_ADC_IT_OVR) == (LL_ADC_IT_OVR)) ? 1UL : 0UL); 8349 } 8350 8351 /** 8352 * @brief Get state of interruption ADC group regular end of sampling 8353 * (0: interrupt disabled, 1: interrupt enabled). 8354 * @rmtoll IER EOSMPIE LL_ADC_IsEnabledIT_EOSMP 8355 * @param ADCx ADC instance 8356 * @retval State of bit (1 or 0). 8357 */ 8358 __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_EOSMP(ADC_TypeDef *ADCx) 8359 { 8360 return ((READ_BIT(ADCx->IER, LL_ADC_IT_EOSMP) == (LL_ADC_IT_EOSMP)) ? 1UL : 0UL); 8361 } 8362 8363 /** 8364 * @brief Get state of interruption ADC group injected end of unitary conversion 8365 * (0: interrupt disabled, 1: interrupt enabled). 8366 * @rmtoll IER JEOCIE LL_ADC_IsEnabledIT_JEOC 8367 * @param ADCx ADC instance 8368 * @retval State of bit (1 or 0). 8369 */ 8370 __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_JEOC(ADC_TypeDef *ADCx) 8371 { 8372 return ((READ_BIT(ADCx->IER, LL_ADC_IT_JEOC) == (LL_ADC_IT_JEOC)) ? 1UL : 0UL); 8373 } 8374 8375 /** 8376 * @brief Get state of interruption ADC group injected end of sequence conversions 8377 * (0: interrupt disabled, 1: interrupt enabled). 8378 * @rmtoll IER JEOSIE LL_ADC_IsEnabledIT_JEOS 8379 * @param ADCx ADC instance 8380 * @retval State of bit (1 or 0). 8381 */ 8382 __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_JEOS(ADC_TypeDef *ADCx) 8383 { 8384 return ((READ_BIT(ADCx->IER, LL_ADC_IT_JEOS) == (LL_ADC_IT_JEOS)) ? 1UL : 0UL); 8385 } 8386 8387 /** 8388 * @brief Get state of interruption ADC group injected context queue overflow interrupt state 8389 * (0: interrupt disabled, 1: interrupt enabled). 8390 * @rmtoll IER JQOVFIE LL_ADC_IsEnabledIT_JQOVF 8391 * @param ADCx ADC instance 8392 * @retval State of bit (1 or 0). 8393 */ 8394 __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_JQOVF(ADC_TypeDef *ADCx) 8395 { 8396 return ((READ_BIT(ADCx->IER, LL_ADC_IT_JQOVF) == (LL_ADC_IT_JQOVF)) ? 1UL : 0UL); 8397 } 8398 8399 /** 8400 * @brief Get state of interruption ADC analog watchdog 1 8401 * (0: interrupt disabled, 1: interrupt enabled). 8402 * @rmtoll IER AWD1IE LL_ADC_IsEnabledIT_AWD1 8403 * @param ADCx ADC instance 8404 * @retval State of bit (1 or 0). 8405 */ 8406 __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_AWD1(ADC_TypeDef *ADCx) 8407 { 8408 return ((READ_BIT(ADCx->IER, LL_ADC_IT_AWD1) == (LL_ADC_IT_AWD1)) ? 1UL : 0UL); 8409 } 8410 8411 /** 8412 * @brief Get state of interruption Get ADC analog watchdog 2 8413 * (0: interrupt disabled, 1: interrupt enabled). 8414 * @rmtoll IER AWD2IE LL_ADC_IsEnabledIT_AWD2 8415 * @param ADCx ADC instance 8416 * @retval State of bit (1 or 0). 8417 */ 8418 __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_AWD2(ADC_TypeDef *ADCx) 8419 { 8420 return ((READ_BIT(ADCx->IER, LL_ADC_IT_AWD2) == (LL_ADC_IT_AWD2)) ? 1UL : 0UL); 8421 } 8422 8423 /** 8424 * @brief Get state of interruption Get ADC analog watchdog 3 8425 * (0: interrupt disabled, 1: interrupt enabled). 8426 * @rmtoll IER AWD3IE LL_ADC_IsEnabledIT_AWD3 8427 * @param ADCx ADC instance 8428 * @retval State of bit (1 or 0). 8429 */ 8430 __STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_AWD3(ADC_TypeDef *ADCx) 8431 { 8432 return ((READ_BIT(ADCx->IER, LL_ADC_IT_AWD3) == (LL_ADC_IT_AWD3)) ? 1UL : 0UL); 8433 } 8434 8435 /** 8436 * @} 8437 */ 8438 8439 #if defined(USE_FULL_LL_DRIVER) || defined(__rtems__) 8440 /** @defgroup ADC_LL_EF_Init Initialization and de-initialization functions 8441 * @ingroup RTEMSBSPsARMSTM32H7 8442 * @{ 8443 */ 8444 8445 /* Initialization of some features of ADC common parameters and multimode */ 8446 ErrorStatus LL_ADC_CommonDeInit(ADC_Common_TypeDef *ADCxy_COMMON); 8447 ErrorStatus LL_ADC_CommonInit(ADC_Common_TypeDef *ADCxy_COMMON, LL_ADC_CommonInitTypeDef *ADC_CommonInitStruct); 8448 void LL_ADC_CommonStructInit(LL_ADC_CommonInitTypeDef *ADC_CommonInitStruct); 8449 8450 /* De-initialization of ADC instance, ADC group regular and ADC group injected */ 8451 /* (availability of ADC group injected depends on STM32 families) */ 8452 ErrorStatus LL_ADC_DeInit(ADC_TypeDef *ADCx); 8453 8454 /* Initialization of some features of ADC instance */ 8455 ErrorStatus LL_ADC_Init(ADC_TypeDef *ADCx, LL_ADC_InitTypeDef *ADC_InitStruct); 8456 void LL_ADC_StructInit(LL_ADC_InitTypeDef *ADC_InitStruct); 8457 8458 /* Initialization of some features of ADC instance and ADC group regular */ 8459 ErrorStatus LL_ADC_REG_Init(ADC_TypeDef *ADCx, LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct); 8460 void LL_ADC_REG_StructInit(LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct); 8461 8462 /* Initialization of some features of ADC instance and ADC group injected */ 8463 ErrorStatus LL_ADC_INJ_Init(ADC_TypeDef *ADCx, LL_ADC_INJ_InitTypeDef *ADC_INJ_InitStruct); 8464 void LL_ADC_INJ_StructInit(LL_ADC_INJ_InitTypeDef *ADC_INJ_InitStruct); 8465 8466 /** 8467 * @} 8468 */ 8469 #endif /* USE_FULL_LL_DRIVER */ 8470 8471 /** 8472 * @} 8473 */ 8474 8475 /** 8476 * @} 8477 */ 8478 8479 #endif /* ADC1 || ADC2 || ADC3 */ 8480 8481 /** 8482 * @} 8483 */ 8484 8485 #ifdef __cplusplus 8486 } 8487 #endif 8488 8489 #endif /* STM32H7xx_LL_ADC_H */ 8490
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |