Subversion Repositories DashDisplay

Rev

Rev 56 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
56 mjames 1
/**
2
  ******************************************************************************
3
  * @file    stm32l1xx_ll_adc.h
4
  * @author  MCD Application Team
5
  * @brief   Header file of ADC LL module.
6
  ******************************************************************************
7
  * @attention
8
  *
9
  * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
10
  * All rights reserved.</center></h2>
11
  *
12
  * This software component is licensed by ST under BSD 3-Clause license,
13
  * the "License"; You may not use this file except in compliance with the
14
  * License. You may obtain a copy of the License at:
15
  *                        opensource.org/licenses/BSD-3-Clause
16
  *
17
  ******************************************************************************
18
  */
19
 
20
/* Define to prevent recursive inclusion -------------------------------------*/
21
#ifndef __STM32L1xx_LL_ADC_H
22
#define __STM32L1xx_LL_ADC_H
23
 
24
#ifdef __cplusplus
25
extern "C" {
26
#endif
27
 
28
/* Includes ------------------------------------------------------------------*/
29
#include "stm32l1xx.h"
30
 
31
/** @addtogroup STM32L1xx_LL_Driver
32
  * @{
33
  */
34
 
35
#if defined (ADC1)
36
 
37
/** @defgroup ADC_LL ADC
38
  * @{
39
  */
40
 
41
/* Private types -------------------------------------------------------------*/
42
/* Private variables ---------------------------------------------------------*/
43
 
44
/* Private constants ---------------------------------------------------------*/
45
/** @defgroup ADC_LL_Private_Constants ADC Private Constants
46
  * @{
47
  */
48
 
49
/* Internal mask for ADC group regular sequencer:                             */
50
/* To select into literal LL_ADC_REG_RANK_x the relevant bits for:            */
51
/* - sequencer register offset                                                */
52
/* - sequencer rank bits position into the selected register                  */
53
 
54
/* Internal register offset for ADC group regular sequencer configuration */
55
/* (offset placed into a spare area of literal definition) */
56
#define ADC_SQR1_REGOFFSET                 0x00000000U
57
#define ADC_SQR2_REGOFFSET                 0x00000100U
58
#define ADC_SQR3_REGOFFSET                 0x00000200U
59
#define ADC_SQR4_REGOFFSET                 0x00000300U
60
#define ADC_SQR5_REGOFFSET                 0x00000400U
61
 
62
#define ADC_REG_SQRX_REGOFFSET_MASK        (ADC_SQR1_REGOFFSET | ADC_SQR2_REGOFFSET | ADC_SQR3_REGOFFSET | ADC_SQR4_REGOFFSET | ADC_SQR5_REGOFFSET)
63
#define ADC_REG_RANK_ID_SQRX_MASK          (ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0)
64
 
65
/* Definition of ADC group regular sequencer bits information to be inserted  */
66
/* into ADC group regular sequencer ranks literals definition.                */
67
#define ADC_REG_RANK_1_SQRX_BITOFFSET_POS  ( 0U) /* Value equivalent to POSITION_VAL(ADC_SQR5_SQ1) */
68
#define ADC_REG_RANK_2_SQRX_BITOFFSET_POS  ( 5U) /* Value equivalent to POSITION_VAL(ADC_SQR5_SQ2) */
69
#define ADC_REG_RANK_3_SQRX_BITOFFSET_POS  (10U) /* Value equivalent to POSITION_VAL(ADC_SQR5_SQ3) */
70
#define ADC_REG_RANK_4_SQRX_BITOFFSET_POS  (15U) /* Value equivalent to POSITION_VAL(ADC_SQR5_SQ4) */
71
#define ADC_REG_RANK_5_SQRX_BITOFFSET_POS  (20U) /* Value equivalent to POSITION_VAL(ADC_SQR5_SQ5) */
72
#define ADC_REG_RANK_6_SQRX_BITOFFSET_POS  (25U) /* Value equivalent to POSITION_VAL(ADC_SQR5_SQ6) */
73
#define ADC_REG_RANK_7_SQRX_BITOFFSET_POS  ( 0U) /* Value equivalent to POSITION_VAL(ADC_SQR4_SQ7) */
74
#define ADC_REG_RANK_8_SQRX_BITOFFSET_POS  ( 5U) /* Value equivalent to POSITION_VAL(ADC_SQR4_SQ8) */
75
#define ADC_REG_RANK_9_SQRX_BITOFFSET_POS  (10U) /* Value equivalent to POSITION_VAL(ADC_SQR4_SQ9) */
76
#define ADC_REG_RANK_10_SQRX_BITOFFSET_POS (15U) /* Value equivalent to POSITION_VAL(ADC_SQR4_SQ10) */
77
#define ADC_REG_RANK_11_SQRX_BITOFFSET_POS (20U) /* Value equivalent to POSITION_VAL(ADC_SQR4_SQ11) */
78
#define ADC_REG_RANK_12_SQRX_BITOFFSET_POS (25U) /* Value equivalent to POSITION_VAL(ADC_SQR4_SQ12) */
79
#define ADC_REG_RANK_13_SQRX_BITOFFSET_POS ( 0U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ13) */
80
#define ADC_REG_RANK_14_SQRX_BITOFFSET_POS ( 5U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ14) */
81
#define ADC_REG_RANK_15_SQRX_BITOFFSET_POS (10U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ15) */
82
#define ADC_REG_RANK_16_SQRX_BITOFFSET_POS (15U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ16) */
83
#define ADC_REG_RANK_17_SQRX_BITOFFSET_POS (20U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ17) */
84
#define ADC_REG_RANK_18_SQRX_BITOFFSET_POS (25U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ18) */
85
#define ADC_REG_RANK_19_SQRX_BITOFFSET_POS ( 0U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ29) */
86
#define ADC_REG_RANK_20_SQRX_BITOFFSET_POS ( 5U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ20) */
87
#define ADC_REG_RANK_21_SQRX_BITOFFSET_POS (10U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ21) */
88
#define ADC_REG_RANK_22_SQRX_BITOFFSET_POS (15U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ22) */
89
#define ADC_REG_RANK_23_SQRX_BITOFFSET_POS (20U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ23) */
90
#define ADC_REG_RANK_24_SQRX_BITOFFSET_POS (25U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ24) */
91
#define ADC_REG_RANK_25_SQRX_BITOFFSET_POS ( 0U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ25) */
92
#define ADC_REG_RANK_26_SQRX_BITOFFSET_POS ( 5U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ26) */
93
#define ADC_REG_RANK_27_SQRX_BITOFFSET_POS (10U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ27) */
94
#if defined(ADC_SQR1_SQ28)
95
#define ADC_REG_RANK_28_SQRX_BITOFFSET_POS (15U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ28) */
96
#endif
97
 
98
 
99
 
100
/* Internal mask for ADC group injected sequencer:                            */
101
/* To select into literal LL_ADC_INJ_RANK_x the relevant bits for:            */
102
/* - data register offset                                                     */
103
/* - offset register offset                                                   */
104
/* - sequencer rank bits position into the selected register                  */
105
 
106
/* Internal register offset for ADC group injected data register */
107
/* (offset placed into a spare area of literal definition) */
108
#define ADC_JDR1_REGOFFSET                 0x00000000U
109
#define ADC_JDR2_REGOFFSET                 0x00000100U
110
#define ADC_JDR3_REGOFFSET                 0x00000200U
111
#define ADC_JDR4_REGOFFSET                 0x00000300U
112
 
113
/* Internal register offset for ADC group injected offset configuration */
114
/* (offset placed into a spare area of literal definition) */
115
#define ADC_JOFR1_REGOFFSET                0x00000000U
116
#define ADC_JOFR2_REGOFFSET                0x00001000U
117
#define ADC_JOFR3_REGOFFSET                0x00002000U
118
#define ADC_JOFR4_REGOFFSET                0x00003000U
119
 
120
#define ADC_INJ_JDRX_REGOFFSET_MASK        (ADC_JDR1_REGOFFSET | ADC_JDR2_REGOFFSET | ADC_JDR3_REGOFFSET | ADC_JDR4_REGOFFSET)
121
#define ADC_INJ_JOFRX_REGOFFSET_MASK       (ADC_JOFR1_REGOFFSET | ADC_JOFR2_REGOFFSET | ADC_JOFR3_REGOFFSET | ADC_JOFR4_REGOFFSET)
122
#define ADC_INJ_RANK_ID_JSQR_MASK          (ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0)
123
 
124
/* Definition of ADC group injected sequencer bits information to be inserted */
125
/* into ADC group injected sequencer ranks literals definition.               */
126
#define ADC_INJ_RANK_1_JSQR_BITOFFSET_POS  ( 0U) /* Value equivalent to POSITION_VAL(ADC_JSQR_JSQ1) */
127
#define ADC_INJ_RANK_2_JSQR_BITOFFSET_POS  ( 5U) /* Value equivalent to POSITION_VAL(ADC_JSQR_JSQ2) */
128
#define ADC_INJ_RANK_3_JSQR_BITOFFSET_POS  (10U) /* Value equivalent to POSITION_VAL(ADC_JSQR_JSQ3) */
129
#define ADC_INJ_RANK_4_JSQR_BITOFFSET_POS  (15U) /* Value equivalent to POSITION_VAL(ADC_JSQR_JSQ4) */
130
 
131
 
132
 
133
/* Internal mask for ADC group regular trigger:                               */
134
/* To select into literal LL_ADC_REG_TRIG_x the relevant bits for:            */
135
/* - regular trigger source                                                   */
136
/* - regular trigger edge                                                     */
137
#define ADC_REG_TRIG_EXT_EDGE_DEFAULT       (ADC_CR2_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) */
138
 
139
/* Mask containing trigger source masks for each of possible                  */
140
/* trigger edge selection duplicated with shifts [0; 4; 8; 12]                */
141
/* corresponding to {SW start; ext trigger; ext trigger; ext trigger}.        */
142
#define ADC_REG_TRIG_SOURCE_MASK            (((LL_ADC_REG_TRIG_SOFTWARE & ADC_CR2_EXTSEL) >> (4U * 0U)) | \
143
                                             ((ADC_CR2_EXTSEL)                            >> (4U * 1U)) | \
144
                                             ((ADC_CR2_EXTSEL)                            >> (4U * 2U)) | \
145
                                             ((ADC_CR2_EXTSEL)                            >> (4U * 3U)))
146
 
147
/* Mask containing trigger edge masks for each of possible                    */
148
/* trigger edge selection duplicated with shifts [0; 4; 8; 12]                */
149
/* corresponding to {SW start; ext trigger; ext trigger; ext trigger}.        */
150
#define ADC_REG_TRIG_EDGE_MASK              (((LL_ADC_REG_TRIG_SOFTWARE & ADC_CR2_EXTEN) >> (4U * 0U)) | \
151
                                             ((ADC_REG_TRIG_EXT_EDGE_DEFAULT)            >> (4U * 1U)) | \
152
                                             ((ADC_REG_TRIG_EXT_EDGE_DEFAULT)            >> (4U * 2U)) | \
153
                                             ((ADC_REG_TRIG_EXT_EDGE_DEFAULT)            >> (4U * 3U)))
154
 
155
/* Definition of ADC group regular trigger bits information.                  */
156
#define ADC_REG_TRIG_EXTSEL_BITOFFSET_POS  (24U) /* Value equivalent to POSITION_VAL(ADC_CR2_EXTSEL) */
157
#define ADC_REG_TRIG_EXTEN_BITOFFSET_POS   (28U) /* Value equivalent to POSITION_VAL(ADC_CR2_EXTEN) */
158
 
159
 
160
 
161
/* Internal mask for ADC group injected trigger:                              */
162
/* To select into literal LL_ADC_INJ_TRIG_x the relevant bits for:            */
163
/* - injected trigger source                                                  */
164
/* - injected trigger edge                                                    */
165
#define ADC_INJ_TRIG_EXT_EDGE_DEFAULT      (ADC_CR2_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) */
166
 
167
/* Mask containing trigger source masks for each of possible                  */
168
/* trigger edge selection duplicated with shifts [0; 4; 8; 12]                */
169
/* corresponding to {SW start; ext trigger; ext trigger; ext trigger}.        */
170
#define ADC_INJ_TRIG_SOURCE_MASK            (((LL_ADC_REG_TRIG_SOFTWARE & ADC_CR2_JEXTSEL) >> (4U * 0U)) | \
171
                                             ((ADC_CR2_JEXTSEL)                            >> (4U * 1U)) | \
172
                                             ((ADC_CR2_JEXTSEL)                            >> (4U * 2U)) | \
173
                                             ((ADC_CR2_JEXTSEL)                            >> (4U * 3U)))
174
 
175
/* Mask containing trigger edge masks for each of possible                    */
176
/* trigger edge selection duplicated with shifts [0; 4; 8; 12]                */
177
/* corresponding to {SW start; ext trigger; ext trigger; ext trigger}.        */
178
#define ADC_INJ_TRIG_EDGE_MASK              (((LL_ADC_INJ_TRIG_SOFTWARE & ADC_CR2_JEXTEN) >> (4U * 0U)) | \
179
                                             ((ADC_INJ_TRIG_EXT_EDGE_DEFAULT)             >> (4U * 1U)) | \
180
                                             ((ADC_INJ_TRIG_EXT_EDGE_DEFAULT)             >> (4U * 2U)) | \
181
                                             ((ADC_INJ_TRIG_EXT_EDGE_DEFAULT)             >> (4U * 3U)))
182
 
183
/* Definition of ADC group injected trigger bits information.                 */
184
#define ADC_INJ_TRIG_EXTSEL_BITOFFSET_POS  (16U) /* Value equivalent to POSITION_VAL(ADC_CR2_JEXTSEL) */
185
#define ADC_INJ_TRIG_EXTEN_BITOFFSET_POS   (20U) /* Value equivalent to POSITION_VAL(ADC_CR2_JEXTEN) */
186
 
187
 
188
 
189
 
190
 
191
 
192
/* Internal mask for ADC channel:                                             */
193
/* To select into literal LL_ADC_CHANNEL_x the relevant bits for:             */
194
/* - channel identifier defined by number                                     */
195
/* - channel differentiation between external channels (connected to          */
196
/*   GPIO pins) and internal channels (connected to internal paths)           */
197
/* - channel sampling time defined by SMPRx register offset                   */
198
/*   and SMPx bits positions into SMPRx register                              */
199
#define ADC_CHANNEL_ID_NUMBER_MASK         (ADC_CR1_AWDCH)
200
#define ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS ( 0U)/* Value equivalent to POSITION_VAL(ADC_CHANNEL_ID_NUMBER_MASK) */
201
#define ADC_CHANNEL_ID_MASK                (ADC_CHANNEL_ID_NUMBER_MASK | ADC_CHANNEL_ID_INTERNAL_CH_MASK)
202
/* Equivalent mask of ADC_CHANNEL_NUMBER_MASK aligned on register LSB (bit 0) */
203
#define ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0 0x0000001FU /* Equivalent to shift: (ADC_CHANNEL_NUMBER_MASK >> POSITION_VAL(ADC_CHANNEL_NUMBER_MASK)) */
204
 
205
/* Channel differentiation between external and internal channels */
206
#define ADC_CHANNEL_ID_INTERNAL_CH         0x80000000U   /* Marker of internal channel */
207
#define ADC_CHANNEL_ID_INTERNAL_CH_MASK    (ADC_CHANNEL_ID_INTERNAL_CH)
208
 
209
/* Internal register offset for ADC channel sampling time configuration */
210
/* (offset placed into a spare area of literal definition) */
211
#define ADC_SMPR1_REGOFFSET                0x00000000U
212
#define ADC_SMPR2_REGOFFSET                0x02000000U
213
#define ADC_SMPR3_REGOFFSET                0x04000000U
214
#if defined(ADC_SMPR0_SMP31)
215
#define ADC_SMPR0_REGOFFSET                0x28000000U   /* SMPR0 register offset from SMPR1 is 20 registers. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
216
#define ADC_CHANNEL_SMPRX_REGOFFSET_MASK   (ADC_SMPR1_REGOFFSET | ADC_SMPR2_REGOFFSET | ADC_SMPR3_REGOFFSET | ADC_SMPR0_REGOFFSET)
217
#else
218
#define ADC_CHANNEL_SMPRX_REGOFFSET_MASK   (ADC_SMPR1_REGOFFSET | ADC_SMPR2_REGOFFSET | ADC_SMPR3_REGOFFSET)
219
#endif /* ADC_SMPR0_SMP31 */
220
 
221
#define ADC_CHANNEL_SMPx_BITOFFSET_MASK    0x01F00000U
222
#define ADC_CHANNEL_SMPx_BITOFFSET_POS     (20U)           /* Value equivalent to POSITION_VAL(ADC_CHANNEL_SMPx_BITOFFSET_MASK) */
223
 
224
/* Definition of channels ID number information to be inserted into           */
225
/* channels literals definition.                                              */
226
#define ADC_CHANNEL_0_NUMBER               0x00000000U
227
#define ADC_CHANNEL_1_NUMBER               (                                                                        ADC_CR1_AWDCH_0)
228
#define ADC_CHANNEL_2_NUMBER               (                                                      ADC_CR1_AWDCH_1                  )
229
#define ADC_CHANNEL_3_NUMBER               (                                                      ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
230
#define ADC_CHANNEL_4_NUMBER               (                                    ADC_CR1_AWDCH_2                                    )
231
#define ADC_CHANNEL_5_NUMBER               (                                    ADC_CR1_AWDCH_2                   | ADC_CR1_AWDCH_0)
232
#define ADC_CHANNEL_6_NUMBER               (                                    ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1                  )
233
#define ADC_CHANNEL_7_NUMBER               (                                    ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
234
#define ADC_CHANNEL_8_NUMBER               (                  ADC_CR1_AWDCH_3                                                      )
235
#define ADC_CHANNEL_9_NUMBER               (                  ADC_CR1_AWDCH_3                                     | ADC_CR1_AWDCH_0)
236
#define ADC_CHANNEL_10_NUMBER              (                  ADC_CR1_AWDCH_3                   | ADC_CR1_AWDCH_1                  )
237
#define ADC_CHANNEL_11_NUMBER              (                  ADC_CR1_AWDCH_3                   | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
238
#define ADC_CHANNEL_12_NUMBER              (                  ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2                                    )
239
#define ADC_CHANNEL_13_NUMBER              (                  ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2                   | ADC_CR1_AWDCH_0)
240
#define ADC_CHANNEL_14_NUMBER              (                  ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1                  )
241
#define ADC_CHANNEL_15_NUMBER              (                  ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
242
#define ADC_CHANNEL_16_NUMBER              (ADC_CR1_AWDCH_4                                                                        )
243
#define ADC_CHANNEL_17_NUMBER              (ADC_CR1_AWDCH_4                                                       | ADC_CR1_AWDCH_0)
244
#define ADC_CHANNEL_18_NUMBER              (ADC_CR1_AWDCH_4                                     | ADC_CR1_AWDCH_1                  )
245
#define ADC_CHANNEL_19_NUMBER              (ADC_CR1_AWDCH_4                                     | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
246
#define ADC_CHANNEL_20_NUMBER              (ADC_CR1_AWDCH_4                   | ADC_CR1_AWDCH_2                                    )
247
#define ADC_CHANNEL_21_NUMBER              (ADC_CR1_AWDCH_4                   | ADC_CR1_AWDCH_2                   | ADC_CR1_AWDCH_0)
248
#define ADC_CHANNEL_22_NUMBER              (ADC_CR1_AWDCH_4                   | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1                  )
249
#define ADC_CHANNEL_23_NUMBER              (ADC_CR1_AWDCH_4                   | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
250
#define ADC_CHANNEL_24_NUMBER              (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_3                                                      )
251
#define ADC_CHANNEL_25_NUMBER              (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_3                                     | ADC_CR1_AWDCH_0)
252
#define ADC_CHANNEL_26_NUMBER              (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_3                   | ADC_CR1_AWDCH_1                  )
253
#if defined(ADC_SMPR0_SMP31)
254
#define ADC_CHANNEL_27_NUMBER              (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_3                   | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
255
#define ADC_CHANNEL_28_NUMBER              (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2                                    )
256
#define ADC_CHANNEL_29_NUMBER              (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2                   | ADC_CR1_AWDCH_0)
257
#define ADC_CHANNEL_30_NUMBER              (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1                  )
258
#define ADC_CHANNEL_31_NUMBER              (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
259
#endif /* ADC_SMPR0_SMP31 */
260
 
261
/* Definition of channels sampling time information to be inserted into       */
262
/* channels literals definition.                                              */
263
#define ADC_CHANNEL_0_SMP                  (ADC_SMPR3_REGOFFSET | (( 0U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP0) */
264
#define ADC_CHANNEL_1_SMP                  (ADC_SMPR3_REGOFFSET | (( 3U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP1) */
265
#define ADC_CHANNEL_2_SMP                  (ADC_SMPR3_REGOFFSET | (( 6U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP2) */
266
#define ADC_CHANNEL_3_SMP                  (ADC_SMPR3_REGOFFSET | (( 9U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP3) */
267
#define ADC_CHANNEL_4_SMP                  (ADC_SMPR3_REGOFFSET | ((12U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP4) */
268
#define ADC_CHANNEL_5_SMP                  (ADC_SMPR3_REGOFFSET | ((15U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP5) */
269
#define ADC_CHANNEL_6_SMP                  (ADC_SMPR3_REGOFFSET | ((18U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP6) */
270
#define ADC_CHANNEL_7_SMP                  (ADC_SMPR3_REGOFFSET | ((21U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP7) */
271
#define ADC_CHANNEL_8_SMP                  (ADC_SMPR3_REGOFFSET | ((24U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP8) */
272
#define ADC_CHANNEL_9_SMP                  (ADC_SMPR3_REGOFFSET | ((27U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP9) */
273
#define ADC_CHANNEL_10_SMP                 (ADC_SMPR2_REGOFFSET | (( 0U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP10) */
274
#define ADC_CHANNEL_11_SMP                 (ADC_SMPR2_REGOFFSET | (( 3U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP11) */
275
#define ADC_CHANNEL_12_SMP                 (ADC_SMPR2_REGOFFSET | (( 6U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP12) */
276
#define ADC_CHANNEL_13_SMP                 (ADC_SMPR2_REGOFFSET | (( 9U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP13) */
277
#define ADC_CHANNEL_14_SMP                 (ADC_SMPR2_REGOFFSET | ((12U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP14) */
278
#define ADC_CHANNEL_15_SMP                 (ADC_SMPR2_REGOFFSET | ((15U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP15) */
279
#define ADC_CHANNEL_16_SMP                 (ADC_SMPR2_REGOFFSET | ((18U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP16) */
280
#define ADC_CHANNEL_17_SMP                 (ADC_SMPR2_REGOFFSET | ((21U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP17) */
281
#define ADC_CHANNEL_18_SMP                 (ADC_SMPR2_REGOFFSET | ((24U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP18) */
282
#define ADC_CHANNEL_19_SMP                 (ADC_SMPR2_REGOFFSET | ((27U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP19) */
283
#define ADC_CHANNEL_20_SMP                 (ADC_SMPR1_REGOFFSET | (( 0U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP20) */
284
#define ADC_CHANNEL_21_SMP                 (ADC_SMPR1_REGOFFSET | (( 3U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP21) */
285
#define ADC_CHANNEL_22_SMP                 (ADC_SMPR1_REGOFFSET | (( 6U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP22) */
286
#define ADC_CHANNEL_23_SMP                 (ADC_SMPR1_REGOFFSET | (( 9U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP23) */
287
#define ADC_CHANNEL_24_SMP                 (ADC_SMPR1_REGOFFSET | ((12U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP24) */
288
#define ADC_CHANNEL_25_SMP                 (ADC_SMPR1_REGOFFSET | ((15U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP25) */
289
#define ADC_CHANNEL_26_SMP                 (ADC_SMPR1_REGOFFSET | ((18U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP26) */
290
#if defined(ADC_SMPR0_SMP31)
291
#define ADC_CHANNEL_27_SMP                 (ADC_SMPR1_REGOFFSET | ((21U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP27) */
292
#define ADC_CHANNEL_28_SMP                 (ADC_SMPR1_REGOFFSET | ((24U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP28) */
293
#define ADC_CHANNEL_29_SMP                 (ADC_SMPR1_REGOFFSET | ((27U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP19) */
294
#define ADC_CHANNEL_30_SMP                 (ADC_SMPR0_REGOFFSET | (( 0U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR0_SMP30) */
295
#define ADC_CHANNEL_31_SMP                 (ADC_SMPR0_REGOFFSET | (( 3U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR0_SMP31) */
296
#endif /* ADC_SMPR0_SMP31 */
297
 
298
 
299
/* Internal mask for ADC analog watchdog:                                     */
300
/* To select into literals LL_ADC_AWD_CHANNELx_xxx the relevant bits for:     */
301
/* (concatenation of multiple bits used in different analog watchdogs,        */
302
/* (feature of several watchdogs not available on all STM32 families)).       */
303
/* - analog watchdog 1: monitored channel defined by number,                  */
304
/*   selection of ADC group (ADC groups regular and-or injected).             */
305
 
306
/* Internal register offset for ADC analog watchdog channel configuration */
307
#define ADC_AWD_CR1_REGOFFSET              0x00000000U
308
 
309
#define ADC_AWD_CRX_REGOFFSET_MASK         (ADC_AWD_CR1_REGOFFSET)
310
 
311
#define ADC_AWD_CR1_CHANNEL_MASK           (ADC_CR1_AWDCH | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL)
312
#define ADC_AWD_CR_ALL_CHANNEL_MASK        (ADC_AWD_CR1_CHANNEL_MASK)
313
 
314
/* Internal register offset for ADC analog watchdog threshold configuration */
315
#define ADC_AWD_TR1_HIGH_REGOFFSET         0x00000000U
316
#define ADC_AWD_TR1_LOW_REGOFFSET          0x00000001U
317
#define ADC_AWD_TRX_REGOFFSET_MASK         (ADC_AWD_TR1_HIGH_REGOFFSET | ADC_AWD_TR1_LOW_REGOFFSET)
318
 
319
 
320
/* ADC registers bits positions */
321
#define ADC_CR1_RES_BITOFFSET_POS          (24U) /* Value equivalent to POSITION_VAL(ADC_CR1_RES) */
322
#define ADC_TR_HT_BITOFFSET_POS            (16U) /* Value equivalent to POSITION_VAL(ADC_TR_HT) */
323
 
324
 
325
/* ADC internal channels related definitions */
326
/* Internal voltage reference VrefInt */
327
#define VREFINT_CAL_ADDR                   ((uint16_t*) VREFINT_CAL_ADDR_CMSIS)     /* Internal voltage reference, address of parameter VREFINT_CAL: VrefInt ADC raw data acquired at temperature 30 DegC (tolerance: +-5 DegC), Vref+ = 3.0 V (tolerance: +-10 mV). */
328
#define VREFINT_CAL_VREF                   ( 3000U)                                 /* Analog voltage reference (Vref+) value with which temperature sensor has been calibrated in production (tolerance: +-10 mV) (unit: mV). */
329
/* Temperature sensor */
330
#if defined (TEMPSENSOR_CAL1_ADDR_CMSIS)
331
#define TEMPSENSOR_CAL1_ADDR               ((uint16_t*) TEMPSENSOR_CAL1_ADDR_CMSIS) /* Internal temperature sensor, address of parameter TS_CAL1: On STM32L1, temperature sensor ADC raw data acquired at temperature  30 DegC (tolerance: +-5 DegC), Vref+ = 3.0 V (tolerance: +-10 mV). */
332
#define TEMPSENSOR_CAL2_ADDR               ((uint16_t*) TEMPSENSOR_CAL2_ADDR_CMSIS) /* Internal temperature sensor, address of parameter TS_CAL2: On STM32L1, temperature sensor ADC raw data acquired at temperature 110 DegC (tolerance: +-5 DegC), Vref+ = 3.0 V (tolerance: +-10 mV). */
333
#endif /* TEMPSENSOR_CAL1_ADDR_CMSIS */
334
#define TEMPSENSOR_CAL1_TEMP               (( int32_t)   30)                        /* Internal temperature sensor, temperature at which temperature sensor has been calibrated in production for data into TEMPSENSOR_CAL1_ADDR (tolerance: +-5 DegC) (unit: DegC). */
335
#define TEMPSENSOR_CAL2_TEMP               (( int32_t)  110)                        /* Internal temperature sensor, temperature at which temperature sensor has been calibrated in production for data into TEMPSENSOR_CAL2_ADDR (tolerance: +-5 DegC) (unit: DegC). */
336
#define TEMPSENSOR_CAL_VREFANALOG          ( 3000U)                                 /* Analog voltage reference (Vref+) voltage with which temperature sensor has been calibrated in production (+-10 mV) (unit: mV). */
337
 
338
 
339
/**
340
  * @}
341
  */
342
 
343
 
344
/* Private macros ------------------------------------------------------------*/
345
/** @defgroup ADC_LL_Private_Macros ADC Private Macros
346
  * @{
347
  */
348
 
349
/**
350
  * @brief  Driver macro reserved for internal use: isolate bits with the
351
  *         selected mask and shift them to the register LSB
352
  *         (shift mask on register position bit 0).
353
  * @param  __BITS__ Bits in register 32 bits
354
  * @param  __MASK__ Mask in register 32 bits
355
  * @retval Bits in register 32 bits
356
  */
357
#define __ADC_MASK_SHIFT(__BITS__, __MASK__)                                   \
358
  (((__BITS__) & (__MASK__)) >> POSITION_VAL((__MASK__)))
359
 
360
/**
361
  * @brief  Driver macro reserved for internal use: set a pointer to
362
  *         a register from a register basis from which an offset
363
  *         is applied.
364
  * @param  __REG__ Register basis from which the offset is applied.
365
  * @param  __REG_OFFFSET__ Offset to be applied (unit: number of registers).
366
  * @retval Pointer to register address
367
  */
368
#define __ADC_PTR_REG_OFFSET(__REG__, __REG_OFFFSET__)                         \
369
 ((uint32_t *)((uint32_t) ((uint32_t)(&(__REG__)) + ((__REG_OFFFSET__) << 2U))))
370
 
371
/**
372
  * @}
373
  */
374
 
375
 
376
/* Exported types ------------------------------------------------------------*/
377
#if defined(USE_FULL_LL_DRIVER)
378
/** @defgroup ADC_LL_ES_INIT ADC Exported Init structure
379
  * @{
380
  */
381
 
382
/**
383
  * @brief  Structure definition of some features of ADC common parameters
384
  *         and multimode
385
  *         (all ADC instances belonging to the same ADC common instance).
386
  * @note   The setting of these parameters by function @ref LL_ADC_CommonInit()
387
  *         is conditioned to ADC instances state (all ADC instances
388
  *         sharing the same ADC common instance):
389
  *         All ADC instances sharing the same ADC common instance must be
390
  *         disabled.
391
  */
392
typedef struct
393
{
394
  uint32_t CommonClock;                 /*!< Set parameter common to several ADC: Clock source and prescaler.
395
                                             This parameter can be a value of @ref ADC_LL_EC_COMMON_CLOCK_SOURCE
396
                                             @note On this STM32 serie, HSI RC oscillator is the only clock source for ADC.
397
                                                   Therefore, HSI RC oscillator must be preliminarily enabled at RCC top level.
398
                                             @note On this STM32 serie, some clock ratio constraints between ADC clock and APB clock
399
                                                   must be respected:
400
                                                    - In all cases: if APB clock frequency is too low compared ADC clock frequency, a delay between conversions must be inserted.
401
                                                    - If ADC group injected is used: ADC clock frequency should be lower than APB clock frequency /4 for resolution 12 or 10 bits, APB clock frequency /3 for resolution 8 bits, APB clock frequency /2 for resolution 6 bits.
402
                                                   Refer to reference manual.
403
 
404
                                             This feature can be modified afterwards using unitary function @ref LL_ADC_SetCommonClock(). */
405
 
406
} LL_ADC_CommonInitTypeDef;
407
 
408
/**
409
  * @brief  Structure definition of some features of ADC instance.
410
  * @note   These parameters have an impact on ADC scope: ADC instance.
411
  *         Affects both group regular and group injected (availability
412
  *         of ADC group injected depends on STM32 families).
413
  *         Refer to corresponding unitary functions into
414
  *         @ref ADC_LL_EF_Configuration_ADC_Instance .
415
  * @note   The setting of these parameters by function @ref LL_ADC_Init()
416
  *         is conditioned to ADC state:
417
  *         ADC instance must be disabled.
418
  *         This condition is applied to all ADC features, for efficiency
419
  *         and compatibility over all STM32 families. However, the different
420
  *         features can be set under different ADC state conditions
421
  *         (setting possible with ADC enabled without conversion on going,
422
  *         ADC enabled with conversion on going, ...)
423
  *         Each feature can be updated afterwards with a unitary function
424
  *         and potentially with ADC in a different state than disabled,
425
  *         refer to description of each function for setting
426
  *         conditioned to ADC state.
427
  */
428
typedef struct
429
{
430
  uint32_t Resolution;                  /*!< Set ADC resolution.
431
                                             This parameter can be a value of @ref ADC_LL_EC_RESOLUTION
432
 
433
                                             This feature can be modified afterwards using unitary function @ref LL_ADC_SetResolution(). */
434
 
435
  uint32_t DataAlignment;               /*!< Set ADC conversion data alignment.
436
                                             This parameter can be a value of @ref ADC_LL_EC_DATA_ALIGN
437
 
438
                                             This feature can be modified afterwards using unitary function @ref LL_ADC_SetDataAlignment(). */
439
 
440
  uint32_t LowPowerMode;                /*!< Set ADC low power mode.
441
                                             This parameter can be a concatenation of a value of @ref ADC_LL_EC_LP_MODE_AUTOWAIT and a value of @ref ADC_LL_EC_LP_MODE_AUTOPOWEROFF
442
 
443
                                             This feature can be modified afterwards using unitary function @ref LL_ADC_SetLowPowerModeAutoWait() and @ref LL_ADC_SetLowPowerModeAutoPowerOff(). */
444
 
445
  uint32_t SequencersScanMode;          /*!< Set ADC scan selection.
446
                                             This parameter can be a value of @ref ADC_LL_EC_SCAN_SELECTION
447
 
448
                                             This feature can be modified afterwards using unitary function @ref LL_ADC_SetSequencersScanMode(). */
449
 
450
} LL_ADC_InitTypeDef;
451
 
452
/**
453
  * @brief  Structure definition of some features of ADC group regular.
454
  * @note   These parameters have an impact on ADC scope: ADC group regular.
455
  *         Refer to corresponding unitary functions into
456
  *         @ref ADC_LL_EF_Configuration_ADC_Group_Regular
457
  *         (functions with prefix "REG").
458
  * @note   The setting of these parameters by function @ref LL_ADC_REG_Init()
459
  *         is conditioned to ADC state:
460
  *         ADC instance must be disabled.
461
  *         This condition is applied to all ADC features, for efficiency
462
  *         and compatibility over all STM32 families. However, the different
463
  *         features can be set under different ADC state conditions
464
  *         (setting possible with ADC enabled without conversion on going,
465
  *         ADC enabled with conversion on going, ...)
466
  *         Each feature can be updated afterwards with a unitary function
467
  *         and potentially with ADC in a different state than disabled,
468
  *         refer to description of each function for setting
469
  *         conditioned to ADC state.
470
  */
471
typedef struct
472
{
473
  uint32_t TriggerSource;               /*!< Set ADC group regular conversion trigger source: internal (SW start) or from external IP (timer event, external interrupt line).
474
                                             This parameter can be a value of @ref ADC_LL_EC_REG_TRIGGER_SOURCE
475
                                             @note On this STM32 serie, setting of external trigger edge is performed
476
                                                   using function @ref LL_ADC_REG_StartConversionExtTrig().
477
 
478
                                             This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetTriggerSource(). */
479
 
480
  uint32_t SequencerLength;             /*!< Set ADC group regular sequencer length.
481
                                             This parameter can be a value of @ref ADC_LL_EC_REG_SEQ_SCAN_LENGTH
482
                                             @note This parameter is discarded if scan mode is disabled (refer to parameter 'ADC_SequencersScanMode').
483
 
484
                                             This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetSequencerLength(). */
485
 
486
  uint32_t SequencerDiscont;            /*!< Set ADC group regular sequencer discontinuous mode: sequence subdivided and scan conversions interrupted every selected number of ranks.
487
                                             This parameter can be a value of @ref ADC_LL_EC_REG_SEQ_DISCONT_MODE
488
                                             @note This parameter has an effect only if group regular sequencer is enabled
489
                                                   (scan length of 2 ranks or more).
490
 
491
                                             This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetSequencerDiscont(). */
492
 
493
  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).
494
                                             This parameter can be a value of @ref ADC_LL_EC_REG_CONTINUOUS_MODE
495
                                             Note: It is not possible to enable both ADC group regular continuous mode and discontinuous mode.
496
 
497
                                             This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetContinuousMode(). */
498
 
499
  uint32_t DMATransfer;                 /*!< Set ADC group regular conversion data transfer: no transfer or transfer by DMA, and DMA requests mode.
500
                                             This parameter can be a value of @ref ADC_LL_EC_REG_DMA_TRANSFER
501
 
502
                                             This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetDMATransfer(). */
503
 
504
} LL_ADC_REG_InitTypeDef;
505
 
506
/**
507
  * @brief  Structure definition of some features of ADC group injected.
508
  * @note   These parameters have an impact on ADC scope: ADC group injected.
509
  *         Refer to corresponding unitary functions into
510
  *         @ref ADC_LL_EF_Configuration_ADC_Group_Regular
511
  *         (functions with prefix "INJ").
512
  * @note   The setting of these parameters by function @ref LL_ADC_INJ_Init()
513
  *         is conditioned to ADC state:
514
  *         ADC instance must be disabled.
515
  *         This condition is applied to all ADC features, for efficiency
516
  *         and compatibility over all STM32 families. However, the different
517
  *         features can be set under different ADC state conditions
518
  *         (setting possible with ADC enabled without conversion on going,
519
  *         ADC enabled with conversion on going, ...)
520
  *         Each feature can be updated afterwards with a unitary function
521
  *         and potentially with ADC in a different state than disabled,
522
  *         refer to description of each function for setting
523
  *         conditioned to ADC state.
524
  */
525
typedef struct
526
{
527
  uint32_t TriggerSource;               /*!< Set ADC group injected conversion trigger source: internal (SW start) or from external IP (timer event, external interrupt line).
528
                                             This parameter can be a value of @ref ADC_LL_EC_INJ_TRIGGER_SOURCE
529
                                             @note On this STM32 serie, setting of external trigger edge is performed
530
                                                   using function @ref LL_ADC_INJ_StartConversionExtTrig().
531
 
532
                                             This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetTriggerSource(). */
533
 
534
  uint32_t SequencerLength;             /*!< Set ADC group injected sequencer length.
535
                                             This parameter can be a value of @ref ADC_LL_EC_INJ_SEQ_SCAN_LENGTH
536
                                             @note This parameter is discarded if scan mode is disabled (refer to parameter 'ADC_SequencersScanMode').
537
 
538
                                             This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetSequencerLength(). */
539
 
540
  uint32_t SequencerDiscont;            /*!< Set ADC group injected sequencer discontinuous mode: sequence subdivided and scan conversions interrupted every selected number of ranks.
541
                                             This parameter can be a value of @ref ADC_LL_EC_INJ_SEQ_DISCONT_MODE
542
                                             @note This parameter has an effect only if group injected sequencer is enabled
543
                                                   (scan length of 2 ranks or more).
544
 
545
                                             This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetSequencerDiscont(). */
546
 
547
  uint32_t TrigAuto;                    /*!< Set ADC group injected conversion trigger: independent or from ADC group regular.
548
                                             This parameter can be a value of @ref ADC_LL_EC_INJ_TRIG_AUTO
549
                                             Note: This parameter must be set to set to independent trigger if injected trigger source is set to an external trigger.
550
 
551
                                             This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetTrigAuto(). */
552
 
553
} LL_ADC_INJ_InitTypeDef;
554
 
555
/**
556
  * @}
557
  */
558
#endif /* USE_FULL_LL_DRIVER */
559
 
560
/* Exported constants --------------------------------------------------------*/
561
/** @defgroup ADC_LL_Exported_Constants ADC Exported Constants
562
  * @{
563
  */
564
 
565
/** @defgroup ADC_LL_EC_FLAG ADC flags
566
  * @brief    Flags defines which can be used with LL_ADC_ReadReg function
567
  * @{
568
  */
569
#define LL_ADC_FLAG_ADRDY                  ADC_SR_ADONS       /*!< ADC flag ADC instance ready */
570
#define LL_ADC_FLAG_STRT                   ADC_SR_STRT        /*!< ADC flag ADC group regular conversion start */
571
#define LL_ADC_FLAG_EOCS                   ADC_SR_EOC         /*!< ADC flag ADC group regular end of unitary conversion or sequence conversions (to configure flag of end of conversion, use function @ref LL_ADC_REG_SetFlagEndOfConversion() ) */
572
#define LL_ADC_FLAG_OVR                    ADC_SR_OVR         /*!< ADC flag ADC group regular overrun */
573
#define LL_ADC_FLAG_JSTRT                  ADC_SR_JSTRT       /*!< ADC flag ADC group injected conversion start */
574
#define LL_ADC_FLAG_JEOS                   ADC_SR_JEOC        /*!< ADC flag ADC group injected end of sequence conversions (Note: on this STM32 serie, there is no flag ADC group injected end of unitary conversion. Flag noted as "JEOC" is corresponding to flag "JEOS" in other STM32 families) */
575
#define LL_ADC_FLAG_AWD1                   ADC_SR_AWD         /*!< ADC flag ADC analog watchdog 1 */
576
/**
577
  * @}
578
  */
579
 
580
/** @defgroup ADC_LL_EC_IT ADC interruptions for configuration (interruption enable or disable)
581
  * @brief    IT defines which can be used with LL_ADC_ReadReg and  LL_ADC_WriteReg functions
582
  * @{
583
  */
584
#define LL_ADC_IT_EOCS                     ADC_CR1_EOCIE      /*!< ADC interruption ADC group regular end of unitary conversion or sequence conversions (to configure flag of end of conversion, use function @ref LL_ADC_REG_SetFlagEndOfConversion() ) */
585
#define LL_ADC_IT_OVR                      ADC_CR1_OVRIE      /*!< ADC interruption ADC group regular overrun */
586
#define LL_ADC_IT_JEOS                     ADC_CR1_JEOCIE     /*!< ADC interruption ADC group injected end of sequence conversions (Note: on this STM32 serie, there is no flag ADC group injected end of unitary conversion. Flag noted as "JEOC" is corresponding to flag "JEOS" in other STM32 families) */
587
#define LL_ADC_IT_AWD1                     ADC_CR1_AWDIE      /*!< ADC interruption ADC analog watchdog 1 */
588
/**
589
  * @}
590
  */
591
 
592
/** @defgroup ADC_LL_EC_REGISTERS  ADC registers compliant with specific purpose
593
  * @{
594
  */
595
/* List of ADC registers intended to be used (most commonly) with             */
596
/* DMA transfer.                                                              */
597
/* Refer to function @ref LL_ADC_DMA_GetRegAddr().                            */
598
#define LL_ADC_DMA_REG_REGULAR_DATA          0x00000000U   /* 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() */
599
/**
600
  * @}
601
  */
602
 
603
/** @defgroup ADC_LL_EC_COMMON_CLOCK_SOURCE  ADC common - Clock source
604
  * @{
605
  */
606
#define LL_ADC_CLOCK_ASYNC_DIV1            0x00000000U                                           /*!< ADC asynchronous clock without prescaler */
607
#define LL_ADC_CLOCK_ASYNC_DIV2            (ADC_CCR_ADCPRE_0)                                    /*!< ADC asynchronous clock with prescaler division by 2   */
608
#define LL_ADC_CLOCK_ASYNC_DIV4            (ADC_CCR_ADCPRE_1)                                    /*!< ADC asynchronous clock with prescaler division by 4   */
609
/**
610
  * @}
611
  */
612
 
613
/** @defgroup ADC_LL_EC_COMMON_PATH_INTERNAL  ADC common - Measurement path to internal channels
614
  * @{
615
  */
616
/* Note: Other measurement paths to internal channels may be available        */
617
/*       (connections to other peripherals).                                  */
618
/*       If they are not listed below, they do not require any specific       */
619
/*       path enable. In this case, Access to measurement path is done        */
620
/*       only by selecting the corresponding ADC internal channel.            */
621
#define LL_ADC_PATH_INTERNAL_NONE          0x00000000U            /*!< ADC measurement pathes all disabled */
622
#define LL_ADC_PATH_INTERNAL_VREFINT       (ADC_CCR_TSVREFE)      /*!< ADC measurement path to internal channel VrefInt */
623
#define LL_ADC_PATH_INTERNAL_TEMPSENSOR    (ADC_CCR_TSVREFE)      /*!< ADC measurement path to internal channel temperature sensor */
624
/**
625
  * @}
626
  */
627
 
628
/** @defgroup ADC_LL_EC_RESOLUTION  ADC instance - Resolution
629
  * @{
630
  */
631
#define LL_ADC_RESOLUTION_12B              0x00000000U                         /*!< ADC resolution 12 bits */
632
#define LL_ADC_RESOLUTION_10B              (                ADC_CR1_RES_0)     /*!< ADC resolution 10 bits */
633
#define LL_ADC_RESOLUTION_8B               (ADC_CR1_RES_1                )     /*!< ADC resolution  8 bits */
634
#define LL_ADC_RESOLUTION_6B               (ADC_CR1_RES_1 | ADC_CR1_RES_0)     /*!< ADC resolution  6 bits */
635
/**
636
  * @}
637
  */
638
 
639
/** @defgroup ADC_LL_EC_DATA_ALIGN  ADC instance - Data alignment
640
  * @{
641
  */
642
#define LL_ADC_DATA_ALIGN_RIGHT            0x00000000U            /*!< ADC conversion data alignment: right aligned (alignment on data register LSB bit 0)*/
643
#define LL_ADC_DATA_ALIGN_LEFT             (ADC_CR2_ALIGN)        /*!< ADC conversion data alignment: left aligned (aligment on data register MSB bit 15)*/
644
/**
645
  * @}
646
  */
647
 
648
/** @defgroup ADC_LL_EC_LP_MODE_AUTOWAIT  ADC instance - Low power mode auto wait (auto delay)
649
  * @{
650
  */
651
#define LL_ADC_LP_AUTOWAIT_NONE               0x00000000U                                        /*!< ADC low power mode auto wait not activated */
652
#define LL_ADC_LP_AUTOWAIT                    (                                  ADC_CR2_DELS_0) /*!< ADC low power mode auto wait: 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_SetLowPowerModeAutoWait(). */
653
#define LL_ADC_LP_AUTOWAIT_7_APBCLOCKCYCLES   (                 ADC_CR2_DELS_1                 ) /*!< ADC low power mode auto wait: Insert a delay between ADC conversions: 7 APB clock cycles */
654
#define LL_ADC_LP_AUTOWAIT_15_APBCLOCKCYCLES  (                 ADC_CR2_DELS_1 | ADC_CR2_DELS_0) /*!< ADC low power mode auto wait: Insert a delay between ADC conversions: 15 APB clock cycles */
655
#define LL_ADC_LP_AUTOWAIT_31_APBCLOCKCYCLES  (ADC_CR2_DELS_2                                  ) /*!< ADC low power mode auto wait: Insert a delay between ADC conversions: 31 APB clock cycles */
656
#define LL_ADC_LP_AUTOWAIT_63_APBCLOCKCYCLES  (ADC_CR2_DELS_2                  | ADC_CR2_DELS_0) /*!< ADC low power mode auto wait: Insert a delay between ADC conversions: 63 APB clock cycles */
657
#define LL_ADC_LP_AUTOWAIT_127_APBCLOCKCYCLES (ADC_CR2_DELS_2 | ADC_CR2_DELS_1                 ) /*!< ADC low power mode auto wait: Insert a delay between ADC conversions: 127 APB clock cycles */
658
#define LL_ADC_LP_AUTOWAIT_255_APBCLOCKCYCLES (ADC_CR2_DELS_2 | ADC_CR2_DELS_1 | ADC_CR2_DELS_0) /*!< ADC low power mode auto wait: Insert a delay between ADC conversions: 255 APB clock cycles */
659
/**
660
  * @}
661
  */
662
 
663
/** @defgroup ADC_LL_EC_LP_MODE_AUTOPOWEROFF  ADC instance - Low power mode auto power-off
664
  * @{
665
  */
666
#define LL_ADC_LP_AUTOPOWEROFF_NONE                 0x00000000U                                  /*!< ADC low power mode auto power-off not activated */
667
#define LL_ADC_LP_AUTOPOWEROFF_IDLE_PHASE           (ADC_CR1_PDI)                                /*!< ADC low power mode auto power-off: ADC power off when ADC is not converting (idle phase) */
668
#define LL_ADC_LP_AUTOPOWEROFF_AUTOWAIT_PHASE       (ADC_CR1_PDD)                                /*!< ADC low power mode auto power-off: ADC power off when a delay is inserted between conversions (refer to function @ref LL_ADC_SetLowPowerModeAutoWait() ) */
669
#define LL_ADC_LP_AUTOPOWEROFF_IDLE_AUTOWAIT_PHASES (ADC_CR1_PDI | ADC_CR1_PDD)                  /*!< ADC low power mode auto power-off: ADC power off when ADC is not converting (idle phase) and when a delay is inserted between conversions (refer to function @ref LL_ADC_SetLowPowerModeAutoWait() ) */
670
/**
671
  * @}
672
  */
673
 
674
/** @defgroup ADC_LL_EC_SCAN_SELECTION ADC instance - Scan selection
675
  * @{
676
  */
677
#define LL_ADC_SEQ_SCAN_DISABLE            0x00000000U    /*!< ADC conversion is performed in unitary conversion mode (one channel converted, that defined in rank 1). Configuration of both groups regular and injected sequencers (sequence length, ...) is discarded: equivalent to length of 1 rank.*/
678
#define LL_ADC_SEQ_SCAN_ENABLE             (ADC_CR1_SCAN) /*!< ADC conversions are performed in sequence conversions mode, according to configuration of both groups regular and injected sequencers (sequence length, ...). */
679
/**
680
  * @}
681
  */
682
 
683
#if defined(ADC_CR2_CFG)
684
/** @defgroup ADC_LL_EC_CHANNELS_BANK ADC instance - Channels bank
685
  * @{
686
  */
687
#define LL_ADC_CHANNELS_BANK_A             0x00000000U   /*!< ADC channels bank A */
688
#define LL_ADC_CHANNELS_BANK_B             (ADC_CR2_CFG) /*!< ADC channels bank B, available in devices categories 3, 4, 5. */
689
/**
690
  * @}
691
  */
692
#endif
693
 
694
/** @defgroup ADC_LL_EC_GROUPS  ADC instance - Groups
695
  * @{
696
  */
697
#define LL_ADC_GROUP_REGULAR               0x00000001U   /*!< ADC group regular (available on all STM32 devices) */
698
#define LL_ADC_GROUP_INJECTED              0x00000002U   /*!< ADC group injected (not available on all STM32 devices)*/
699
#define LL_ADC_GROUP_REGULAR_INJECTED      0x00000003U   /*!< ADC both groups regular and injected */
700
/**
701
  * @}
702
  */
703
 
704
/** @defgroup ADC_LL_EC_CHANNEL  ADC instance - Channel number
705
  * @{
706
  */
707
#define LL_ADC_CHANNEL_0                   (ADC_CHANNEL_0_NUMBER  | ADC_CHANNEL_0_SMP)  /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN0 . Channel different in bank A and bank B. */
708
#define LL_ADC_CHANNEL_1                   (ADC_CHANNEL_1_NUMBER  | ADC_CHANNEL_1_SMP)  /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN1 . Channel different in bank A and bank B. */
709
#define LL_ADC_CHANNEL_2                   (ADC_CHANNEL_2_NUMBER  | ADC_CHANNEL_2_SMP)  /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN2 . Channel different in bank A and bank B. */
710
#define LL_ADC_CHANNEL_3                   (ADC_CHANNEL_3_NUMBER  | ADC_CHANNEL_3_SMP)  /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN3 . Channel different in bank A and bank B. */
711
#define LL_ADC_CHANNEL_4                   (ADC_CHANNEL_4_NUMBER  | ADC_CHANNEL_4_SMP)  /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN4 . Direct (fast) channel. */
712
#define LL_ADC_CHANNEL_5                   (ADC_CHANNEL_5_NUMBER  | ADC_CHANNEL_5_SMP)  /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN5 . Direct (fast) channel. */
713
#define LL_ADC_CHANNEL_6                   (ADC_CHANNEL_6_NUMBER  | ADC_CHANNEL_6_SMP)  /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN6 . Channel different in bank A and bank B. */
714
#define LL_ADC_CHANNEL_7                   (ADC_CHANNEL_7_NUMBER  | ADC_CHANNEL_7_SMP)  /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN7 . Channel different in bank A and bank B. */
715
#define LL_ADC_CHANNEL_8                   (ADC_CHANNEL_8_NUMBER  | ADC_CHANNEL_8_SMP)  /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN8 . Channel different in bank A and bank B. */
716
#define LL_ADC_CHANNEL_9                   (ADC_CHANNEL_9_NUMBER  | ADC_CHANNEL_9_SMP)  /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN9 . Channel different in bank A and bank B. */
717
#define LL_ADC_CHANNEL_10                  (ADC_CHANNEL_10_NUMBER | ADC_CHANNEL_10_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN10. Channel different in bank A and bank B. */
718
#define LL_ADC_CHANNEL_11                  (ADC_CHANNEL_11_NUMBER | ADC_CHANNEL_11_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN11. Channel different in bank A and bank B. */
719
#define LL_ADC_CHANNEL_12                  (ADC_CHANNEL_12_NUMBER | ADC_CHANNEL_12_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN12. Channel different in bank A and bank B. */
720
#define LL_ADC_CHANNEL_13                  (ADC_CHANNEL_13_NUMBER | ADC_CHANNEL_13_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN13. Channel common to both bank A and bank B. */
721
#define LL_ADC_CHANNEL_14                  (ADC_CHANNEL_14_NUMBER | ADC_CHANNEL_14_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN14. Channel common to both bank A and bank B. */
722
#define LL_ADC_CHANNEL_15                  (ADC_CHANNEL_15_NUMBER | ADC_CHANNEL_15_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN15. Channel common to both bank A and bank B. */
723
#define LL_ADC_CHANNEL_16                  (ADC_CHANNEL_16_NUMBER | ADC_CHANNEL_16_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN16. Channel common to both bank A and bank B. */
724
#define LL_ADC_CHANNEL_17                  (ADC_CHANNEL_17_NUMBER | ADC_CHANNEL_17_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN17. Channel common to both bank A and bank B. */
725
#define LL_ADC_CHANNEL_18                  (ADC_CHANNEL_18_NUMBER | ADC_CHANNEL_18_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN18. Channel common to both bank A and bank B. */
726
#define LL_ADC_CHANNEL_19                  (ADC_CHANNEL_19_NUMBER | ADC_CHANNEL_19_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN19. Channel common to both bank A and bank B. */
727
#define LL_ADC_CHANNEL_20                  (ADC_CHANNEL_20_NUMBER | ADC_CHANNEL_20_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN20. Channel common to both bank A and bank B. */
728
#define LL_ADC_CHANNEL_21                  (ADC_CHANNEL_21_NUMBER | ADC_CHANNEL_21_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN21. Channel common to both bank A and bank B. */
729
#define LL_ADC_CHANNEL_22                  (ADC_CHANNEL_22_NUMBER | ADC_CHANNEL_22_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN22. Direct (fast) channel. */
730
#define LL_ADC_CHANNEL_23                  (ADC_CHANNEL_23_NUMBER | ADC_CHANNEL_23_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN23. Direct (fast) channel. */
731
#define LL_ADC_CHANNEL_24                  (ADC_CHANNEL_24_NUMBER | ADC_CHANNEL_24_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN24. Direct (fast) channel. */
732
#define LL_ADC_CHANNEL_25                  (ADC_CHANNEL_25_NUMBER | ADC_CHANNEL_25_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN25. Direct (fast) channel. */
733
#define LL_ADC_CHANNEL_26                  (ADC_CHANNEL_26_NUMBER | ADC_CHANNEL_26_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN26. Direct (fast) channel. */
734
#if defined(ADC_SMPR0_SMP31)
735
#define LL_ADC_CHANNEL_27                  (ADC_CHANNEL_27_NUMBER | ADC_CHANNEL_27_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN27. Channel common to both bank A and bank B. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
736
#define LL_ADC_CHANNEL_28                  (ADC_CHANNEL_28_NUMBER | ADC_CHANNEL_28_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN28. Channel common to both bank A and bank B. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
737
#define LL_ADC_CHANNEL_29                  (ADC_CHANNEL_29_NUMBER | ADC_CHANNEL_29_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN29. Channel common to both bank A and bank B. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
738
#define LL_ADC_CHANNEL_30                  (ADC_CHANNEL_30_NUMBER | ADC_CHANNEL_30_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN30. Channel common to both bank A and bank B. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
739
#define LL_ADC_CHANNEL_31                  (ADC_CHANNEL_31_NUMBER | ADC_CHANNEL_31_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN31. Channel common to both bank A and bank B. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
740
#endif /* ADC_SMPR0_SMP31 */
741
#define LL_ADC_CHANNEL_VREFINT             (LL_ADC_CHANNEL_17 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to VrefInt: Internal voltage reference. Channel common to both bank A and bank B. */
742
#define LL_ADC_CHANNEL_TEMPSENSOR          (LL_ADC_CHANNEL_16 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to Temperature sensor. Channel common to both bank A and bank B. */
743
#define LL_ADC_CHANNEL_VCOMP               (LL_ADC_CHANNEL_26 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to comparator COMP1 positive input via ADC switch matrix. Channel common to both bank A and bank B. */
744
#if defined(OPAMP_CSR_OPA1PD) || defined (OPAMP_CSR_OPA2PD) || defined (OPAMP_CSR_OPA3PD)
745
#define LL_ADC_CHANNEL_VOPAMP1             (LL_ADC_CHANNEL_3 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to OPAMP1 output via ADC switch matrix. Channel common to both bank A and bank B. */
746
#define LL_ADC_CHANNEL_VOPAMP2             (LL_ADC_CHANNEL_8 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to OPAMP2 output via ADC switch matrix. Channel common to both bank A and bank B. */
747
#if defined(OPAMP_CSR_OPA3PD)
748
#define LL_ADC_CHANNEL_VOPAMP3             (LL_ADC_CHANNEL_13 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to OPAMP3 output via ADC switch matrix. Channel common to both bank A and bank B. */
749
#endif /* OPAMP_CSR_OPA3PD */
750
#endif /* OPAMP_CSR_OPA1PD || OPAMP_CSR_OPA2PD || OPAMP_CSR_OPA3PD */
751
/**
752
  * @}
753
  */
754
 
755
/** @defgroup ADC_LL_EC_REG_TRIGGER_SOURCE  ADC group regular - Trigger source
756
  * @{
757
  */
758
#define LL_ADC_REG_TRIG_SOFTWARE           0x00000000U                                                                                                 /*!< ADC group regular conversion trigger internal: SW start. */
759
#define LL_ADC_REG_TRIG_EXT_TIM2_TRGO      (ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT)                                       /*!< ADC group regular conversion trigger from external IP: TIM2 TRGO. Trigger edge set to rising edge (default setting). */
760
#define LL_ADC_REG_TRIG_EXT_TIM2_CH3       (ADC_CR2_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT)                                                          /*!< ADC group regular conversion trigger from external IP: TIM2 channel 3 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
761
#define LL_ADC_REG_TRIG_EXT_TIM3_TRGO      (ADC_CR2_EXTSEL_2 | ADC_REG_TRIG_EXT_EDGE_DEFAULT)                                                          /*!< ADC group regular conversion trigger from external IP: TIM3 TRGO. Trigger edge set to rising edge (default setting). */
762
#define LL_ADC_REG_TRIG_EXT_TIM2_CH2       (ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT)                                       /*!< ADC group regular conversion trigger from external IP: TIM2 channel 2 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
763
#define LL_ADC_REG_TRIG_EXT_TIM3_CH1       (ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT)                    /*!< ADC group regular conversion trigger from external IP: TIM3 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
764
#define LL_ADC_REG_TRIG_EXT_TIM3_CH3       (ADC_CR2_EXTSEL_3 | ADC_REG_TRIG_EXT_EDGE_DEFAULT)                                                          /*!< ADC group regular conversion trigger from external IP: TIM3 channel 3 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
765
#define LL_ADC_REG_TRIG_EXT_TIM4_TRGO      (ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT)                                       /*!< ADC group regular conversion trigger from external IP: TIM4 TRGO. Trigger edge set to rising edge (default setting). */
766
#define LL_ADC_REG_TRIG_EXT_TIM4_CH4       (ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT)                                       /*!< ADC group regular conversion trigger from external IP: TIM4 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
767
#define LL_ADC_REG_TRIG_EXT_TIM6_TRGO      (ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT)                                       /*!< ADC group regular conversion trigger from external IP: TIM6 TRGO. Trigger edge set to rising edge (default setting). */
768
#define LL_ADC_REG_TRIG_EXT_TIM9_CH2       (ADC_REG_TRIG_EXT_EDGE_DEFAULT)                                                                             /*!< ADC group regular conversion trigger from external IP: TIM9 channel 2 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
769
#define LL_ADC_REG_TRIG_EXT_TIM9_TRGO      (ADC_CR2_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT)                                                          /*!< ADC group regular conversion trigger from external IP: TIM9 TRGO. Trigger edge set to rising edge (default setting). */
770
#define LL_ADC_REG_TRIG_EXT_EXTI_LINE11    (ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: external interrupt line 11. Trigger edge set to rising edge (default setting). */
771
/**
772
  * @}
773
  */
774
 
775
/** @defgroup ADC_LL_EC_REG_TRIGGER_EDGE  ADC group regular - Trigger edge
776
  * @{
777
  */
778
#define LL_ADC_REG_TRIG_EXT_RISING         (                  ADC_CR2_EXTEN_0)     /*!< ADC group regular conversion trigger polarity set to rising edge */
779
#define LL_ADC_REG_TRIG_EXT_FALLING        (ADC_CR2_EXTEN_1                  )     /*!< ADC group regular conversion trigger polarity set to falling edge */
780
#define LL_ADC_REG_TRIG_EXT_RISINGFALLING  (ADC_CR2_EXTEN_1 | ADC_CR2_EXTEN_0)     /*!< ADC group regular conversion trigger polarity set to both rising and falling edges */
781
/**
782
  * @}
783
  */
784
 
785
/** @defgroup ADC_LL_EC_REG_CONTINUOUS_MODE  ADC group regular - Continuous mode
786
* @{
787
*/
788
#define LL_ADC_REG_CONV_SINGLE             0x00000000U             /*!< ADC conversions are performed in single mode: one conversion per trigger */
789
#define LL_ADC_REG_CONV_CONTINUOUS         (ADC_CR2_CONT)          /*!< ADC conversions are performed in continuous mode: after the first trigger, following conversions launched successively automatically */
790
/**
791
  * @}
792
  */
793
 
794
/** @defgroup ADC_LL_EC_REG_DMA_TRANSFER  ADC group regular - DMA transfer of ADC conversion data
795
  * @{
796
  */
797
#define LL_ADC_REG_DMA_TRANSFER_NONE       0x00000000U              /*!< ADC conversions are not transferred by DMA */
798
#define LL_ADC_REG_DMA_TRANSFER_LIMITED    (              ADC_CR2_DMA)          /*!< 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. */
799
#define LL_ADC_REG_DMA_TRANSFER_UNLIMITED  (ADC_CR2_DDS | ADC_CR2_DMA)          /*!< 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. */
800
/**
801
  * @}
802
  */
803
 
804
/** @defgroup ADC_LL_EC_REG_FLAG_EOC_SELECTION ADC group regular - Flag EOC selection (unitary or sequence conversions)
805
  * @{
806
  */
807
#define LL_ADC_REG_FLAG_EOC_SEQUENCE_CONV       0x00000000U    /*!< ADC flag EOC (end of unitary conversion) selected */
808
#define LL_ADC_REG_FLAG_EOC_UNITARY_CONV        (ADC_CR2_EOCS) /*!< ADC flag EOS (end of sequence conversions) selected */
809
/**
810
  * @}
811
  */
812
 
813
/** @defgroup ADC_LL_EC_REG_SEQ_SCAN_LENGTH  ADC group regular - Sequencer scan length
814
  * @{
815
  */
816
#define LL_ADC_REG_SEQ_SCAN_DISABLE        0x00000000U                                                 /*!< ADC group regular sequencer disable (equivalent to sequencer of 1 rank: ADC conversion on only 1 channel) */
817
#define LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS  (                                             ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 2 ranks in the sequence */
818
#define LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS  (                              ADC_SQR1_L_1               ) /*!< ADC group regular sequencer enable with 3 ranks in the sequence */
819
#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 */
820
#define LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS  (               ADC_SQR1_L_2                              ) /*!< ADC group regular sequencer enable with 5 ranks in the sequence */
821
#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 */
822
#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 */
823
#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 */
824
#define LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS  (ADC_SQR1_L_3                                             ) /*!< ADC group regular sequencer enable with 9 ranks in the sequence */
825
#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 */
826
#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 */
827
#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 */
828
#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 */
829
#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 */
830
#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 */
831
#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 */
832
/**
833
  * @}
834
  */
835
 
836
/** @defgroup ADC_LL_EC_REG_SEQ_DISCONT_MODE  ADC group regular - Sequencer discontinuous mode
837
  * @{
838
  */
839
#define LL_ADC_REG_SEQ_DISCONT_DISABLE     0x00000000U                                                                  /*!< ADC group regular sequencer discontinuous mode disable */
840
#define LL_ADC_REG_SEQ_DISCONT_1RANK       (                                                            ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every rank */
841
#define LL_ADC_REG_SEQ_DISCONT_2RANKS      (                                        ADC_CR1_DISCNUM_0 | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enabled with sequence interruption every 2 ranks */
842
#define LL_ADC_REG_SEQ_DISCONT_3RANKS      (                    ADC_CR1_DISCNUM_1                     | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 3 ranks */
843
#define LL_ADC_REG_SEQ_DISCONT_4RANKS      (                    ADC_CR1_DISCNUM_1 | ADC_CR1_DISCNUM_0 | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 4 ranks */
844
#define LL_ADC_REG_SEQ_DISCONT_5RANKS      (ADC_CR1_DISCNUM_2                                         | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 5 ranks */
845
#define LL_ADC_REG_SEQ_DISCONT_6RANKS      (ADC_CR1_DISCNUM_2                     | ADC_CR1_DISCNUM_0 | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 6 ranks */
846
#define LL_ADC_REG_SEQ_DISCONT_7RANKS      (ADC_CR1_DISCNUM_2 | ADC_CR1_DISCNUM_1                     | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 7 ranks */
847
#define LL_ADC_REG_SEQ_DISCONT_8RANKS      (ADC_CR1_DISCNUM_2 | ADC_CR1_DISCNUM_1 | ADC_CR1_DISCNUM_0 | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 8 ranks */
848
/**
849
  * @}
850
  */
851
 
852
/** @defgroup ADC_LL_EC_REG_SEQ_RANKS  ADC group regular - Sequencer ranks
853
  * @{
854
  */
855
#define LL_ADC_REG_RANK_1                  (ADC_SQR5_REGOFFSET | ADC_REG_RANK_1_SQRX_BITOFFSET_POS)  /*!< ADC group regular sequencer rank 1 */
856
#define LL_ADC_REG_RANK_2                  (ADC_SQR5_REGOFFSET | ADC_REG_RANK_2_SQRX_BITOFFSET_POS)  /*!< ADC group regular sequencer rank 2 */
857
#define LL_ADC_REG_RANK_3                  (ADC_SQR5_REGOFFSET | ADC_REG_RANK_3_SQRX_BITOFFSET_POS)  /*!< ADC group regular sequencer rank 3 */
858
#define LL_ADC_REG_RANK_4                  (ADC_SQR5_REGOFFSET | ADC_REG_RANK_4_SQRX_BITOFFSET_POS)  /*!< ADC group regular sequencer rank 4 */
859
#define LL_ADC_REG_RANK_5                  (ADC_SQR5_REGOFFSET | ADC_REG_RANK_5_SQRX_BITOFFSET_POS)  /*!< ADC group regular sequencer rank 5 */
860
#define LL_ADC_REG_RANK_6                  (ADC_SQR5_REGOFFSET | ADC_REG_RANK_6_SQRX_BITOFFSET_POS)  /*!< ADC group regular sequencer rank 6 */
861
#define LL_ADC_REG_RANK_7                  (ADC_SQR4_REGOFFSET | ADC_REG_RANK_7_SQRX_BITOFFSET_POS)  /*!< ADC group regular sequencer rank 7 */
862
#define LL_ADC_REG_RANK_8                  (ADC_SQR4_REGOFFSET | ADC_REG_RANK_8_SQRX_BITOFFSET_POS)  /*!< ADC group regular sequencer rank 8 */
863
#define LL_ADC_REG_RANK_9                  (ADC_SQR4_REGOFFSET | ADC_REG_RANK_9_SQRX_BITOFFSET_POS)  /*!< ADC group regular sequencer rank 9 */
864
#define LL_ADC_REG_RANK_10                 (ADC_SQR4_REGOFFSET | ADC_REG_RANK_10_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 10 */
865
#define LL_ADC_REG_RANK_11                 (ADC_SQR4_REGOFFSET | ADC_REG_RANK_11_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 11 */
866
#define LL_ADC_REG_RANK_12                 (ADC_SQR4_REGOFFSET | ADC_REG_RANK_12_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 12 */
867
#define LL_ADC_REG_RANK_13                 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_13_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 13 */
868
#define LL_ADC_REG_RANK_14                 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_14_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 14 */
869
#define LL_ADC_REG_RANK_15                 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_15_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 15 */
870
#define LL_ADC_REG_RANK_16                 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_16_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 16 */
871
#define LL_ADC_REG_RANK_17                 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_17_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 17 */
872
#define LL_ADC_REG_RANK_18                 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_18_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 18 */
873
#define LL_ADC_REG_RANK_19                 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_19_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 19 */
874
#define LL_ADC_REG_RANK_20                 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_20_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 20 */
875
#define LL_ADC_REG_RANK_21                 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_21_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 21 */
876
#define LL_ADC_REG_RANK_22                 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_22_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 22 */
877
#define LL_ADC_REG_RANK_23                 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_23_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 23 */
878
#define LL_ADC_REG_RANK_24                 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_24_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 24 */
879
#define LL_ADC_REG_RANK_25                 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_25_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 25 */
880
#define LL_ADC_REG_RANK_26                 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_26_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 26 */
881
#define LL_ADC_REG_RANK_27                 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_27_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 27 */
882
#if defined(ADC_SQR1_SQ28)
883
#define LL_ADC_REG_RANK_28                 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_28_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 28 */
884
#endif
885
/**
886
  * @}
887
  */
888
 
889
/** @defgroup ADC_LL_EC_INJ_TRIGGER_SOURCE  ADC group injected - Trigger source
890
  * @{
891
  */
892
#define LL_ADC_INJ_TRIG_SOFTWARE           0x00000000U                                                                                                     /*!< ADC group injected conversion trigger internal: SW start. */
893
#define LL_ADC_INJ_TRIG_EXT_TIM9_CH1       (ADC_INJ_TRIG_EXT_EDGE_DEFAULT)                                                                                 /*!< ADC group injected conversion trigger from external IP: TIM9 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
894
#define LL_ADC_INJ_TRIG_EXT_TIM9_TRGO      (ADC_CR2_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT)                                                             /*!< ADC group injected conversion trigger from external IP: TIM9 TRGO. Trigger edge set to rising edge (default setting). */
895
#define LL_ADC_INJ_TRIG_EXT_TIM2_TRGO      (ADC_CR2_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT)                                                             /*!< ADC group injected conversion trigger from external IP: TIM2 TRGO. Trigger edge set to rising edge (default setting). */
896
#define LL_ADC_INJ_TRIG_EXT_TIM2_CH1       (ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT)                                         /*!< ADC group injected conversion trigger from external IP: TIM2 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
897
#define LL_ADC_INJ_TRIG_EXT_TIM3_CH4       (ADC_CR2_JEXTSEL_2 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT)                                                             /*!< ADC group injected conversion trigger from external IP: TIM3 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
898
#define LL_ADC_INJ_TRIG_EXT_TIM4_TRGO      (ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT)                                         /*!< ADC group injected conversion trigger from external IP: TIM4 TRGO. Trigger edge set to rising edge (default setting). */
899
#define LL_ADC_INJ_TRIG_EXT_TIM4_CH1       (ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT)                                         /*!< ADC group injected conversion trigger from external IP: TIM4 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
900
#define LL_ADC_INJ_TRIG_EXT_TIM4_CH2       (ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT)                     /*!< ADC group injected conversion trigger from external IP: TIM4 channel 2 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
901
#define LL_ADC_INJ_TRIG_EXT_TIM4_CH3       (ADC_CR2_JEXTSEL_3 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT)                                                             /*!< ADC group injected conversion trigger from external IP: TIM4 channel 3 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
902
#define LL_ADC_INJ_TRIG_EXT_TIM10_CH1      (ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT)                                         /*!< ADC group injected conversion trigger from external IP: TIM10 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
903
#define LL_ADC_INJ_TRIG_EXT_TIM7_TRGO      (ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT)                                         /*!< ADC group injected conversion trigger from external IP: TIM7 TRGO. Trigger edge set to rising edge (default setting). */
904
#define LL_ADC_INJ_TRIG_EXT_EXTI_LINE15    (ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: external interrupt line 15. Trigger edge set to rising edge (default setting). */
905
/**
906
  * @}
907
  */
908
 
909
/** @defgroup ADC_LL_EC_INJ_TRIGGER_EDGE  ADC group injected - Trigger edge
910
  * @{
911
  */
912
#define LL_ADC_INJ_TRIG_EXT_RISING         (                   ADC_CR2_JEXTEN_0)   /*!< ADC group injected conversion trigger polarity set to rising edge */
913
#define LL_ADC_INJ_TRIG_EXT_FALLING        (ADC_CR2_JEXTEN_1                   )   /*!< ADC group injected conversion trigger polarity set to falling edge */
914
#define LL_ADC_INJ_TRIG_EXT_RISINGFALLING  (ADC_CR2_JEXTEN_1 | ADC_CR2_JEXTEN_0)   /*!< ADC group injected conversion trigger polarity set to both rising and falling edges */
915
/**
916
  * @}
917
  */
918
 
919
/** @defgroup ADC_LL_EC_INJ_TRIG_AUTO  ADC group injected - Automatic trigger mode
920
* @{
921
*/
922
#define LL_ADC_INJ_TRIG_INDEPENDENT        0x00000000U            /*!< ADC group injected conversion trigger independent. Setting mandatory if ADC group injected injected trigger source is set to an external trigger. */
923
#define LL_ADC_INJ_TRIG_FROM_GRP_REGULAR   (ADC_CR1_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. */
924
/**
925
  * @}
926
  */
927
 
928
 
929
/** @defgroup ADC_LL_EC_INJ_SEQ_SCAN_LENGTH  ADC group injected - Sequencer scan length
930
  * @{
931
  */
932
#define LL_ADC_INJ_SEQ_SCAN_DISABLE        0x00000000U                     /*!< ADC group injected sequencer disable (equivalent to sequencer of 1 rank: ADC conversion on only 1 channel) */
933
#define LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS  (                ADC_JSQR_JL_0) /*!< ADC group injected sequencer enable with 2 ranks in the sequence */
934
#define LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS  (ADC_JSQR_JL_1                ) /*!< ADC group injected sequencer enable with 3 ranks in the sequence */
935
#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 */
936
/**
937
  * @}
938
  */
939
 
940
/** @defgroup ADC_LL_EC_INJ_SEQ_DISCONT_MODE  ADC group injected - Sequencer discontinuous mode
941
  * @{
942
  */
943
#define LL_ADC_INJ_SEQ_DISCONT_DISABLE     0x00000000U            /*!< ADC group injected sequencer discontinuous mode disable */
944
#define LL_ADC_INJ_SEQ_DISCONT_1RANK       (ADC_CR1_JDISCEN)      /*!< ADC group injected sequencer discontinuous mode enable with sequence interruption every rank */
945
/**
946
  * @}
947
  */
948
 
949
/** @defgroup ADC_LL_EC_INJ_SEQ_RANKS  ADC group injected - Sequencer ranks
950
  * @{
951
  */
952
#define LL_ADC_INJ_RANK_1                  (ADC_JDR1_REGOFFSET | ADC_JOFR1_REGOFFSET | ADC_INJ_RANK_1_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 1 */
953
#define LL_ADC_INJ_RANK_2                  (ADC_JDR2_REGOFFSET | ADC_JOFR2_REGOFFSET | ADC_INJ_RANK_2_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 2 */
954
#define LL_ADC_INJ_RANK_3                  (ADC_JDR3_REGOFFSET | ADC_JOFR3_REGOFFSET | ADC_INJ_RANK_3_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 3 */
955
#define LL_ADC_INJ_RANK_4                  (ADC_JDR4_REGOFFSET | ADC_JOFR4_REGOFFSET | ADC_INJ_RANK_4_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 4 */
956
/**
957
  * @}
958
  */
959
 
960
/** @defgroup ADC_LL_EC_CHANNEL_SAMPLINGTIME  Channel - Sampling time
961
  * @{
962
  */
963
#define LL_ADC_SAMPLINGTIME_4CYCLES        0x00000000U                                              /*!< Sampling time 4 ADC clock cycles */
964
#define LL_ADC_SAMPLINGTIME_9CYCLES        (ADC_SMPR3_SMP0_0)                                       /*!< Sampling time 9 ADC clock cycles */
965
#define LL_ADC_SAMPLINGTIME_16CYCLES       (ADC_SMPR3_SMP0_1)                                       /*!< Sampling time 16 ADC clock cycles */
966
#define LL_ADC_SAMPLINGTIME_24CYCLES       (ADC_SMPR3_SMP0_1 | ADC_SMPR3_SMP0_0)                    /*!< Sampling time 24 ADC clock cycles */
967
#define LL_ADC_SAMPLINGTIME_48CYCLES       (ADC_SMPR3_SMP0_2)                                       /*!< Sampling time 48 ADC clock cycles */
968
#define LL_ADC_SAMPLINGTIME_96CYCLES       (ADC_SMPR3_SMP0_2 | ADC_SMPR3_SMP0_0)                    /*!< Sampling time 96 ADC clock cycles */
969
#define LL_ADC_SAMPLINGTIME_192CYCLES      (ADC_SMPR3_SMP0_2 | ADC_SMPR3_SMP0_1)                    /*!< Sampling time 192 ADC clock cycles */
970
#define LL_ADC_SAMPLINGTIME_384CYCLES      (ADC_SMPR3_SMP0_2 | ADC_SMPR3_SMP0_1 | ADC_SMPR3_SMP0_0) /*!< Sampling time 384 ADC clock cycles */
971
/**
972
  * @}
973
  */
974
 
975
#if defined(COMP_CSR_FCH3)
976
/** @defgroup ADC_LL_EC_CHANNEL_ROUTING_LIST  Channel - Routing channels list
977
  * @{
978
  */
979
#define LL_ADC_CHANNEL_3_ROUTING           (COMP_CSR_FCH3)  /*!< ADC channel 3 routing. Used as ADC direct channel (fast channel) if OPAMP1 is in power down mode. */
980
#define LL_ADC_CHANNEL_8_ROUTING           (COMP_CSR_FCH8)  /*!< ADC channel 8 routing. Used as ADC direct channel (fast channel) if OPAMP2 is in power down mode. */
981
#define LL_ADC_CHANNEL_13_ROUTING          (COMP_CSR_RCH13) /*!< ADC channel 13 routing. Used as ADC re-routed channel if OPAMP3 is in power down mode. Otherwise, channel 13 is connected to OPAMP3 output and routed through switches COMP1_SW1 and VCOMP to ADC switch matrix. (Note: OPAMP3 is available on STM32L1 Cat.4 only). */
982
/**
983
  * @}
984
  */
985
 
986
/** @defgroup ADC_LL_EC_CHANNEL_ROUTING_SELECTION  Channel - Routing selection
987
  * @{
988
  */
989
#define LL_ADC_CHANNEL_ROUTING_DEFAULT     0x00000000U  /*!< ADC channel routing default: slow channel */
990
#define LL_ADC_CHANNEL_ROUTING_DIRECT      0x00000001U  /*!< ADC channel routing direct: fast channel. */
991
/**
992
  * @}
993
  */
994
#endif
995
 
996
/** @defgroup ADC_LL_EC_AWD_NUMBER Analog watchdog - Analog watchdog number
997
  * @{
998
  */
999
#define LL_ADC_AWD1                        (ADC_AWD_CR1_CHANNEL_MASK  | ADC_AWD_CR1_REGOFFSET) /*!< ADC analog watchdog number 1 */
1000
/**
1001
  * @}
1002
  */
1003
 
1004
/** @defgroup ADC_LL_EC_AWD_CHANNELS  Analog watchdog - Monitored channels
1005
  * @{
1006
  */
1007
#define LL_ADC_AWD_DISABLE                 0x00000000U                                                                                   /*!< ADC analog watchdog monitoring disabled */
1008
#define LL_ADC_AWD_ALL_CHANNELS_REG        (                                                             ADC_CR1_AWDEN                 ) /*!< ADC analog watchdog monitoring of all channels, converted by group regular only */
1009
#define LL_ADC_AWD_ALL_CHANNELS_INJ        (                                            ADC_CR1_JAWDEN                                 ) /*!< ADC analog watchdog monitoring of all channels, converted by group injected only */
1010
#define LL_ADC_AWD_ALL_CHANNELS_REG_INJ    (                                            ADC_CR1_JAWDEN | ADC_CR1_AWDEN                 ) /*!< ADC analog watchdog monitoring of all channels, converted by either group regular or injected */
1011
#define LL_ADC_AWD_CHANNEL_0_REG           ((LL_ADC_CHANNEL_0  & ADC_CHANNEL_ID_MASK)                  | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN0, converted by group regular only */
1012
#define LL_ADC_AWD_CHANNEL_0_INJ           ((LL_ADC_CHANNEL_0  & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN                 | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN0, converted by group injected only */
1013
#define LL_ADC_AWD_CHANNEL_0_REG_INJ       ((LL_ADC_CHANNEL_0  & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN0, converted by either group regular or injected */
1014
#define LL_ADC_AWD_CHANNEL_1_REG           ((LL_ADC_CHANNEL_1  & ADC_CHANNEL_ID_MASK)                  | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN1, converted by group regular only */
1015
#define LL_ADC_AWD_CHANNEL_1_INJ           ((LL_ADC_CHANNEL_1  & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN                 | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN1, converted by group injected only */
1016
#define LL_ADC_AWD_CHANNEL_1_REG_INJ       ((LL_ADC_CHANNEL_1  & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN1, converted by either group regular or injected */
1017
#define LL_ADC_AWD_CHANNEL_2_REG           ((LL_ADC_CHANNEL_2  & ADC_CHANNEL_ID_MASK)                  | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN2, converted by group regular only */
1018
#define LL_ADC_AWD_CHANNEL_2_INJ           ((LL_ADC_CHANNEL_2  & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN                 | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN2, converted by group injected only */
1019
#define LL_ADC_AWD_CHANNEL_2_REG_INJ       ((LL_ADC_CHANNEL_2  & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN2, converted by either group regular or injected */
1020
#define LL_ADC_AWD_CHANNEL_3_REG           ((LL_ADC_CHANNEL_3  & ADC_CHANNEL_ID_MASK)                  | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN3, converted by group regular only */
1021
#define LL_ADC_AWD_CHANNEL_3_INJ           ((LL_ADC_CHANNEL_3  & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN                 | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN3, converted by group injected only */
1022
#define LL_ADC_AWD_CHANNEL_3_REG_INJ       ((LL_ADC_CHANNEL_3  & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN3, converted by either group regular or injected */
1023
#define LL_ADC_AWD_CHANNEL_4_REG           ((LL_ADC_CHANNEL_4  & ADC_CHANNEL_ID_MASK)                  | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN4, converted by group regular only */
1024
#define LL_ADC_AWD_CHANNEL_4_INJ           ((LL_ADC_CHANNEL_4  & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN                 | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN4, converted by group injected only */
1025
#define LL_ADC_AWD_CHANNEL_4_REG_INJ       ((LL_ADC_CHANNEL_4  & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN4, converted by either group regular or injected */
1026
#define LL_ADC_AWD_CHANNEL_5_REG           ((LL_ADC_CHANNEL_5  & ADC_CHANNEL_ID_MASK)                  | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN5, converted by group regular only */
1027
#define LL_ADC_AWD_CHANNEL_5_INJ           ((LL_ADC_CHANNEL_5  & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN                 | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN5, converted by group injected only */
1028
#define LL_ADC_AWD_CHANNEL_5_REG_INJ       ((LL_ADC_CHANNEL_5  & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN5, converted by either group regular or injected */
1029
#define LL_ADC_AWD_CHANNEL_6_REG           ((LL_ADC_CHANNEL_6  & ADC_CHANNEL_ID_MASK)                  | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN6, converted by group regular only */
1030
#define LL_ADC_AWD_CHANNEL_6_INJ           ((LL_ADC_CHANNEL_6  & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN                 | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN6, converted by group injected only */
1031
#define LL_ADC_AWD_CHANNEL_6_REG_INJ       ((LL_ADC_CHANNEL_6  & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN6, converted by either group regular or injected */
1032
#define LL_ADC_AWD_CHANNEL_7_REG           ((LL_ADC_CHANNEL_7  & ADC_CHANNEL_ID_MASK)                  | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN7, converted by group regular only */
1033
#define LL_ADC_AWD_CHANNEL_7_INJ           ((LL_ADC_CHANNEL_7  & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN                 | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN7, converted by group injected only */
1034
#define LL_ADC_AWD_CHANNEL_7_REG_INJ       ((LL_ADC_CHANNEL_7  & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN7, converted by either group regular or injected */
1035
#define LL_ADC_AWD_CHANNEL_8_REG           ((LL_ADC_CHANNEL_8  & ADC_CHANNEL_ID_MASK)                  | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN8, converted by group regular only */
1036
#define LL_ADC_AWD_CHANNEL_8_INJ           ((LL_ADC_CHANNEL_8  & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN                 | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN8, converted by group injected only */
1037
#define LL_ADC_AWD_CHANNEL_8_REG_INJ       ((LL_ADC_CHANNEL_8  & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN8, converted by either group regular or injected */
1038
#define LL_ADC_AWD_CHANNEL_9_REG           ((LL_ADC_CHANNEL_9  & ADC_CHANNEL_ID_MASK)                  | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN9, converted by group regular only */
1039
#define LL_ADC_AWD_CHANNEL_9_INJ           ((LL_ADC_CHANNEL_9  & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN                 | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN9, converted by group injected only */
1040
#define LL_ADC_AWD_CHANNEL_9_REG_INJ       ((LL_ADC_CHANNEL_9  & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN9, converted by either group regular or injected */
1041
#define LL_ADC_AWD_CHANNEL_10_REG          ((LL_ADC_CHANNEL_10 & ADC_CHANNEL_ID_MASK)                  | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN10, converted by group regular only */
1042
#define LL_ADC_AWD_CHANNEL_10_INJ          ((LL_ADC_CHANNEL_10 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN                 | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN10, converted by group injected only */
1043
#define LL_ADC_AWD_CHANNEL_10_REG_INJ      ((LL_ADC_CHANNEL_10 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN10, converted by either group regular or injected */
1044
#define LL_ADC_AWD_CHANNEL_11_REG          ((LL_ADC_CHANNEL_11 & ADC_CHANNEL_ID_MASK)                  | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN11, converted by group regular only */
1045
#define LL_ADC_AWD_CHANNEL_11_INJ          ((LL_ADC_CHANNEL_11 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN                 | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN11, converted by group injected only */
1046
#define LL_ADC_AWD_CHANNEL_11_REG_INJ      ((LL_ADC_CHANNEL_11 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN11, converted by either group regular or injected */
1047
#define LL_ADC_AWD_CHANNEL_12_REG          ((LL_ADC_CHANNEL_12 & ADC_CHANNEL_ID_MASK)                  | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN12, converted by group regular only */
1048
#define LL_ADC_AWD_CHANNEL_12_INJ          ((LL_ADC_CHANNEL_12 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN                 | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN12, converted by group injected only */
1049
#define LL_ADC_AWD_CHANNEL_12_REG_INJ      ((LL_ADC_CHANNEL_12 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN12, converted by either group regular or injected */
1050
#define LL_ADC_AWD_CHANNEL_13_REG          ((LL_ADC_CHANNEL_13 & ADC_CHANNEL_ID_MASK)                  | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN13, converted by group regular only */
1051
#define LL_ADC_AWD_CHANNEL_13_INJ          ((LL_ADC_CHANNEL_13 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN                 | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN13, converted by group injected only */
1052
#define LL_ADC_AWD_CHANNEL_13_REG_INJ      ((LL_ADC_CHANNEL_13 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN13, converted by either group regular or injected */
1053
#define LL_ADC_AWD_CHANNEL_14_REG          ((LL_ADC_CHANNEL_14 & ADC_CHANNEL_ID_MASK)                  | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN14, converted by group regular only */
1054
#define LL_ADC_AWD_CHANNEL_14_INJ          ((LL_ADC_CHANNEL_14 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN                 | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN14, converted by group injected only */
1055
#define LL_ADC_AWD_CHANNEL_14_REG_INJ      ((LL_ADC_CHANNEL_14 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN14, converted by either group regular or injected */
1056
#define LL_ADC_AWD_CHANNEL_15_REG          ((LL_ADC_CHANNEL_15 & ADC_CHANNEL_ID_MASK)                  | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN15, converted by group regular only */
1057
#define LL_ADC_AWD_CHANNEL_15_INJ          ((LL_ADC_CHANNEL_15 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN                 | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN15, converted by group injected only */
1058
#define LL_ADC_AWD_CHANNEL_15_REG_INJ      ((LL_ADC_CHANNEL_15 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN15, converted by either group regular or injected */
1059
#define LL_ADC_AWD_CHANNEL_16_REG          ((LL_ADC_CHANNEL_16 & ADC_CHANNEL_ID_MASK)                  | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN16, converted by group regular only */
1060
#define LL_ADC_AWD_CHANNEL_16_INJ          ((LL_ADC_CHANNEL_16 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN                 | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN16, converted by group injected only */
1061
#define LL_ADC_AWD_CHANNEL_16_REG_INJ      ((LL_ADC_CHANNEL_16 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN16, converted by either group regular or injected */
1062
#define LL_ADC_AWD_CHANNEL_17_REG          ((LL_ADC_CHANNEL_17 & ADC_CHANNEL_ID_MASK)                  | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN17, converted by group regular only */
1063
#define LL_ADC_AWD_CHANNEL_17_INJ          ((LL_ADC_CHANNEL_17 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN                 | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN17, converted by group injected only */
1064
#define LL_ADC_AWD_CHANNEL_17_REG_INJ      ((LL_ADC_CHANNEL_17 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN17, converted by either group regular or injected */
1065
#define LL_ADC_AWD_CHANNEL_18_REG          ((LL_ADC_CHANNEL_18 & ADC_CHANNEL_ID_MASK)                  | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN18, converted by group regular only */
1066
#define LL_ADC_AWD_CHANNEL_18_INJ          ((LL_ADC_CHANNEL_18 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN                 | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN18, converted by group injected only */
1067
#define LL_ADC_AWD_CHANNEL_18_REG_INJ      ((LL_ADC_CHANNEL_18 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN18, converted by either group regular or injected */
1068
#define LL_ADC_AWD_CHANNEL_19_REG          ((LL_ADC_CHANNEL_19 & ADC_CHANNEL_ID_MASK)                  | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN19, converted by group regular only */
1069
#define LL_ADC_AWD_CHANNEL_19_INJ          ((LL_ADC_CHANNEL_19 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN                 | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN19, converted by group injected only */
1070
#define LL_ADC_AWD_CHANNEL_19_REG_INJ      ((LL_ADC_CHANNEL_19 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN19, converted by either group regular or injected */
1071
#define LL_ADC_AWD_CHANNEL_20_REG          ((LL_ADC_CHANNEL_20 & ADC_CHANNEL_ID_MASK)                  | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN20, converted by group regular only */
1072
#define LL_ADC_AWD_CHANNEL_20_INJ          ((LL_ADC_CHANNEL_20 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN                 | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN20, converted by group injected only */
1073
#define LL_ADC_AWD_CHANNEL_20_REG_INJ      ((LL_ADC_CHANNEL_20 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN20, converted by either group regular or injected */
1074
#define LL_ADC_AWD_CHANNEL_21_REG          ((LL_ADC_CHANNEL_21 & ADC_CHANNEL_ID_MASK)                  | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN21, converted by group regular only */
1075
#define LL_ADC_AWD_CHANNEL_21_INJ          ((LL_ADC_CHANNEL_21 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN                 | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN21, converted by group injected only */
1076
#define LL_ADC_AWD_CHANNEL_21_REG_INJ      ((LL_ADC_CHANNEL_21 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN21, converted by either group regular or injected */
1077
#define LL_ADC_AWD_CHANNEL_22_REG          ((LL_ADC_CHANNEL_22 & ADC_CHANNEL_ID_MASK)                  | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN22, converted by group regular only */
1078
#define LL_ADC_AWD_CHANNEL_22_INJ          ((LL_ADC_CHANNEL_22 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN                 | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN22, converted by group injected only */
1079
#define LL_ADC_AWD_CHANNEL_22_REG_INJ      ((LL_ADC_CHANNEL_22 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN22, converted by either group regular or injected */
1080
#define LL_ADC_AWD_CHANNEL_23_REG          ((LL_ADC_CHANNEL_23 & ADC_CHANNEL_ID_MASK)                  | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN23, converted by group regular only */
1081
#define LL_ADC_AWD_CHANNEL_23_INJ          ((LL_ADC_CHANNEL_23 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN                 | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN23, converted by group injected only */
1082
#define LL_ADC_AWD_CHANNEL_23_REG_INJ      ((LL_ADC_CHANNEL_23 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN23, converted by either group regular or injected */
1083
#define LL_ADC_AWD_CHANNEL_24_REG          ((LL_ADC_CHANNEL_24 & ADC_CHANNEL_ID_MASK)                  | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN24, converted by group regular only */
1084
#define LL_ADC_AWD_CHANNEL_24_INJ          ((LL_ADC_CHANNEL_24 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN                 | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN24, converted by group injected only */
1085
#define LL_ADC_AWD_CHANNEL_24_REG_INJ      ((LL_ADC_CHANNEL_24 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN24, converted by either group regular or injected */
1086
#define LL_ADC_AWD_CHANNEL_25_REG          ((LL_ADC_CHANNEL_25 & ADC_CHANNEL_ID_MASK)                  | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN25, converted by group regular only */
1087
#define LL_ADC_AWD_CHANNEL_25_INJ          ((LL_ADC_CHANNEL_25 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN                 | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN25, converted by group injected only */
1088
#define LL_ADC_AWD_CHANNEL_25_REG_INJ      ((LL_ADC_CHANNEL_25 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN25, converted by either group regular or injected */
1089
#define LL_ADC_AWD_CHANNEL_26_REG          ((LL_ADC_CHANNEL_26 & ADC_CHANNEL_ID_MASK)                  | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN26, converted by group regular only */
1090
#define LL_ADC_AWD_CHANNEL_26_INJ          ((LL_ADC_CHANNEL_26 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN                 | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN26, converted by group injected only */
1091
#define LL_ADC_AWD_CHANNEL_26_REG_INJ      ((LL_ADC_CHANNEL_26 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN26, converted by either group regular or injected */
1092
#if defined(ADC_SMPR0_SMP31)
1093
#define LL_ADC_AWD_CHANNEL_27_REG          ((LL_ADC_CHANNEL_27 & ADC_CHANNEL_ID_MASK)                  | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN27, converted by group regular only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.  */
1094
#define LL_ADC_AWD_CHANNEL_27_INJ          ((LL_ADC_CHANNEL_27 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN                 | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN27, converted by group injected only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.  */
1095
#define LL_ADC_AWD_CHANNEL_27_REG_INJ      ((LL_ADC_CHANNEL_27 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN27, converted by either group regular or injected. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.  */
1096
#define LL_ADC_AWD_CHANNEL_28_REG          ((LL_ADC_CHANNEL_28 & ADC_CHANNEL_ID_MASK)                  | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN28, converted by group regular only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.  */
1097
#define LL_ADC_AWD_CHANNEL_28_INJ          ((LL_ADC_CHANNEL_28 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN                 | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN28, converted by group injected only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.  */
1098
#define LL_ADC_AWD_CHANNEL_28_REG_INJ      ((LL_ADC_CHANNEL_28 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN28, converted by either group regular or injected. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.  */
1099
#define LL_ADC_AWD_CHANNEL_29_REG          ((LL_ADC_CHANNEL_29 & ADC_CHANNEL_ID_MASK)                  | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN29, converted by group regular only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.  */
1100
#define LL_ADC_AWD_CHANNEL_29_INJ          ((LL_ADC_CHANNEL_29 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN                 | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN29, converted by group injected only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.  */
1101
#define LL_ADC_AWD_CHANNEL_29_REG_INJ      ((LL_ADC_CHANNEL_29 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN29, converted by either group regular or injected. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.  */
1102
#define LL_ADC_AWD_CHANNEL_30_REG          ((LL_ADC_CHANNEL_30 & ADC_CHANNEL_ID_MASK)                  | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN30, converted by group regular only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.  */
1103
#define LL_ADC_AWD_CHANNEL_30_INJ          ((LL_ADC_CHANNEL_30 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN                 | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN30, converted by group injected only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.  */
1104
#define LL_ADC_AWD_CHANNEL_30_REG_INJ      ((LL_ADC_CHANNEL_30 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN30, converted by either group regular or injected. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.  */
1105
#define LL_ADC_AWD_CHANNEL_31_REG          ((LL_ADC_CHANNEL_31 & ADC_CHANNEL_ID_MASK)                  | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN31, converted by group regular only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.  */
1106
#define LL_ADC_AWD_CHANNEL_31_INJ          ((LL_ADC_CHANNEL_31 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN                 | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN31, converted by group injected only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.  */
1107
#define LL_ADC_AWD_CHANNEL_31_REG_INJ      ((LL_ADC_CHANNEL_31 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN31, converted by either group regular or injected. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.  */
1108
#endif /* ADC_SMPR0_SMP31 */
1109
#define LL_ADC_AWD_CH_VREFINT_REG          ((LL_ADC_CHANNEL_VREFINT    & ADC_CHANNEL_ID_MASK)                  | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to VrefInt: Internal voltage reference, converted by group regular only. Channel common to both bank A and bank B. */
1110
#define LL_ADC_AWD_CH_VREFINT_INJ          ((LL_ADC_CHANNEL_VREFINT    & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN                 | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to VrefInt: Internal voltage reference, converted by group injected only. Channel common to both bank A and bank B. */
1111
#define LL_ADC_AWD_CH_VREFINT_REG_INJ      ((LL_ADC_CHANNEL_VREFINT    & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to VrefInt: Internal voltage reference, converted by either group regular or injected. Channel common to both bank A and bank B. */
1112
#define LL_ADC_AWD_CH_TEMPSENSOR_REG       ((LL_ADC_CHANNEL_TEMPSENSOR & ADC_CHANNEL_ID_MASK)                  | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Temperature sensor, converted by group regular only. Channel common to both bank A and bank B. */
1113
#define LL_ADC_AWD_CH_TEMPSENSOR_INJ       ((LL_ADC_CHANNEL_TEMPSENSOR & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN                 | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Temperature sensor, converted by group injected only. Channel common to both bank A and bank B. */
1114
#define LL_ADC_AWD_CH_TEMPSENSOR_REG_INJ   ((LL_ADC_CHANNEL_TEMPSENSOR & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Temperature sensor, converted by either group regular or injected. Channel common to both bank A and bank B. */
1115
#define LL_ADC_AWD_CH_VCOMP_REG            ((LL_ADC_CHANNEL_VCOMP      & ADC_CHANNEL_ID_MASK)                  | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to comparator COMP1 positive input via ADC switch matrix. Channel common to both bank A and bank B. */
1116
#define LL_ADC_AWD_CH_VCOMP_INJ            ((LL_ADC_CHANNEL_VCOMP      & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN                 | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to comparator COMP1 positive input via ADC switch matrix. Channel common to both bank A and bank B. */
1117
#define LL_ADC_AWD_CH_VCOMP_REG_INJ        ((LL_ADC_CHANNEL_VCOMP      & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to comparator COMP1 positive input via ADC switch matrix. Channel common to both bank A and bank B. */
1118
#if defined(OPAMP_CSR_OPA1PD) || defined (OPAMP_CSR_OPA2PD) || defined (OPAMP_CSR_OPA3PD)
1119
#define LL_ADC_AWD_CH_VOPAMP1_REG          ((LL_ADC_CHANNEL_VOPAMP1    & ADC_CHANNEL_ID_MASK)                  | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to OPAMP1 output via ADC switch matrix. Channel common to both bank A and bank B. */
1120
#define LL_ADC_AWD_CH_VOPAMP1_INJ          ((LL_ADC_CHANNEL_VOPAMP1    & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN                 | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to OPAMP1 output via ADC switch matrix. Channel common to both bank A and bank B. */
1121
#define LL_ADC_AWD_CH_VOPAMP1_REG_INJ      ((LL_ADC_CHANNEL_VOPAMP1    & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to OPAMP1 output via ADC switch matrix. Channel common to both bank A and bank B. */
1122
#define LL_ADC_AWD_CH_VOPAMP2_REG          ((LL_ADC_CHANNEL_VOPAMP2    & ADC_CHANNEL_ID_MASK)                  | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to OPAMP2 output via ADC switch matrix. Channel common to both bank A and bank B. */
1123
#define LL_ADC_AWD_CH_VOPAMP2_INJ          ((LL_ADC_CHANNEL_VOPAMP2    & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN                 | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to OPAMP2 output via ADC switch matrix. Channel common to both bank A and bank B. */
1124
#define LL_ADC_AWD_CH_VOPAMP2_REG_INJ      ((LL_ADC_CHANNEL_VOPAMP2    & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to OPAMP2 output via ADC switch matrix. Channel common to both bank A and bank B. */
1125
#if defined(OPAMP_CSR_OPA3PD)
1126
#define LL_ADC_AWD_CH_VOPAMP3_REG          ((LL_ADC_CHANNEL_VOPAMP3    & ADC_CHANNEL_ID_MASK)                  | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to OPAMP3 output via ADC switch matrix. Channel common to both bank A and bank B. */
1127
#define LL_ADC_AWD_CH_VOPAMP3_INJ          ((LL_ADC_CHANNEL_VOPAMP3    & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN                 | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to OPAMP3 output via ADC switch matrix. Channel common to both bank A and bank B. */
1128
#define LL_ADC_AWD_CH_VOPAMP3_REG_INJ      ((LL_ADC_CHANNEL_VOPAMP3    & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to OPAMP3 output via ADC switch matrix. Channel common to both bank A and bank B. */
1129
#endif /* OPAMP_CSR_OPA3PD */
1130
#endif /* OPAMP_CSR_OPA1PD || OPAMP_CSR_OPA2PD || OPAMP_CSR_OPA3PD */
1131
/**
1132
  * @}
1133
  */
1134
 
1135
/** @defgroup ADC_LL_EC_AWD_THRESHOLDS  Analog watchdog - Thresholds
1136
  * @{
1137
  */
1138
#define LL_ADC_AWD_THRESHOLD_HIGH          (ADC_AWD_TR1_HIGH_REGOFFSET) /*!< ADC analog watchdog threshold high */
1139
#define LL_ADC_AWD_THRESHOLD_LOW           (ADC_AWD_TR1_LOW_REGOFFSET)  /*!< ADC analog watchdog threshold low */
1140
/**
1141
  * @}
1142
  */
1143
 
1144
 
1145
/** @defgroup ADC_LL_EC_HW_DELAYS  Definitions of ADC hardware constraints delays
1146
  * @note   Only ADC IP HW delays are defined in ADC LL driver driver,
1147
  *         not timeout values.
1148
  *         For details on delays values, refer to descriptions in source code
1149
  *         above each literal definition.
1150
  * @{
1151
  */
1152
 
1153
/* Note: Only ADC IP HW delays are defined in ADC LL driver driver,           */
1154
/*       not timeout values.                                                  */
1155
/*       Timeout values for ADC operations are dependent to device clock      */
1156
/*       configuration (system clock versus ADC clock),                       */
1157
/*       and therefore must be defined in user application.                   */
1158
/*       Indications for estimation of ADC timeout delays, for this           */
1159
/*       STM32 serie:                                                         */
1160
/*       - ADC enable time: maximum delay is 3.5us                            */
1161
/*         (refer to device datasheet, parameter "tSTAB")                     */
1162
/*       - ADC conversion time: duration depending on ADC clock and ADC       */
1163
/*         configuration.                                                     */
1164
/*         (refer to device reference manual, section "Timing")               */
1165
 
1166
/* Delay for internal voltage reference stabilization time.                   */
1167
/* Delay set to maximum value (refer to device datasheet,                     */
1168
/* parameter "TADC_BUF").                                                     */
1169
/* Unit: us                                                                   */
1170
#define LL_ADC_DELAY_VREFINT_STAB_US       (  10U)  /*!< Delay for internal voltage reference stabilization time */
1171
 
1172
/* Delay for temperature sensor stabilization time.                           */
1173
/* Literal set to maximum value (refer to device datasheet,                   */
1174
/* parameter "tSTART").                                                       */
1175
/* Unit: us                                                                   */
1176
#define LL_ADC_DELAY_TEMPSENSOR_STAB_US    (  10U)  /*!< Delay for internal voltage reference stabilization time */
1177
 
1178
/**
1179
  * @}
1180
  */
1181
 
1182
/**
1183
  * @}
1184
  */
1185
 
1186
 
1187
/* Exported macro ------------------------------------------------------------*/
1188
/** @defgroup ADC_LL_Exported_Macros ADC Exported Macros
1189
  * @{
1190
  */
1191
 
1192
/** @defgroup ADC_LL_EM_WRITE_READ Common write and read registers Macros
1193
  * @{
1194
  */
1195
 
1196
/**
1197
  * @brief  Write a value in ADC register
1198
  * @param  __INSTANCE__ ADC Instance
1199
  * @param  __REG__ Register to be written
1200
  * @param  __VALUE__ Value to be written in the register
1201
  * @retval None
1202
  */
1203
#define LL_ADC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
1204
 
1205
/**
1206
  * @brief  Read a value in ADC register
1207
  * @param  __INSTANCE__ ADC Instance
1208
  * @param  __REG__ Register to be read
1209
  * @retval Register value
1210
  */
1211
#define LL_ADC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
1212
/**
1213
  * @}
1214
  */
1215
 
1216
/** @defgroup ADC_LL_EM_HELPER_MACRO ADC helper macro
1217
  * @{
1218
  */
1219
 
1220
/**
1221
  * @brief  Helper macro to get ADC channel number in decimal format
1222
  *         from literals LL_ADC_CHANNEL_x.
1223
  * @note   Example:
1224
  *           __LL_ADC_CHANNEL_TO_DECIMAL_NB(LL_ADC_CHANNEL_4)
1225
  *           will return decimal number "4".
1226
  * @note   The input can be a value from functions where a channel
1227
  *         number is returned, either defined with number
1228
  *         or with bitfield (only one bit must be set).
1229
  * @param  __CHANNEL__ This parameter can be one of the following values:
1230
  *         @arg @ref LL_ADC_CHANNEL_0          (2)
1231
  *         @arg @ref LL_ADC_CHANNEL_1          (2)
1232
  *         @arg @ref LL_ADC_CHANNEL_2          (2)
1233
  *         @arg @ref LL_ADC_CHANNEL_3          (2)
1234
  *         @arg @ref LL_ADC_CHANNEL_4          (1)
1235
  *         @arg @ref LL_ADC_CHANNEL_5          (1)
1236
  *         @arg @ref LL_ADC_CHANNEL_6          (2)
1237
  *         @arg @ref LL_ADC_CHANNEL_7          (2)
1238
  *         @arg @ref LL_ADC_CHANNEL_8          (2)
1239
  *         @arg @ref LL_ADC_CHANNEL_9          (2)
1240
  *         @arg @ref LL_ADC_CHANNEL_10         (2)
1241
  *         @arg @ref LL_ADC_CHANNEL_11         (2)
1242
  *         @arg @ref LL_ADC_CHANNEL_12         (2)
1243
  *         @arg @ref LL_ADC_CHANNEL_13         (3)
1244
  *         @arg @ref LL_ADC_CHANNEL_14         (3)
1245
  *         @arg @ref LL_ADC_CHANNEL_15         (3)
1246
  *         @arg @ref LL_ADC_CHANNEL_16         (3)
1247
  *         @arg @ref LL_ADC_CHANNEL_17         (3)
1248
  *         @arg @ref LL_ADC_CHANNEL_18         (3)
1249
  *         @arg @ref LL_ADC_CHANNEL_19         (3)
1250
  *         @arg @ref LL_ADC_CHANNEL_20         (3)
1251
  *         @arg @ref LL_ADC_CHANNEL_21         (3)
1252
  *         @arg @ref LL_ADC_CHANNEL_22         (1)
1253
  *         @arg @ref LL_ADC_CHANNEL_23         (1)
1254
  *         @arg @ref LL_ADC_CHANNEL_24         (1)
1255
  *         @arg @ref LL_ADC_CHANNEL_25         (1)
1256
  *         @arg @ref LL_ADC_CHANNEL_26         (3)
1257
  *         @arg @ref LL_ADC_CHANNEL_27         (3)(4)
1258
  *         @arg @ref LL_ADC_CHANNEL_28         (3)(4)
1259
  *         @arg @ref LL_ADC_CHANNEL_29         (3)(4)
1260
  *         @arg @ref LL_ADC_CHANNEL_30         (3)(4)
1261
  *         @arg @ref LL_ADC_CHANNEL_31         (3)(4)
1262
  *         @arg @ref LL_ADC_CHANNEL_VREFINT    (3)
1263
  *         @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)
1264
  *         @arg @ref LL_ADC_CHANNEL_VCOMP      (3)
1265
  *         @arg @ref LL_ADC_CHANNEL_VOPAMP1    (3)(5)
1266
  *         @arg @ref LL_ADC_CHANNEL_VOPAMP2    (3)(5)
1267
  *         @arg @ref LL_ADC_CHANNEL_VOPAMP3    (3)(5)
1268
  *        
1269
  *         (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
1270
  *         (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
1271
  *         (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
1272
  *         (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
1273
  *         (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
1274
  * @retval Value between Min_Data=0 and Max_Data=18
1275
  */
1276
#define __LL_ADC_CHANNEL_TO_DECIMAL_NB(__CHANNEL__)                                        \
1277
  (((__CHANNEL__) & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS)
1278
 
1279
/**
1280
  * @brief  Helper macro to get ADC channel in literal format LL_ADC_CHANNEL_x
1281
  *         from number in decimal format.
1282
  * @note   Example:
1283
  *           __LL_ADC_DECIMAL_NB_TO_CHANNEL(4)
1284
  *           will return a data equivalent to "LL_ADC_CHANNEL_4".
1285
  * @param  __DECIMAL_NB__ Value between Min_Data=0 and Max_Data=18
1286
  * @retval Returned value can be one of the following values:
1287
  *         @arg @ref LL_ADC_CHANNEL_0          (2)
1288
  *         @arg @ref LL_ADC_CHANNEL_1          (2)
1289
  *         @arg @ref LL_ADC_CHANNEL_2          (2)
1290
  *         @arg @ref LL_ADC_CHANNEL_3          (2)
1291
  *         @arg @ref LL_ADC_CHANNEL_4          (1)
1292
  *         @arg @ref LL_ADC_CHANNEL_5          (1)
1293
  *         @arg @ref LL_ADC_CHANNEL_6          (2)
1294
  *         @arg @ref LL_ADC_CHANNEL_7          (2)
1295
  *         @arg @ref LL_ADC_CHANNEL_8          (2)
1296
  *         @arg @ref LL_ADC_CHANNEL_9          (2)
1297
  *         @arg @ref LL_ADC_CHANNEL_10         (2)
1298
  *         @arg @ref LL_ADC_CHANNEL_11         (2)
1299
  *         @arg @ref LL_ADC_CHANNEL_12         (2)
1300
  *         @arg @ref LL_ADC_CHANNEL_13         (3)
1301
  *         @arg @ref LL_ADC_CHANNEL_14         (3)
1302
  *         @arg @ref LL_ADC_CHANNEL_15         (3)
1303
  *         @arg @ref LL_ADC_CHANNEL_16         (3)
1304
  *         @arg @ref LL_ADC_CHANNEL_17         (3)
1305
  *         @arg @ref LL_ADC_CHANNEL_18         (3)
1306
  *         @arg @ref LL_ADC_CHANNEL_19         (3)
1307
  *         @arg @ref LL_ADC_CHANNEL_20         (3)
1308
  *         @arg @ref LL_ADC_CHANNEL_21         (3)
1309
  *         @arg @ref LL_ADC_CHANNEL_22         (1)
1310
  *         @arg @ref LL_ADC_CHANNEL_23         (1)
1311
  *         @arg @ref LL_ADC_CHANNEL_24         (1)
1312
  *         @arg @ref LL_ADC_CHANNEL_25         (1)
1313
  *         @arg @ref LL_ADC_CHANNEL_26         (3)
1314
  *         @arg @ref LL_ADC_CHANNEL_27         (3)(4)
1315
  *         @arg @ref LL_ADC_CHANNEL_28         (3)(4)
1316
  *         @arg @ref LL_ADC_CHANNEL_29         (3)(4)
1317
  *         @arg @ref LL_ADC_CHANNEL_30         (3)(4)
1318
  *         @arg @ref LL_ADC_CHANNEL_31         (3)(4)
1319
  *         @arg @ref LL_ADC_CHANNEL_VREFINT    (3)(6)
1320
  *         @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)(6)
1321
  *         @arg @ref LL_ADC_CHANNEL_VCOMP      (3)(6)
1322
  *         @arg @ref LL_ADC_CHANNEL_VOPAMP1    (3)(5)
1323
  *         @arg @ref LL_ADC_CHANNEL_VOPAMP2    (3)(5)
1324
  *         @arg @ref LL_ADC_CHANNEL_VOPAMP3    (3)(5)
1325
  *        
1326
  *         (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
1327
  *         (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
1328
  *         (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
1329
  *         (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
1330
  *         (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5.\n
1331
  *         (6) For ADC channel read back from ADC register,
1332
  *             comparison with internal channel parameter to be done
1333
  *             using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
1334
  */
1335
#if defined(ADC_SMPR0_SMP31)
1336
#define __LL_ADC_DECIMAL_NB_TO_CHANNEL(__DECIMAL_NB__)                                                                  \
1337
  (((__DECIMAL_NB__) <= 9U)                                                                                             \
1338
    ? (                                                                                                                 \
1339
       ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS)                                       |                \
1340
       (ADC_SMPR3_REGOFFSET | (((uint32_t) (3U * (__DECIMAL_NB__))) << ADC_CHANNEL_SMPx_BITOFFSET_POS))                 \
1341
      )                                                                                                                 \
1342
      :                                                                                                                 \
1343
      (((__DECIMAL_NB__) <= 19U)                                                                                        \
1344
        ? (                                                                                                             \
1345
           ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS)                                       |            \
1346
           (ADC_SMPR2_REGOFFSET | (((uint32_t) (3U * ((__DECIMAL_NB__) -10U))) << ADC_CHANNEL_SMPx_BITOFFSET_POS))      \
1347
          )                                                                                                             \
1348
          :                                                                                                             \
1349
          (((__DECIMAL_NB__) <= 28U)                                                                                    \
1350
            ? (                                                                                                         \
1351
               ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS)                                       |        \
1352
               (ADC_SMPR1_REGOFFSET | (((uint32_t) (3U * ((__DECIMAL_NB__) -20U))) << ADC_CHANNEL_SMPx_BITOFFSET_POS))  \
1353
              )                                                                                                         \
1354
              :                                                                                                         \
1355
              (                                                                                                         \
1356
               ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS)                                              | \
1357
               (ADC_SMPR0_REGOFFSET | (((uint32_t) (3U * ((__DECIMAL_NB__) - 30U))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \
1358
              )                                                                                                         \
1359
          )                                                                                                             \
1360
      )                                                                                                                 \
1361
  )
1362
#else
1363
#define __LL_ADC_DECIMAL_NB_TO_CHANNEL(__DECIMAL_NB__)                                                                  \
1364
  (((__DECIMAL_NB__) <= 9U)                                                                                             \
1365
    ? (                                                                                                                 \
1366
       ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS)                                       |                \
1367
       (ADC_SMPR3_REGOFFSET | (((uint32_t) (3U * (__DECIMAL_NB__))) << ADC_CHANNEL_SMPx_BITOFFSET_POS))                 \
1368
      )                                                                                                                 \
1369
      :                                                                                                                 \
1370
      (((__DECIMAL_NB__) <= 19U)                                                                                        \
1371
        ? (                                                                                                             \
1372
           ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS)                                       |            \
1373
           (ADC_SMPR2_REGOFFSET | (((uint32_t) (3U * ((__DECIMAL_NB__) -10U))) << ADC_CHANNEL_SMPx_BITOFFSET_POS))      \
1374
          )                                                                                                             \
1375
          :                                                                                                             \
1376
          (                                                                                                             \
1377
           ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS)                                       |            \
1378
           (ADC_SMPR1_REGOFFSET | (((uint32_t) (3U * ((__DECIMAL_NB__) -20U))) << ADC_CHANNEL_SMPx_BITOFFSET_POS))      \
1379
          )                                                                                                             \
1380
      )                                                                                                                 \
1381
  )
1382
#endif /* ADC_SMPR0_SMP31 */
1383
 
1384
/**
1385
  * @brief  Helper macro to determine whether the selected channel
1386
  *         corresponds to literal definitions of driver.
1387
  * @note   The different literal definitions of ADC channels are:
1388
  *         - ADC internal channel:
1389
  *           LL_ADC_CHANNEL_VREFINT, LL_ADC_CHANNEL_TEMPSENSOR, ...
1390
  *         - ADC external channel (channel connected to a GPIO pin):
1391
  *           LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...
1392
  * @note   The channel parameter must be a value defined from literal
1393
  *         definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
1394
  *         LL_ADC_CHANNEL_TEMPSENSOR, ...),
1395
  *         ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...),
1396
  *         must not be a value from functions where a channel number is
1397
  *         returned from ADC registers,
1398
  *         because internal and external channels share the same channel
1399
  *         number in ADC registers. The differentiation is made only with
1400
  *         parameters definitions of driver.
1401
  * @param  __CHANNEL__ This parameter can be one of the following values:
1402
  *         @arg @ref LL_ADC_CHANNEL_0          (2)
1403
  *         @arg @ref LL_ADC_CHANNEL_1          (2)
1404
  *         @arg @ref LL_ADC_CHANNEL_2          (2)
1405
  *         @arg @ref LL_ADC_CHANNEL_3          (2)
1406
  *         @arg @ref LL_ADC_CHANNEL_4          (1)
1407
  *         @arg @ref LL_ADC_CHANNEL_5          (1)
1408
  *         @arg @ref LL_ADC_CHANNEL_6          (2)
1409
  *         @arg @ref LL_ADC_CHANNEL_7          (2)
1410
  *         @arg @ref LL_ADC_CHANNEL_8          (2)
1411
  *         @arg @ref LL_ADC_CHANNEL_9          (2)
1412
  *         @arg @ref LL_ADC_CHANNEL_10         (2)
1413
  *         @arg @ref LL_ADC_CHANNEL_11         (2)
1414
  *         @arg @ref LL_ADC_CHANNEL_12         (2)
1415
  *         @arg @ref LL_ADC_CHANNEL_13         (3)
1416
  *         @arg @ref LL_ADC_CHANNEL_14         (3)
1417
  *         @arg @ref LL_ADC_CHANNEL_15         (3)
1418
  *         @arg @ref LL_ADC_CHANNEL_16         (3)
1419
  *         @arg @ref LL_ADC_CHANNEL_17         (3)
1420
  *         @arg @ref LL_ADC_CHANNEL_18         (3)
1421
  *         @arg @ref LL_ADC_CHANNEL_19         (3)
1422
  *         @arg @ref LL_ADC_CHANNEL_20         (3)
1423
  *         @arg @ref LL_ADC_CHANNEL_21         (3)
1424
  *         @arg @ref LL_ADC_CHANNEL_22         (1)
1425
  *         @arg @ref LL_ADC_CHANNEL_23         (1)
1426
  *         @arg @ref LL_ADC_CHANNEL_24         (1)
1427
  *         @arg @ref LL_ADC_CHANNEL_25         (1)
1428
  *         @arg @ref LL_ADC_CHANNEL_26         (3)
1429
  *         @arg @ref LL_ADC_CHANNEL_27         (3)(4)
1430
  *         @arg @ref LL_ADC_CHANNEL_28         (3)(4)
1431
  *         @arg @ref LL_ADC_CHANNEL_29         (3)(4)
1432
  *         @arg @ref LL_ADC_CHANNEL_30         (3)(4)
1433
  *         @arg @ref LL_ADC_CHANNEL_31         (3)(4)
1434
  *         @arg @ref LL_ADC_CHANNEL_VREFINT    (3)
1435
  *         @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)
1436
  *         @arg @ref LL_ADC_CHANNEL_VCOMP      (3)
1437
  *         @arg @ref LL_ADC_CHANNEL_VOPAMP1    (3)(5)
1438
  *         @arg @ref LL_ADC_CHANNEL_VOPAMP2    (3)(5)
1439
  *         @arg @ref LL_ADC_CHANNEL_VOPAMP3    (3)(5)
1440
  *        
1441
  *         (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
1442
  *         (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
1443
  *         (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
1444
  *         (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
1445
  *         (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
1446
  * @retval Value "0" if the channel corresponds to a parameter definition of a ADC external channel (channel connected to a GPIO pin).
1447
  *         Value "1" if the channel corresponds to a parameter definition of a ADC internal channel.
1448
  */
1449
#define __LL_ADC_IS_CHANNEL_INTERNAL(__CHANNEL__)                              \
1450
  (((__CHANNEL__) & ADC_CHANNEL_ID_INTERNAL_CH_MASK) != 0U)
1451
 
1452
/**
1453
  * @brief  Helper macro to convert a channel defined from parameter
1454
  *         definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
1455
  *         LL_ADC_CHANNEL_TEMPSENSOR, ...),
1456
  *         to its equivalent parameter definition of a ADC external channel
1457
  *         (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...).
1458
  * @note   The channel parameter can be, additionally to a value
1459
  *         defined from parameter definition of a ADC internal channel
1460
  *         (LL_ADC_CHANNEL_VREFINT, LL_ADC_CHANNEL_TEMPSENSOR, ...),
1461
  *         a value defined from parameter definition of
1462
  *         ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...)
1463
  *         or a value from functions where a channel number is returned
1464
  *         from ADC registers.
1465
  * @param  __CHANNEL__ This parameter can be one of the following values:
1466
  *         @arg @ref LL_ADC_CHANNEL_0          (2)
1467
  *         @arg @ref LL_ADC_CHANNEL_1          (2)
1468
  *         @arg @ref LL_ADC_CHANNEL_2          (2)
1469
  *         @arg @ref LL_ADC_CHANNEL_3          (2)
1470
  *         @arg @ref LL_ADC_CHANNEL_4          (1)
1471
  *         @arg @ref LL_ADC_CHANNEL_5          (1)
1472
  *         @arg @ref LL_ADC_CHANNEL_6          (2)
1473
  *         @arg @ref LL_ADC_CHANNEL_7          (2)
1474
  *         @arg @ref LL_ADC_CHANNEL_8          (2)
1475
  *         @arg @ref LL_ADC_CHANNEL_9          (2)
1476
  *         @arg @ref LL_ADC_CHANNEL_10         (2)
1477
  *         @arg @ref LL_ADC_CHANNEL_11         (2)
1478
  *         @arg @ref LL_ADC_CHANNEL_12         (2)
1479
  *         @arg @ref LL_ADC_CHANNEL_13         (3)
1480
  *         @arg @ref LL_ADC_CHANNEL_14         (3)
1481
  *         @arg @ref LL_ADC_CHANNEL_15         (3)
1482
  *         @arg @ref LL_ADC_CHANNEL_16         (3)
1483
  *         @arg @ref LL_ADC_CHANNEL_17         (3)
1484
  *         @arg @ref LL_ADC_CHANNEL_18         (3)
1485
  *         @arg @ref LL_ADC_CHANNEL_19         (3)
1486
  *         @arg @ref LL_ADC_CHANNEL_20         (3)
1487
  *         @arg @ref LL_ADC_CHANNEL_21         (3)
1488
  *         @arg @ref LL_ADC_CHANNEL_22         (1)
1489
  *         @arg @ref LL_ADC_CHANNEL_23         (1)
1490
  *         @arg @ref LL_ADC_CHANNEL_24         (1)
1491
  *         @arg @ref LL_ADC_CHANNEL_25         (1)
1492
  *         @arg @ref LL_ADC_CHANNEL_26         (3)
1493
  *         @arg @ref LL_ADC_CHANNEL_27         (3)(4)
1494
  *         @arg @ref LL_ADC_CHANNEL_28         (3)(4)
1495
  *         @arg @ref LL_ADC_CHANNEL_29         (3)(4)
1496
  *         @arg @ref LL_ADC_CHANNEL_30         (3)(4)
1497
  *         @arg @ref LL_ADC_CHANNEL_31         (3)(4)
1498
  *         @arg @ref LL_ADC_CHANNEL_VREFINT    (3)
1499
  *         @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)
1500
  *         @arg @ref LL_ADC_CHANNEL_VCOMP      (3)
1501
  *         @arg @ref LL_ADC_CHANNEL_VOPAMP1    (3)(5)
1502
  *         @arg @ref LL_ADC_CHANNEL_VOPAMP2    (3)(5)
1503
  *         @arg @ref LL_ADC_CHANNEL_VOPAMP3    (3)(5)
1504
  *        
1505
  *         (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
1506
  *         (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
1507
  *         (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
1508
  *         (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
1509
  *         (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
1510
  * @retval Returned value can be one of the following values:
1511
  *         @arg @ref LL_ADC_CHANNEL_0
1512
  *         @arg @ref LL_ADC_CHANNEL_1
1513
  *         @arg @ref LL_ADC_CHANNEL_2
1514
  *         @arg @ref LL_ADC_CHANNEL_3
1515
  *         @arg @ref LL_ADC_CHANNEL_4
1516
  *         @arg @ref LL_ADC_CHANNEL_5
1517
  *         @arg @ref LL_ADC_CHANNEL_6
1518
  *         @arg @ref LL_ADC_CHANNEL_7
1519
  *         @arg @ref LL_ADC_CHANNEL_8
1520
  *         @arg @ref LL_ADC_CHANNEL_9
1521
  *         @arg @ref LL_ADC_CHANNEL_10
1522
  *         @arg @ref LL_ADC_CHANNEL_11
1523
  *         @arg @ref LL_ADC_CHANNEL_12
1524
  *         @arg @ref LL_ADC_CHANNEL_13
1525
  *         @arg @ref LL_ADC_CHANNEL_14
1526
  *         @arg @ref LL_ADC_CHANNEL_15
1527
  *         @arg @ref LL_ADC_CHANNEL_16
1528
  *         @arg @ref LL_ADC_CHANNEL_17
1529
  *         @arg @ref LL_ADC_CHANNEL_18
1530
  */
1531
#define __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL(__CHANNEL__)                     \
1532
  ((__CHANNEL__) & ~ADC_CHANNEL_ID_INTERNAL_CH_MASK)
1533
 
1534
/**
1535
  * @brief  Helper macro to determine whether the internal channel
1536
  *         selected is available on the ADC instance selected.
1537
  * @note   The channel parameter must be a value defined from parameter
1538
  *         definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
1539
  *         LL_ADC_CHANNEL_TEMPSENSOR, ...),
1540
  *         must not be a value defined from parameter definition of
1541
  *         ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...)
1542
  *         or a value from functions where a channel number is
1543
  *         returned from ADC registers,
1544
  *         because internal and external channels share the same channel
1545
  *         number in ADC registers. The differentiation is made only with
1546
  *         parameters definitions of driver.
1547
  * @param  __ADC_INSTANCE__ ADC instance
1548
  * @param  __CHANNEL__ This parameter can be one of the following values:
1549
  *         @arg @ref LL_ADC_CHANNEL_VREFINT    (3)
1550
  *         @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)
1551
  *         @arg @ref LL_ADC_CHANNEL_VCOMP      (3)
1552
  *         @arg @ref LL_ADC_CHANNEL_VOPAMP1    (3)(5)
1553
  *         @arg @ref LL_ADC_CHANNEL_VOPAMP2    (3)(5)
1554
  *         @arg @ref LL_ADC_CHANNEL_VOPAMP3    (3)(5)
1555
  *        
1556
  *         (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
1557
  *         (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
1558
  *         (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
1559
  *         (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
1560
  *         (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
1561
  * @retval Value "0" if the internal channel selected is not available on the ADC instance selected.
1562
  *         Value "1" if the internal channel selected is available on the ADC instance selected.
1563
  */
1564
#if defined (OPAMP_CSR_OPA3PD)
1565
#define __LL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE(__ADC_INSTANCE__, __CHANNEL__)  \
1566
  (                                                                            \
1567
    ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT)    ||                            \
1568
    ((__CHANNEL__) == LL_ADC_CHANNEL_TEMPSENSOR) ||                            \
1569
    ((__CHANNEL__) == LL_ADC_CHANNEL_VCOMP)      ||                            \
1570
    ((__CHANNEL__) == LL_ADC_CHANNEL_VOPAMP1)    ||                            \
1571
    ((__CHANNEL__) == LL_ADC_CHANNEL_VOPAMP2)    ||                            \
1572
    ((__CHANNEL__) == LL_ADC_CHANNEL_VOPAMP3)                                  \
1573
  )
1574
#elif defined(OPAMP_CSR_OPA1PD) || defined (OPAMP_CSR_OPA2PD)
1575
#define __LL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE(__ADC_INSTANCE__, __CHANNEL__)  \
1576
  (                                                                            \
1577
    ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT)    ||                            \
1578
    ((__CHANNEL__) == LL_ADC_CHANNEL_TEMPSENSOR) ||                            \
1579
    ((__CHANNEL__) == LL_ADC_CHANNEL_VCOMP)      ||                            \
1580
    ((__CHANNEL__) == LL_ADC_CHANNEL_VOPAMP1)    ||                            \
1581
    ((__CHANNEL__) == LL_ADC_CHANNEL_VOPAMP2)                                  \
1582
  )
1583
#else
1584
#define __LL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE(__ADC_INSTANCE__, __CHANNEL__)  \
1585
  (                                                                            \
1586
    ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT)    ||                            \
1587
    ((__CHANNEL__) == LL_ADC_CHANNEL_TEMPSENSOR) ||                            \
1588
    ((__CHANNEL__) == LL_ADC_CHANNEL_VCOMP)                                    \
1589
  )
1590
#endif
1591
 
1592
/**
1593
  * @brief  Helper macro to define ADC analog watchdog parameter:
1594
  *         define a single channel to monitor with analog watchdog
1595
  *         from sequencer channel and groups definition.
1596
  * @note   To be used with function @ref LL_ADC_SetAnalogWDMonitChannels().
1597
  *         Example:
1598
  *           LL_ADC_SetAnalogWDMonitChannels(
1599
  *             ADC1, LL_ADC_AWD1,
1600
  *             __LL_ADC_ANALOGWD_CHANNEL_GROUP(LL_ADC_CHANNEL4, LL_ADC_GROUP_REGULAR))
1601
  * @param  __CHANNEL__ This parameter can be one of the following values:
1602
  *         @arg @ref LL_ADC_CHANNEL_0          (2)
1603
  *         @arg @ref LL_ADC_CHANNEL_1          (2)
1604
  *         @arg @ref LL_ADC_CHANNEL_2          (2)
1605
  *         @arg @ref LL_ADC_CHANNEL_3          (2)
1606
  *         @arg @ref LL_ADC_CHANNEL_4          (1)
1607
  *         @arg @ref LL_ADC_CHANNEL_5          (1)
1608
  *         @arg @ref LL_ADC_CHANNEL_6          (2)
1609
  *         @arg @ref LL_ADC_CHANNEL_7          (2)
1610
  *         @arg @ref LL_ADC_CHANNEL_8          (2)
1611
  *         @arg @ref LL_ADC_CHANNEL_9          (2)
1612
  *         @arg @ref LL_ADC_CHANNEL_10         (2)
1613
  *         @arg @ref LL_ADC_CHANNEL_11         (2)
1614
  *         @arg @ref LL_ADC_CHANNEL_12         (2)
1615
  *         @arg @ref LL_ADC_CHANNEL_13         (3)
1616
  *         @arg @ref LL_ADC_CHANNEL_14         (3)
1617
  *         @arg @ref LL_ADC_CHANNEL_15         (3)
1618
  *         @arg @ref LL_ADC_CHANNEL_16         (3)
1619
  *         @arg @ref LL_ADC_CHANNEL_17         (3)
1620
  *         @arg @ref LL_ADC_CHANNEL_18         (3)
1621
  *         @arg @ref LL_ADC_CHANNEL_19         (3)
1622
  *         @arg @ref LL_ADC_CHANNEL_20         (3)
1623
  *         @arg @ref LL_ADC_CHANNEL_21         (3)
1624
  *         @arg @ref LL_ADC_CHANNEL_22         (1)
1625
  *         @arg @ref LL_ADC_CHANNEL_23         (1)
1626
  *         @arg @ref LL_ADC_CHANNEL_24         (1)
1627
  *         @arg @ref LL_ADC_CHANNEL_25         (1)
1628
  *         @arg @ref LL_ADC_CHANNEL_26         (3)
1629
  *         @arg @ref LL_ADC_CHANNEL_27         (3)(4)
1630
  *         @arg @ref LL_ADC_CHANNEL_28         (3)(4)
1631
  *         @arg @ref LL_ADC_CHANNEL_29         (3)(4)
1632
  *         @arg @ref LL_ADC_CHANNEL_30         (3)(4)
1633
  *         @arg @ref LL_ADC_CHANNEL_31         (3)(4)
1634
  *         @arg @ref LL_ADC_CHANNEL_VREFINT    (3)(6)
1635
  *         @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)(6)
1636
  *         @arg @ref LL_ADC_CHANNEL_VCOMP      (3)(6)
1637
  *         @arg @ref LL_ADC_CHANNEL_VOPAMP1    (3)(5)
1638
  *         @arg @ref LL_ADC_CHANNEL_VOPAMP2    (3)(5)
1639
  *         @arg @ref LL_ADC_CHANNEL_VOPAMP3    (3)(5)
1640
  *        
1641
  *         (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
1642
  *         (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
1643
  *         (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
1644
  *         (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
1645
  *         (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5.\n
1646
  *         (6) For ADC channel read back from ADC register,
1647
  *             comparison with internal channel parameter to be done
1648
  *             using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
1649
  * @param  __GROUP__ This parameter can be one of the following values:
1650
  *         @arg @ref LL_ADC_GROUP_REGULAR
1651
  *         @arg @ref LL_ADC_GROUP_INJECTED
1652
  *         @arg @ref LL_ADC_GROUP_REGULAR_INJECTED
1653
  * @retval Returned value can be one of the following values:
1654
  *         @arg @ref LL_ADC_AWD_DISABLE
1655
  *         @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG
1656
  *         @arg @ref LL_ADC_AWD_ALL_CHANNELS_INJ
1657
  *         @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG_INJ
1658
  *         @arg @ref LL_ADC_AWD_CHANNEL_0_REG           (2)
1659
  *         @arg @ref LL_ADC_AWD_CHANNEL_0_INJ           (2)
1660
  *         @arg @ref LL_ADC_AWD_CHANNEL_0_REG_INJ       (2)
1661
  *         @arg @ref LL_ADC_AWD_CHANNEL_1_REG           (2)
1662
  *         @arg @ref LL_ADC_AWD_CHANNEL_1_INJ           (2)
1663
  *         @arg @ref LL_ADC_AWD_CHANNEL_1_REG_INJ       (2)
1664
  *         @arg @ref LL_ADC_AWD_CHANNEL_2_REG           (2)
1665
  *         @arg @ref LL_ADC_AWD_CHANNEL_2_INJ           (2)
1666
  *         @arg @ref LL_ADC_AWD_CHANNEL_2_REG_INJ       (2)
1667
  *         @arg @ref LL_ADC_AWD_CHANNEL_3_REG           (2)
1668
  *         @arg @ref LL_ADC_AWD_CHANNEL_3_INJ           (2)
1669
  *         @arg @ref LL_ADC_AWD_CHANNEL_3_REG_INJ       (2)
1670
  *         @arg @ref LL_ADC_AWD_CHANNEL_4_REG           (1)
1671
  *         @arg @ref LL_ADC_AWD_CHANNEL_4_INJ           (1)
1672
  *         @arg @ref LL_ADC_AWD_CHANNEL_4_REG_INJ       (1)
1673
  *         @arg @ref LL_ADC_AWD_CHANNEL_5_REG           (1)
1674
  *         @arg @ref LL_ADC_AWD_CHANNEL_5_INJ           (1)
1675
  *         @arg @ref LL_ADC_AWD_CHANNEL_5_REG_INJ       (1)
1676
  *         @arg @ref LL_ADC_AWD_CHANNEL_6_REG           (2)
1677
  *         @arg @ref LL_ADC_AWD_CHANNEL_6_INJ           (2)
1678
  *         @arg @ref LL_ADC_AWD_CHANNEL_6_REG_INJ       (2)
1679
  *         @arg @ref LL_ADC_AWD_CHANNEL_7_REG           (2)
1680
  *         @arg @ref LL_ADC_AWD_CHANNEL_7_INJ           (2)
1681
  *         @arg @ref LL_ADC_AWD_CHANNEL_7_REG_INJ       (2)
1682
  *         @arg @ref LL_ADC_AWD_CHANNEL_8_REG           (2)
1683
  *         @arg @ref LL_ADC_AWD_CHANNEL_8_INJ           (2)
1684
  *         @arg @ref LL_ADC_AWD_CHANNEL_8_REG_INJ       (2)
1685
  *         @arg @ref LL_ADC_AWD_CHANNEL_9_REG           (2)
1686
  *         @arg @ref LL_ADC_AWD_CHANNEL_9_INJ           (2)
1687
  *         @arg @ref LL_ADC_AWD_CHANNEL_9_REG_INJ       (2)
1688
  *         @arg @ref LL_ADC_AWD_CHANNEL_10_REG          (2)
1689
  *         @arg @ref LL_ADC_AWD_CHANNEL_10_INJ          (2)
1690
  *         @arg @ref LL_ADC_AWD_CHANNEL_10_REG_INJ      (2)
1691
  *         @arg @ref LL_ADC_AWD_CHANNEL_11_REG          (2)
1692
  *         @arg @ref LL_ADC_AWD_CHANNEL_11_INJ          (2)
1693
  *         @arg @ref LL_ADC_AWD_CHANNEL_11_REG_INJ      (2)
1694
  *         @arg @ref LL_ADC_AWD_CHANNEL_12_REG          (2)
1695
  *         @arg @ref LL_ADC_AWD_CHANNEL_12_INJ          (2)
1696
  *         @arg @ref LL_ADC_AWD_CHANNEL_12_REG_INJ      (2)
1697
  *         @arg @ref LL_ADC_AWD_CHANNEL_13_REG          (3)
1698
  *         @arg @ref LL_ADC_AWD_CHANNEL_13_INJ          (3)
1699
  *         @arg @ref LL_ADC_AWD_CHANNEL_13_REG_INJ      (3)
1700
  *         @arg @ref LL_ADC_AWD_CHANNEL_14_REG          (3)
1701
  *         @arg @ref LL_ADC_AWD_CHANNEL_14_INJ          (3)
1702
  *         @arg @ref LL_ADC_AWD_CHANNEL_14_REG_INJ      (3)
1703
  *         @arg @ref LL_ADC_AWD_CHANNEL_15_REG          (3)
1704
  *         @arg @ref LL_ADC_AWD_CHANNEL_15_INJ          (3)
1705
  *         @arg @ref LL_ADC_AWD_CHANNEL_15_REG_INJ      (3)
1706
  *         @arg @ref LL_ADC_AWD_CHANNEL_16_REG          (3)
1707
  *         @arg @ref LL_ADC_AWD_CHANNEL_16_INJ          (3)
1708
  *         @arg @ref LL_ADC_AWD_CHANNEL_16_REG_INJ      (3)
1709
  *         @arg @ref LL_ADC_AWD_CHANNEL_17_REG          (3)
1710
  *         @arg @ref LL_ADC_AWD_CHANNEL_17_INJ          (3)
1711
  *         @arg @ref LL_ADC_AWD_CHANNEL_17_REG_INJ      (3)
1712
  *         @arg @ref LL_ADC_AWD_CHANNEL_18_REG          (3)
1713
  *         @arg @ref LL_ADC_AWD_CHANNEL_18_INJ          (3)
1714
  *         @arg @ref LL_ADC_AWD_CHANNEL_18_REG_INJ      (3)
1715
  *         @arg @ref LL_ADC_AWD_CHANNEL_19_REG          (3)
1716
  *         @arg @ref LL_ADC_AWD_CHANNEL_19_INJ          (3)
1717
  *         @arg @ref LL_ADC_AWD_CHANNEL_19_REG_INJ      (3)
1718
  *         @arg @ref LL_ADC_AWD_CHANNEL_20_REG          (3)
1719
  *         @arg @ref LL_ADC_AWD_CHANNEL_20_INJ          (3)
1720
  *         @arg @ref LL_ADC_AWD_CHANNEL_20_REG_INJ      (3)
1721
  *         @arg @ref LL_ADC_AWD_CHANNEL_21_REG          (3)
1722
  *         @arg @ref LL_ADC_AWD_CHANNEL_21_INJ          (3)
1723
  *         @arg @ref LL_ADC_AWD_CHANNEL_21_REG_INJ      (3)
1724
  *         @arg @ref LL_ADC_AWD_CHANNEL_22_REG          (1)
1725
  *         @arg @ref LL_ADC_AWD_CHANNEL_22_INJ          (1)
1726
  *         @arg @ref LL_ADC_AWD_CHANNEL_22_REG_INJ      (1)
1727
  *         @arg @ref LL_ADC_AWD_CHANNEL_23_REG          (1)
1728
  *         @arg @ref LL_ADC_AWD_CHANNEL_23_INJ          (1)
1729
  *         @arg @ref LL_ADC_AWD_CHANNEL_23_REG_INJ      (1)
1730
  *         @arg @ref LL_ADC_AWD_CHANNEL_24_REG          (1)
1731
  *         @arg @ref LL_ADC_AWD_CHANNEL_24_INJ          (1)
1732
  *         @arg @ref LL_ADC_AWD_CHANNEL_24_REG_INJ      (1)
1733
  *         @arg @ref LL_ADC_AWD_CHANNEL_25_REG          (1)
1734
  *         @arg @ref LL_ADC_AWD_CHANNEL_25_INJ          (1)
1735
  *         @arg @ref LL_ADC_AWD_CHANNEL_25_REG_INJ      (1)
1736
  *         @arg @ref LL_ADC_AWD_CHANNEL_26_REG          (3)
1737
  *         @arg @ref LL_ADC_AWD_CHANNEL_26_INJ          (3)
1738
  *         @arg @ref LL_ADC_AWD_CHANNEL_26_REG_INJ      (3)
1739
  *         @arg @ref LL_ADC_AWD_CHANNEL_27_REG          (3)(4)
1740
  *         @arg @ref LL_ADC_AWD_CHANNEL_27_INJ          (3)(4)
1741
  *         @arg @ref LL_ADC_AWD_CHANNEL_27_REG_INJ      (3)(4)
1742
  *         @arg @ref LL_ADC_AWD_CHANNEL_28_REG          (3)(4)
1743
  *         @arg @ref LL_ADC_AWD_CHANNEL_28_INJ          (3)(4)
1744
  *         @arg @ref LL_ADC_AWD_CHANNEL_28_REG_INJ      (3)(4)
1745
  *         @arg @ref LL_ADC_AWD_CHANNEL_29_REG          (3)(4)
1746
  *         @arg @ref LL_ADC_AWD_CHANNEL_29_INJ          (3)(4)
1747
  *         @arg @ref LL_ADC_AWD_CHANNEL_29_REG_INJ      (3)(4)
1748
  *         @arg @ref LL_ADC_AWD_CHANNEL_30_REG          (3)(4)
1749
  *         @arg @ref LL_ADC_AWD_CHANNEL_30_INJ          (3)(4)
1750
  *         @arg @ref LL_ADC_AWD_CHANNEL_30_REG_INJ      (3)(4)
1751
  *         @arg @ref LL_ADC_AWD_CHANNEL_31_REG          (3)(4)
1752
  *         @arg @ref LL_ADC_AWD_CHANNEL_31_INJ          (3)(4)
1753
  *         @arg @ref LL_ADC_AWD_CHANNEL_31_REG_INJ      (3)(4)
1754
  *         @arg @ref LL_ADC_AWD_CH_VREFINT_REG          (3)
1755
  *         @arg @ref LL_ADC_AWD_CH_VREFINT_INJ          (3)
1756
  *         @arg @ref LL_ADC_AWD_CH_VREFINT_REG_INJ      (3)
1757
  *         @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG       (3)
1758
  *         @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_INJ       (3)
1759
  *         @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG_INJ   (3)
1760
  *         @arg @ref LL_ADC_AWD_CH_VCOMP_REG            (3)
1761
  *         @arg @ref LL_ADC_AWD_CH_VCOMP_INJ            (3)
1762
  *         @arg @ref LL_ADC_AWD_CH_VCOMP_REG_INJ        (3)
1763
  *         @arg @ref LL_ADC_AWD_CH_VOPAMP1_REG          (3)(5)
1764
  *         @arg @ref LL_ADC_AWD_CH_VOPAMP1_INJ          (3)(5)
1765
  *         @arg @ref LL_ADC_AWD_CH_VOPAMP1_REG_INJ      (3)(5)
1766
  *         @arg @ref LL_ADC_AWD_CH_VOPAMP2_REG          (3)(5)
1767
  *         @arg @ref LL_ADC_AWD_CH_VOPAMP2_INJ          (3)(5)
1768
  *         @arg @ref LL_ADC_AWD_CH_VOPAMP2_REG_INJ      (3)(5)
1769
  *         @arg @ref LL_ADC_AWD_CH_VOPAMP3_REG          (3)(5)
1770
  *         @arg @ref LL_ADC_AWD_CH_VOPAMP3_INJ          (3)(5)
1771
  *         @arg @ref LL_ADC_AWD_CH_VOPAMP3_REG_INJ      (3)(5)
1772
  *        
1773
  *         (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
1774
  *         (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
1775
  *         (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
1776
  *         (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
1777
  *         (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
1778
  */
1779
#define __LL_ADC_ANALOGWD_CHANNEL_GROUP(__CHANNEL__, __GROUP__)                                           \
1780
  (((__GROUP__) == LL_ADC_GROUP_REGULAR)                                                                  \
1781
    ? (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL)                            \
1782
      :                                                                                                   \
1783
      ((__GROUP__) == LL_ADC_GROUP_INJECTED)                                                              \
1784
       ? (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL)                        \
1785
         :                                                                                                \
1786
         (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL)        \
1787
  )
1788
 
1789
/**
1790
  * @brief  Helper macro to set the value of ADC analog watchdog threshold high
1791
  *         or low in function of ADC resolution, when ADC resolution is
1792
  *         different of 12 bits.
1793
  * @note   To be used with function @ref LL_ADC_SetAnalogWDThresholds().
1794
  *         Example, with a ADC resolution of 8 bits, to set the value of
1795
  *         analog watchdog threshold high (on 8 bits):
1796
  *           LL_ADC_SetAnalogWDThresholds
1797
  *            (< ADCx param >,
1798
  *             __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION(LL_ADC_RESOLUTION_8B, <threshold_value_8_bits>)
1799
  *            );
1800
  * @param  __ADC_RESOLUTION__ This parameter can be one of the following values:
1801
  *         @arg @ref LL_ADC_RESOLUTION_12B
1802
  *         @arg @ref LL_ADC_RESOLUTION_10B
1803
  *         @arg @ref LL_ADC_RESOLUTION_8B
1804
  *         @arg @ref LL_ADC_RESOLUTION_6B
1805
  * @param  __AWD_THRESHOLD__ Value between Min_Data=0x000 and Max_Data=0xFFF
1806
  * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
1807
  */
1808
#define __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION(__ADC_RESOLUTION__, __AWD_THRESHOLD__) \
1809
  ((__AWD_THRESHOLD__) << ((__ADC_RESOLUTION__) >> (ADC_CR1_RES_BITOFFSET_POS - 1U )))
1810
 
1811
/**
1812
  * @brief  Helper macro to get the value of ADC analog watchdog threshold high
1813
  *         or low in function of ADC resolution, when ADC resolution is
1814
  *         different of 12 bits.
1815
  * @note   To be used with function @ref LL_ADC_GetAnalogWDThresholds().
1816
  *         Example, with a ADC resolution of 8 bits, to get the value of
1817
  *         analog watchdog threshold high (on 8 bits):
1818
  *           < threshold_value_6_bits > = __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION
1819
  *            (LL_ADC_RESOLUTION_8B,
1820
  *             LL_ADC_GetAnalogWDThresholds(<ADCx param>, LL_ADC_AWD_THRESHOLD_HIGH)
1821
  *            );
1822
  * @param  __ADC_RESOLUTION__ This parameter can be one of the following values:
1823
  *         @arg @ref LL_ADC_RESOLUTION_12B
1824
  *         @arg @ref LL_ADC_RESOLUTION_10B
1825
  *         @arg @ref LL_ADC_RESOLUTION_8B
1826
  *         @arg @ref LL_ADC_RESOLUTION_6B
1827
  * @param  __AWD_THRESHOLD_12_BITS__ Value between Min_Data=0x000 and Max_Data=0xFFF
1828
  * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
1829
  */
1830
#define __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION(__ADC_RESOLUTION__, __AWD_THRESHOLD_12_BITS__) \
1831
  ((__AWD_THRESHOLD_12_BITS__) >> ((__ADC_RESOLUTION__) >> (ADC_CR1_RES_BITOFFSET_POS - 1U )))
1832
 
1833
/**
1834
  * @brief  Helper macro to select the ADC common instance
1835
  *         to which is belonging the selected ADC instance.
1836
  * @note   ADC common register instance can be used for:
1837
  *         - Set parameters common to several ADC instances
1838
  *         - Multimode (for devices with several ADC instances)
1839
  *         Refer to functions having argument "ADCxy_COMMON" as parameter.
1840
  * @param  __ADCx__ ADC instance
1841
  * @retval ADC common register instance
1842
  */
1843
#define __LL_ADC_COMMON_INSTANCE(__ADCx__)                                     \
1844
  (ADC1_COMMON)
1845
 
1846
/**
1847
  * @brief  Helper macro to check if all ADC instances sharing the same
1848
  *         ADC common instance are disabled.
1849
  * @note   This check is required by functions with setting conditioned to
1850
  *         ADC state:
1851
  *         All ADC instances of the ADC common group must be disabled.
1852
  *         Refer to functions having argument "ADCxy_COMMON" as parameter.
1853
  * @note   On devices with only 1 ADC common instance, parameter of this macro
1854
  *         is useless and can be ignored (parameter kept for compatibility
1855
  *         with devices featuring several ADC common instances).
1856
  * @param  __ADCXY_COMMON__ ADC common instance
1857
  *         (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
1858
  * @retval Value "0" if all ADC instances sharing the same ADC common instance
1859
  *         are disabled.
1860
  *         Value "1" if at least one ADC instance sharing the same ADC common instance
1861
  *         is enabled.
1862
  */
1863
#define __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(__ADCXY_COMMON__)              \
1864
  LL_ADC_IsEnabled(ADC1)
1865
 
1866
/**
1867
  * @brief  Helper macro to define the ADC conversion data full-scale digital
1868
  *         value corresponding to the selected ADC resolution.
1869
  * @note   ADC conversion data full-scale corresponds to voltage range
1870
  *         determined by analog voltage references Vref+ and Vref-
1871
  *         (refer to reference manual).
1872
  * @param  __ADC_RESOLUTION__ This parameter can be one of the following values:
1873
  *         @arg @ref LL_ADC_RESOLUTION_12B
1874
  *         @arg @ref LL_ADC_RESOLUTION_10B
1875
  *         @arg @ref LL_ADC_RESOLUTION_8B
1876
  *         @arg @ref LL_ADC_RESOLUTION_6B
1877
  * @retval ADC conversion data equivalent voltage value (unit: mVolt)
1878
  */
1879
#define __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__)                             \
1880
  (0xFFFU >> ((__ADC_RESOLUTION__) >> (ADC_CR1_RES_BITOFFSET_POS - 1U)))
1881
 
1882
/**
1883
  * @brief  Helper macro to convert the ADC conversion data from
1884
  *         a resolution to another resolution.
1885
  * @param  __DATA__ ADC conversion data to be converted
1886
  * @param  __ADC_RESOLUTION_CURRENT__ Resolution of to the data to be converted
1887
  *         This parameter can be one of the following values:
1888
  *         @arg @ref LL_ADC_RESOLUTION_12B
1889
  *         @arg @ref LL_ADC_RESOLUTION_10B
1890
  *         @arg @ref LL_ADC_RESOLUTION_8B
1891
  *         @arg @ref LL_ADC_RESOLUTION_6B
1892
  * @param  __ADC_RESOLUTION_TARGET__ Resolution of the data after conversion
1893
  *         This parameter can be one of the following values:
1894
  *         @arg @ref LL_ADC_RESOLUTION_12B
1895
  *         @arg @ref LL_ADC_RESOLUTION_10B
1896
  *         @arg @ref LL_ADC_RESOLUTION_8B
1897
  *         @arg @ref LL_ADC_RESOLUTION_6B
1898
  * @retval ADC conversion data to the requested resolution
1899
  */
1900
#define __LL_ADC_CONVERT_DATA_RESOLUTION(__DATA__, __ADC_RESOLUTION_CURRENT__, __ADC_RESOLUTION_TARGET__) \
1901
  (((__DATA__)                                                                 \
1902
    << ((__ADC_RESOLUTION_CURRENT__) >> (ADC_CR1_RES_BITOFFSET_POS - 1U)))     \
1903
   >> ((__ADC_RESOLUTION_TARGET__) >> (ADC_CR1_RES_BITOFFSET_POS - 1U))        \
1904
  )
1905
 
1906
/**
1907
  * @brief  Helper macro to calculate the voltage (unit: mVolt)
1908
  *         corresponding to a ADC conversion data (unit: digital value).
1909
  * @note   Analog reference voltage (Vref+) must be either known from
1910
  *         user board environment or can be calculated using ADC measurement
1911
  *         and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
1912
  * @param  __VREFANALOG_VOLTAGE__ Analog reference voltage (unit: mV)
1913
  * @param  __ADC_DATA__ ADC conversion data (resolution 12 bits)
1914
  *                       (unit: digital value).
1915
  * @param  __ADC_RESOLUTION__ This parameter can be one of the following values:
1916
  *         @arg @ref LL_ADC_RESOLUTION_12B
1917
  *         @arg @ref LL_ADC_RESOLUTION_10B
1918
  *         @arg @ref LL_ADC_RESOLUTION_8B
1919
  *         @arg @ref LL_ADC_RESOLUTION_6B
1920
  * @retval ADC conversion data equivalent voltage value (unit: mVolt)
1921
  */
1922
#define __LL_ADC_CALC_DATA_TO_VOLTAGE(__VREFANALOG_VOLTAGE__,\
1923
                                      __ADC_DATA__,\
1924
                                      __ADC_RESOLUTION__)                      \
1925
  ((__ADC_DATA__) * (__VREFANALOG_VOLTAGE__)                                   \
1926
   / __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__)                                \
1927
  )
1928
 
1929
/**
1930
  * @brief  Helper macro to calculate analog reference voltage (Vref+)
1931
  *         (unit: mVolt) from ADC conversion data of internal voltage
1932
  *         reference VrefInt.
1933
  * @note   Computation is using VrefInt calibration value
1934
  *         stored in system memory for each device during production.
1935
  * @note   This voltage depends on user board environment: voltage level
1936
  *         connected to pin Vref+.
1937
  *         On devices with small package, the pin Vref+ is not present
1938
  *         and internally bonded to pin Vdda.
1939
  * @note   On this STM32 serie, calibration data of internal voltage reference
1940
  *         VrefInt corresponds to a resolution of 12 bits,
1941
  *         this is the recommended ADC resolution to convert voltage of
1942
  *         internal voltage reference VrefInt.
1943
  *         Otherwise, this macro performs the processing to scale
1944
  *         ADC conversion data to 12 bits.
1945
  * @param  __VREFINT_ADC_DATA__ ADC conversion data (resolution 12 bits)
1946
  *         of internal voltage reference VrefInt (unit: digital value).
1947
  * @param  __ADC_RESOLUTION__ This parameter can be one of the following values:
1948
  *         @arg @ref LL_ADC_RESOLUTION_12B
1949
  *         @arg @ref LL_ADC_RESOLUTION_10B
1950
  *         @arg @ref LL_ADC_RESOLUTION_8B
1951
  *         @arg @ref LL_ADC_RESOLUTION_6B
1952
  * @retval Analog reference voltage (unit: mV)
1953
  */
1954
#define __LL_ADC_CALC_VREFANALOG_VOLTAGE(__VREFINT_ADC_DATA__,\
1955
                                         __ADC_RESOLUTION__)                   \
1956
  (((uint32_t)(*VREFINT_CAL_ADDR) * VREFINT_CAL_VREF)                          \
1957
    / __LL_ADC_CONVERT_DATA_RESOLUTION((__VREFINT_ADC_DATA__),                 \
1958
                                       (__ADC_RESOLUTION__),                   \
1959
                                       LL_ADC_RESOLUTION_12B)                  \
1960
  )
1961
 
61 mjames 1962
/* Note: On device STM32L100, calibration parameters TS_CAL1 and TS_CAL2 are not available. */
1963
/*       Therefore, helper macro __LL_ADC_CALC_TEMPERATURE() is not available.*/
1964
/*       Use helper macro @ref __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS().        */
1965
#if defined(TEMPSENSOR_CAL1_ADDR_CMSIS)
56 mjames 1966
/**
1967
  * @brief  Helper macro to calculate the temperature (unit: degree Celsius)
1968
  *         from ADC conversion data of internal temperature sensor.
1969
  * @note   Computation is using temperature sensor calibration values
1970
  *         stored in system memory for each device during production.
1971
  * @note   Calculation formula:
1972
  *           Temperature = ((TS_ADC_DATA - TS_CAL1)
1973
  *                           * (TS_CAL2_TEMP - TS_CAL1_TEMP))
1974
  *                         / (TS_CAL2 - TS_CAL1) + TS_CAL1_TEMP
1975
  *           with TS_ADC_DATA = temperature sensor raw data measured by ADC
1976
  *                Avg_Slope = (TS_CAL2 - TS_CAL1)
1977
  *                            / (TS_CAL2_TEMP - TS_CAL1_TEMP)
1978
  *                TS_CAL1   = equivalent TS_ADC_DATA at temperature
1979
  *                            TEMP_DEGC_CAL1 (calibrated in factory)
1980
  *                TS_CAL2   = equivalent TS_ADC_DATA at temperature
1981
  *                            TEMP_DEGC_CAL2 (calibrated in factory)
1982
  *         Caution: Calculation relevancy under reserve that calibration
1983
  *                  parameters are correct (address and data).
1984
  *                  To calculate temperature using temperature sensor
1985
  *                  datasheet typical values (generic values less, therefore
1986
  *                  less accurate than calibrated values),
1987
  *                  use helper macro @ref __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS().
1988
  * @note   As calculation input, the analog reference voltage (Vref+) must be
1989
  *         defined as it impacts the ADC LSB equivalent voltage.
1990
  * @note   Analog reference voltage (Vref+) must be either known from
1991
  *         user board environment or can be calculated using ADC measurement
1992
  *         and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
1993
  * @note   On this STM32 serie, calibration data of temperature sensor
1994
  *         corresponds to a resolution of 12 bits,
1995
  *         this is the recommended ADC resolution to convert voltage of
1996
  *         temperature sensor.
1997
  *         Otherwise, this macro performs the processing to scale
1998
  *         ADC conversion data to 12 bits.
1999
  * @param  __VREFANALOG_VOLTAGE__  Analog reference voltage (unit: mV)
2000
  * @param  __TEMPSENSOR_ADC_DATA__ ADC conversion data of internal
2001
  *                                 temperature sensor (unit: digital value).
2002
  * @param  __ADC_RESOLUTION__      ADC resolution at which internal temperature
2003
  *                                 sensor voltage has been measured.
2004
  *         This parameter can be one of the following values:
2005
  *         @arg @ref LL_ADC_RESOLUTION_12B
2006
  *         @arg @ref LL_ADC_RESOLUTION_10B
2007
  *         @arg @ref LL_ADC_RESOLUTION_8B
2008
  *         @arg @ref LL_ADC_RESOLUTION_6B
2009
  * @retval Temperature (unit: degree Celsius)
2010
  */
2011
#define __LL_ADC_CALC_TEMPERATURE(__VREFANALOG_VOLTAGE__,\
2012
                                  __TEMPSENSOR_ADC_DATA__,\
2013
                                  __ADC_RESOLUTION__)                              \
2014
  (((( ((int32_t)((__LL_ADC_CONVERT_DATA_RESOLUTION((__TEMPSENSOR_ADC_DATA__),     \
2015
                                                    (__ADC_RESOLUTION__),          \
2016
                                                    LL_ADC_RESOLUTION_12B)         \
2017
                   * (__VREFANALOG_VOLTAGE__))                                     \
2018
                  / TEMPSENSOR_CAL_VREFANALOG)                                     \
2019
        - (int32_t) *TEMPSENSOR_CAL1_ADDR)                                         \
2020
     ) * (int32_t)(TEMPSENSOR_CAL2_TEMP - TEMPSENSOR_CAL1_TEMP)                    \
2021
    ) / (int32_t)((int32_t)*TEMPSENSOR_CAL2_ADDR - (int32_t)*TEMPSENSOR_CAL1_ADDR) \
2022
   ) + TEMPSENSOR_CAL1_TEMP                                                        \
2023
  )
61 mjames 2024
#endif /* TEMPSENSOR_CAL1_ADDR_CMSIS */
56 mjames 2025
 
2026
/**
2027
  * @brief  Helper macro to calculate the temperature (unit: degree Celsius)
2028
  *         from ADC conversion data of internal temperature sensor.
2029
  * @note   Computation is using temperature sensor typical values
2030
  *         (refer to device datasheet).
2031
  * @note   Calculation formula:
2032
  *           Temperature = (TS_TYP_CALx_VOLT(uV) - TS_ADC_DATA * Conversion_uV)
2033
  *                         / Avg_Slope + CALx_TEMP
2034
  *           with TS_ADC_DATA      = temperature sensor raw data measured by ADC
2035
  *                                   (unit: digital value)
2036
  *                Avg_Slope        = temperature sensor slope
2037
  *                                   (unit: uV/Degree Celsius)
2038
  *                TS_TYP_CALx_VOLT = temperature sensor digital value at
2039
  *                                   temperature CALx_TEMP (unit: mV)
2040
  *         Caution: Calculation relevancy under reserve the temperature sensor
2041
  *                  of the current device has characteristics in line with
2042
  *                  datasheet typical values.
2043
  *                  If temperature sensor calibration values are available on
2044
  *                  on this device (presence of macro __LL_ADC_CALC_TEMPERATURE()),
2045
  *                  temperature calculation will be more accurate using
2046
  *                  helper macro @ref __LL_ADC_CALC_TEMPERATURE().
2047
  * @note   As calculation input, the analog reference voltage (Vref+) must be
2048
  *         defined as it impacts the ADC LSB equivalent voltage.
2049
  * @note   Analog reference voltage (Vref+) must be either known from
2050
  *         user board environment or can be calculated using ADC measurement
2051
  *         and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
2052
  * @note   ADC measurement data must correspond to a resolution of 12bits
2053
  *         (full scale digital value 4095). If not the case, the data must be
2054
  *         preliminarily rescaled to an equivalent resolution of 12 bits.
2055
  * @param  __TEMPSENSOR_TYP_AVGSLOPE__   Device datasheet data: Temperature sensor slope typical value (unit: uV/DegCelsius).
2056
  *                                       On STM32L1, refer to device datasheet parameter "Avg_Slope".
2057
  * @param  __TEMPSENSOR_TYP_CALX_V__     Device datasheet data: Temperature sensor voltage typical value (at temperature and Vref+ defined in parameters below) (unit: mV).
2058
  *                                       On STM32L1, refer to device datasheet parameter "V110" (corresponding to TS_CAL2).
2059
  * @param  __TEMPSENSOR_CALX_TEMP__      Device datasheet data: Temperature at which temperature sensor voltage (see parameter above) is corresponding (unit: mV)
2060
  * @param  __VREFANALOG_VOLTAGE__        Analog voltage reference (Vref+) voltage (unit: mV)
2061
  * @param  __TEMPSENSOR_ADC_DATA__       ADC conversion data of internal temperature sensor (unit: digital value).
2062
  * @param  __ADC_RESOLUTION__            ADC resolution at which internal temperature sensor voltage has been measured.
2063
  *         This parameter can be one of the following values:
2064
  *         @arg @ref LL_ADC_RESOLUTION_12B
2065
  *         @arg @ref LL_ADC_RESOLUTION_10B
2066
  *         @arg @ref LL_ADC_RESOLUTION_8B
2067
  *         @arg @ref LL_ADC_RESOLUTION_6B
2068
  * @retval Temperature (unit: degree Celsius)
2069
  */
2070
#define __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS(__TEMPSENSOR_TYP_AVGSLOPE__,\
2071
                                             __TEMPSENSOR_TYP_CALX_V__,\
2072
                                             __TEMPSENSOR_CALX_TEMP__,\
2073
                                             __VREFANALOG_VOLTAGE__,\
2074
                                             __TEMPSENSOR_ADC_DATA__,\
2075
                                             __ADC_RESOLUTION__)               \
2076
  ((( (                                                                        \
2077
       (int32_t)((((__TEMPSENSOR_ADC_DATA__) * (__VREFANALOG_VOLTAGE__))       \
2078
                  / __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__))                \
2079
                 * 1000)                                                       \
2080
       -                                                                       \
2081
       (int32_t)(((__TEMPSENSOR_TYP_CALX_V__))                                 \
2082
                 * 1000)                                                       \
2083
      )                                                                        \
2084
    ) / (__TEMPSENSOR_TYP_AVGSLOPE__)                                          \
2085
   ) + (__TEMPSENSOR_CALX_TEMP__)                                              \
2086
  )
2087
 
2088
/**
2089
  * @}
2090
  */
2091
 
2092
/**
2093
  * @}
2094
  */
2095
 
2096
 
2097
/* Exported functions --------------------------------------------------------*/
2098
/** @defgroup ADC_LL_Exported_Functions ADC Exported Functions
2099
  * @{
2100
  */
2101
 
2102
/** @defgroup ADC_LL_EF_DMA_Management ADC DMA management
2103
  * @{
2104
  */
2105
/* Note: LL ADC functions to set DMA transfer are located into sections of    */
2106
/*       configuration of ADC instance, groups and multimode (if available):  */
2107
/*       @ref LL_ADC_REG_SetDMATransfer(), ...                                */
2108
 
2109
/**
2110
  * @brief  Function to help to configure DMA transfer from ADC: retrieve the
2111
  *         ADC register address from ADC instance and a list of ADC registers
2112
  *         intended to be used (most commonly) with DMA transfer.
2113
  * @note   These ADC registers are data registers:
2114
  *         when ADC conversion data is available in ADC data registers,
2115
  *         ADC generates a DMA transfer request.
2116
  * @note   This macro is intended to be used with LL DMA driver, refer to
2117
  *         function "LL_DMA_ConfigAddresses()".
2118
  *         Example:
2119
  *           LL_DMA_ConfigAddresses(DMA1,
2120
  *                                  LL_DMA_CHANNEL_1,
2121
  *                                  LL_ADC_DMA_GetRegAddr(ADC1, LL_ADC_DMA_REG_REGULAR_DATA),
2122
  *                                  (uint32_t)&< array or variable >,
2123
  *                                  LL_DMA_DIRECTION_PERIPH_TO_MEMORY);
2124
  * @note   For devices with several ADC: in multimode, some devices
2125
  *         use a different data register outside of ADC instance scope
2126
  *         (common data register). This macro manages this register difference,
2127
  *         only ADC instance has to be set as parameter.
2128
  * @rmtoll DR       DATA           LL_ADC_DMA_GetRegAddr
2129
  * @param  ADCx ADC instance
2130
  * @param  Register This parameter can be one of the following values:
2131
  *         @arg @ref LL_ADC_DMA_REG_REGULAR_DATA
2132
  * @retval ADC register address
2133
  */
2134
__STATIC_INLINE uint32_t LL_ADC_DMA_GetRegAddr(ADC_TypeDef *ADCx, uint32_t Register)
2135
{
2136
  /* Retrieve address of register DR */
2137
  return (uint32_t)&(ADCx->DR);
2138
}
2139
 
2140
/**
2141
  * @}
2142
  */
2143
 
2144
/** @defgroup ADC_LL_EF_Configuration_ADC_Common Configuration of ADC hierarchical scope: common to several ADC instances
2145
  * @{
2146
  */
2147
 
2148
/**
2149
  * @brief  Set parameter common to several ADC: Clock source and prescaler.
2150
  * @note   On this STM32 serie, HSI RC oscillator is the only clock source for ADC.
2151
  *         Therefore, HSI RC oscillator must be preliminarily enabled at RCC top level.
2152
  * @note   On this STM32 serie, some clock ratio constraints between ADC clock and APB clock
2153
  *         must be respected:
2154
  *         - In all cases: if APB clock frequency is too low compared ADC clock frequency, a delay between conversions must be inserted.
2155
  *         - If ADC group injected is used: ADC clock frequency should be lower than APB clock frequency /4 for resolution 12 or 10 bits, APB clock frequency /3 for resolution 8 bits, APB clock frequency /2 for resolution 6 bits.
2156
  *         Refer to reference manual.
2157
  * @rmtoll CCR      ADCPRE         LL_ADC_SetCommonClock
2158
  * @param  ADCxy_COMMON ADC common instance
2159
  *         (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
2160
  * @param  CommonClock This parameter can be one of the following values:
2161
  *         @arg @ref LL_ADC_CLOCK_ASYNC_DIV1
2162
  *         @arg @ref LL_ADC_CLOCK_ASYNC_DIV2
2163
  *         @arg @ref LL_ADC_CLOCK_ASYNC_DIV4
2164
  * @retval None
2165
  */
2166
__STATIC_INLINE void LL_ADC_SetCommonClock(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t CommonClock)
2167
{
2168
  MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_ADCPRE, CommonClock);
2169
}
2170
 
2171
/**
2172
  * @brief  Get parameter common to several ADC: Clock source and prescaler.
2173
  * @rmtoll CCR      ADCPRE         LL_ADC_GetCommonClock
2174
  * @param  ADCxy_COMMON ADC common instance
2175
  *         (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
2176
  * @retval Returned value can be one of the following values:
2177
  *         @arg @ref LL_ADC_CLOCK_ASYNC_DIV1
2178
  *         @arg @ref LL_ADC_CLOCK_ASYNC_DIV2
2179
  *         @arg @ref LL_ADC_CLOCK_ASYNC_DIV4
2180
  */
2181
__STATIC_INLINE uint32_t LL_ADC_GetCommonClock(ADC_Common_TypeDef *ADCxy_COMMON)
2182
{
2183
  return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_ADCPRE));
2184
}
2185
 
2186
/**
2187
  * @brief  Set parameter common to several ADC: measurement path to internal
2188
  *         channels (VrefInt, temperature sensor, ...).
2189
  * @note   One or several values can be selected.
2190
  *         Example: (LL_ADC_PATH_INTERNAL_VREFINT |
2191
  *                   LL_ADC_PATH_INTERNAL_TEMPSENSOR)
2192
  * @note   Stabilization time of measurement path to internal channel:
2193
  *         After enabling internal paths, before starting ADC conversion,
2194
  *         a delay is required for internal voltage reference and
2195
  *         temperature sensor stabilization time.
2196
  *         Refer to device datasheet.
2197
  *         Refer to literal @ref LL_ADC_DELAY_VREFINT_STAB_US.
2198
  *         Refer to literal @ref LL_ADC_DELAY_TEMPSENSOR_STAB_US.
2199
  * @note   ADC internal channel sampling time constraint:
2200
  *         For ADC conversion of internal channels,
2201
  *         a sampling time minimum value is required.
2202
  *         Refer to device datasheet.
2203
  * @rmtoll CCR      TSVREFE        LL_ADC_SetCommonPathInternalCh
2204
  * @param  ADCxy_COMMON ADC common instance
2205
  *         (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
2206
  * @param  PathInternal This parameter can be a combination of the following values:
2207
  *         @arg @ref LL_ADC_PATH_INTERNAL_NONE
2208
  *         @arg @ref LL_ADC_PATH_INTERNAL_VREFINT
2209
  *         @arg @ref LL_ADC_PATH_INTERNAL_TEMPSENSOR
2210
  * @retval None
2211
  */
2212
__STATIC_INLINE void LL_ADC_SetCommonPathInternalCh(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t PathInternal)
2213
{
2214
  MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_TSVREFE, PathInternal);
2215
}
2216
 
2217
/**
2218
  * @brief  Get parameter common to several ADC: measurement path to internal
2219
  *         channels (VrefInt, temperature sensor, ...).
2220
  * @note   One or several values can be selected.
2221
  *         Example: (LL_ADC_PATH_INTERNAL_VREFINT |
2222
  *                   LL_ADC_PATH_INTERNAL_TEMPSENSOR)
2223
  * @rmtoll CCR      TSVREFE        LL_ADC_GetCommonPathInternalCh
2224
  * @param  ADCxy_COMMON ADC common instance
2225
  *         (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
2226
  * @retval Returned value can be a combination of the following values:
2227
  *         @arg @ref LL_ADC_PATH_INTERNAL_NONE
2228
  *         @arg @ref LL_ADC_PATH_INTERNAL_VREFINT
2229
  *         @arg @ref LL_ADC_PATH_INTERNAL_TEMPSENSOR
2230
  */
2231
__STATIC_INLINE uint32_t LL_ADC_GetCommonPathInternalCh(ADC_Common_TypeDef *ADCxy_COMMON)
2232
{
2233
  return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_TSVREFE));
2234
}
2235
 
2236
/**
2237
  * @}
2238
  */
2239
 
2240
/** @defgroup ADC_LL_EF_Configuration_ADC_Instance Configuration of ADC hierarchical scope: ADC instance
2241
  * @{
2242
  */
2243
 
2244
/**
2245
  * @brief  Set ADC resolution.
2246
  *         Refer to reference manual for alignments formats
2247
  *         dependencies to ADC resolutions.
2248
  * @rmtoll CR1      RES            LL_ADC_SetResolution
2249
  * @param  ADCx ADC instance
2250
  * @param  Resolution This parameter can be one of the following values:
2251
  *         @arg @ref LL_ADC_RESOLUTION_12B
2252
  *         @arg @ref LL_ADC_RESOLUTION_10B
2253
  *         @arg @ref LL_ADC_RESOLUTION_8B
2254
  *         @arg @ref LL_ADC_RESOLUTION_6B
2255
  * @retval None
2256
  */
2257
__STATIC_INLINE void LL_ADC_SetResolution(ADC_TypeDef *ADCx, uint32_t Resolution)
2258
{
2259
  MODIFY_REG(ADCx->CR1, ADC_CR1_RES, Resolution);
2260
}
2261
 
2262
/**
2263
  * @brief  Get ADC resolution.
2264
  *         Refer to reference manual for alignments formats
2265
  *         dependencies to ADC resolutions.
2266
  * @rmtoll CR1      RES            LL_ADC_GetResolution
2267
  * @param  ADCx ADC instance
2268
  * @retval Returned value can be one of the following values:
2269
  *         @arg @ref LL_ADC_RESOLUTION_12B
2270
  *         @arg @ref LL_ADC_RESOLUTION_10B
2271
  *         @arg @ref LL_ADC_RESOLUTION_8B
2272
  *         @arg @ref LL_ADC_RESOLUTION_6B
2273
  */
2274
__STATIC_INLINE uint32_t LL_ADC_GetResolution(ADC_TypeDef *ADCx)
2275
{
2276
  return (uint32_t)(READ_BIT(ADCx->CR1, ADC_CR1_RES));
2277
}
2278
 
2279
/**
2280
  * @brief  Set ADC conversion data alignment.
2281
  * @note   Refer to reference manual for alignments formats
2282
  *         dependencies to ADC resolutions.
2283
  * @rmtoll CR2      ALIGN          LL_ADC_SetDataAlignment
2284
  * @param  ADCx ADC instance
2285
  * @param  DataAlignment This parameter can be one of the following values:
2286
  *         @arg @ref LL_ADC_DATA_ALIGN_RIGHT
2287
  *         @arg @ref LL_ADC_DATA_ALIGN_LEFT
2288
  * @retval None
2289
  */
2290
__STATIC_INLINE void LL_ADC_SetDataAlignment(ADC_TypeDef *ADCx, uint32_t DataAlignment)
2291
{
2292
  MODIFY_REG(ADCx->CR2, ADC_CR2_ALIGN, DataAlignment);
2293
}
2294
 
2295
/**
2296
  * @brief  Get ADC conversion data alignment.
2297
  * @note   Refer to reference manual for alignments formats
2298
  *         dependencies to ADC resolutions.
2299
  * @rmtoll CR2      ALIGN          LL_ADC_SetDataAlignment
2300
  * @param  ADCx ADC instance
2301
  * @retval Returned value can be one of the following values:
2302
  *         @arg @ref LL_ADC_DATA_ALIGN_RIGHT
2303
  *         @arg @ref LL_ADC_DATA_ALIGN_LEFT
2304
  */
2305
__STATIC_INLINE uint32_t LL_ADC_GetDataAlignment(ADC_TypeDef *ADCx)
2306
{
2307
  return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_ALIGN));
2308
}
2309
 
2310
/**
2311
  * @brief  Set ADC low power mode auto wait.
2312
  * @note   Description of ADC low power modes:
2313
  *         - ADC low power mode "auto wait": Dynamic low power mode,
2314
  *           ADC conversions occurrences are limited to the minimum necessary
2315
  *           in order to reduce power consumption.
2316
  *           New ADC conversion starts only when the previous
2317
  *           unitary conversion data (for ADC group regular)
2318
  *           or previous sequence conversions data (for ADC group injected)
2319
  *           has been retrieved by user software.
2320
  *           In the meantime, ADC remains idle: does not performs any
2321
  *           other conversion.
2322
  *           This mode allows to automatically adapt the ADC conversions
2323
  *           triggers to the speed of the software that reads the data.
2324
  *           Moreover, this avoids risk of overrun for low frequency
2325
  *           applications.
2326
  *           How to use this low power mode:
2327
  *           - Do not use with interruption or DMA since these modes
2328
  *             have to clear immediately the EOC flag to free the
2329
  *             IRQ vector sequencer.
2330
  *           - Do use with polling: 1. Start conversion,
2331
  *             2. Later on, when conversion data is needed: poll for end of
2332
  *             conversion  to ensure that conversion is completed and
2333
  *             retrieve ADC conversion data. This will trig another
2334
  *             ADC conversion start.
2335
  *         - ADC low power mode "auto power-off":
2336
  *           refer to function @ref LL_ADC_SetLowPowerModeAutoPowerOff().
2337
  * @note   With ADC low power mode "auto wait", the ADC conversion data read
2338
  *         is corresponding to previous ADC conversion start, independently
2339
  *         of delay during which ADC was idle.
2340
  *         Therefore, the ADC conversion data may be outdated: does not
2341
  *         correspond to the current voltage level on the selected
2342
  *         ADC channel.
2343
  * @rmtoll CR2      DELS           LL_ADC_SetLowPowerModeAutoWait
2344
  * @param  ADCx ADC instance
2345
  * @param  LowPowerModeAutoWait This parameter can be one of the following values:
2346
  *         @arg @ref LL_ADC_LP_AUTOWAIT_NONE
2347
  *         @arg @ref LL_ADC_LP_AUTOWAIT
2348
  *         @arg @ref LL_ADC_LP_AUTOWAIT_7_APBCLOCKCYCLES
2349
  *         @arg @ref LL_ADC_LP_AUTOWAIT_15_APBCLOCKCYCLES
2350
  *         @arg @ref LL_ADC_LP_AUTOWAIT_31_APBCLOCKCYCLES
2351
  *         @arg @ref LL_ADC_LP_AUTOWAIT_63_APBCLOCKCYCLES
2352
  *         @arg @ref LL_ADC_LP_AUTOWAIT_127_APBCLOCKCYCLES
2353
  *         @arg @ref LL_ADC_LP_AUTOWAIT_255_APBCLOCKCYCLES
2354
  * @retval None
2355
  */
2356
__STATIC_INLINE void LL_ADC_SetLowPowerModeAutoWait(ADC_TypeDef *ADCx, uint32_t LowPowerModeAutoWait)
2357
{
2358
  MODIFY_REG(ADCx->CR2, ADC_CR2_DELS, LowPowerModeAutoWait);
2359
}
2360
 
2361
/**
2362
  * @brief  Get ADC low power mode auto wait.
2363
  * @note   Description of ADC low power modes:
2364
  *         - ADC low power mode "auto wait": Dynamic low power mode,
2365
  *           ADC conversions occurrences are limited to the minimum necessary
2366
  *           in order to reduce power consumption.
2367
  *           New ADC conversion starts only when the previous
2368
  *           unitary conversion data (for ADC group regular)
2369
  *           or previous sequence conversions data (for ADC group injected)
2370
  *           has been retrieved by user software.
2371
  *           In the meantime, ADC remains idle: does not performs any
2372
  *           other conversion.
2373
  *           This mode allows to automatically adapt the ADC conversions
2374
  *           triggers to the speed of the software that reads the data.
2375
  *           Moreover, this avoids risk of overrun for low frequency
2376
  *           applications.
2377
  *           How to use this low power mode:
2378
  *           - Do not use with interruption or DMA since these modes
2379
  *             have to clear immediately the EOC flag to free the
2380
  *             IRQ vector sequencer.
2381
  *           - Do use with polling: 1. Start conversion,
2382
  *             2. Later on, when conversion data is needed: poll for end of
2383
  *             conversion  to ensure that conversion is completed and
2384
  *             retrieve ADC conversion data. This will trig another
2385
  *             ADC conversion start.
2386
  *         - ADC low power mode "auto power-off":
2387
  *           refer to function @ref LL_ADC_SetLowPowerModeAutoPowerOff().
2388
  * @note   With ADC low power mode "auto wait", the ADC conversion data read
2389
  *         is corresponding to previous ADC conversion start, independently
2390
  *         of delay during which ADC was idle.
2391
  *         Therefore, the ADC conversion data may be outdated: does not
2392
  *         correspond to the current voltage level on the selected
2393
  *         ADC channel.
2394
  * @rmtoll CR2      DELS           LL_ADC_GetLowPowerModeAutoWait
2395
  * @param  ADCx ADC instance
2396
  * @retval Returned value can be one of the following values:
2397
  *         @arg @ref LL_ADC_LP_AUTOWAIT_NONE
2398
  *         @arg @ref LL_ADC_LP_AUTOWAIT
2399
  *         @arg @ref LL_ADC_LP_AUTOWAIT_7_APBCLOCKCYCLES
2400
  *         @arg @ref LL_ADC_LP_AUTOWAIT_15_APBCLOCKCYCLES
2401
  *         @arg @ref LL_ADC_LP_AUTOWAIT_31_APBCLOCKCYCLES
2402
  *         @arg @ref LL_ADC_LP_AUTOWAIT_63_APBCLOCKCYCLES
2403
  *         @arg @ref LL_ADC_LP_AUTOWAIT_127_APBCLOCKCYCLES
2404
  *         @arg @ref LL_ADC_LP_AUTOWAIT_255_APBCLOCKCYCLES
2405
  */
2406
__STATIC_INLINE uint32_t LL_ADC_GetLowPowerModeAutoWait(ADC_TypeDef *ADCx)
2407
{
2408
  return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_DELS));
2409
}
2410
 
2411
/**
2412
  * @brief  Set ADC low power mode auto power-off.
2413
  * @note   Description of ADC low power modes:
2414
  *         - ADC low power mode "auto wait":
2415
  *           refer to function @ref LL_ADC_SetLowPowerModeAutoWait().
2416
  *         - ADC low power mode "auto power-off":
2417
  *           the ADC automatically powers-off after a conversion and
2418
  *           automatically wakes up when a new conversion is triggered
2419
  *           (with startup time between trigger and start of sampling).
2420
  *           This feature can be combined with low power mode "auto wait".
2421
  * @rmtoll CR1      PDI            LL_ADC_GetLowPowerModeAutoPowerOff\n
2422
  *         CR1      PDD            LL_ADC_GetLowPowerModeAutoPowerOff
2423
  * @param  ADCx ADC instance
2424
  * @param  LowPowerModeAutoPowerOff This parameter can be one of the following values:
2425
  *         @arg @ref LL_ADC_LP_AUTOPOWEROFF_NONE
2426
  *         @arg @ref LL_ADC_LP_AUTOPOWEROFF_IDLE_PHASE
2427
  *         @arg @ref LL_ADC_LP_AUTOPOWEROFF_AUTOWAIT_PHASE
2428
  *         @arg @ref LL_ADC_LP_AUTOPOWEROFF_IDLE_AUTOWAIT_PHASES
2429
  * @retval None
2430
  */
2431
__STATIC_INLINE void LL_ADC_SetLowPowerModeAutoPowerOff(ADC_TypeDef *ADCx, uint32_t LowPowerModeAutoPowerOff)
2432
{
2433
  MODIFY_REG(ADCx->CR1, (ADC_CR1_PDI | ADC_CR1_PDD), LowPowerModeAutoPowerOff);
2434
}
2435
 
2436
/**
2437
  * @brief  Get ADC low power mode auto power-off.
2438
  * @note   Description of ADC low power modes:
2439
  *         - ADC low power mode "auto wait":
2440
  *           refer to function @ref LL_ADC_SetLowPowerModeAutoWait().
2441
  *         - ADC low power mode "auto power-off":
2442
  *           the ADC automatically powers-off after a conversion and
2443
  *           automatically wakes up when a new conversion is triggered
2444
  *           (with startup time between trigger and start of sampling).
2445
  *           This feature can be combined with low power mode "auto wait".
2446
  * @rmtoll CR1      PDI            LL_ADC_GetLowPowerModeAutoPowerOff\n
2447
  *         CR1      PDD            LL_ADC_GetLowPowerModeAutoPowerOff
2448
  * @param  ADCx ADC instance
2449
  * @retval Returned value can be one of the following values:
2450
  *         @arg @ref LL_ADC_LP_AUTOPOWEROFF_NONE
2451
  *         @arg @ref LL_ADC_LP_AUTOPOWEROFF_IDLE_PHASE
2452
  *         @arg @ref LL_ADC_LP_AUTOPOWEROFF_AUTOWAIT_PHASE
2453
  *         @arg @ref LL_ADC_LP_AUTOPOWEROFF_IDLE_AUTOWAIT_PHASES
2454
  */
2455
__STATIC_INLINE uint32_t LL_ADC_GetLowPowerModeAutoPowerOff(ADC_TypeDef *ADCx)
2456
{
2457
  return (uint32_t)(READ_BIT(ADCx->CR1, (ADC_CR1_PDI | ADC_CR1_PDD)));
2458
}
2459
 
2460
/**
2461
  * @brief  Set ADC sequencers scan mode, for all ADC groups
2462
  *         (group regular, group injected).
2463
  * @note  According to sequencers scan mode :
2464
  *         - If disabled: ADC conversion is performed in unitary conversion
2465
  *           mode (one channel converted, that defined in rank 1).
2466
  *           Configuration of sequencers of all ADC groups
2467
  *           (sequencer scan length, ...) is discarded: equivalent to
2468
  *           scan length of 1 rank.
2469
  *         - If enabled: ADC conversions are performed in sequence conversions
2470
  *           mode, according to configuration of sequencers of
2471
  *           each ADC group (sequencer scan length, ...).
2472
  *           Refer to function @ref LL_ADC_REG_SetSequencerLength()
2473
  *           and to function @ref LL_ADC_INJ_SetSequencerLength().
2474
  * @note   On this STM32 serie, setting of this feature is conditioned to
2475
  *         ADC state:
2476
  *         ADC must be disabled or enabled without conversion on going
2477
  *         on either groups regular or injected.
2478
  * @rmtoll CR1      SCAN           LL_ADC_SetSequencersScanMode
2479
  * @param  ADCx ADC instance
2480
  * @param  ScanMode This parameter can be one of the following values:
2481
  *         @arg @ref LL_ADC_SEQ_SCAN_DISABLE
2482
  *         @arg @ref LL_ADC_SEQ_SCAN_ENABLE
2483
  * @retval None
2484
  */
2485
__STATIC_INLINE void LL_ADC_SetSequencersScanMode(ADC_TypeDef *ADCx, uint32_t ScanMode)
2486
{
2487
  MODIFY_REG(ADCx->CR1, ADC_CR1_SCAN, ScanMode);
2488
}
2489
 
2490
/**
2491
  * @brief  Get ADC sequencers scan mode, for all ADC groups
2492
  *         (group regular, group injected).
2493
  * @note  According to sequencers scan mode :
2494
  *         - If disabled: ADC conversion is performed in unitary conversion
2495
  *           mode (one channel converted, that defined in rank 1).
2496
  *           Configuration of sequencers of all ADC groups
2497
  *           (sequencer scan length, ...) is discarded: equivalent to
2498
  *           scan length of 1 rank.
2499
  *         - If enabled: ADC conversions are performed in sequence conversions
2500
  *           mode, according to configuration of sequencers of
2501
  *           each ADC group (sequencer scan length, ...).
2502
  *           Refer to function @ref LL_ADC_REG_SetSequencerLength()
2503
  *           and to function @ref LL_ADC_INJ_SetSequencerLength().
2504
  * @rmtoll CR1      SCAN           LL_ADC_GetSequencersScanMode
2505
  * @param  ADCx ADC instance
2506
  * @retval Returned value can be one of the following values:
2507
  *         @arg @ref LL_ADC_SEQ_SCAN_DISABLE
2508
  *         @arg @ref LL_ADC_SEQ_SCAN_ENABLE
2509
  */
2510
__STATIC_INLINE uint32_t LL_ADC_GetSequencersScanMode(ADC_TypeDef *ADCx)
2511
{
2512
  return (uint32_t)(READ_BIT(ADCx->CR1, ADC_CR1_SCAN));
2513
}
2514
 
2515
#if defined(ADC_CR2_CFG)
2516
/**
2517
  * @brief  Set ADC channels bank.
2518
  * @note   Bank selected applies to ADC scope, on all channels
2519
  *         (independently of channel mapped on ADC group regular
2520
  *         or group injected).
2521
  * @note   Banks availability depends on devices categories.
2522
  * @note   On this STM32 serie, setting of this feature is conditioned to
2523
  *         ADC state:
2524
  *         ADC must be disabled or enabled without conversion on going
2525
  *         on either groups regular or injected.
2526
  * @rmtoll CR2      ADC_CFG        LL_ADC_SetChannelsBank
2527
  * @param  ADCx ADC instance
2528
  * @param  ChannelsBank This parameter can be one of the following values:
2529
  *         @arg @ref LL_ADC_CHANNELS_BANK_A
2530
  *         @arg @ref LL_ADC_CHANNELS_BANK_B
2531
  * @retval None
2532
  */
2533
__STATIC_INLINE void LL_ADC_SetChannelsBank(ADC_TypeDef *ADCx, uint32_t ChannelsBank)
2534
{
2535
  MODIFY_REG(ADCx->CR2, ADC_CR2_CFG, ChannelsBank);
2536
}
2537
 
2538
/**
2539
  * @brief  Get ADC channels bank.
2540
  * @note   Bank selected applies to ADC scope, on all channels
2541
  *         (independently of channel mapped on ADC group regular
2542
  *         or group injected).
2543
  * @note   Banks availability depends on devices categories.
2544
  * @rmtoll CR2      ADC_CFG        LL_ADC_GetChannelsBank
2545
  * @param  ADCx ADC instance
2546
  * @retval Returned value can be one of the following values:
2547
  *         @arg @ref LL_ADC_CHANNELS_BANK_A
2548
  *         @arg @ref LL_ADC_CHANNELS_BANK_B
2549
  */
2550
__STATIC_INLINE uint32_t LL_ADC_GetChannelsBank(ADC_TypeDef *ADCx)
2551
{
2552
  return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_CFG));
2553
}
2554
#endif
2555
 
2556
/**
2557
  * @}
2558
  */
2559
 
2560
/** @defgroup ADC_LL_EF_Configuration_ADC_Group_Regular Configuration of ADC hierarchical scope: group regular
2561
  * @{
2562
  */
2563
 
2564
/**
2565
  * @brief  Set ADC group regular conversion trigger source:
2566
  *         internal (SW start) or from external IP (timer event,
2567
  *         external interrupt line).
2568
  * @note   On this STM32 serie, setting of external trigger edge is performed
2569
  *         using function @ref LL_ADC_REG_StartConversionExtTrig().
2570
  * @note   Availability of parameters of trigger sources from timer
2571
  *         depends on timers availability on the selected device.
2572
  * @rmtoll CR2      EXTSEL         LL_ADC_REG_SetTriggerSource\n
2573
  *         CR2      EXTEN          LL_ADC_REG_SetTriggerSource
2574
  * @param  ADCx ADC instance
2575
  * @param  TriggerSource This parameter can be one of the following values:
2576
  *         @arg @ref LL_ADC_REG_TRIG_SOFTWARE
2577
  *         @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_TRGO
2578
  *         @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH3
2579
  *         @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_TRGO
2580
  *         @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH2
2581
  *         @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_CH1
2582
  *         @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_CH3
2583
  *         @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_TRGO
2584
  *         @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_CH4
2585
  *         @arg @ref LL_ADC_REG_TRIG_EXT_TIM6_TRGO
2586
  *         @arg @ref LL_ADC_REG_TRIG_EXT_TIM9_CH2
2587
  *         @arg @ref LL_ADC_REG_TRIG_EXT_TIM9_TRGO
2588
  *         @arg @ref LL_ADC_REG_TRIG_EXT_EXTI_LINE11
2589
  * @retval None
2590
  */
2591
__STATIC_INLINE void LL_ADC_REG_SetTriggerSource(ADC_TypeDef *ADCx, uint32_t TriggerSource)
2592
{
2593
/* Note: On this STM32 serie, ADC group regular external trigger edge        */
2594
/*       is used to perform a ADC conversion start.                           */
2595
/*       This function does not set external trigger edge.                    */
2596
/*       This feature is set using function                                   */
2597
/*       @ref LL_ADC_REG_StartConversionExtTrig().                            */
2598
  MODIFY_REG(ADCx->CR2, ADC_CR2_EXTSEL, (TriggerSource & ADC_CR2_EXTSEL));
2599
}
2600
 
2601
/**
2602
  * @brief  Get ADC group regular conversion trigger source:
2603
  *         internal (SW start) or from external IP (timer event,
2604
  *         external interrupt line).
2605
  * @note   To determine whether group regular trigger source is
2606
  *         internal (SW start) or external, without detail
2607
  *         of which peripheral is selected as external trigger,
2608
  *         (equivalent to
2609
  *         "if(LL_ADC_REG_GetTriggerSource(ADC1) == LL_ADC_REG_TRIG_SOFTWARE)")
2610
  *         use function @ref LL_ADC_REG_IsTriggerSourceSWStart.
2611
  * @note   Availability of parameters of trigger sources from timer
2612
  *         depends on timers availability on the selected device.
2613
  * @rmtoll CR2      EXTSEL         LL_ADC_REG_GetTriggerSource\n
2614
  *         CR2      EXTEN          LL_ADC_REG_GetTriggerSource
2615
  * @param  ADCx ADC instance
2616
  * @retval Returned value can be one of the following values:
2617
  *         @arg @ref LL_ADC_REG_TRIG_SOFTWARE
2618
  *         @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_TRGO
2619
  *         @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH3
2620
  *         @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_TRGO
2621
  *         @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH2
2622
  *         @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_CH1
2623
  *         @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_CH3
2624
  *         @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_TRGO
2625
  *         @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_CH4
2626
  *         @arg @ref LL_ADC_REG_TRIG_EXT_TIM6_TRGO
2627
  *         @arg @ref LL_ADC_REG_TRIG_EXT_TIM9_CH2
2628
  *         @arg @ref LL_ADC_REG_TRIG_EXT_TIM9_TRGO
2629
  *         @arg @ref LL_ADC_REG_TRIG_EXT_EXTI_LINE11
2630
  */
2631
__STATIC_INLINE uint32_t LL_ADC_REG_GetTriggerSource(ADC_TypeDef *ADCx)
2632
{
2633
  uint32_t TriggerSource = READ_BIT(ADCx->CR2, ADC_CR2_EXTSEL | ADC_CR2_EXTEN);
2634
 
2635
  /* Value for shift of {0; 4; 8; 12} depending on value of bitfield          */
2636
  /* corresponding to ADC_CR2_EXTEN {0; 1; 2; 3}.                             */
2637
  uint32_t ShiftExten = ((TriggerSource & ADC_CR2_EXTEN) >> (ADC_REG_TRIG_EXTEN_BITOFFSET_POS - 2U));
2638
 
2639
  /* Set bitfield corresponding to ADC_CR2_EXTEN and ADC_CR2_EXTSEL           */
2640
  /* to match with triggers literals definition.                              */
2641
  return ((TriggerSource
2642
           & (ADC_REG_TRIG_SOURCE_MASK << ShiftExten) & ADC_CR2_EXTSEL)
2643
          | ((ADC_REG_TRIG_EDGE_MASK << ShiftExten) & ADC_CR2_EXTEN)
2644
         );
2645
}
2646
 
2647
/**
2648
  * @brief  Get ADC group regular conversion trigger source internal (SW start)
2649
            or external.
2650
  * @note   In case of group regular trigger source set to external trigger,
2651
  *         to determine which peripheral is selected as external trigger,
2652
  *         use function @ref LL_ADC_REG_GetTriggerSource().
2653
  * @rmtoll CR2      EXTEN          LL_ADC_REG_IsTriggerSourceSWStart
2654
  * @param  ADCx ADC instance
2655
  * @retval Value "0" if trigger source external trigger
2656
  *         Value "1" if trigger source SW start.
2657
  */
2658
__STATIC_INLINE uint32_t LL_ADC_REG_IsTriggerSourceSWStart(ADC_TypeDef *ADCx)
2659
{
2660
  return (READ_BIT(ADCx->CR2, ADC_CR2_EXTEN) == (LL_ADC_REG_TRIG_SOFTWARE & ADC_CR2_EXTEN));
2661
}
2662
 
2663
/**
2664
  * @brief  Get ADC group regular conversion trigger polarity.
2665
  * @note   Applicable only for trigger source set to external trigger.
2666
  * @note   On this STM32 serie, setting of external trigger edge is performed
2667
  *         using function @ref LL_ADC_REG_StartConversionExtTrig().
2668
  * @rmtoll CR2      EXTEN          LL_ADC_REG_GetTriggerEdge
2669
  * @param  ADCx ADC instance
2670
  * @retval Returned value can be one of the following values:
2671
  *         @arg @ref LL_ADC_REG_TRIG_EXT_RISING
2672
  *         @arg @ref LL_ADC_REG_TRIG_EXT_FALLING
2673
  *         @arg @ref LL_ADC_REG_TRIG_EXT_RISINGFALLING
2674
  */
2675
__STATIC_INLINE uint32_t LL_ADC_REG_GetTriggerEdge(ADC_TypeDef *ADCx)
2676
{
2677
  return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_EXTEN));
2678
}
2679
 
2680
 
2681
/**
2682
  * @brief  Set ADC group regular sequencer length and scan direction.
2683
  * @note   Description of ADC group regular sequencer features:
2684
  *         - For devices with sequencer fully configurable
2685
  *           (function "LL_ADC_REG_SetSequencerRanks()" available):
2686
  *           sequencer length and each rank affectation to a channel
2687
  *           are configurable.
2688
  *           This function performs configuration of:
2689
  *           - Sequence length: Number of ranks in the scan sequence.
2690
  *           - Sequence direction: Unless specified in parameters, sequencer
2691
  *             scan direction is forward (from rank 1 to rank n).
2692
  *           Sequencer ranks are selected using
2693
  *           function "LL_ADC_REG_SetSequencerRanks()".
2694
  *         - For devices with sequencer not fully configurable
2695
  *           (function "LL_ADC_REG_SetSequencerChannels()" available):
2696
  *           sequencer length and each rank affectation to a channel
2697
  *           are defined by channel number.
2698
  *           This function performs configuration of:
2699
  *           - Sequence length: Number of ranks in the scan sequence is
2700
  *             defined by number of channels set in the sequence,
2701
  *             rank of each channel is fixed by channel HW number.
2702
  *             (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
2703
  *           - Sequence direction: Unless specified in parameters, sequencer
2704
  *             scan direction is forward (from lowest channel number to
2705
  *             highest channel number).
2706
  *           Sequencer ranks are selected using
2707
  *           function "LL_ADC_REG_SetSequencerChannels()".
2708
  * @note   On this STM32 serie, group regular sequencer configuration
2709
  *         is conditioned to ADC instance sequencer mode.
2710
  *         If ADC instance sequencer mode is disabled, sequencers of
2711
  *         all groups (group regular, group injected) can be configured
2712
  *         but their execution is disabled (limited to rank 1).
2713
  *         Refer to function @ref LL_ADC_SetSequencersScanMode().
2714
  * @note   Sequencer disabled is equivalent to sequencer of 1 rank:
2715
  *         ADC conversion on only 1 channel.
2716
  * @rmtoll SQR1     L              LL_ADC_REG_SetSequencerLength
2717
  * @param  ADCx ADC instance
2718
  * @param  SequencerNbRanks This parameter can be one of the following values:
2719
  *         @arg @ref LL_ADC_REG_SEQ_SCAN_DISABLE
2720
  *         @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS
2721
  *         @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS
2722
  *         @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_4RANKS
2723
  *         @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS
2724
  *         @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS
2725
  *         @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_7RANKS
2726
  *         @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_8RANKS
2727
  *         @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS
2728
  *         @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_10RANKS
2729
  *         @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_11RANKS
2730
  *         @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_12RANKS
2731
  *         @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_13RANKS
2732
  *         @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_14RANKS
2733
  *         @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_15RANKS
2734
  *         @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_16RANKS
2735
  * @retval None
2736
  */
2737
__STATIC_INLINE void LL_ADC_REG_SetSequencerLength(ADC_TypeDef *ADCx, uint32_t SequencerNbRanks)
2738
{
2739
  MODIFY_REG(ADCx->SQR1, ADC_SQR1_L, SequencerNbRanks);
2740
}
2741
 
2742
/**
2743
  * @brief  Get ADC group regular sequencer length and scan direction.
2744
  * @note   Description of ADC group regular sequencer features:
2745
  *         - For devices with sequencer fully configurable
2746
  *           (function "LL_ADC_REG_SetSequencerRanks()" available):
2747
  *           sequencer length and each rank affectation to a channel
2748
  *           are configurable.
2749
  *           This function retrieves:
2750
  *           - Sequence length: Number of ranks in the scan sequence.
2751
  *           - Sequence direction: Unless specified in parameters, sequencer
2752
  *             scan direction is forward (from rank 1 to rank n).
2753
  *           Sequencer ranks are selected using
2754
  *           function "LL_ADC_REG_SetSequencerRanks()".
2755
  *         - For devices with sequencer not fully configurable
2756
  *           (function "LL_ADC_REG_SetSequencerChannels()" available):
2757
  *           sequencer length and each rank affectation to a channel
2758
  *           are defined by channel number.
2759
  *           This function retrieves:
2760
  *           - Sequence length: Number of ranks in the scan sequence is
2761
  *             defined by number of channels set in the sequence,
2762
  *             rank of each channel is fixed by channel HW number.
2763
  *             (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
2764
  *           - Sequence direction: Unless specified in parameters, sequencer
2765
  *             scan direction is forward (from lowest channel number to
2766
  *             highest channel number).
2767
  *           Sequencer ranks are selected using
2768
  *           function "LL_ADC_REG_SetSequencerChannels()".
2769
  * @note   On this STM32 serie, group regular sequencer configuration
2770
  *         is conditioned to ADC instance sequencer mode.
2771
  *         If ADC instance sequencer mode is disabled, sequencers of
2772
  *         all groups (group regular, group injected) can be configured
2773
  *         but their execution is disabled (limited to rank 1).
2774
  *         Refer to function @ref LL_ADC_SetSequencersScanMode().
2775
  * @note   Sequencer disabled is equivalent to sequencer of 1 rank:
2776
  *         ADC conversion on only 1 channel.
2777
  * @rmtoll SQR1     L              LL_ADC_REG_SetSequencerLength
2778
  * @param  ADCx ADC instance
2779
  * @retval Returned value can be one of the following values:
2780
  *         @arg @ref LL_ADC_REG_SEQ_SCAN_DISABLE
2781
  *         @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS
2782
  *         @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS
2783
  *         @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_4RANKS
2784
  *         @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS
2785
  *         @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS
2786
  *         @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_7RANKS
2787
  *         @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_8RANKS
2788
  *         @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS
2789
  *         @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_10RANKS
2790
  *         @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_11RANKS
2791
  *         @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_12RANKS
2792
  *         @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_13RANKS
2793
  *         @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_14RANKS
2794
  *         @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_15RANKS
2795
  *         @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_16RANKS
2796
  */
2797
__STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerLength(ADC_TypeDef *ADCx)
2798
{
2799
  return (uint32_t)(READ_BIT(ADCx->SQR1, ADC_SQR1_L));
2800
}
2801
 
2802
/**
2803
  * @brief  Set ADC group regular sequencer discontinuous mode:
2804
  *         sequence subdivided and scan conversions interrupted every selected
2805
  *         number of ranks.
2806
  * @note   It is not possible to enable both ADC group regular
2807
  *         continuous mode and sequencer discontinuous mode.
2808
  * @note   It is not possible to enable both ADC auto-injected mode
2809
  *         and ADC group regular sequencer discontinuous mode.
2810
  * @rmtoll CR1      DISCEN         LL_ADC_REG_SetSequencerDiscont\n
2811
  *         CR1      DISCNUM        LL_ADC_REG_SetSequencerDiscont
2812
  * @param  ADCx ADC instance
2813
  * @param  SeqDiscont This parameter can be one of the following values:
2814
  *         @arg @ref LL_ADC_REG_SEQ_DISCONT_DISABLE
2815
  *         @arg @ref LL_ADC_REG_SEQ_DISCONT_1RANK
2816
  *         @arg @ref LL_ADC_REG_SEQ_DISCONT_2RANKS
2817
  *         @arg @ref LL_ADC_REG_SEQ_DISCONT_3RANKS
2818
  *         @arg @ref LL_ADC_REG_SEQ_DISCONT_4RANKS
2819
  *         @arg @ref LL_ADC_REG_SEQ_DISCONT_5RANKS
2820
  *         @arg @ref LL_ADC_REG_SEQ_DISCONT_6RANKS
2821
  *         @arg @ref LL_ADC_REG_SEQ_DISCONT_7RANKS
2822
  *         @arg @ref LL_ADC_REG_SEQ_DISCONT_8RANKS
2823
  * @retval None
2824
  */
2825
__STATIC_INLINE void LL_ADC_REG_SetSequencerDiscont(ADC_TypeDef *ADCx, uint32_t SeqDiscont)
2826
{
2827
  MODIFY_REG(ADCx->CR1, ADC_CR1_DISCEN | ADC_CR1_DISCNUM, SeqDiscont);
2828
}
2829
 
2830
/**
2831
  * @brief  Get ADC group regular sequencer discontinuous mode:
2832
  *         sequence subdivided and scan conversions interrupted every selected
2833
  *         number of ranks.
2834
  * @rmtoll CR1      DISCEN         LL_ADC_REG_GetSequencerDiscont\n
2835
  *         CR1      DISCNUM        LL_ADC_REG_GetSequencerDiscont
2836
  * @param  ADCx ADC instance
2837
  * @retval Returned value can be one of the following values:
2838
  *         @arg @ref LL_ADC_REG_SEQ_DISCONT_DISABLE
2839
  *         @arg @ref LL_ADC_REG_SEQ_DISCONT_1RANK
2840
  *         @arg @ref LL_ADC_REG_SEQ_DISCONT_2RANKS
2841
  *         @arg @ref LL_ADC_REG_SEQ_DISCONT_3RANKS
2842
  *         @arg @ref LL_ADC_REG_SEQ_DISCONT_4RANKS
2843
  *         @arg @ref LL_ADC_REG_SEQ_DISCONT_5RANKS
2844
  *         @arg @ref LL_ADC_REG_SEQ_DISCONT_6RANKS
2845
  *         @arg @ref LL_ADC_REG_SEQ_DISCONT_7RANKS
2846
  *         @arg @ref LL_ADC_REG_SEQ_DISCONT_8RANKS
2847
  */
2848
__STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerDiscont(ADC_TypeDef *ADCx)
2849
{
2850
  return (uint32_t)(READ_BIT(ADCx->CR1, ADC_CR1_DISCEN | ADC_CR1_DISCNUM));
2851
}
2852
 
2853
/**
2854
  * @brief  Set ADC group regular sequence: channel on the selected
2855
  *         scan sequence rank.
2856
  * @note   This function performs configuration of:
2857
  *         - Channels ordering into each rank of scan sequence:
2858
  *           whatever channel can be placed into whatever rank.
2859
  * @note   On this STM32 serie, ADC group regular sequencer is
2860
  *         fully configurable: sequencer length and each rank
2861
  *         affectation to a channel are configurable.
2862
  *         Refer to description of function @ref LL_ADC_REG_SetSequencerLength().
2863
  * @note   Depending on devices and packages, some channels may not be available.
2864
  *         Refer to device datasheet for channels availability.
2865
  * @note   On this STM32 serie, to measure internal channels (VrefInt,
2866
  *         TempSensor, ...), measurement paths to internal channels must be
2867
  *         enabled separately.
2868
  *         This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
2869
  * @rmtoll SQR5     SQ1            LL_ADC_REG_SetSequencerRanks\n
2870
  *         SQR5     SQ2            LL_ADC_REG_SetSequencerRanks\n
2871
  *         SQR5     SQ3            LL_ADC_REG_SetSequencerRanks\n
2872
  *         SQR5     SQ4            LL_ADC_REG_SetSequencerRanks\n
2873
  *         SQR5     SQ5            LL_ADC_REG_SetSequencerRanks\n
2874
  *         SQR5     SQ6            LL_ADC_REG_SetSequencerRanks\n
2875
  *         SQR4     SQ7            LL_ADC_REG_SetSequencerRanks\n
2876
  *         SQR4     SQ8            LL_ADC_REG_SetSequencerRanks\n
2877
  *         SQR4     SQ9            LL_ADC_REG_SetSequencerRanks\n
2878
  *         SQR4     SQ10           LL_ADC_REG_SetSequencerRanks\n
2879
  *         SQR4     SQ11           LL_ADC_REG_SetSequencerRanks\n
2880
  *         SQR4     SQ12           LL_ADC_REG_SetSequencerRanks\n
2881
  *         SQR3     SQ13           LL_ADC_REG_SetSequencerRanks\n
2882
  *         SQR3     SQ14           LL_ADC_REG_SetSequencerRanks\n
2883
  *         SQR3     SQ15           LL_ADC_REG_SetSequencerRanks\n
2884
  *         SQR3     SQ16           LL_ADC_REG_SetSequencerRanks\n
2885
  *         SQR3     SQ17           LL_ADC_REG_SetSequencerRanks\n
2886
  *         SQR3     SQ18           LL_ADC_REG_SetSequencerRanks\n
2887
  *         SQR2     SQ19           LL_ADC_REG_SetSequencerRanks\n
2888
  *         SQR2     SQ20           LL_ADC_REG_SetSequencerRanks\n
2889
  *         SQR2     SQ21           LL_ADC_REG_SetSequencerRanks\n
2890
  *         SQR2     SQ22           LL_ADC_REG_SetSequencerRanks\n
2891
  *         SQR2     SQ23           LL_ADC_REG_SetSequencerRanks\n
2892
  *         SQR2     SQ24           LL_ADC_REG_SetSequencerRanks\n
2893
  *         SQR1     SQ25           LL_ADC_REG_SetSequencerRanks\n
2894
  *         SQR1     SQ26           LL_ADC_REG_SetSequencerRanks\n
2895
  *         SQR1     SQ27           LL_ADC_REG_SetSequencerRanks\n
2896
  *         SQR1     SQ28           LL_ADC_REG_SetSequencerRanks
2897
  * @param  ADCx ADC instance
2898
  * @param  Rank This parameter can be one of the following values:
2899
  *         @arg @ref LL_ADC_REG_RANK_1
2900
  *         @arg @ref LL_ADC_REG_RANK_2
2901
  *         @arg @ref LL_ADC_REG_RANK_3
2902
  *         @arg @ref LL_ADC_REG_RANK_4
2903
  *         @arg @ref LL_ADC_REG_RANK_5
2904
  *         @arg @ref LL_ADC_REG_RANK_6
2905
  *         @arg @ref LL_ADC_REG_RANK_7
2906
  *         @arg @ref LL_ADC_REG_RANK_8
2907
  *         @arg @ref LL_ADC_REG_RANK_9
2908
  *         @arg @ref LL_ADC_REG_RANK_10
2909
  *         @arg @ref LL_ADC_REG_RANK_11
2910
  *         @arg @ref LL_ADC_REG_RANK_12
2911
  *         @arg @ref LL_ADC_REG_RANK_13
2912
  *         @arg @ref LL_ADC_REG_RANK_14
2913
  *         @arg @ref LL_ADC_REG_RANK_15
2914
  *         @arg @ref LL_ADC_REG_RANK_16
2915
  *         @arg @ref LL_ADC_REG_RANK_17
2916
  *         @arg @ref LL_ADC_REG_RANK_18
2917
  *         @arg @ref LL_ADC_REG_RANK_19
2918
  *         @arg @ref LL_ADC_REG_RANK_20
2919
  *         @arg @ref LL_ADC_REG_RANK_21
2920
  *         @arg @ref LL_ADC_REG_RANK_22
2921
  *         @arg @ref LL_ADC_REG_RANK_23
2922
  *         @arg @ref LL_ADC_REG_RANK_24
2923
  *         @arg @ref LL_ADC_REG_RANK_25
2924
  *         @arg @ref LL_ADC_REG_RANK_26
2925
  *         @arg @ref LL_ADC_REG_RANK_27
2926
  *         @arg @ref LL_ADC_REG_RANK_28 (1)
2927
  *        
2928
  *         (1) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.3, Cat.4 and Cat.5.
2929
  * @param  Channel This parameter can be one of the following values:
2930
  *         @arg @ref LL_ADC_CHANNEL_0          (2)
2931
  *         @arg @ref LL_ADC_CHANNEL_1          (2)
2932
  *         @arg @ref LL_ADC_CHANNEL_2          (2)
2933
  *         @arg @ref LL_ADC_CHANNEL_3          (2)
2934
  *         @arg @ref LL_ADC_CHANNEL_4          (1)
2935
  *         @arg @ref LL_ADC_CHANNEL_5          (1)
2936
  *         @arg @ref LL_ADC_CHANNEL_6          (2)
2937
  *         @arg @ref LL_ADC_CHANNEL_7          (2)
2938
  *         @arg @ref LL_ADC_CHANNEL_8          (2)
2939
  *         @arg @ref LL_ADC_CHANNEL_9          (2)
2940
  *         @arg @ref LL_ADC_CHANNEL_10         (2)
2941
  *         @arg @ref LL_ADC_CHANNEL_11         (2)
2942
  *         @arg @ref LL_ADC_CHANNEL_12         (2)
2943
  *         @arg @ref LL_ADC_CHANNEL_13         (3)
2944
  *         @arg @ref LL_ADC_CHANNEL_14         (3)
2945
  *         @arg @ref LL_ADC_CHANNEL_15         (3)
2946
  *         @arg @ref LL_ADC_CHANNEL_16         (3)
2947
  *         @arg @ref LL_ADC_CHANNEL_17         (3)
2948
  *         @arg @ref LL_ADC_CHANNEL_18         (3)
2949
  *         @arg @ref LL_ADC_CHANNEL_19         (3)
2950
  *         @arg @ref LL_ADC_CHANNEL_20         (3)
2951
  *         @arg @ref LL_ADC_CHANNEL_21         (3)
2952
  *         @arg @ref LL_ADC_CHANNEL_22         (1)
2953
  *         @arg @ref LL_ADC_CHANNEL_23         (1)
2954
  *         @arg @ref LL_ADC_CHANNEL_24         (1)
2955
  *         @arg @ref LL_ADC_CHANNEL_25         (1)
2956
  *         @arg @ref LL_ADC_CHANNEL_26         (3)
2957
  *         @arg @ref LL_ADC_CHANNEL_27         (3)(4)
2958
  *         @arg @ref LL_ADC_CHANNEL_28         (3)(4)
2959
  *         @arg @ref LL_ADC_CHANNEL_29         (3)(4)
2960
  *         @arg @ref LL_ADC_CHANNEL_30         (3)(4)
2961
  *         @arg @ref LL_ADC_CHANNEL_31         (3)(4)
2962
  *         @arg @ref LL_ADC_CHANNEL_VREFINT    (3)
2963
  *         @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)
2964
  *         @arg @ref LL_ADC_CHANNEL_VCOMP      (3)
2965
  *         @arg @ref LL_ADC_CHANNEL_VOPAMP1    (3)(5)
2966
  *         @arg @ref LL_ADC_CHANNEL_VOPAMP2    (3)(5)
2967
  *         @arg @ref LL_ADC_CHANNEL_VOPAMP3    (3)(5)
2968
  *        
2969
  *         (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
2970
  *         (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
2971
  *         (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
2972
  *         (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
2973
  *         (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
2974
  * @retval None
2975
  */
2976
__STATIC_INLINE void LL_ADC_REG_SetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank, uint32_t Channel)
2977
{
2978
  /* Set bits with content of parameter "Channel" with bits position          */
2979
  /* in register and register position depending on parameter "Rank".         */
2980
  /* Parameters "Rank" and "Channel" are used with masks because containing   */
2981
  /* other bits reserved for other purpose.                                   */
2982
  uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SQR1, __ADC_MASK_SHIFT(Rank, ADC_REG_SQRX_REGOFFSET_MASK));
2983
 
2984
  MODIFY_REG(*preg,
2985
             ADC_CHANNEL_ID_NUMBER_MASK << (Rank & ADC_REG_RANK_ID_SQRX_MASK),
2986
             (Channel & ADC_CHANNEL_ID_NUMBER_MASK) << (Rank & ADC_REG_RANK_ID_SQRX_MASK));
2987
}
2988
 
2989
/**
2990
  * @brief  Get ADC group regular sequence: channel on the selected
2991
  *         scan sequence rank.
2992
  * @note   On this STM32 serie, ADC group regular sequencer is
2993
  *         fully configurable: sequencer length and each rank
2994
  *         affectation to a channel are configurable.
2995
  *         Refer to description of function @ref LL_ADC_REG_SetSequencerLength().
2996
  * @note   Depending on devices and packages, some channels may not be available.
2997
  *         Refer to device datasheet for channels availability.
2998
  * @note   Usage of the returned channel number:
2999
  *         - To reinject this channel into another function LL_ADC_xxx:
3000
  *           the returned channel number is only partly formatted on definition
3001
  *           of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
3002
  *           with parts of literals LL_ADC_CHANNEL_x or using
3003
  *           helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
3004
  *           Then the selected literal LL_ADC_CHANNEL_x can be used
3005
  *           as parameter for another function.
3006
  *         - To get the channel number in decimal format:
3007
  *           process the returned value with the helper macro
3008
  *           @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
3009
  * @rmtoll SQR5     SQ1            LL_ADC_REG_GetSequencerRanks\n
3010
  *         SQR5     SQ2            LL_ADC_REG_GetSequencerRanks\n
3011
  *         SQR5     SQ3            LL_ADC_REG_GetSequencerRanks\n
3012
  *         SQR5     SQ4            LL_ADC_REG_GetSequencerRanks\n
3013
  *         SQR5     SQ5            LL_ADC_REG_GetSequencerRanks\n
3014
  *         SQR5     SQ6            LL_ADC_REG_GetSequencerRanks\n
3015
  *         SQR4     SQ7            LL_ADC_REG_GetSequencerRanks\n
3016
  *         SQR4     SQ8            LL_ADC_REG_GetSequencerRanks\n
3017
  *         SQR4     SQ9            LL_ADC_REG_GetSequencerRanks\n
3018
  *         SQR4     SQ10           LL_ADC_REG_GetSequencerRanks\n
3019
  *         SQR4     SQ11           LL_ADC_REG_GetSequencerRanks\n
3020
  *         SQR4     SQ12           LL_ADC_REG_GetSequencerRanks\n
3021
  *         SQR3     SQ13           LL_ADC_REG_GetSequencerRanks\n
3022
  *         SQR3     SQ14           LL_ADC_REG_GetSequencerRanks\n
3023
  *         SQR3     SQ15           LL_ADC_REG_GetSequencerRanks\n
3024
  *         SQR3     SQ16           LL_ADC_REG_GetSequencerRanks\n
3025
  *         SQR3     SQ17           LL_ADC_REG_GetSequencerRanks\n
3026
  *         SQR3     SQ18           LL_ADC_REG_GetSequencerRanks\n
3027
  *         SQR2     SQ19           LL_ADC_REG_GetSequencerRanks\n
3028
  *         SQR2     SQ20           LL_ADC_REG_GetSequencerRanks\n
3029
  *         SQR2     SQ21           LL_ADC_REG_GetSequencerRanks\n
3030
  *         SQR2     SQ22           LL_ADC_REG_GetSequencerRanks\n
3031
  *         SQR2     SQ23           LL_ADC_REG_GetSequencerRanks\n
3032
  *         SQR2     SQ24           LL_ADC_REG_GetSequencerRanks\n
3033
  *         SQR1     SQ25           LL_ADC_REG_GetSequencerRanks\n
3034
  *         SQR1     SQ26           LL_ADC_REG_GetSequencerRanks\n
3035
  *         SQR1     SQ27           LL_ADC_REG_GetSequencerRanks\n
3036
  *         SQR1     SQ28           LL_ADC_REG_GetSequencerRanks
3037
  * @param  ADCx ADC instance
3038
  * @param  Rank This parameter can be one of the following values:
3039
  *         @arg @ref LL_ADC_REG_RANK_1
3040
  *         @arg @ref LL_ADC_REG_RANK_2
3041
  *         @arg @ref LL_ADC_REG_RANK_3
3042
  *         @arg @ref LL_ADC_REG_RANK_4
3043
  *         @arg @ref LL_ADC_REG_RANK_5
3044
  *         @arg @ref LL_ADC_REG_RANK_6
3045
  *         @arg @ref LL_ADC_REG_RANK_7
3046
  *         @arg @ref LL_ADC_REG_RANK_8
3047
  *         @arg @ref LL_ADC_REG_RANK_9
3048
  *         @arg @ref LL_ADC_REG_RANK_10
3049
  *         @arg @ref LL_ADC_REG_RANK_11
3050
  *         @arg @ref LL_ADC_REG_RANK_12
3051
  *         @arg @ref LL_ADC_REG_RANK_13
3052
  *         @arg @ref LL_ADC_REG_RANK_14
3053
  *         @arg @ref LL_ADC_REG_RANK_15
3054
  *         @arg @ref LL_ADC_REG_RANK_16
3055
  *         @arg @ref LL_ADC_REG_RANK_17
3056
  *         @arg @ref LL_ADC_REG_RANK_18
3057
  *         @arg @ref LL_ADC_REG_RANK_19
3058
  *         @arg @ref LL_ADC_REG_RANK_20
3059
  *         @arg @ref LL_ADC_REG_RANK_21
3060
  *         @arg @ref LL_ADC_REG_RANK_22
3061
  *         @arg @ref LL_ADC_REG_RANK_23
3062
  *         @arg @ref LL_ADC_REG_RANK_24
3063
  *         @arg @ref LL_ADC_REG_RANK_25
3064
  *         @arg @ref LL_ADC_REG_RANK_26
3065
  *         @arg @ref LL_ADC_REG_RANK_27
3066
  *         @arg @ref LL_ADC_REG_RANK_28 (1)
3067
  *        
3068
  *         (1) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.3, Cat.4 and Cat.5.
3069
  * @retval Returned value can be one of the following values:
3070
  *         @arg @ref LL_ADC_CHANNEL_0          (2)
3071
  *         @arg @ref LL_ADC_CHANNEL_1          (2)
3072
  *         @arg @ref LL_ADC_CHANNEL_2          (2)
3073
  *         @arg @ref LL_ADC_CHANNEL_3          (2)
3074
  *         @arg @ref LL_ADC_CHANNEL_4          (1)
3075
  *         @arg @ref LL_ADC_CHANNEL_5          (1)
3076
  *         @arg @ref LL_ADC_CHANNEL_6          (2)
3077
  *         @arg @ref LL_ADC_CHANNEL_7          (2)
3078
  *         @arg @ref LL_ADC_CHANNEL_8          (2)
3079
  *         @arg @ref LL_ADC_CHANNEL_9          (2)
3080
  *         @arg @ref LL_ADC_CHANNEL_10         (2)
3081
  *         @arg @ref LL_ADC_CHANNEL_11         (2)
3082
  *         @arg @ref LL_ADC_CHANNEL_12         (2)
3083
  *         @arg @ref LL_ADC_CHANNEL_13         (3)
3084
  *         @arg @ref LL_ADC_CHANNEL_14         (3)
3085
  *         @arg @ref LL_ADC_CHANNEL_15         (3)
3086
  *         @arg @ref LL_ADC_CHANNEL_16         (3)
3087
  *         @arg @ref LL_ADC_CHANNEL_17         (3)
3088
  *         @arg @ref LL_ADC_CHANNEL_18         (3)
3089
  *         @arg @ref LL_ADC_CHANNEL_19         (3)
3090
  *         @arg @ref LL_ADC_CHANNEL_20         (3)
3091
  *         @arg @ref LL_ADC_CHANNEL_21         (3)
3092
  *         @arg @ref LL_ADC_CHANNEL_22         (1)
3093
  *         @arg @ref LL_ADC_CHANNEL_23         (1)
3094
  *         @arg @ref LL_ADC_CHANNEL_24         (1)
3095
  *         @arg @ref LL_ADC_CHANNEL_25         (1)
3096
  *         @arg @ref LL_ADC_CHANNEL_26         (3)
3097
  *         @arg @ref LL_ADC_CHANNEL_27         (3)(4)
3098
  *         @arg @ref LL_ADC_CHANNEL_28         (3)(4)
3099
  *         @arg @ref LL_ADC_CHANNEL_29         (3)(4)
3100
  *         @arg @ref LL_ADC_CHANNEL_30         (3)(4)
3101
  *         @arg @ref LL_ADC_CHANNEL_31         (3)(4)
3102
  *         @arg @ref LL_ADC_CHANNEL_VREFINT    (3)(6)
3103
  *         @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)(6)
3104
  *         @arg @ref LL_ADC_CHANNEL_VCOMP      (3)(6)
3105
  *         @arg @ref LL_ADC_CHANNEL_VOPAMP1    (3)(5)
3106
  *         @arg @ref LL_ADC_CHANNEL_VOPAMP2    (3)(5)
3107
  *         @arg @ref LL_ADC_CHANNEL_VOPAMP3    (3)(5)
3108
  *        
3109
  *         (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
3110
  *         (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
3111
  *         (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
3112
  *         (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
3113
  *         (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5.\n
3114
  *         (6) For ADC channel read back from ADC register,
3115
  *             comparison with internal channel parameter to be done
3116
  *             using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
3117
  */
3118
__STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank)
3119
{
3120
  uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SQR1, __ADC_MASK_SHIFT(Rank, ADC_REG_SQRX_REGOFFSET_MASK));
3121
 
3122
  return (uint32_t) (READ_BIT(*preg,
3123
                              ADC_CHANNEL_ID_NUMBER_MASK << (Rank & ADC_REG_RANK_ID_SQRX_MASK))
3124
                     >> (Rank & ADC_REG_RANK_ID_SQRX_MASK)
3125
                    );
3126
}
3127
 
3128
/**
3129
  * @brief  Set ADC continuous conversion mode on ADC group regular.
3130
  * @note   Description of ADC continuous conversion mode:
3131
  *         - single mode: one conversion per trigger
3132
  *         - continuous mode: after the first trigger, following
3133
  *           conversions launched successively automatically.
3134
  * @note   It is not possible to enable both ADC group regular
3135
  *         continuous mode and sequencer discontinuous mode.
3136
  * @rmtoll CR2      CONT           LL_ADC_REG_SetContinuousMode
3137
  * @param  ADCx ADC instance
3138
  * @param  Continuous This parameter can be one of the following values:
3139
  *         @arg @ref LL_ADC_REG_CONV_SINGLE
3140
  *         @arg @ref LL_ADC_REG_CONV_CONTINUOUS
3141
  * @retval None
3142
  */
3143
__STATIC_INLINE void LL_ADC_REG_SetContinuousMode(ADC_TypeDef *ADCx, uint32_t Continuous)
3144
{
3145
  MODIFY_REG(ADCx->CR2, ADC_CR2_CONT, Continuous);
3146
}
3147
 
3148
/**
3149
  * @brief  Get ADC continuous conversion mode on ADC group regular.
3150
  * @note   Description of ADC continuous conversion mode:
3151
  *         - single mode: one conversion per trigger
3152
  *         - continuous mode: after the first trigger, following
3153
  *           conversions launched successively automatically.
3154
  * @rmtoll CR2      CONT           LL_ADC_REG_GetContinuousMode
3155
  * @param  ADCx ADC instance
3156
  * @retval Returned value can be one of the following values:
3157
  *         @arg @ref LL_ADC_REG_CONV_SINGLE
3158
  *         @arg @ref LL_ADC_REG_CONV_CONTINUOUS
3159
  */
3160
__STATIC_INLINE uint32_t LL_ADC_REG_GetContinuousMode(ADC_TypeDef *ADCx)
3161
{
3162
  return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_CONT));
3163
}
3164
 
3165
/**
3166
  * @brief  Set ADC group regular conversion data transfer: no transfer or
3167
  *         transfer by DMA, and DMA requests mode.
3168
  * @note   If transfer by DMA selected, specifies the DMA requests
3169
  *         mode:
3170
  *         - Limited mode (One shot mode): DMA transfer requests are stopped
3171
  *           when number of DMA data transfers (number of
3172
  *           ADC conversions) is reached.
3173
  *           This ADC mode is intended to be used with DMA mode non-circular.
3174
  *         - Unlimited mode: DMA transfer requests are unlimited,
3175
  *           whatever number of DMA data transfers (number of
3176
  *           ADC conversions).
3177
  *           This ADC mode is intended to be used with DMA mode circular.
3178
  * @note   If ADC DMA requests mode is set to unlimited and DMA is set to
3179
  *         mode non-circular:
3180
  *         when DMA transfers size will be reached, DMA will stop transfers of
3181
  *         ADC conversions data ADC will raise an overrun error
3182
  *        (overrun flag and interruption if enabled).
3183
  * @note   To configure DMA source address (peripheral address),
3184
  *         use function @ref LL_ADC_DMA_GetRegAddr().
3185
  * @rmtoll CR2      DMA            LL_ADC_REG_SetDMATransfer\n
3186
  *         CR2      DDS            LL_ADC_REG_SetDMATransfer
3187
  * @param  ADCx ADC instance
3188
  * @param  DMATransfer This parameter can be one of the following values:
3189
  *         @arg @ref LL_ADC_REG_DMA_TRANSFER_NONE
3190
  *         @arg @ref LL_ADC_REG_DMA_TRANSFER_LIMITED
3191
  *         @arg @ref LL_ADC_REG_DMA_TRANSFER_UNLIMITED
3192
  * @retval None
3193
  */
3194
__STATIC_INLINE void LL_ADC_REG_SetDMATransfer(ADC_TypeDef *ADCx, uint32_t DMATransfer)
3195
{
3196
  MODIFY_REG(ADCx->CR2, ADC_CR2_DMA | ADC_CR2_DDS, DMATransfer);
3197
}
3198
 
3199
/**
3200
  * @brief  Get ADC group regular conversion data transfer: no transfer or
3201
  *         transfer by DMA, and DMA requests mode.
3202
  * @note   If transfer by DMA selected, specifies the DMA requests
3203
  *         mode:
3204
  *         - Limited mode (One shot mode): DMA transfer requests are stopped
3205
  *           when number of DMA data transfers (number of
3206
  *           ADC conversions) is reached.
3207
  *           This ADC mode is intended to be used with DMA mode non-circular.
3208
  *         - Unlimited mode: DMA transfer requests are unlimited,
3209
  *           whatever number of DMA data transfers (number of
3210
  *           ADC conversions).
3211
  *           This ADC mode is intended to be used with DMA mode circular.
3212
  * @note   If ADC DMA requests mode is set to unlimited and DMA is set to
3213
  *         mode non-circular:
3214
  *         when DMA transfers size will be reached, DMA will stop transfers of
3215
  *         ADC conversions data ADC will raise an overrun error
3216
  *         (overrun flag and interruption if enabled).
3217
  * @note   To configure DMA source address (peripheral address),
3218
  *         use function @ref LL_ADC_DMA_GetRegAddr().
3219
  * @rmtoll CR2      DMA            LL_ADC_REG_GetDMATransfer\n
3220
  *         CR2      DDS            LL_ADC_REG_GetDMATransfer
3221
  * @param  ADCx ADC instance
3222
  * @retval Returned value can be one of the following values:
3223
  *         @arg @ref LL_ADC_REG_DMA_TRANSFER_NONE
3224
  *         @arg @ref LL_ADC_REG_DMA_TRANSFER_LIMITED
3225
  *         @arg @ref LL_ADC_REG_DMA_TRANSFER_UNLIMITED
3226
  */
3227
__STATIC_INLINE uint32_t LL_ADC_REG_GetDMATransfer(ADC_TypeDef *ADCx)
3228
{
3229
  return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_DMA | ADC_CR2_DDS));
3230
}
3231
 
3232
/**
3233
  * @brief  Specify which ADC flag between EOC (end of unitary conversion)
3234
  *         or EOS (end of sequence conversions) is used to indicate
3235
  *         the end of conversion.
3236
  * @note   This feature is aimed to be set when using ADC with
3237
  *         programming model by polling or interruption
3238
  *         (programming model by DMA usually uses DMA interruptions
3239
  *         to indicate end of conversion and data transfer).
3240
  * @note   For ADC group injected, end of conversion (flag&IT) is raised
3241
  *         only at the end of the sequence.
3242
  * @rmtoll CR2      EOCS           LL_ADC_REG_SetFlagEndOfConversion
3243
  * @param  ADCx ADC instance
3244
  * @param  EocSelection This parameter can be one of the following values:
3245
  *         @arg @ref LL_ADC_REG_FLAG_EOC_SEQUENCE_CONV
3246
  *         @arg @ref LL_ADC_REG_FLAG_EOC_UNITARY_CONV
3247
  * @retval None
3248
  */
3249
__STATIC_INLINE void LL_ADC_REG_SetFlagEndOfConversion(ADC_TypeDef *ADCx, uint32_t EocSelection)
3250
{
3251
  MODIFY_REG(ADCx->CR2, ADC_CR2_EOCS, EocSelection);
3252
}
3253
 
3254
/**
3255
  * @brief  Get which ADC flag between EOC (end of unitary conversion)
3256
  *         or EOS (end of sequence conversions) is used to indicate
3257
  *         the end of conversion.
3258
  * @rmtoll CR2      EOCS           LL_ADC_REG_GetFlagEndOfConversion
3259
  * @param  ADCx ADC instance
3260
  * @retval Returned value can be one of the following values:
3261
  *         @arg @ref LL_ADC_REG_FLAG_EOC_SEQUENCE_CONV
3262
  *         @arg @ref LL_ADC_REG_FLAG_EOC_UNITARY_CONV
3263
  */
3264
__STATIC_INLINE uint32_t LL_ADC_REG_GetFlagEndOfConversion(ADC_TypeDef *ADCx)
3265
{
3266
  return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_EOCS));
3267
}
3268
 
3269
/**
3270
  * @}
3271
  */
3272
 
3273
/** @defgroup ADC_LL_EF_Configuration_ADC_Group_Injected Configuration of ADC hierarchical scope: group injected
3274
  * @{
3275
  */
3276
 
3277
/**
3278
  * @brief  Set ADC group injected conversion trigger source:
3279
  *         internal (SW start) or from external IP (timer event,
3280
  *         external interrupt line).
3281
  * @note   On this STM32 serie, setting of external trigger edge is performed
3282
  *         using function @ref LL_ADC_INJ_StartConversionExtTrig().
3283
  * @note   Availability of parameters of trigger sources from timer
3284
  *         depends on timers availability on the selected device.
3285
  * @rmtoll CR2      JEXTSEL        LL_ADC_INJ_SetTriggerSource\n
3286
  *         CR2      JEXTEN         LL_ADC_INJ_SetTriggerSource
3287
  * @param  ADCx ADC instance
3288
  * @param  TriggerSource This parameter can be one of the following values:
3289
  *         @arg @ref LL_ADC_INJ_TRIG_SOFTWARE
3290
  *         @arg @ref LL_ADC_INJ_TRIG_EXT_TIM9_CH1
3291
  *         @arg @ref LL_ADC_INJ_TRIG_EXT_TIM9_TRGO
3292
  *         @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO
3293
  *         @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_CH1
3294
  *         @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH4
3295
  *         @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO
3296
  *         @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH1
3297
  *         @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH2
3298
  *         @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH3
3299
  *         @arg @ref LL_ADC_INJ_TRIG_EXT_TIM10_CH1
3300
  *         @arg @ref LL_ADC_INJ_TRIG_EXT_TIM7_TRGO
3301
  *         @arg @ref LL_ADC_INJ_TRIG_EXT_EXTI_LINE15
3302
  * @retval None
3303
  */
3304
__STATIC_INLINE void LL_ADC_INJ_SetTriggerSource(ADC_TypeDef *ADCx, uint32_t TriggerSource)
3305
{
3306
/* Note: On this STM32 serie, ADC group injected external trigger edge       */
3307
/*       is used to perform a ADC conversion start.                           */
3308
/*       This function does not set external trigger edge.                    */
3309
/*       This feature is set using function                                   */
3310
/*       @ref LL_ADC_INJ_StartConversionExtTrig().                            */
3311
  MODIFY_REG(ADCx->CR2, ADC_CR2_JEXTSEL, (TriggerSource & ADC_CR2_JEXTSEL));
3312
}
3313
 
3314
/**
3315
  * @brief  Get ADC group injected conversion trigger source:
3316
  *         internal (SW start) or from external IP (timer event,
3317
  *         external interrupt line).
3318
  * @note   To determine whether group injected trigger source is
3319
  *         internal (SW start) or external, without detail
3320
  *         of which peripheral is selected as external trigger,
3321
  *         (equivalent to
3322
  *         "if(LL_ADC_INJ_GetTriggerSource(ADC1) == LL_ADC_INJ_TRIG_SOFTWARE)")
3323
  *         use function @ref LL_ADC_INJ_IsTriggerSourceSWStart.
3324
  * @note   Availability of parameters of trigger sources from timer
3325
  *         depends on timers availability on the selected device.
3326
  * @rmtoll CR2      JEXTSEL        LL_ADC_INJ_GetTriggerSource\n
3327
  *         CR2      JEXTEN         LL_ADC_INJ_GetTriggerSource
3328
  * @param  ADCx ADC instance
3329
  * @retval Returned value can be one of the following values:
3330
  *         @arg @ref LL_ADC_INJ_TRIG_SOFTWARE
3331
  *         @arg @ref LL_ADC_INJ_TRIG_EXT_TIM9_CH1
3332
  *         @arg @ref LL_ADC_INJ_TRIG_EXT_TIM9_TRGO
3333
  *         @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO
3334
  *         @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_CH1
3335
  *         @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH4
3336
  *         @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO
3337
  *         @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH1
3338
  *         @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH2
3339
  *         @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH3
3340
  *         @arg @ref LL_ADC_INJ_TRIG_EXT_TIM10_CH1
3341
  *         @arg @ref LL_ADC_INJ_TRIG_EXT_TIM7_TRGO
3342
  *         @arg @ref LL_ADC_INJ_TRIG_EXT_EXTI_LINE15
3343
  */
3344
__STATIC_INLINE uint32_t LL_ADC_INJ_GetTriggerSource(ADC_TypeDef *ADCx)
3345
{
3346
  uint32_t TriggerSource = READ_BIT(ADCx->CR2, ADC_CR2_JEXTSEL | ADC_CR2_JEXTEN);
3347
 
3348
  /* Value for shift of {0; 4; 8; 12} depending on value of bitfield          */
3349
  /* corresponding to ADC_CR2_JEXTEN {0; 1; 2; 3}.                            */
3350
  uint32_t ShiftExten = ((TriggerSource & ADC_CR2_JEXTEN) >> (ADC_INJ_TRIG_EXTEN_BITOFFSET_POS - 2U));
3351
 
3352
  /* Set bitfield corresponding to ADC_CR2_JEXTEN and ADC_CR2_JEXTSEL         */
3353
  /* to match with triggers literals definition.                              */
3354
  return ((TriggerSource
3355
           & (ADC_INJ_TRIG_SOURCE_MASK << ShiftExten) & ADC_CR2_JEXTSEL)
3356
          | ((ADC_INJ_TRIG_EDGE_MASK << ShiftExten) & ADC_CR2_JEXTEN)
3357
         );
3358
}
3359
 
3360
/**
3361
  * @brief  Get ADC group injected conversion trigger source internal (SW start)
3362
            or external
3363
  * @note   In case of group injected trigger source set to external trigger,
3364
  *         to determine which peripheral is selected as external trigger,
3365
  *         use function @ref LL_ADC_INJ_GetTriggerSource.
3366
  * @rmtoll CR2      JEXTEN         LL_ADC_INJ_IsTriggerSourceSWStart
3367
  * @param  ADCx ADC instance
3368
  * @retval Value "0" if trigger source external trigger
3369
  *         Value "1" if trigger source SW start.
3370
  */
3371
__STATIC_INLINE uint32_t LL_ADC_INJ_IsTriggerSourceSWStart(ADC_TypeDef *ADCx)
3372
{
3373
  return (READ_BIT(ADCx->CR2, ADC_CR2_JEXTEN) == (LL_ADC_INJ_TRIG_SOFTWARE & ADC_CR2_JEXTEN));
3374
}
3375
 
3376
/**
3377
  * @brief  Get ADC group injected conversion trigger polarity.
3378
  *         Applicable only for trigger source set to external trigger.
3379
  * @rmtoll CR2      JEXTEN         LL_ADC_INJ_GetTriggerEdge
3380
  * @param  ADCx ADC instance
3381
  * @retval Returned value can be one of the following values:
3382
  *         @arg @ref LL_ADC_INJ_TRIG_EXT_RISING
3383
  *         @arg @ref LL_ADC_INJ_TRIG_EXT_FALLING
3384
  *         @arg @ref LL_ADC_INJ_TRIG_EXT_RISINGFALLING
3385
  */
3386
__STATIC_INLINE uint32_t LL_ADC_INJ_GetTriggerEdge(ADC_TypeDef *ADCx)
3387
{
3388
  return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_JEXTEN));
3389
}
3390
 
3391
/**
3392
  * @brief  Set ADC group injected sequencer length and scan direction.
3393
  * @note   This function performs configuration of:
3394
  *         - Sequence length: Number of ranks in the scan sequence.
3395
  *         - Sequence direction: Unless specified in parameters, sequencer
3396
  *           scan direction is forward (from rank 1 to rank n).
3397
  * @note   On this STM32 serie, group injected sequencer configuration
3398
  *         is conditioned to ADC instance sequencer mode.
3399
  *         If ADC instance sequencer mode is disabled, sequencers of
3400
  *         all groups (group regular, group injected) can be configured
3401
  *         but their execution is disabled (limited to rank 1).
3402
  *         Refer to function @ref LL_ADC_SetSequencersScanMode().
3403
  * @note   Sequencer disabled is equivalent to sequencer of 1 rank:
3404
  *         ADC conversion on only 1 channel.
3405
  * @rmtoll JSQR     JL             LL_ADC_INJ_SetSequencerLength
3406
  * @param  ADCx ADC instance
3407
  * @param  SequencerNbRanks This parameter can be one of the following values:
3408
  *         @arg @ref LL_ADC_INJ_SEQ_SCAN_DISABLE
3409
  *         @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS
3410
  *         @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS
3411
  *         @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS
3412
  * @retval None
3413
  */
3414
__STATIC_INLINE void LL_ADC_INJ_SetSequencerLength(ADC_TypeDef *ADCx, uint32_t SequencerNbRanks)
3415
{
3416
  MODIFY_REG(ADCx->JSQR, ADC_JSQR_JL, SequencerNbRanks);
3417
}
3418
 
3419
/**
3420
  * @brief  Get ADC group injected sequencer length and scan direction.
3421
  * @note   This function retrieves:
3422
  *         - Sequence length: Number of ranks in the scan sequence.
3423
  *         - Sequence direction: Unless specified in parameters, sequencer
3424
  *           scan direction is forward (from rank 1 to rank n).
3425
  * @note   On this STM32 serie, group injected sequencer configuration
3426
  *         is conditioned to ADC instance sequencer mode.
3427
  *         If ADC instance sequencer mode is disabled, sequencers of
3428
  *         all groups (group regular, group injected) can be configured
3429
  *         but their execution is disabled (limited to rank 1).
3430
  *         Refer to function @ref LL_ADC_SetSequencersScanMode().
3431
  * @note   Sequencer disabled is equivalent to sequencer of 1 rank:
3432
  *         ADC conversion on only 1 channel.
3433
  * @rmtoll JSQR     JL             LL_ADC_INJ_GetSequencerLength
3434
  * @param  ADCx ADC instance
3435
  * @retval Returned value can be one of the following values:
3436
  *         @arg @ref LL_ADC_INJ_SEQ_SCAN_DISABLE
3437
  *         @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS
3438
  *         @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS
3439
  *         @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS
3440
  */
3441
__STATIC_INLINE uint32_t LL_ADC_INJ_GetSequencerLength(ADC_TypeDef *ADCx)
3442
{
3443
  return (uint32_t)(READ_BIT(ADCx->JSQR, ADC_JSQR_JL));
3444
}
3445
 
3446
/**
3447
  * @brief  Set ADC group injected sequencer discontinuous mode:
3448
  *         sequence subdivided and scan conversions interrupted every selected
3449
  *         number of ranks.
3450
  * @note   It is not possible to enable both ADC group injected
3451
  *         auto-injected mode and sequencer discontinuous mode.
3452
  * @rmtoll CR1      DISCEN         LL_ADC_INJ_SetSequencerDiscont
3453
  * @param  ADCx ADC instance
3454
  * @param  SeqDiscont This parameter can be one of the following values:
3455
  *         @arg @ref LL_ADC_INJ_SEQ_DISCONT_DISABLE
3456
  *         @arg @ref LL_ADC_INJ_SEQ_DISCONT_1RANK
3457
  * @retval None
3458
  */
3459
__STATIC_INLINE void LL_ADC_INJ_SetSequencerDiscont(ADC_TypeDef *ADCx, uint32_t SeqDiscont)
3460
{
3461
  MODIFY_REG(ADCx->CR1, ADC_CR1_JDISCEN, SeqDiscont);
3462
}
3463
 
3464
/**
3465
  * @brief  Get ADC group injected sequencer discontinuous mode:
3466
  *         sequence subdivided and scan conversions interrupted every selected
3467
  *         number of ranks.
3468
  * @rmtoll CR1      DISCEN         LL_ADC_REG_GetSequencerDiscont
3469
  * @param  ADCx ADC instance
3470
  * @retval Returned value can be one of the following values:
3471
  *         @arg @ref LL_ADC_INJ_SEQ_DISCONT_DISABLE
3472
  *         @arg @ref LL_ADC_INJ_SEQ_DISCONT_1RANK
3473
  */
3474
__STATIC_INLINE uint32_t LL_ADC_INJ_GetSequencerDiscont(ADC_TypeDef *ADCx)
3475
{
3476
  return (uint32_t)(READ_BIT(ADCx->CR1, ADC_CR1_JDISCEN));
3477
}
3478
 
3479
/**
3480
  * @brief  Set ADC group injected sequence: channel on the selected
3481
  *         sequence rank.
3482
  * @note   Depending on devices and packages, some channels may not be available.
3483
  *         Refer to device datasheet for channels availability.
3484
  * @note   On this STM32 serie, to measure internal channels (VrefInt,
3485
  *         TempSensor, ...), measurement paths to internal channels must be
3486
  *         enabled separately.
3487
  *         This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
3488
  * @rmtoll JSQR     JSQ1           LL_ADC_INJ_SetSequencerRanks\n
3489
  *         JSQR     JSQ2           LL_ADC_INJ_SetSequencerRanks\n
3490
  *         JSQR     JSQ3           LL_ADC_INJ_SetSequencerRanks\n
3491
  *         JSQR     JSQ4           LL_ADC_INJ_SetSequencerRanks
3492
  * @param  ADCx ADC instance
3493
  * @param  Rank This parameter can be one of the following values:
3494
  *         @arg @ref LL_ADC_INJ_RANK_1
3495
  *         @arg @ref LL_ADC_INJ_RANK_2
3496
  *         @arg @ref LL_ADC_INJ_RANK_3
3497
  *         @arg @ref LL_ADC_INJ_RANK_4
3498
  * @param  Channel This parameter can be one of the following values:
3499
  *         @arg @ref LL_ADC_CHANNEL_0          (2)
3500
  *         @arg @ref LL_ADC_CHANNEL_1          (2)
3501
  *         @arg @ref LL_ADC_CHANNEL_2          (2)
3502
  *         @arg @ref LL_ADC_CHANNEL_3          (2)
3503
  *         @arg @ref LL_ADC_CHANNEL_4          (1)
3504
  *         @arg @ref LL_ADC_CHANNEL_5          (1)
3505
  *         @arg @ref LL_ADC_CHANNEL_6          (2)
3506
  *         @arg @ref LL_ADC_CHANNEL_7          (2)
3507
  *         @arg @ref LL_ADC_CHANNEL_8          (2)
3508
  *         @arg @ref LL_ADC_CHANNEL_9          (2)
3509
  *         @arg @ref LL_ADC_CHANNEL_10         (2)
3510
  *         @arg @ref LL_ADC_CHANNEL_11         (2)
3511
  *         @arg @ref LL_ADC_CHANNEL_12         (2)
3512
  *         @arg @ref LL_ADC_CHANNEL_13         (3)
3513
  *         @arg @ref LL_ADC_CHANNEL_14         (3)
3514
  *         @arg @ref LL_ADC_CHANNEL_15         (3)
3515
  *         @arg @ref LL_ADC_CHANNEL_16         (3)
3516
  *         @arg @ref LL_ADC_CHANNEL_17         (3)
3517
  *         @arg @ref LL_ADC_CHANNEL_18         (3)
3518
  *         @arg @ref LL_ADC_CHANNEL_19         (3)
3519
  *         @arg @ref LL_ADC_CHANNEL_20         (3)
3520
  *         @arg @ref LL_ADC_CHANNEL_21         (3)
3521
  *         @arg @ref LL_ADC_CHANNEL_22         (1)
3522
  *         @arg @ref LL_ADC_CHANNEL_23         (1)
3523
  *         @arg @ref LL_ADC_CHANNEL_24         (1)
3524
  *         @arg @ref LL_ADC_CHANNEL_25         (1)
3525
  *         @arg @ref LL_ADC_CHANNEL_26         (3)
3526
  *         @arg @ref LL_ADC_CHANNEL_27         (3)(4)
3527
  *         @arg @ref LL_ADC_CHANNEL_28         (3)(4)
3528
  *         @arg @ref LL_ADC_CHANNEL_29         (3)(4)
3529
  *         @arg @ref LL_ADC_CHANNEL_30         (3)(4)
3530
  *         @arg @ref LL_ADC_CHANNEL_31         (3)(4)
3531
  *         @arg @ref LL_ADC_CHANNEL_VREFINT    (3)
3532
  *         @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)
3533
  *         @arg @ref LL_ADC_CHANNEL_VCOMP      (3)
3534
  *         @arg @ref LL_ADC_CHANNEL_VOPAMP1    (3)(5)
3535
  *         @arg @ref LL_ADC_CHANNEL_VOPAMP2    (3)(5)
3536
  *         @arg @ref LL_ADC_CHANNEL_VOPAMP3    (3)(5)
3537
  *        
3538
  *         (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
3539
  *         (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
3540
  *         (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
3541
  *         (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
3542
  *         (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
3543
  * @retval None
3544
  */
3545
__STATIC_INLINE void LL_ADC_INJ_SetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank, uint32_t Channel)
3546
{
3547
  /* Set bits with content of parameter "Channel" with bits position          */
3548
  /* in register depending on parameter "Rank".                               */
3549
  /* Parameters "Rank" and "Channel" are used with masks because containing   */
3550
  /* other bits reserved for other purpose.                                   */
3551
  MODIFY_REG(ADCx->JSQR,
3552
             ADC_CHANNEL_ID_NUMBER_MASK << (Rank & ADC_INJ_RANK_ID_JSQR_MASK),
3553
             (Channel & ADC_CHANNEL_ID_NUMBER_MASK) << (Rank & ADC_INJ_RANK_ID_JSQR_MASK));
3554
}
3555
 
3556
/**
3557
  * @brief  Get ADC group injected sequence: channel on the selected
3558
  *         sequence rank.
3559
  * @note   Depending on devices and packages, some channels may not be available.
3560
  *         Refer to device datasheet for channels availability.
3561
  * @note   Usage of the returned channel number:
3562
  *         - To reinject this channel into another function LL_ADC_xxx:
3563
  *           the returned channel number is only partly formatted on definition
3564
  *           of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
3565
  *           with parts of literals LL_ADC_CHANNEL_x or using
3566
  *           helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
3567
  *           Then the selected literal LL_ADC_CHANNEL_x can be used
3568
  *           as parameter for another function.
3569
  *         - To get the channel number in decimal format:
3570
  *           process the returned value with the helper macro
3571
  *           @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
3572
  * @rmtoll JSQR     JSQ1           LL_ADC_INJ_SetSequencerRanks\n
3573
  *         JSQR     JSQ2           LL_ADC_INJ_SetSequencerRanks\n
3574
  *         JSQR     JSQ3           LL_ADC_INJ_SetSequencerRanks\n
3575
  *         JSQR     JSQ4           LL_ADC_INJ_SetSequencerRanks
3576
  * @param  ADCx ADC instance
3577
  * @param  Rank This parameter can be one of the following values:
3578
  *         @arg @ref LL_ADC_INJ_RANK_1
3579
  *         @arg @ref LL_ADC_INJ_RANK_2
3580
  *         @arg @ref LL_ADC_INJ_RANK_3
3581
  *         @arg @ref LL_ADC_INJ_RANK_4
3582
  * @retval Returned value can be one of the following values:
3583
  *         @arg @ref LL_ADC_CHANNEL_0          (2)
3584
  *         @arg @ref LL_ADC_CHANNEL_1          (2)
3585
  *         @arg @ref LL_ADC_CHANNEL_2          (2)
3586
  *         @arg @ref LL_ADC_CHANNEL_3          (2)
3587
  *         @arg @ref LL_ADC_CHANNEL_4          (1)
3588
  *         @arg @ref LL_ADC_CHANNEL_5          (1)
3589
  *         @arg @ref LL_ADC_CHANNEL_6          (2)
3590
  *         @arg @ref LL_ADC_CHANNEL_7          (2)
3591
  *         @arg @ref LL_ADC_CHANNEL_8          (2)
3592
  *         @arg @ref LL_ADC_CHANNEL_9          (2)
3593
  *         @arg @ref LL_ADC_CHANNEL_10         (2)
3594
  *         @arg @ref LL_ADC_CHANNEL_11         (2)
3595
  *         @arg @ref LL_ADC_CHANNEL_12         (2)
3596
  *         @arg @ref LL_ADC_CHANNEL_13         (3)
3597
  *         @arg @ref LL_ADC_CHANNEL_14         (3)
3598
  *         @arg @ref LL_ADC_CHANNEL_15         (3)
3599
  *         @arg @ref LL_ADC_CHANNEL_16         (3)
3600
  *         @arg @ref LL_ADC_CHANNEL_17         (3)
3601
  *         @arg @ref LL_ADC_CHANNEL_18         (3)
3602
  *         @arg @ref LL_ADC_CHANNEL_19         (3)
3603
  *         @arg @ref LL_ADC_CHANNEL_20         (3)
3604
  *         @arg @ref LL_ADC_CHANNEL_21         (3)
3605
  *         @arg @ref LL_ADC_CHANNEL_22         (1)
3606
  *         @arg @ref LL_ADC_CHANNEL_23         (1)
3607
  *         @arg @ref LL_ADC_CHANNEL_24         (1)
3608
  *         @arg @ref LL_ADC_CHANNEL_25         (1)
3609
  *         @arg @ref LL_ADC_CHANNEL_26         (3)
3610
  *         @arg @ref LL_ADC_CHANNEL_27         (3)(4)
3611
  *         @arg @ref LL_ADC_CHANNEL_28         (3)(4)
3612
  *         @arg @ref LL_ADC_CHANNEL_29         (3)(4)
3613
  *         @arg @ref LL_ADC_CHANNEL_30         (3)(4)
3614
  *         @arg @ref LL_ADC_CHANNEL_31         (3)(4)
3615
  *         @arg @ref LL_ADC_CHANNEL_VREFINT    (3)(6)
3616
  *         @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)(6)
3617
  *         @arg @ref LL_ADC_CHANNEL_VCOMP      (3)(6)
3618
  *         @arg @ref LL_ADC_CHANNEL_VOPAMP1    (3)(5)
3619
  *         @arg @ref LL_ADC_CHANNEL_VOPAMP2    (3)(5)
3620
  *         @arg @ref LL_ADC_CHANNEL_VOPAMP3    (3)(5)
3621
  *        
3622
  *         (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
3623
  *         (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
3624
  *         (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
3625
  *         (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
3626
  *         (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5.\n
3627
  *         (6) For ADC channel read back from ADC register,
3628
  *             comparison with internal channel parameter to be done
3629
  *             using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
3630
  */
3631
__STATIC_INLINE uint32_t LL_ADC_INJ_GetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank)
3632
{
3633
  return (uint32_t)(READ_BIT(ADCx->JSQR,
3634
                             ADC_CHANNEL_ID_NUMBER_MASK << (Rank & ADC_INJ_RANK_ID_JSQR_MASK))
3635
                    >> (Rank & ADC_INJ_RANK_ID_JSQR_MASK)
3636
                   );
3637
}
3638
 
3639
/**
3640
  * @brief  Set ADC group injected conversion trigger:
3641
  *         independent or from ADC group regular.
3642
  * @note   This mode can be used to extend number of data registers
3643
  *         updated after one ADC conversion trigger and with data
3644
  *         permanently kept (not erased by successive conversions of scan of
3645
  *         ADC sequencer ranks), up to 5 data registers:
3646
  *         1 data register on ADC group regular, 4 data registers
3647
  *         on ADC group injected.            
3648
  * @note   If ADC group injected injected trigger source is set to an
3649
  *         external trigger, this feature must be must be set to
3650
  *         independent trigger.
3651
  *         ADC group injected automatic trigger is compliant only with
3652
  *         group injected trigger source set to SW start, without any
3653
  *         further action on  ADC group injected conversion start or stop:
3654
  *         in this case, ADC group injected is controlled only
3655
  *         from ADC group regular.
3656
  * @note   It is not possible to enable both ADC group injected
3657
  *         auto-injected mode and sequencer discontinuous mode.
3658
  * @rmtoll CR1      JAUTO          LL_ADC_INJ_SetTrigAuto
3659
  * @param  ADCx ADC instance
3660
  * @param  TrigAuto This parameter can be one of the following values:
3661
  *         @arg @ref LL_ADC_INJ_TRIG_INDEPENDENT
3662
  *         @arg @ref LL_ADC_INJ_TRIG_FROM_GRP_REGULAR
3663
  * @retval None
3664
  */
3665
__STATIC_INLINE void LL_ADC_INJ_SetTrigAuto(ADC_TypeDef *ADCx, uint32_t TrigAuto)
3666
{
3667
  MODIFY_REG(ADCx->CR1, ADC_CR1_JAUTO, TrigAuto);
3668
}
3669
 
3670
/**
3671
  * @brief  Get ADC group injected conversion trigger:
3672
  *         independent or from ADC group regular.
3673
  * @rmtoll CR1      JAUTO          LL_ADC_INJ_GetTrigAuto
3674
  * @param  ADCx ADC instance
3675
  * @retval Returned value can be one of the following values:
3676
  *         @arg @ref LL_ADC_INJ_TRIG_INDEPENDENT
3677
  *         @arg @ref LL_ADC_INJ_TRIG_FROM_GRP_REGULAR
3678
  */
3679
__STATIC_INLINE uint32_t LL_ADC_INJ_GetTrigAuto(ADC_TypeDef *ADCx)
3680
{
3681
  return (uint32_t)(READ_BIT(ADCx->CR1, ADC_CR1_JAUTO));
3682
}
3683
 
3684
/**
3685
  * @brief  Set ADC group injected offset.
3686
  * @note   It sets:
3687
  *         - ADC group injected rank to which the offset programmed
3688
  *           will be applied
3689
  *         - Offset level (offset to be subtracted from the raw
3690
  *           converted data).
3691
  *         Caution: Offset format is dependent to ADC resolution:
3692
  *         offset has to be left-aligned on bit 11, the LSB (right bits)
3693
  *         are set to 0.
3694
  * @note   Offset cannot be enabled or disabled.
3695
  *         To emulate offset disabled, set an offset value equal to 0.
3696
  * @rmtoll JOFR1    JOFFSET1       LL_ADC_INJ_SetOffset\n
3697
  *         JOFR2    JOFFSET2       LL_ADC_INJ_SetOffset\n
3698
  *         JOFR3    JOFFSET3       LL_ADC_INJ_SetOffset\n
3699
  *         JOFR4    JOFFSET4       LL_ADC_INJ_SetOffset
3700
  * @param  ADCx ADC instance
3701
  * @param  Rank This parameter can be one of the following values:
3702
  *         @arg @ref LL_ADC_INJ_RANK_1
3703
  *         @arg @ref LL_ADC_INJ_RANK_2
3704
  *         @arg @ref LL_ADC_INJ_RANK_3
3705
  *         @arg @ref LL_ADC_INJ_RANK_4
3706
  * @param  OffsetLevel Value between Min_Data=0x000 and Max_Data=0xFFF
3707
  * @retval None
3708
  */
3709
__STATIC_INLINE void LL_ADC_INJ_SetOffset(ADC_TypeDef *ADCx, uint32_t Rank, uint32_t OffsetLevel)
3710
{
3711
  uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JOFR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JOFRX_REGOFFSET_MASK));
3712
 
3713
  MODIFY_REG(*preg,
3714
             ADC_JOFR1_JOFFSET1,
3715
             OffsetLevel);
3716
}
3717
 
3718
/**
3719
  * @brief  Get ADC group injected offset.
3720
  * @note   It gives offset level (offset to be subtracted from the raw converted data).
3721
  *         Caution: Offset format is dependent to ADC resolution:
3722
  *         offset has to be left-aligned on bit 11, the LSB (right bits)
3723
  *         are set to 0.
3724
  * @rmtoll JOFR1    JOFFSET1       LL_ADC_INJ_GetOffset\n
3725
  *         JOFR2    JOFFSET2       LL_ADC_INJ_GetOffset\n
3726
  *         JOFR3    JOFFSET3       LL_ADC_INJ_GetOffset\n
3727
  *         JOFR4    JOFFSET4       LL_ADC_INJ_GetOffset
3728
  * @param  ADCx ADC instance
3729
  * @param  Rank This parameter can be one of the following values:
3730
  *         @arg @ref LL_ADC_INJ_RANK_1
3731
  *         @arg @ref LL_ADC_INJ_RANK_2
3732
  *         @arg @ref LL_ADC_INJ_RANK_3
3733
  *         @arg @ref LL_ADC_INJ_RANK_4
3734
  * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
3735
  */
3736
__STATIC_INLINE uint32_t LL_ADC_INJ_GetOffset(ADC_TypeDef *ADCx, uint32_t Rank)
3737
{
3738
  uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JOFR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JOFRX_REGOFFSET_MASK));
3739
 
3740
  return (uint32_t)(READ_BIT(*preg,
3741
                             ADC_JOFR1_JOFFSET1)
3742
                   );
3743
}
3744
 
3745
/**
3746
  * @}
3747
  */
3748
 
3749
/** @defgroup ADC_LL_EF_Configuration_Channels Configuration of ADC hierarchical scope: channels
3750
  * @{
3751
  */
3752
 
3753
/**
3754
  * @brief  Set sampling time of the selected ADC channel
3755
  *         Unit: ADC clock cycles.
3756
  * @note   On this device, sampling time is on channel scope: independently
3757
  *         of channel mapped on ADC group regular or injected.
3758
  * @note   In case of internal channel (VrefInt, TempSensor, ...) to be
3759
  *         converted:
3760
  *         sampling time constraints must be respected (sampling time can be
3761
  *         adjusted in function of ADC clock frequency and sampling time
3762
  *         setting).
3763
  *         Refer to device datasheet for timings values (parameters TS_vrefint,
3764
  *         TS_temp, ...).
3765
  * @note   Conversion time is the addition of sampling time and processing time.
3766
  *         Refer to reference manual for ADC processing time of
3767
  *         this STM32 serie.
3768
  * @note   In case of ADC conversion of internal channel (VrefInt,
3769
  *         temperature sensor, ...), a sampling time minimum value
3770
  *         is required.
3771
  *         Refer to device datasheet.
3772
  * @rmtoll SMPR0    SMP31          LL_ADC_SetChannelSamplingTime\n
3773
  *         SMPR0    SMP30          LL_ADC_SetChannelSamplingTime\n
3774
  *         SMPR1    SMP29          LL_ADC_SetChannelSamplingTime\n
3775
  *         SMPR1    SMP28          LL_ADC_SetChannelSamplingTime\n
3776
  *         SMPR1    SMP27          LL_ADC_SetChannelSamplingTime\n
3777
  *         SMPR1    SMP26          LL_ADC_SetChannelSamplingTime\n
3778
  *         SMPR1    SMP25          LL_ADC_SetChannelSamplingTime\n
3779
  *         SMPR1    SMP24          LL_ADC_SetChannelSamplingTime\n
3780
  *         SMPR1    SMP23          LL_ADC_SetChannelSamplingTime\n
3781
  *         SMPR1    SMP22          LL_ADC_SetChannelSamplingTime\n
3782
  *         SMPR1    SMP21          LL_ADC_SetChannelSamplingTime\n
3783
  *         SMPR1    SMP20          LL_ADC_SetChannelSamplingTime\n
3784
  *         SMPR2    SMP19          LL_ADC_SetChannelSamplingTime\n
3785
  *         SMPR2    SMP18          LL_ADC_SetChannelSamplingTime\n
3786
  *         SMPR2    SMP17          LL_ADC_SetChannelSamplingTime\n
3787
  *         SMPR2    SMP16          LL_ADC_SetChannelSamplingTime\n
3788
  *         SMPR2    SMP15          LL_ADC_SetChannelSamplingTime\n
3789
  *         SMPR2    SMP14          LL_ADC_SetChannelSamplingTime\n
3790
  *         SMPR2    SMP13          LL_ADC_SetChannelSamplingTime\n
3791
  *         SMPR2    SMP12          LL_ADC_SetChannelSamplingTime\n
3792
  *         SMPR2    SMP11          LL_ADC_SetChannelSamplingTime\n
3793
  *         SMPR2    SMP10          LL_ADC_SetChannelSamplingTime\n
3794
  *         SMPR3    SMP9           LL_ADC_SetChannelSamplingTime\n
3795
  *         SMPR3    SMP8           LL_ADC_SetChannelSamplingTime\n
3796
  *         SMPR3    SMP7           LL_ADC_SetChannelSamplingTime\n
3797
  *         SMPR3    SMP6           LL_ADC_SetChannelSamplingTime\n
3798
  *         SMPR3    SMP5           LL_ADC_SetChannelSamplingTime\n
3799
  *         SMPR3    SMP4           LL_ADC_SetChannelSamplingTime\n
3800
  *         SMPR3    SMP3           LL_ADC_SetChannelSamplingTime\n
3801
  *         SMPR3    SMP2           LL_ADC_SetChannelSamplingTime\n
3802
  *         SMPR3    SMP1           LL_ADC_SetChannelSamplingTime\n
3803
  *         SMPR3    SMP0           LL_ADC_SetChannelSamplingTime
3804
  * @param  ADCx ADC instance
3805
  * @param  Channel This parameter can be one of the following values:
3806
  *         @arg @ref LL_ADC_CHANNEL_0          (2)
3807
  *         @arg @ref LL_ADC_CHANNEL_1          (2)
3808
  *         @arg @ref LL_ADC_CHANNEL_2          (2)
3809
  *         @arg @ref LL_ADC_CHANNEL_3          (2)
3810
  *         @arg @ref LL_ADC_CHANNEL_4          (1)
3811
  *         @arg @ref LL_ADC_CHANNEL_5          (1)
3812
  *         @arg @ref LL_ADC_CHANNEL_6          (2)
3813
  *         @arg @ref LL_ADC_CHANNEL_7          (2)
3814
  *         @arg @ref LL_ADC_CHANNEL_8          (2)
3815
  *         @arg @ref LL_ADC_CHANNEL_9          (2)
3816
  *         @arg @ref LL_ADC_CHANNEL_10         (2)
3817
  *         @arg @ref LL_ADC_CHANNEL_11         (2)
3818
  *         @arg @ref LL_ADC_CHANNEL_12         (2)
3819
  *         @arg @ref LL_ADC_CHANNEL_13         (3)
3820
  *         @arg @ref LL_ADC_CHANNEL_14         (3)
3821
  *         @arg @ref LL_ADC_CHANNEL_15         (3)
3822
  *         @arg @ref LL_ADC_CHANNEL_16         (3)
3823
  *         @arg @ref LL_ADC_CHANNEL_17         (3)
3824
  *         @arg @ref LL_ADC_CHANNEL_18         (3)
3825
  *         @arg @ref LL_ADC_CHANNEL_19         (3)
3826
  *         @arg @ref LL_ADC_CHANNEL_20         (3)
3827
  *         @arg @ref LL_ADC_CHANNEL_21         (3)
3828
  *         @arg @ref LL_ADC_CHANNEL_22         (1)
3829
  *         @arg @ref LL_ADC_CHANNEL_23         (1)
3830
  *         @arg @ref LL_ADC_CHANNEL_24         (1)
3831
  *         @arg @ref LL_ADC_CHANNEL_25         (1)
3832
  *         @arg @ref LL_ADC_CHANNEL_26         (3)
3833
  *         @arg @ref LL_ADC_CHANNEL_27         (3)(4)
3834
  *         @arg @ref LL_ADC_CHANNEL_28         (3)(4)
3835
  *         @arg @ref LL_ADC_CHANNEL_29         (3)(4)
3836
  *         @arg @ref LL_ADC_CHANNEL_30         (3)(4)
3837
  *         @arg @ref LL_ADC_CHANNEL_31         (3)(4)
3838
  *         @arg @ref LL_ADC_CHANNEL_VREFINT    (3)
3839
  *         @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)
3840
  *         @arg @ref LL_ADC_CHANNEL_VCOMP      (3)
3841
  *         @arg @ref LL_ADC_CHANNEL_VOPAMP1    (3)(5)
3842
  *         @arg @ref LL_ADC_CHANNEL_VOPAMP2    (3)(5)
3843
  *         @arg @ref LL_ADC_CHANNEL_VOPAMP3    (3)(5)
3844
  *        
3845
  *         (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
3846
  *         (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
3847
  *         (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
3848
  *         (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
3849
  *         (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
3850
  * @param  SamplingTime This parameter can be one of the following values:
3851
  *         @arg @ref LL_ADC_SAMPLINGTIME_4CYCLES
3852
  *         @arg @ref LL_ADC_SAMPLINGTIME_9CYCLES
3853
  *         @arg @ref LL_ADC_SAMPLINGTIME_16CYCLES
3854
  *         @arg @ref LL_ADC_SAMPLINGTIME_24CYCLES
3855
  *         @arg @ref LL_ADC_SAMPLINGTIME_48CYCLES
3856
  *         @arg @ref LL_ADC_SAMPLINGTIME_96CYCLES
3857
  *         @arg @ref LL_ADC_SAMPLINGTIME_192CYCLES
3858
  *         @arg @ref LL_ADC_SAMPLINGTIME_384CYCLES
3859
  * @retval None
3860
  */
3861
__STATIC_INLINE void LL_ADC_SetChannelSamplingTime(ADC_TypeDef *ADCx, uint32_t Channel, uint32_t SamplingTime)
3862
{
3863
  /* Set bits with content of parameter "SamplingTime" with bits position     */
3864
  /* in register and register position depending on parameter "Channel".      */
3865
  /* Parameter "Channel" is used with masks because containing                */
3866
  /* other bits reserved for other purpose.                                   */
3867
  uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SMPR1, __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPRX_REGOFFSET_MASK));
3868
 
3869
  MODIFY_REG(*preg,
3870
             ADC_SMPR3_SMP0 << __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK),
3871
             SamplingTime   << __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK));
3872
}
3873
 
3874
/**
3875
  * @brief  Get sampling time of the selected ADC channel
3876
  *         Unit: ADC clock cycles.
3877
  * @note   On this device, sampling time is on channel scope: independently
3878
  *         of channel mapped on ADC group regular or injected.
3879
  * @note   Conversion time is the addition of sampling time and processing time.
3880
  *         Refer to reference manual for ADC processing time of
3881
  *         this STM32 serie.
3882
  * @rmtoll SMPR0    SMP31          LL_ADC_GetChannelSamplingTime\n
3883
  *         SMPR0    SMP30          LL_ADC_GetChannelSamplingTime\n
3884
  *         SMPR1    SMP29          LL_ADC_GetChannelSamplingTime\n
3885
  *         SMPR1    SMP28          LL_ADC_GetChannelSamplingTime\n
3886
  *         SMPR1    SMP27          LL_ADC_GetChannelSamplingTime\n
3887
  *         SMPR1    SMP26          LL_ADC_GetChannelSamplingTime\n
3888
  *         SMPR1    SMP25          LL_ADC_GetChannelSamplingTime\n
3889
  *         SMPR1    SMP24          LL_ADC_GetChannelSamplingTime\n
3890
  *         SMPR1    SMP23          LL_ADC_GetChannelSamplingTime\n
3891
  *         SMPR1    SMP22          LL_ADC_GetChannelSamplingTime\n
3892
  *         SMPR1    SMP21          LL_ADC_GetChannelSamplingTime\n
3893
  *         SMPR1    SMP20          LL_ADC_GetChannelSamplingTime\n
3894
  *         SMPR2    SMP19          LL_ADC_GetChannelSamplingTime\n
3895
  *         SMPR2    SMP18          LL_ADC_GetChannelSamplingTime\n
3896
  *         SMPR2    SMP17          LL_ADC_GetChannelSamplingTime\n
3897
  *         SMPR2    SMP16          LL_ADC_GetChannelSamplingTime\n
3898
  *         SMPR2    SMP15          LL_ADC_GetChannelSamplingTime\n
3899
  *         SMPR2    SMP14          LL_ADC_GetChannelSamplingTime\n
3900
  *         SMPR2    SMP13          LL_ADC_GetChannelSamplingTime\n
3901
  *         SMPR2    SMP12          LL_ADC_GetChannelSamplingTime\n
3902
  *         SMPR2    SMP11          LL_ADC_GetChannelSamplingTime\n
3903
  *         SMPR2    SMP10          LL_ADC_GetChannelSamplingTime\n
3904
  *         SMPR3    SMP9           LL_ADC_GetChannelSamplingTime\n
3905
  *         SMPR3    SMP8           LL_ADC_GetChannelSamplingTime\n
3906
  *         SMPR3    SMP7           LL_ADC_GetChannelSamplingTime\n
3907
  *         SMPR3    SMP6           LL_ADC_GetChannelSamplingTime\n
3908
  *         SMPR3    SMP5           LL_ADC_GetChannelSamplingTime\n
3909
  *         SMPR3    SMP4           LL_ADC_GetChannelSamplingTime\n
3910
  *         SMPR3    SMP3           LL_ADC_GetChannelSamplingTime\n
3911
  *         SMPR3    SMP2           LL_ADC_GetChannelSamplingTime\n
3912
  *         SMPR3    SMP1           LL_ADC_GetChannelSamplingTime\n
3913
  *         SMPR3    SMP0           LL_ADC_GetChannelSamplingTime
3914
  * @param  ADCx ADC instance
3915
  * @param  Channel This parameter can be one of the following values:
3916
  *         @arg @ref LL_ADC_CHANNEL_0          (2)
3917
  *         @arg @ref LL_ADC_CHANNEL_1          (2)
3918
  *         @arg @ref LL_ADC_CHANNEL_2          (2)
3919
  *         @arg @ref LL_ADC_CHANNEL_3          (2)
3920
  *         @arg @ref LL_ADC_CHANNEL_4          (1)
3921
  *         @arg @ref LL_ADC_CHANNEL_5          (1)
3922
  *         @arg @ref LL_ADC_CHANNEL_6          (2)
3923
  *         @arg @ref LL_ADC_CHANNEL_7          (2)
3924
  *         @arg @ref LL_ADC_CHANNEL_8          (2)
3925
  *         @arg @ref LL_ADC_CHANNEL_9          (2)
3926
  *         @arg @ref LL_ADC_CHANNEL_10         (2)
3927
  *         @arg @ref LL_ADC_CHANNEL_11         (2)
3928
  *         @arg @ref LL_ADC_CHANNEL_12         (2)
3929
  *         @arg @ref LL_ADC_CHANNEL_13         (3)
3930
  *         @arg @ref LL_ADC_CHANNEL_14         (3)
3931
  *         @arg @ref LL_ADC_CHANNEL_15         (3)
3932
  *         @arg @ref LL_ADC_CHANNEL_16         (3)
3933
  *         @arg @ref LL_ADC_CHANNEL_17         (3)
3934
  *         @arg @ref LL_ADC_CHANNEL_18         (3)
3935
  *         @arg @ref LL_ADC_CHANNEL_19         (3)
3936
  *         @arg @ref LL_ADC_CHANNEL_20         (3)
3937
  *         @arg @ref LL_ADC_CHANNEL_21         (3)
3938
  *         @arg @ref LL_ADC_CHANNEL_22         (1)
3939
  *         @arg @ref LL_ADC_CHANNEL_23         (1)
3940
  *         @arg @ref LL_ADC_CHANNEL_24         (1)
3941
  *         @arg @ref LL_ADC_CHANNEL_25         (1)
3942
  *         @arg @ref LL_ADC_CHANNEL_26         (3)
3943
  *         @arg @ref LL_ADC_CHANNEL_27         (3)(4)
3944
  *         @arg @ref LL_ADC_CHANNEL_28         (3)(4)
3945
  *         @arg @ref LL_ADC_CHANNEL_29         (3)(4)
3946
  *         @arg @ref LL_ADC_CHANNEL_30         (3)(4)
3947
  *         @arg @ref LL_ADC_CHANNEL_31         (3)(4)
3948
  *         @arg @ref LL_ADC_CHANNEL_VREFINT    (3)
3949
  *         @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)
3950
  *         @arg @ref LL_ADC_CHANNEL_VCOMP      (3)
3951
  *         @arg @ref LL_ADC_CHANNEL_VOPAMP1    (3)(5)
3952
  *         @arg @ref LL_ADC_CHANNEL_VOPAMP2    (3)(5)
3953
  *         @arg @ref LL_ADC_CHANNEL_VOPAMP3    (3)(5)
3954
  *        
3955
  *         (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
3956
  *         (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
3957
  *         (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
3958
  *         (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
3959
  *         (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
3960
  * @retval Returned value can be one of the following values:
3961
  *         @arg @ref LL_ADC_SAMPLINGTIME_4CYCLES
3962
  *         @arg @ref LL_ADC_SAMPLINGTIME_9CYCLES
3963
  *         @arg @ref LL_ADC_SAMPLINGTIME_16CYCLES
3964
  *         @arg @ref LL_ADC_SAMPLINGTIME_24CYCLES
3965
  *         @arg @ref LL_ADC_SAMPLINGTIME_48CYCLES
3966
  *         @arg @ref LL_ADC_SAMPLINGTIME_96CYCLES
3967
  *         @arg @ref LL_ADC_SAMPLINGTIME_192CYCLES
3968
  *         @arg @ref LL_ADC_SAMPLINGTIME_384CYCLES
3969
  */
3970
__STATIC_INLINE uint32_t LL_ADC_GetChannelSamplingTime(ADC_TypeDef *ADCx, uint32_t Channel)
3971
{
3972
  uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SMPR1, __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPRX_REGOFFSET_MASK));
3973
 
3974
  return (uint32_t)(READ_BIT(*preg,
3975
                             ADC_SMPR3_SMP0 << __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK))
3976
                    >> __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK)
3977
                   );
3978
}
3979
 
3980
#if defined(COMP_CSR_FCH3)
3981
/**
3982
  * @brief  Set ADC channels routing.
3983
  * @note   Channel routing set configuration between ADC IP and GPIO pads,
3984
  *         it is used to increase ADC channels speed (setting of
3985
  *         direct channel).
3986
  * @note   This feature is specific to STM32L1, on devices
3987
  *         category Cat.3, Cat.4, Cat.5.
3988
  *         To use this function, COMP RCC clock domain must be enabled.
3989
  *         Refer to @ref LL_APB1_GRP1_PERIPH_COMP.
3990
  * @rmtoll CSR      FCH3           LL_ADC_SetChannelRouting
3991
  * @rmtoll CSR      FCH8           LL_ADC_SetChannelRouting
3992
  * @rmtoll CSR      RCH13          LL_ADC_SetChannelRouting
3993
  * @param  ADCx ADC instance
3994
  * @param  Channel This parameter can be one of the following values:
3995
  *         @arg @ref LL_ADC_CHANNEL_3_ROUTING  (1)
3996
  *         @arg @ref LL_ADC_CHANNEL_8_ROUTING  (2)
3997
  *         @arg @ref LL_ADC_CHANNEL_13_ROUTING (3)
3998
  *
3999
  *         (1) Used as ADC direct channel (fast channel) if OPAMP1 is
4000
  *             in power down mode.\n
4001
  *         (2) Used as ADC direct channel (fast channel) if OPAMP2 is
4002
  *             in power down mode.\n
4003
  *         (3) Used as ADC re-routed channel if OPAMP3 is
4004
  *             in power down mode.
4005
  *             Otherwise, channel 13 is connected to OPAMP3 output and routed
4006
  *             through switches COMP1_SW1 and VCOMP to ADC switch matrix.
4007
  *             (Note: OPAMP3 is available on STM32L1 Cat.4 only).
4008
  * @param  Routing This parameter can be one of the following values:
4009
  *         @arg @ref LL_ADC_CHANNEL_ROUTING_DEFAULT
4010
  *         @arg @ref LL_ADC_CHANNEL_ROUTING_DIRECT
4011
  */
4012
__STATIC_INLINE void LL_ADC_SetChannelRouting(ADC_TypeDef *ADCx, uint32_t Channel, uint32_t Routing)
4013
{
4014
  /* Note: Bit is located in comparator IP, but dedicated to ADC */
4015
  MODIFY_REG(COMP->CSR, Channel, (Routing << POSITION_VAL(Channel)));
4016
}
4017
 
4018
/**
4019
  * @brief  Get ADC channels speed.
4020
  * @note   Channel routing set configuration between ADC IP and GPIO pads,
4021
  *         it is used to increase ADC channels speed (setting of
4022
  *         direct channel).
4023
  * @note   This feature is specific to STM32L1, on devices
4024
  *         category Cat.3, Cat.4, Cat.5.
4025
  *         To use this function, COMP RCC clock domain must be enabled.
4026
  *         Refer to @ref LL_APB1_GRP1_PERIPH_COMP.
4027
  * @rmtoll CSR      FCH3           LL_ADC_GetChannelRouting
4028
  * @rmtoll CSR      FCH8           LL_ADC_GetChannelRouting
4029
  * @rmtoll CSR      RCH13          LL_ADC_GetChannelRouting
4030
  * @param  ADCx ADC instance
4031
  * @param  Channel This parameter can be one of the following values:
4032
  *         @arg @ref LL_ADC_CHANNEL_3_ROUTING  (1)
4033
  *         @arg @ref LL_ADC_CHANNEL_8_ROUTING  (2)
4034
  *         @arg @ref LL_ADC_CHANNEL_13_ROUTING (3)
4035
  *
4036
  *         (1) Used as ADC direct channel (fast channel) if OPAMP1 is
4037
  *             in power down mode.\n
4038
  *         (2) Used as ADC direct channel (fast channel) if OPAMP2 is
4039
  *             in power down mode.\n
4040
  *         (3) Used as ADC re-routed channel if OPAMP3 is
4041
  *             in power down mode.
4042
  *             Otherwise, channel 13 is connected to OPAMP3 output and routed
4043
  *             through switches COMP1_SW1 and VCOMP to ADC switch matrix.
4044
  *             (Note: OPAMP3 is available on STM32L1 Cat.4 only).
4045
  * @retval Returned value can be one of the following values:
4046
  *         @arg @ref LL_ADC_CHANNEL_ROUTING_DEFAULT
4047
  *         @arg @ref LL_ADC_CHANNEL_ROUTING_DIRECT
4048
  */
4049
__STATIC_INLINE uint32_t LL_ADC_GetChannelRouting(ADC_TypeDef *ADCx, uint32_t Channel)
4050
{
4051
  /* Note: Bit is located in comparator IP, but dedicated to ADC */
4052
  return (uint32_t)(READ_BIT(COMP->CSR, Channel) >> POSITION_VAL(Channel));
4053
}
4054
#endif
4055
 
4056
/**
4057
  * @}
4058
  */
4059
 
4060
/** @defgroup ADC_LL_EF_Configuration_ADC_AnalogWatchdog Configuration of ADC transversal scope: analog watchdog
4061
  * @{
4062
  */
4063
 
4064
/**
4065
  * @brief  Set ADC analog watchdog monitored channels:
4066
  *         a single channel or all channels,
4067
  *         on ADC groups regular and-or injected.
4068
  * @note   Once monitored channels are selected, analog watchdog
4069
  *         is enabled.
4070
  * @note   In case of need to define a single channel to monitor
4071
  *         with analog watchdog from sequencer channel definition,
4072
  *         use helper macro @ref __LL_ADC_ANALOGWD_CHANNEL_GROUP().
4073
  * @note   On this STM32 serie, there is only 1 kind of analog watchdog
4074
  *         instance:
4075
  *         - AWD standard (instance AWD1):
4076
  *           - channels monitored: can monitor 1 channel or all channels.
4077
  *           - groups monitored: ADC groups regular and-or injected.
4078
  *           - resolution: resolution is not limited (corresponds to
4079
  *             ADC resolution configured).
4080
  * @rmtoll CR1      AWD1CH         LL_ADC_SetAnalogWDMonitChannels\n
4081
  *         CR1      AWD1SGL        LL_ADC_SetAnalogWDMonitChannels\n
4082
  *         CR1      AWD1EN         LL_ADC_SetAnalogWDMonitChannels
4083
  * @param  ADCx ADC instance
4084
  * @param  AWDChannelGroup This parameter can be one of the following values:
4085
  *         @arg @ref LL_ADC_AWD_DISABLE
4086
  *         @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG
4087
  *         @arg @ref LL_ADC_AWD_ALL_CHANNELS_INJ
4088
  *         @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG_INJ
4089
  *         @arg @ref LL_ADC_AWD_CHANNEL_0_REG           (2)
4090
  *         @arg @ref LL_ADC_AWD_CHANNEL_0_INJ           (2)
4091
  *         @arg @ref LL_ADC_AWD_CHANNEL_0_REG_INJ       (2)
4092
  *         @arg @ref LL_ADC_AWD_CHANNEL_1_REG           (2)
4093
  *         @arg @ref LL_ADC_AWD_CHANNEL_1_INJ           (2)
4094
  *         @arg @ref LL_ADC_AWD_CHANNEL_1_REG_INJ       (2)
4095
  *         @arg @ref LL_ADC_AWD_CHANNEL_2_REG           (2)
4096
  *         @arg @ref LL_ADC_AWD_CHANNEL_2_INJ           (2)
4097
  *         @arg @ref LL_ADC_AWD_CHANNEL_2_REG_INJ       (2)
4098
  *         @arg @ref LL_ADC_AWD_CHANNEL_3_REG           (2)
4099
  *         @arg @ref LL_ADC_AWD_CHANNEL_3_INJ           (2)
4100
  *         @arg @ref LL_ADC_AWD_CHANNEL_3_REG_INJ       (2)
4101
  *         @arg @ref LL_ADC_AWD_CHANNEL_4_REG           (1)
4102
  *         @arg @ref LL_ADC_AWD_CHANNEL_4_INJ           (1)
4103
  *         @arg @ref LL_ADC_AWD_CHANNEL_4_REG_INJ       (1)
4104
  *         @arg @ref LL_ADC_AWD_CHANNEL_5_REG           (1)
4105
  *         @arg @ref LL_ADC_AWD_CHANNEL_5_INJ           (1)
4106
  *         @arg @ref LL_ADC_AWD_CHANNEL_5_REG_INJ       (1)
4107
  *         @arg @ref LL_ADC_AWD_CHANNEL_6_REG           (2)
4108
  *         @arg @ref LL_ADC_AWD_CHANNEL_6_INJ           (2)
4109
  *         @arg @ref LL_ADC_AWD_CHANNEL_6_REG_INJ       (2)
4110
  *         @arg @ref LL_ADC_AWD_CHANNEL_7_REG           (2)
4111
  *         @arg @ref LL_ADC_AWD_CHANNEL_7_INJ           (2)
4112
  *         @arg @ref LL_ADC_AWD_CHANNEL_7_REG_INJ       (2)
4113
  *         @arg @ref LL_ADC_AWD_CHANNEL_8_REG           (2)
4114
  *         @arg @ref LL_ADC_AWD_CHANNEL_8_INJ           (2)
4115
  *         @arg @ref LL_ADC_AWD_CHANNEL_8_REG_INJ       (2)
4116
  *         @arg @ref LL_ADC_AWD_CHANNEL_9_REG           (2)
4117
  *         @arg @ref LL_ADC_AWD_CHANNEL_9_INJ           (2)
4118
  *         @arg @ref LL_ADC_AWD_CHANNEL_9_REG_INJ       (2)
4119
  *         @arg @ref LL_ADC_AWD_CHANNEL_10_REG          (2)
4120
  *         @arg @ref LL_ADC_AWD_CHANNEL_10_INJ          (2)
4121
  *         @arg @ref LL_ADC_AWD_CHANNEL_10_REG_INJ      (2)
4122
  *         @arg @ref LL_ADC_AWD_CHANNEL_11_REG          (2)
4123
  *         @arg @ref LL_ADC_AWD_CHANNEL_11_INJ          (2)
4124
  *         @arg @ref LL_ADC_AWD_CHANNEL_11_REG_INJ      (2)
4125
  *         @arg @ref LL_ADC_AWD_CHANNEL_12_REG          (2)
4126
  *         @arg @ref LL_ADC_AWD_CHANNEL_12_INJ          (2)
4127
  *         @arg @ref LL_ADC_AWD_CHANNEL_12_REG_INJ      (2)
4128
  *         @arg @ref LL_ADC_AWD_CHANNEL_13_REG          (3)
4129
  *         @arg @ref LL_ADC_AWD_CHANNEL_13_INJ          (3)
4130
  *         @arg @ref LL_ADC_AWD_CHANNEL_13_REG_INJ      (3)
4131
  *         @arg @ref LL_ADC_AWD_CHANNEL_14_REG          (3)
4132
  *         @arg @ref LL_ADC_AWD_CHANNEL_14_INJ          (3)
4133
  *         @arg @ref LL_ADC_AWD_CHANNEL_14_REG_INJ      (3)
4134
  *         @arg @ref LL_ADC_AWD_CHANNEL_15_REG          (3)
4135
  *         @arg @ref LL_ADC_AWD_CHANNEL_15_INJ          (3)
4136
  *         @arg @ref LL_ADC_AWD_CHANNEL_15_REG_INJ      (3)
4137
  *         @arg @ref LL_ADC_AWD_CHANNEL_16_REG          (3)
4138
  *         @arg @ref LL_ADC_AWD_CHANNEL_16_INJ          (3)
4139
  *         @arg @ref LL_ADC_AWD_CHANNEL_16_REG_INJ      (3)
4140
  *         @arg @ref LL_ADC_AWD_CHANNEL_17_REG          (3)
4141
  *         @arg @ref LL_ADC_AWD_CHANNEL_17_INJ          (3)
4142
  *         @arg @ref LL_ADC_AWD_CHANNEL_17_REG_INJ      (3)
4143
  *         @arg @ref LL_ADC_AWD_CHANNEL_18_REG          (3)
4144
  *         @arg @ref LL_ADC_AWD_CHANNEL_18_INJ          (3)
4145
  *         @arg @ref LL_ADC_AWD_CHANNEL_18_REG_INJ      (3)
4146
  *         @arg @ref LL_ADC_AWD_CHANNEL_19_REG          (3)
4147
  *         @arg @ref LL_ADC_AWD_CHANNEL_19_INJ          (3)
4148
  *         @arg @ref LL_ADC_AWD_CHANNEL_19_REG_INJ      (3)
4149
  *         @arg @ref LL_ADC_AWD_CHANNEL_20_REG          (3)
4150
  *         @arg @ref LL_ADC_AWD_CHANNEL_20_INJ          (3)
4151
  *         @arg @ref LL_ADC_AWD_CHANNEL_20_REG_INJ      (3)
4152
  *         @arg @ref LL_ADC_AWD_CHANNEL_21_REG          (3)
4153
  *         @arg @ref LL_ADC_AWD_CHANNEL_21_INJ          (3)
4154
  *         @arg @ref LL_ADC_AWD_CHANNEL_21_REG_INJ      (3)
4155
  *         @arg @ref LL_ADC_AWD_CHANNEL_22_REG          (1)
4156
  *         @arg @ref LL_ADC_AWD_CHANNEL_22_INJ          (1)
4157
  *         @arg @ref LL_ADC_AWD_CHANNEL_22_REG_INJ      (1)
4158
  *         @arg @ref LL_ADC_AWD_CHANNEL_23_REG          (1)
4159
  *         @arg @ref LL_ADC_AWD_CHANNEL_23_INJ          (1)
4160
  *         @arg @ref LL_ADC_AWD_CHANNEL_23_REG_INJ      (1)
4161
  *         @arg @ref LL_ADC_AWD_CHANNEL_24_REG          (1)
4162
  *         @arg @ref LL_ADC_AWD_CHANNEL_24_INJ          (1)
4163
  *         @arg @ref LL_ADC_AWD_CHANNEL_24_REG_INJ      (1)
4164
  *         @arg @ref LL_ADC_AWD_CHANNEL_25_REG          (1)
4165
  *         @arg @ref LL_ADC_AWD_CHANNEL_25_INJ          (1)
4166
  *         @arg @ref LL_ADC_AWD_CHANNEL_25_REG_INJ      (1)
4167
  *         @arg @ref LL_ADC_AWD_CHANNEL_26_REG          (3)
4168
  *         @arg @ref LL_ADC_AWD_CHANNEL_26_INJ          (3)
4169
  *         @arg @ref LL_ADC_AWD_CHANNEL_26_REG_INJ      (3)
4170
  *         @arg @ref LL_ADC_AWD_CHANNEL_27_REG          (3)(4)
4171
  *         @arg @ref LL_ADC_AWD_CHANNEL_27_INJ          (3)(4)
4172
  *         @arg @ref LL_ADC_AWD_CHANNEL_27_REG_INJ      (3)(4)
4173
  *         @arg @ref LL_ADC_AWD_CHANNEL_28_REG          (3)(4)
4174
  *         @arg @ref LL_ADC_AWD_CHANNEL_28_INJ          (3)(4)
4175
  *         @arg @ref LL_ADC_AWD_CHANNEL_28_REG_INJ      (3)(4)
4176
  *         @arg @ref LL_ADC_AWD_CHANNEL_29_REG          (3)(4)
4177
  *         @arg @ref LL_ADC_AWD_CHANNEL_29_INJ          (3)(4)
4178
  *         @arg @ref LL_ADC_AWD_CHANNEL_29_REG_INJ      (3)(4)
4179
  *         @arg @ref LL_ADC_AWD_CHANNEL_30_REG          (3)(4)
4180
  *         @arg @ref LL_ADC_AWD_CHANNEL_30_INJ          (3)(4)
4181
  *         @arg @ref LL_ADC_AWD_CHANNEL_30_REG_INJ      (3)(4)
4182
  *         @arg @ref LL_ADC_AWD_CHANNEL_31_REG          (3)(4)
4183
  *         @arg @ref LL_ADC_AWD_CHANNEL_31_INJ          (3)(4)
4184
  *         @arg @ref LL_ADC_AWD_CHANNEL_31_REG_INJ      (3)(4)
4185
  *         @arg @ref LL_ADC_AWD_CH_VREFINT_REG          (3)
4186
  *         @arg @ref LL_ADC_AWD_CH_VREFINT_INJ          (3)
4187
  *         @arg @ref LL_ADC_AWD_CH_VREFINT_REG_INJ      (3)
4188
  *         @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG       (3)
4189
  *         @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_INJ       (3)
4190
  *         @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG_INJ   (3)
4191
  *         @arg @ref LL_ADC_AWD_CH_VCOMP_REG            (3)
4192
  *         @arg @ref LL_ADC_AWD_CH_VCOMP_INJ            (3)
4193
  *         @arg @ref LL_ADC_AWD_CH_VCOMP_REG_INJ        (3)
4194
  *         @arg @ref LL_ADC_AWD_CH_VOPAMP1_REG          (3)(5)
4195
  *         @arg @ref LL_ADC_AWD_CH_VOPAMP1_INJ          (3)(5)
4196
  *         @arg @ref LL_ADC_AWD_CH_VOPAMP1_REG_INJ      (3)(5)
4197
  *         @arg @ref LL_ADC_AWD_CH_VOPAMP2_REG          (3)(5)
4198
  *         @arg @ref LL_ADC_AWD_CH_VOPAMP2_INJ          (3)(5)
4199
  *         @arg @ref LL_ADC_AWD_CH_VOPAMP2_REG_INJ      (3)(5)
4200
  *         @arg @ref LL_ADC_AWD_CH_VOPAMP3_REG          (3)(5)
4201
  *         @arg @ref LL_ADC_AWD_CH_VOPAMP3_INJ          (3)(5)
4202
  *         @arg @ref LL_ADC_AWD_CH_VOPAMP3_REG_INJ      (3)(5)
4203
  *        
4204
  *         (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
4205
  *         (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
4206
  *         (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
4207
  *         (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
4208
  *         (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
4209
  * @retval None
4210
  */
4211
__STATIC_INLINE void LL_ADC_SetAnalogWDMonitChannels(ADC_TypeDef *ADCx, uint32_t AWDChannelGroup)
4212
{
4213
  MODIFY_REG(ADCx->CR1,
4214
             (ADC_CR1_AWDEN | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL | ADC_CR1_AWDCH),
4215
             AWDChannelGroup);
4216
}
4217
 
4218
/**
4219
  * @brief  Get ADC analog watchdog monitored channel.
4220
  * @note   Usage of the returned channel number:
4221
  *         - To reinject this channel into another function LL_ADC_xxx:
4222
  *           the returned channel number is only partly formatted on definition
4223
  *           of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
4224
  *           with parts of literals LL_ADC_CHANNEL_x or using
4225
  *           helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
4226
  *           Then the selected literal LL_ADC_CHANNEL_x can be used
4227
  *           as parameter for another function.
4228
  *         - To get the channel number in decimal format:
4229
  *           process the returned value with the helper macro
4230
  *           @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
4231
  *           Applicable only when the analog watchdog is set to monitor
4232
  *           one channel.
4233
  * @note   On this STM32 serie, there is only 1 kind of analog watchdog
4234
  *         instance:
4235
  *         - AWD standard (instance AWD1):
4236
  *           - channels monitored: can monitor 1 channel or all channels.
4237
  *           - groups monitored: ADC groups regular and-or injected.
4238
  *           - resolution: resolution is not limited (corresponds to
4239
  *             ADC resolution configured).
4240
  * @rmtoll CR1      AWD1CH         LL_ADC_GetAnalogWDMonitChannels\n
4241
  *         CR1      AWD1SGL        LL_ADC_GetAnalogWDMonitChannels\n
4242
  *         CR1      AWD1EN         LL_ADC_GetAnalogWDMonitChannels
4243
  * @param  ADCx ADC instance
4244
  * @retval Returned value can be one of the following values:
4245
  *         @arg @ref LL_ADC_AWD_DISABLE
4246
  *         @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG
4247
  *         @arg @ref LL_ADC_AWD_ALL_CHANNELS_INJ
4248
  *         @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG_INJ
4249
  *         @arg @ref LL_ADC_AWD_CHANNEL_0_REG           (2)
4250
  *         @arg @ref LL_ADC_AWD_CHANNEL_0_INJ           (2)
4251
  *         @arg @ref LL_ADC_AWD_CHANNEL_0_REG_INJ       (2)
4252
  *         @arg @ref LL_ADC_AWD_CHANNEL_1_REG           (2)
4253
  *         @arg @ref LL_ADC_AWD_CHANNEL_1_INJ           (2)
4254
  *         @arg @ref LL_ADC_AWD_CHANNEL_1_REG_INJ       (2)
4255
  *         @arg @ref LL_ADC_AWD_CHANNEL_2_REG           (2)
4256
  *         @arg @ref LL_ADC_AWD_CHANNEL_2_INJ           (2)
4257
  *         @arg @ref LL_ADC_AWD_CHANNEL_2_REG_INJ       (2)
4258
  *         @arg @ref LL_ADC_AWD_CHANNEL_3_REG           (2)
4259
  *         @arg @ref LL_ADC_AWD_CHANNEL_3_INJ           (2)
4260
  *         @arg @ref LL_ADC_AWD_CHANNEL_3_REG_INJ       (2)
4261
  *         @arg @ref LL_ADC_AWD_CHANNEL_4_REG           (1)
4262
  *         @arg @ref LL_ADC_AWD_CHANNEL_4_INJ           (1)
4263
  *         @arg @ref LL_ADC_AWD_CHANNEL_4_REG_INJ       (1)
4264
  *         @arg @ref LL_ADC_AWD_CHANNEL_5_REG           (1)
4265
  *         @arg @ref LL_ADC_AWD_CHANNEL_5_INJ           (1)
4266
  *         @arg @ref LL_ADC_AWD_CHANNEL_5_REG_INJ       (1)
4267
  *         @arg @ref LL_ADC_AWD_CHANNEL_6_REG           (2)
4268
  *         @arg @ref LL_ADC_AWD_CHANNEL_6_INJ           (2)
4269
  *         @arg @ref LL_ADC_AWD_CHANNEL_6_REG_INJ       (2)
4270
  *         @arg @ref LL_ADC_AWD_CHANNEL_7_REG           (2)
4271
  *         @arg @ref LL_ADC_AWD_CHANNEL_7_INJ           (2)
4272
  *         @arg @ref LL_ADC_AWD_CHANNEL_7_REG_INJ       (2)
4273
  *         @arg @ref LL_ADC_AWD_CHANNEL_8_REG           (2)
4274
  *         @arg @ref LL_ADC_AWD_CHANNEL_8_INJ           (2)
4275
  *         @arg @ref LL_ADC_AWD_CHANNEL_8_REG_INJ       (2)
4276
  *         @arg @ref LL_ADC_AWD_CHANNEL_9_REG           (2)
4277
  *         @arg @ref LL_ADC_AWD_CHANNEL_9_INJ           (2)
4278
  *         @arg @ref LL_ADC_AWD_CHANNEL_9_REG_INJ       (2)
4279
  *         @arg @ref LL_ADC_AWD_CHANNEL_10_REG          (2)
4280
  *         @arg @ref LL_ADC_AWD_CHANNEL_10_INJ          (2)
4281
  *         @arg @ref LL_ADC_AWD_CHANNEL_10_REG_INJ      (2)
4282
  *         @arg @ref LL_ADC_AWD_CHANNEL_11_REG          (2)
4283
  *         @arg @ref LL_ADC_AWD_CHANNEL_11_INJ          (2)
4284
  *         @arg @ref LL_ADC_AWD_CHANNEL_11_REG_INJ      (2)
4285
  *         @arg @ref LL_ADC_AWD_CHANNEL_12_REG          (2)
4286
  *         @arg @ref LL_ADC_AWD_CHANNEL_12_INJ          (2)
4287
  *         @arg @ref LL_ADC_AWD_CHANNEL_12_REG_INJ      (2)
4288
  *         @arg @ref LL_ADC_AWD_CHANNEL_13_REG          (3)
4289
  *         @arg @ref LL_ADC_AWD_CHANNEL_13_INJ          (3)
4290
  *         @arg @ref LL_ADC_AWD_CHANNEL_13_REG_INJ      (3)
4291
  *         @arg @ref LL_ADC_AWD_CHANNEL_14_REG          (3)
4292
  *         @arg @ref LL_ADC_AWD_CHANNEL_14_INJ          (3)
4293
  *         @arg @ref LL_ADC_AWD_CHANNEL_14_REG_INJ      (3)
4294
  *         @arg @ref LL_ADC_AWD_CHANNEL_15_REG          (3)
4295
  *         @arg @ref LL_ADC_AWD_CHANNEL_15_INJ          (3)
4296
  *         @arg @ref LL_ADC_AWD_CHANNEL_15_REG_INJ      (3)
4297
  *         @arg @ref LL_ADC_AWD_CHANNEL_16_REG          (3)
4298
  *         @arg @ref LL_ADC_AWD_CHANNEL_16_INJ          (3)
4299
  *         @arg @ref LL_ADC_AWD_CHANNEL_16_REG_INJ      (3)
4300
  *         @arg @ref LL_ADC_AWD_CHANNEL_17_REG          (3)
4301
  *         @arg @ref LL_ADC_AWD_CHANNEL_17_INJ          (3)
4302
  *         @arg @ref LL_ADC_AWD_CHANNEL_17_REG_INJ      (3)
4303
  *         @arg @ref LL_ADC_AWD_CHANNEL_18_REG          (3)
4304
  *         @arg @ref LL_ADC_AWD_CHANNEL_18_INJ          (3)
4305
  *         @arg @ref LL_ADC_AWD_CHANNEL_18_REG_INJ      (3)
4306
  *         @arg @ref LL_ADC_AWD_CHANNEL_19_REG          (3)
4307
  *         @arg @ref LL_ADC_AWD_CHANNEL_19_INJ          (3)
4308
  *         @arg @ref LL_ADC_AWD_CHANNEL_19_REG_INJ      (3)
4309
  *         @arg @ref LL_ADC_AWD_CHANNEL_20_REG          (3)
4310
  *         @arg @ref LL_ADC_AWD_CHANNEL_20_INJ          (3)
4311
  *         @arg @ref LL_ADC_AWD_CHANNEL_20_REG_INJ      (3)
4312
  *         @arg @ref LL_ADC_AWD_CHANNEL_21_REG          (3)
4313
  *         @arg @ref LL_ADC_AWD_CHANNEL_21_INJ          (3)
4314
  *         @arg @ref LL_ADC_AWD_CHANNEL_21_REG_INJ      (3)
4315
  *         @arg @ref LL_ADC_AWD_CHANNEL_22_REG          (1)
4316
  *         @arg @ref LL_ADC_AWD_CHANNEL_22_INJ          (1)
4317
  *         @arg @ref LL_ADC_AWD_CHANNEL_22_REG_INJ      (1)
4318
  *         @arg @ref LL_ADC_AWD_CHANNEL_23_REG          (1)
4319
  *         @arg @ref LL_ADC_AWD_CHANNEL_23_INJ          (1)
4320
  *         @arg @ref LL_ADC_AWD_CHANNEL_23_REG_INJ      (1)
4321
  *         @arg @ref LL_ADC_AWD_CHANNEL_24_REG          (1)
4322
  *         @arg @ref LL_ADC_AWD_CHANNEL_24_INJ          (1)
4323
  *         @arg @ref LL_ADC_AWD_CHANNEL_24_REG_INJ      (1)
4324
  *         @arg @ref LL_ADC_AWD_CHANNEL_25_REG          (1)
4325
  *         @arg @ref LL_ADC_AWD_CHANNEL_25_INJ          (1)
4326
  *         @arg @ref LL_ADC_AWD_CHANNEL_25_REG_INJ      (1)
4327
  *         @arg @ref LL_ADC_AWD_CHANNEL_26_REG          (3)
4328
  *         @arg @ref LL_ADC_AWD_CHANNEL_26_INJ          (3)
4329
  *         @arg @ref LL_ADC_AWD_CHANNEL_26_REG_INJ      (3)
4330
  *         @arg @ref LL_ADC_AWD_CHANNEL_27_REG          (3)(4)
4331
  *         @arg @ref LL_ADC_AWD_CHANNEL_27_INJ          (3)(4)
4332
  *         @arg @ref LL_ADC_AWD_CHANNEL_27_REG_INJ      (3)(4)
4333
  *         @arg @ref LL_ADC_AWD_CHANNEL_28_REG          (3)(4)
4334
  *         @arg @ref LL_ADC_AWD_CHANNEL_28_INJ          (3)(4)
4335
  *         @arg @ref LL_ADC_AWD_CHANNEL_28_REG_INJ      (3)(4)
4336
  *         @arg @ref LL_ADC_AWD_CHANNEL_29_REG          (3)(4)
4337
  *         @arg @ref LL_ADC_AWD_CHANNEL_29_INJ          (3)(4)
4338
  *         @arg @ref LL_ADC_AWD_CHANNEL_29_REG_INJ      (3)(4)
4339
  *         @arg @ref LL_ADC_AWD_CHANNEL_30_REG          (3)(4)
4340
  *         @arg @ref LL_ADC_AWD_CHANNEL_30_INJ          (3)(4)
4341
  *         @arg @ref LL_ADC_AWD_CHANNEL_30_REG_INJ      (3)(4)
4342
  *         @arg @ref LL_ADC_AWD_CHANNEL_31_REG          (3)(4)
4343
  *         @arg @ref LL_ADC_AWD_CHANNEL_31_INJ          (3)(4)
4344
  *         @arg @ref LL_ADC_AWD_CHANNEL_31_REG_INJ      (3)(4)
4345
  *        
4346
  *         (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
4347
  *         (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
4348
  *         (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
4349
  *         (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.
4350
  */
4351
__STATIC_INLINE uint32_t LL_ADC_GetAnalogWDMonitChannels(ADC_TypeDef *ADCx)
4352
{
4353
  return (uint32_t)(READ_BIT(ADCx->CR1, (ADC_CR1_AWDEN | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL | ADC_CR1_AWDCH)));
4354
}
4355
 
4356
/**
4357
  * @brief  Set ADC analog watchdog threshold value of threshold
4358
  *         high or low.
4359
  * @note   In case of ADC resolution different of 12 bits,
4360
  *         analog watchdog thresholds data require a specific shift.
4361
  *         Use helper macro @ref __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION().
4362
  * @note   On this STM32 serie, there is only 1 kind of analog watchdog
4363
  *         instance:
4364
  *         - AWD standard (instance AWD1):
4365
  *           - channels monitored: can monitor 1 channel or all channels.
4366
  *           - groups monitored: ADC groups regular and-or injected.
4367
  *           - resolution: resolution is not limited (corresponds to
4368
  *             ADC resolution configured).
4369
  * @rmtoll HTR      HT             LL_ADC_SetAnalogWDThresholds\n
4370
  *         LTR      LT             LL_ADC_SetAnalogWDThresholds
4371
  * @param  ADCx ADC instance
4372
  * @param  AWDThresholdsHighLow This parameter can be one of the following values:
4373
  *         @arg @ref LL_ADC_AWD_THRESHOLD_HIGH
4374
  *         @arg @ref LL_ADC_AWD_THRESHOLD_LOW
4375
  * @param  AWDThresholdValue Value between Min_Data=0x000 and Max_Data=0xFFF
4376
  * @retval None
4377
  */
4378
__STATIC_INLINE void LL_ADC_SetAnalogWDThresholds(ADC_TypeDef *ADCx, uint32_t AWDThresholdsHighLow, uint32_t AWDThresholdValue)
4379
{
4380
  uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->HTR, AWDThresholdsHighLow);
4381
 
4382
  MODIFY_REG(*preg,
4383
             ADC_HTR_HT,
4384
             AWDThresholdValue);
4385
}
4386
 
4387
/**
4388
  * @brief  Get ADC analog watchdog threshold value of threshold high or
4389
  *         threshold low.
4390
  * @note   In case of ADC resolution different of 12 bits,
4391
  *         analog watchdog thresholds data require a specific shift.
4392
  *         Use helper macro @ref __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION().
4393
  * @rmtoll HTR      HT             LL_ADC_GetAnalogWDThresholds\n
4394
  *         LTR      LT             LL_ADC_GetAnalogWDThresholds
4395
  * @param  ADCx ADC instance
4396
  * @param  AWDThresholdsHighLow This parameter can be one of the following values:
4397
  *         @arg @ref LL_ADC_AWD_THRESHOLD_HIGH
4398
  *         @arg @ref LL_ADC_AWD_THRESHOLD_LOW
4399
  * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
4400
*/
4401
__STATIC_INLINE uint32_t LL_ADC_GetAnalogWDThresholds(ADC_TypeDef *ADCx, uint32_t AWDThresholdsHighLow)
4402
{
4403
  uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->HTR, AWDThresholdsHighLow);
4404
 
4405
  return (uint32_t)(READ_BIT(*preg, ADC_HTR_HT));
4406
}
4407
 
4408
/**
4409
  * @}
4410
  */
4411
 
4412
/** @defgroup ADC_LL_EF_Operation_ADC_Instance Operation on ADC hierarchical scope: ADC instance
4413
  * @{
4414
  */
4415
 
4416
/**
4417
  * @brief  Enable the selected ADC instance.
4418
  * @note   On this STM32 serie, after ADC enable, a delay for
4419
  *         ADC internal analog stabilization is required before performing a
4420
  *         ADC conversion start.
4421
  *         Refer to device datasheet, parameter tSTAB.
4422
  * @note   Due to the latency introduced by the synchronization between
4423
  *         two clock domains (ADC clock source asynchronous),
4424
  *         some hardware constraints must be respected:
4425
  *         - ADC must be enabled (@ref LL_ADC_Enable() ) only
4426
  *           when ADC is not ready to convert.
4427
  *         - ADC must be disabled (@ref LL_ADC_Disable() ) only
4428
  *           when ADC is ready to convert.
4429
  *         Status of ADC ready to convert can be checked using function
4430
  *         @ref LL_ADC_IsActiveFlag_ADRDY().
4431
  * @rmtoll CR2      ADON           LL_ADC_Enable
4432
  * @param  ADCx ADC instance
4433
  * @retval None
4434
  */
4435
__STATIC_INLINE void LL_ADC_Enable(ADC_TypeDef *ADCx)
4436
{
4437
  SET_BIT(ADCx->CR2, ADC_CR2_ADON);
4438
}
4439
 
4440
/**
4441
  * @brief  Disable the selected ADC instance.
4442
  * @note   Due to the latency introduced by the synchronization between
4443
  *         two clock domains (ADC clock source asynchronous),
4444
  *         some hardware constraints must be respected:
4445
  *         - ADC must be enabled (@ref LL_ADC_Enable() ) only
4446
  *           when ADC is not ready to convert.
4447
  *         - ADC must be disabled (@ref LL_ADC_Disable() ) only
4448
  *           when ADC is ready to convert.
4449
  *         Status of ADC ready to convert can be checked using function
4450
  *         @ref LL_ADC_IsActiveFlag_ADRDY().
4451
  * @rmtoll CR2      ADON           LL_ADC_Disable
4452
  * @param  ADCx ADC instance
4453
  * @retval None
4454
  */
4455
__STATIC_INLINE void LL_ADC_Disable(ADC_TypeDef *ADCx)
4456
{
4457
  CLEAR_BIT(ADCx->CR2, ADC_CR2_ADON);
4458
}
4459
 
4460
/**
4461
  * @brief  Get the selected ADC instance enable state.
4462
  * @rmtoll CR2      ADON           LL_ADC_IsEnabled
4463
  * @param  ADCx ADC instance
4464
  * @retval 0: ADC is disabled, 1: ADC is enabled.
4465
  */
4466
__STATIC_INLINE uint32_t LL_ADC_IsEnabled(ADC_TypeDef *ADCx)
4467
{
4468
  return (READ_BIT(ADCx->CR2, ADC_CR2_ADON) == (ADC_CR2_ADON));
4469
}
4470
 
4471
/**
4472
  * @}
4473
  */
4474
 
4475
/** @defgroup ADC_LL_EF_Operation_ADC_Group_Regular Operation on ADC hierarchical scope: group regular
4476
  * @{
4477
  */
4478
 
4479
/**
4480
  * @brief  Start ADC group regular conversion.
4481
  * @note   On this STM32 serie, this function is relevant only for
4482
  *         internal trigger (SW start), not for external trigger:
4483
  *         - If ADC trigger has been set to software start, ADC conversion
4484
  *           starts immediately.
4485
  *         - If ADC trigger has been set to external trigger, ADC conversion
4486
  *           start must be performed using function
4487
  *           @ref LL_ADC_REG_StartConversionExtTrig().
4488
  *           (if external trigger edge would have been set during ADC other
4489
  *           settings, ADC conversion would start at trigger event
4490
  *           as soon as ADC is enabled).
4491
  * @rmtoll CR2      SWSTART        LL_ADC_REG_StartConversionSWStart
4492
  * @param  ADCx ADC instance
4493
  * @retval None
4494
  */
4495
__STATIC_INLINE void LL_ADC_REG_StartConversionSWStart(ADC_TypeDef *ADCx)
4496
{
4497
  SET_BIT(ADCx->CR2, ADC_CR2_SWSTART);
4498
}
4499
 
4500
/**
4501
  * @brief  Start ADC group regular conversion from external trigger.
4502
  * @note   ADC conversion will start at next trigger event (on the selected
4503
  *         trigger edge) following the ADC start conversion command.
4504
  * @note   On this STM32 serie, this function is relevant for
4505
  *         ADC conversion start from external trigger.
4506
  *         If internal trigger (SW start) is needed, perform ADC conversion
4507
  *         start using function @ref LL_ADC_REG_StartConversionSWStart().
4508
  * @rmtoll CR2      EXTEN          LL_ADC_REG_StartConversionExtTrig
4509
  * @param  ExternalTriggerEdge This parameter can be one of the following values:
4510
  *         @arg @ref LL_ADC_REG_TRIG_EXT_RISING
4511
  *         @arg @ref LL_ADC_REG_TRIG_EXT_FALLING
4512
  *         @arg @ref LL_ADC_REG_TRIG_EXT_RISINGFALLING
4513
  * @param  ADCx ADC instance
4514
  * @retval None
4515
  */
4516
__STATIC_INLINE void LL_ADC_REG_StartConversionExtTrig(ADC_TypeDef *ADCx, uint32_t ExternalTriggerEdge)
4517
{
4518
  SET_BIT(ADCx->CR2, ExternalTriggerEdge);
4519
}
4520
 
4521
/**
4522
  * @brief  Stop ADC group regular conversion from external trigger.
4523
  * @note   No more ADC conversion will start at next trigger event
4524
  *         following the ADC stop conversion command.
4525
  *         If a conversion is on-going, it will be completed.
4526
  * @note   On this STM32 serie, there is no specific command
4527
  *         to stop a conversion on-going or to stop ADC converting
4528
  *         in continuous mode. These actions can be performed
4529
  *         using function @ref LL_ADC_Disable().
4530
  * @rmtoll CR2      EXTEN          LL_ADC_REG_StopConversionExtTrig
4531
  * @param  ADCx ADC instance
4532
  * @retval None
4533
  */
4534
__STATIC_INLINE void LL_ADC_REG_StopConversionExtTrig(ADC_TypeDef *ADCx)
4535
{
4536
  CLEAR_BIT(ADCx->CR2, ADC_CR2_EXTEN);
4537
}
4538
 
4539
/**
4540
  * @brief  Get ADC group regular conversion data, range fit for
4541
  *         all ADC configurations: all ADC resolutions and
4542
  *         all oversampling increased data width (for devices
4543
  *         with feature oversampling).
4544
  * @rmtoll DR       RDATA          LL_ADC_REG_ReadConversionData32
4545
  * @param  ADCx ADC instance
4546
  * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
4547
  */
4548
__STATIC_INLINE uint32_t LL_ADC_REG_ReadConversionData32(ADC_TypeDef *ADCx)
4549
{
4550
  return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
4551
}
4552
 
4553
/**
4554
  * @brief  Get ADC group regular conversion data, range fit for
4555
  *         ADC resolution 12 bits.
4556
  * @note   For devices with feature oversampling: Oversampling
4557
  *         can increase data width, function for extended range
4558
  *         may be needed: @ref LL_ADC_REG_ReadConversionData32.
4559
  * @rmtoll DR       RDATA          LL_ADC_REG_ReadConversionData12
4560
  * @param  ADCx ADC instance
4561
  * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
4562
  */
4563
__STATIC_INLINE uint16_t LL_ADC_REG_ReadConversionData12(ADC_TypeDef *ADCx)
4564
{
4565
  return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
4566
}
4567
 
4568
/**
4569
  * @brief  Get ADC group regular conversion data, range fit for
4570
  *         ADC resolution 10 bits.
4571
  * @note   For devices with feature oversampling: Oversampling
4572
  *         can increase data width, function for extended range
4573
  *         may be needed: @ref LL_ADC_REG_ReadConversionData32.
4574
  * @rmtoll DR       RDATA          LL_ADC_REG_ReadConversionData10
4575
  * @param  ADCx ADC instance
4576
  * @retval Value between Min_Data=0x000 and Max_Data=0x3FF
4577
  */
4578
__STATIC_INLINE uint16_t LL_ADC_REG_ReadConversionData10(ADC_TypeDef *ADCx)
4579
{
4580
  return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
4581
}
4582
 
4583
/**
4584
  * @brief  Get ADC group regular conversion data, range fit for
4585
  *         ADC resolution 8 bits.
4586
  * @note   For devices with feature oversampling: Oversampling
4587
  *         can increase data width, function for extended range
4588
  *         may be needed: @ref LL_ADC_REG_ReadConversionData32.
4589
  * @rmtoll DR       RDATA          LL_ADC_REG_ReadConversionData8
4590
  * @param  ADCx ADC instance
4591
  * @retval Value between Min_Data=0x00 and Max_Data=0xFF
4592
  */
4593
__STATIC_INLINE uint8_t LL_ADC_REG_ReadConversionData8(ADC_TypeDef *ADCx)
4594
{
4595
  return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
4596
}
4597
 
4598
/**
4599
  * @brief  Get ADC group regular conversion data, range fit for
4600
  *         ADC resolution 6 bits.
4601
  * @note   For devices with feature oversampling: Oversampling
4602
  *         can increase data width, function for extended range
4603
  *         may be needed: @ref LL_ADC_REG_ReadConversionData32.
4604
  * @rmtoll DR       RDATA          LL_ADC_REG_ReadConversionData6
4605
  * @param  ADCx ADC instance
4606
  * @retval Value between Min_Data=0x00 and Max_Data=0x3F
4607
  */
4608
__STATIC_INLINE uint8_t LL_ADC_REG_ReadConversionData6(ADC_TypeDef *ADCx)
4609
{
4610
  return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
4611
}
4612
 
4613
/**
4614
  * @}
4615
  */
4616
 
4617
/** @defgroup ADC_LL_EF_Operation_ADC_Group_Injected Operation on ADC hierarchical scope: group injected
4618
  * @{
4619
  */
4620
 
4621
/**
4622
  * @brief  Start ADC group injected conversion.
4623
  * @note   On this STM32 serie, this function is relevant only for
4624
  *         internal trigger (SW start), not for external trigger:
4625
  *         - If ADC trigger has been set to software start, ADC conversion
4626
  *           starts immediately.
4627
  *         - If ADC trigger has been set to external trigger, ADC conversion
4628
  *           start must be performed using function
4629
  *           @ref LL_ADC_INJ_StartConversionExtTrig().
4630
  *           (if external trigger edge would have been set during ADC other
4631
  *           settings, ADC conversion would start at trigger event
4632
  *           as soon as ADC is enabled).
4633
  * @rmtoll CR2      JSWSTART       LL_ADC_INJ_StartConversionSWStart
4634
  * @param  ADCx ADC instance
4635
  * @retval None
4636
  */
4637
__STATIC_INLINE void LL_ADC_INJ_StartConversionSWStart(ADC_TypeDef *ADCx)
4638
{
4639
  SET_BIT(ADCx->CR2, ADC_CR2_JSWSTART);
4640
}
4641
 
4642
/**
4643
  * @brief  Start ADC group injected conversion from external trigger.
4644
  * @note   ADC conversion will start at next trigger event (on the selected
4645
  *         trigger edge) following the ADC start conversion command.
4646
  * @note   On this STM32 serie, this function is relevant for
4647
  *         ADC conversion start from external trigger.
4648
  *         If internal trigger (SW start) is needed, perform ADC conversion
4649
  *         start using function @ref LL_ADC_INJ_StartConversionSWStart().
4650
  * @rmtoll CR2      JEXTEN         LL_ADC_INJ_StartConversionExtTrig
4651
  * @param  ExternalTriggerEdge This parameter can be one of the following values:
4652
  *         @arg @ref LL_ADC_INJ_TRIG_EXT_RISING
4653
  *         @arg @ref LL_ADC_INJ_TRIG_EXT_FALLING
4654
  *         @arg @ref LL_ADC_INJ_TRIG_EXT_RISINGFALLING
4655
  * @param  ADCx ADC instance
4656
  * @retval None
4657
  */
4658
__STATIC_INLINE void LL_ADC_INJ_StartConversionExtTrig(ADC_TypeDef *ADCx, uint32_t ExternalTriggerEdge)
4659
{
4660
  SET_BIT(ADCx->CR2, ExternalTriggerEdge);
4661
}
4662
 
4663
/**
4664
  * @brief  Stop ADC group injected conversion from external trigger.
4665
  * @note   No more ADC conversion will start at next trigger event
4666
  *         following the ADC stop conversion command.
4667
  *         If a conversion is on-going, it will be completed.
4668
  * @note   On this STM32 serie, there is no specific command
4669
  *         to stop a conversion on-going or to stop ADC converting
4670
  *         in continuous mode. These actions can be performed
4671
  *         using function @ref LL_ADC_Disable().
4672
  * @rmtoll CR2      JEXTEN         LL_ADC_INJ_StopConversionExtTrig
4673
  * @param  ADCx ADC instance
4674
  * @retval None
4675
  */
4676
__STATIC_INLINE void LL_ADC_INJ_StopConversionExtTrig(ADC_TypeDef *ADCx)
4677
{
4678
  CLEAR_BIT(ADCx->CR2, ADC_CR2_JEXTEN);
4679
}
4680
 
4681
/**
4682
  * @brief  Get ADC group regular conversion data, range fit for
4683
  *         all ADC configurations: all ADC resolutions and
4684
  *         all oversampling increased data width (for devices
4685
  *         with feature oversampling).
4686
  * @rmtoll JDR1     JDATA          LL_ADC_INJ_ReadConversionData32\n
4687
  *         JDR2     JDATA          LL_ADC_INJ_ReadConversionData32\n
4688
  *         JDR3     JDATA          LL_ADC_INJ_ReadConversionData32\n
4689
  *         JDR4     JDATA          LL_ADC_INJ_ReadConversionData32
4690
  * @param  ADCx ADC instance
4691
  * @param  Rank This parameter can be one of the following values:
4692
  *         @arg @ref LL_ADC_INJ_RANK_1
4693
  *         @arg @ref LL_ADC_INJ_RANK_2
4694
  *         @arg @ref LL_ADC_INJ_RANK_3
4695
  *         @arg @ref LL_ADC_INJ_RANK_4
4696
  * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
4697
  */
4698
__STATIC_INLINE uint32_t LL_ADC_INJ_ReadConversionData32(ADC_TypeDef *ADCx, uint32_t Rank)
4699
{
4700
  uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
4701
 
4702
  return (uint32_t)(READ_BIT(*preg,
4703
                             ADC_JDR1_JDATA)
4704
                   );
4705
}
4706
 
4707
/**
4708
  * @brief  Get ADC group injected conversion data, range fit for
4709
  *         ADC resolution 12 bits.
4710
  * @note   For devices with feature oversampling: Oversampling
4711
  *         can increase data width, function for extended range
4712
  *         may be needed: @ref LL_ADC_INJ_ReadConversionData32.
4713
  * @rmtoll JDR1     JDATA          LL_ADC_INJ_ReadConversionData12\n
4714
  *         JDR2     JDATA          LL_ADC_INJ_ReadConversionData12\n
4715
  *         JDR3     JDATA          LL_ADC_INJ_ReadConversionData12\n
4716
  *         JDR4     JDATA          LL_ADC_INJ_ReadConversionData12
4717
  * @param  ADCx ADC instance
4718
  * @param  Rank This parameter can be one of the following values:
4719
  *         @arg @ref LL_ADC_INJ_RANK_1
4720
  *         @arg @ref LL_ADC_INJ_RANK_2
4721
  *         @arg @ref LL_ADC_INJ_RANK_3
4722
  *         @arg @ref LL_ADC_INJ_RANK_4
4723
  * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
4724
  */
4725
__STATIC_INLINE uint16_t LL_ADC_INJ_ReadConversionData12(ADC_TypeDef *ADCx, uint32_t Rank)
4726
{
4727
  uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
4728
 
4729
  return (uint16_t)(READ_BIT(*preg,
4730
                             ADC_JDR1_JDATA)
4731
                   );
4732
}
4733
 
4734
/**
4735
  * @brief  Get ADC group injected conversion data, range fit for
4736
  *         ADC resolution 10 bits.
4737
  * @note   For devices with feature oversampling: Oversampling
4738
  *         can increase data width, function for extended range
4739
  *         may be needed: @ref LL_ADC_INJ_ReadConversionData32.
4740
  * @rmtoll JDR1     JDATA          LL_ADC_INJ_ReadConversionData10\n
4741
  *         JDR2     JDATA          LL_ADC_INJ_ReadConversionData10\n
4742
  *         JDR3     JDATA          LL_ADC_INJ_ReadConversionData10\n
4743
  *         JDR4     JDATA          LL_ADC_INJ_ReadConversionData10
4744
  * @param  ADCx ADC instance
4745
  * @param  Rank This parameter can be one of the following values:
4746
  *         @arg @ref LL_ADC_INJ_RANK_1
4747
  *         @arg @ref LL_ADC_INJ_RANK_2
4748
  *         @arg @ref LL_ADC_INJ_RANK_3
4749
  *         @arg @ref LL_ADC_INJ_RANK_4
4750
  * @retval Value between Min_Data=0x000 and Max_Data=0x3FF
4751
  */
4752
__STATIC_INLINE uint16_t LL_ADC_INJ_ReadConversionData10(ADC_TypeDef *ADCx, uint32_t Rank)
4753
{
4754
  uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
4755
 
4756
  return (uint16_t)(READ_BIT(*preg,
4757
                             ADC_JDR1_JDATA)
4758
                   );
4759
}
4760
 
4761
/**
4762
  * @brief  Get ADC group injected conversion data, range fit for
4763
  *         ADC resolution 8 bits.
4764
  * @note   For devices with feature oversampling: Oversampling
4765
  *         can increase data width, function for extended range
4766
  *         may be needed: @ref LL_ADC_INJ_ReadConversionData32.
4767
  * @rmtoll JDR1     JDATA          LL_ADC_INJ_ReadConversionData8\n
4768
  *         JDR2     JDATA          LL_ADC_INJ_ReadConversionData8\n
4769
  *         JDR3     JDATA          LL_ADC_INJ_ReadConversionData8\n
4770
  *         JDR4     JDATA          LL_ADC_INJ_ReadConversionData8
4771
  * @param  ADCx ADC instance
4772
  * @param  Rank This parameter can be one of the following values:
4773
  *         @arg @ref LL_ADC_INJ_RANK_1
4774
  *         @arg @ref LL_ADC_INJ_RANK_2
4775
  *         @arg @ref LL_ADC_INJ_RANK_3
4776
  *         @arg @ref LL_ADC_INJ_RANK_4
4777
  * @retval Value between Min_Data=0x00 and Max_Data=0xFF
4778
  */
4779
__STATIC_INLINE uint8_t LL_ADC_INJ_ReadConversionData8(ADC_TypeDef *ADCx, uint32_t Rank)
4780
{
4781
  uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
4782
 
4783
  return (uint8_t)(READ_BIT(*preg,
4784
                            ADC_JDR1_JDATA)
4785
                  );
4786
}
4787
 
4788
/**
4789
  * @brief  Get ADC group injected conversion data, range fit for
4790
  *         ADC resolution 6 bits.
4791
  * @note   For devices with feature oversampling: Oversampling
4792
  *         can increase data width, function for extended range
4793
  *         may be needed: @ref LL_ADC_INJ_ReadConversionData32.
4794
  * @rmtoll JDR1     JDATA          LL_ADC_INJ_ReadConversionData6\n
4795
  *         JDR2     JDATA          LL_ADC_INJ_ReadConversionData6\n
4796
  *         JDR3     JDATA          LL_ADC_INJ_ReadConversionData6\n
4797
  *         JDR4     JDATA          LL_ADC_INJ_ReadConversionData6
4798
  * @param  ADCx ADC instance
4799
  * @param  Rank This parameter can be one of the following values:
4800
  *         @arg @ref LL_ADC_INJ_RANK_1
4801
  *         @arg @ref LL_ADC_INJ_RANK_2
4802
  *         @arg @ref LL_ADC_INJ_RANK_3
4803
  *         @arg @ref LL_ADC_INJ_RANK_4
4804
  * @retval Value between Min_Data=0x00 and Max_Data=0x3F
4805
  */
4806
__STATIC_INLINE uint8_t LL_ADC_INJ_ReadConversionData6(ADC_TypeDef *ADCx, uint32_t Rank)
4807
{
4808
  uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
4809
 
4810
  return (uint8_t)(READ_BIT(*preg,
4811
                            ADC_JDR1_JDATA)
4812
                  );
4813
}
4814
 
4815
/**
4816
  * @}
4817
  */
4818
 
4819
/** @defgroup ADC_LL_EF_FLAG_Management ADC flag management
4820
  * @{
4821
  */
4822
 
4823
/**
4824
  * @brief  Get flag ADC ready.
4825
  * @rmtoll SR       ADONS          LL_ADC_IsActiveFlag_ADRDY
4826
  * @param  ADCx ADC instance
4827
  * @retval State of bit (1 or 0).
4828
  */
4829
__STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_ADRDY(ADC_TypeDef *ADCx)
4830
{
4831
  return (READ_BIT(ADCx->SR, LL_ADC_FLAG_ADRDY) == (LL_ADC_FLAG_ADRDY));
4832
}
4833
 
4834
/**
4835
  * @brief  Get flag ADC group regular end of unitary conversion
4836
  *         or end of sequence conversions, depending on
4837
  *         ADC configuration.
4838
  * @note   To configure flag of end of conversion,
4839
  *         use function @ref LL_ADC_REG_SetFlagEndOfConversion().
4840
  * @rmtoll SR       EOC            LL_ADC_IsActiveFlag_EOCS
4841
  * @param  ADCx ADC instance
4842
  * @retval State of bit (1 or 0).
4843
  */
4844
__STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_EOCS(ADC_TypeDef *ADCx)
4845
{
4846
  return (READ_BIT(ADCx->SR, LL_ADC_FLAG_EOCS) == (LL_ADC_FLAG_EOCS));
4847
}
4848
 
4849
/**
4850
  * @brief  Get flag ADC group regular overrun.
4851
  * @rmtoll SR       OVR            LL_ADC_IsActiveFlag_OVR
4852
  * @param  ADCx ADC instance
4853
  * @retval State of bit (1 or 0).
4854
  */
4855
__STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_OVR(ADC_TypeDef *ADCx)
4856
{
4857
  return (READ_BIT(ADCx->SR, LL_ADC_FLAG_OVR) == (LL_ADC_FLAG_OVR));
4858
}
4859
 
4860
 
4861
/**
4862
  * @brief  Get flag ADC group injected end of sequence conversions.
4863
  * @rmtoll SR       JEOC           LL_ADC_IsActiveFlag_JEOS
4864
  * @param  ADCx ADC instance
4865
  * @retval State of bit (1 or 0).
4866
  */
4867
__STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_JEOS(ADC_TypeDef *ADCx)
4868
{
4869
  /* Note: on this STM32 serie, there is no flag ADC group injected          */
4870
  /*       end of unitary conversion.                                         */
4871
  /*       Flag noted as "JEOC" is corresponding to flag "JEOS"               */
4872
  /*       in other STM32 families).                                          */
4873
  return (READ_BIT(ADCx->SR, LL_ADC_FLAG_JEOS) == (LL_ADC_FLAG_JEOS));
4874
}
4875
 
4876
/**
4877
  * @brief  Get flag ADC analog watchdog 1 flag
4878
  * @rmtoll SR       AWD            LL_ADC_IsActiveFlag_AWD1
4879
  * @param  ADCx ADC instance
4880
  * @retval State of bit (1 or 0).
4881
  */
4882
__STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_AWD1(ADC_TypeDef *ADCx)
4883
{
4884
  return (READ_BIT(ADCx->SR, LL_ADC_FLAG_AWD1) == (LL_ADC_FLAG_AWD1));
4885
}
4886
 
4887
/**
4888
  * @brief  Clear flag ADC group regular end of unitary conversion
4889
  *         or end of sequence conversions, depending on
4890
  *         ADC configuration.
4891
  * @note   To configure flag of end of conversion,
4892
  *         use function @ref LL_ADC_REG_SetFlagEndOfConversion().
4893
  * @rmtoll SR       EOC            LL_ADC_ClearFlag_EOCS
4894
  * @param  ADCx ADC instance
4895
  * @retval None
4896
  */
4897
__STATIC_INLINE void LL_ADC_ClearFlag_EOCS(ADC_TypeDef *ADCx)
4898
{
4899
  WRITE_REG(ADCx->SR, ~LL_ADC_FLAG_EOCS);
4900
}
4901
 
4902
/**
4903
  * @brief  Clear flag ADC group regular overrun.
4904
  * @rmtoll SR       OVR            LL_ADC_ClearFlag_OVR
4905
  * @param  ADCx ADC instance
4906
  * @retval None
4907
  */
4908
__STATIC_INLINE void LL_ADC_ClearFlag_OVR(ADC_TypeDef *ADCx)
4909
{
4910
  WRITE_REG(ADCx->SR, ~LL_ADC_FLAG_OVR);
4911
}
4912
 
4913
 
4914
/**
4915
  * @brief  Clear flag ADC group injected end of sequence conversions.
4916
  * @rmtoll SR       JEOC           LL_ADC_ClearFlag_JEOS
4917
  * @param  ADCx ADC instance
4918
  * @retval None
4919
  */
4920
__STATIC_INLINE void LL_ADC_ClearFlag_JEOS(ADC_TypeDef *ADCx)
4921
{
4922
  /* Note: on this STM32 serie, there is no flag ADC group injected          */
4923
  /*       end of unitary conversion.                                         */
4924
  /*       Flag noted as "JEOC" is corresponding to flag "JEOS"               */
4925
  /*       in other STM32 families).                                          */
4926
  WRITE_REG(ADCx->SR, ~LL_ADC_FLAG_JEOS);
4927
}
4928
 
4929
/**
4930
  * @brief  Clear flag ADC analog watchdog 1.
4931
  * @rmtoll SR       AWD            LL_ADC_ClearFlag_AWD1
4932
  * @param  ADCx ADC instance
4933
  * @retval None
4934
  */
4935
__STATIC_INLINE void LL_ADC_ClearFlag_AWD1(ADC_TypeDef *ADCx)
4936
{
4937
  WRITE_REG(ADCx->SR, ~LL_ADC_FLAG_AWD1);
4938
}
4939
 
4940
/**
4941
  * @}
4942
  */
4943
 
4944
/** @defgroup ADC_LL_EF_IT_Management ADC IT management
4945
  * @{
4946
  */
4947
 
4948
/**
4949
  * @brief  Enable interruption ADC group regular end of unitary conversion
4950
  *         or end of sequence conversions, depending on
4951
  *         ADC configuration.
4952
  * @note   To configure flag of end of conversion,
4953
  *         use function @ref LL_ADC_REG_SetFlagEndOfConversion().
4954
  * @rmtoll CR1      EOCIE          LL_ADC_EnableIT_EOCS
4955
  * @param  ADCx ADC instance
4956
  * @retval None
4957
  */
4958
__STATIC_INLINE void LL_ADC_EnableIT_EOCS(ADC_TypeDef *ADCx)
4959
{
4960
  SET_BIT(ADCx->CR1, LL_ADC_IT_EOCS);
4961
}
4962
 
4963
/**
4964
  * @brief  Enable ADC group regular interruption overrun.
4965
  * @rmtoll CR1      OVRIE          LL_ADC_EnableIT_OVR
4966
  * @param  ADCx ADC instance
4967
  * @retval None
4968
  */
4969
__STATIC_INLINE void LL_ADC_EnableIT_OVR(ADC_TypeDef *ADCx)
4970
{
4971
  SET_BIT(ADCx->CR1, LL_ADC_IT_OVR);
4972
}
4973
 
4974
 
4975
/**
4976
  * @brief  Enable interruption ADC group injected end of sequence conversions.
4977
  * @rmtoll CR1      JEOCIE         LL_ADC_EnableIT_JEOS
4978
  * @param  ADCx ADC instance
4979
  * @retval None
4980
  */
4981
__STATIC_INLINE void LL_ADC_EnableIT_JEOS(ADC_TypeDef *ADCx)
4982
{
4983
  /* Note: on this STM32 serie, there is no flag ADC group injected          */
4984
  /*       end of unitary conversion.                                         */
4985
  /*       Flag noted as "JEOC" is corresponding to flag "JEOS"               */
4986
  /*       in other STM32 families).                                          */
4987
  SET_BIT(ADCx->CR1, LL_ADC_IT_JEOS);
4988
}
4989
 
4990
/**
4991
  * @brief  Enable interruption ADC analog watchdog 1.
4992
  * @rmtoll CR1      AWDIE          LL_ADC_EnableIT_AWD1
4993
  * @param  ADCx ADC instance
4994
  * @retval None
4995
  */
4996
__STATIC_INLINE void LL_ADC_EnableIT_AWD1(ADC_TypeDef *ADCx)
4997
{
4998
  SET_BIT(ADCx->CR1, LL_ADC_IT_AWD1);
4999
}
5000
 
5001
/**
5002
  * @brief  Disable interruption ADC group regular end of unitary conversion
5003
  *         or end of sequence conversions, depending on
5004
  *         ADC configuration.
5005
  * @note   To configure flag of end of conversion,
5006
  *         use function @ref LL_ADC_REG_SetFlagEndOfConversion().
5007
  * @rmtoll CR1      EOCIE          LL_ADC_DisableIT_EOCS
5008
  * @param  ADCx ADC instance
5009
  * @retval None
5010
  */
5011
__STATIC_INLINE void LL_ADC_DisableIT_EOCS(ADC_TypeDef *ADCx)
5012
{
5013
  CLEAR_BIT(ADCx->CR1, LL_ADC_IT_EOCS);
5014
}
5015
 
5016
/**
5017
  * @brief  Disable interruption ADC group regular overrun.
5018
  * @rmtoll CR1      OVRIE          LL_ADC_DisableIT_OVR
5019
  * @param  ADCx ADC instance
5020
  * @retval None
5021
  */
5022
__STATIC_INLINE void LL_ADC_DisableIT_OVR(ADC_TypeDef *ADCx)
5023
{
5024
  CLEAR_BIT(ADCx->CR1, LL_ADC_IT_OVR);
5025
}
5026
 
5027
 
5028
/**
5029
  * @brief  Disable interruption ADC group injected end of sequence conversions.
5030
  * @rmtoll CR1      JEOCIE         LL_ADC_EnableIT_JEOS
5031
  * @param  ADCx ADC instance
5032
  * @retval None
5033
  */
5034
__STATIC_INLINE void LL_ADC_DisableIT_JEOS(ADC_TypeDef *ADCx)
5035
{
5036
  /* Note: on this STM32 serie, there is no flag ADC group injected          */
5037
  /*       end of unitary conversion.                                         */
5038
  /*       Flag noted as "JEOC" is corresponding to flag "JEOS"               */
5039
  /*       in other STM32 families).                                          */
5040
  CLEAR_BIT(ADCx->CR1, LL_ADC_IT_JEOS);
5041
}
5042
 
5043
/**
5044
  * @brief  Disable interruption ADC analog watchdog 1.
5045
  * @rmtoll CR1      AWDIE          LL_ADC_EnableIT_AWD1
5046
  * @param  ADCx ADC instance
5047
  * @retval None
5048
  */
5049
__STATIC_INLINE void LL_ADC_DisableIT_AWD1(ADC_TypeDef *ADCx)
5050
{
5051
  CLEAR_BIT(ADCx->CR1, LL_ADC_IT_AWD1);
5052
}
5053
 
5054
/**
5055
  * @brief  Get state of interruption ADC group regular end of unitary conversion
5056
  *         or end of sequence conversions, depending on
5057
  *         ADC configuration.
5058
  * @note   To configure flag of end of conversion,
5059
  *         use function @ref LL_ADC_REG_SetFlagEndOfConversion().
5060
  *         (0: interrupt disabled, 1: interrupt enabled)
5061
  * @rmtoll CR1      EOCIE          LL_ADC_IsEnabledIT_EOCS
5062
  * @param  ADCx ADC instance
5063
  * @retval State of bit (1 or 0).
5064
  */
5065
__STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_EOCS(ADC_TypeDef *ADCx)
5066
{
5067
  return (READ_BIT(ADCx->CR1, LL_ADC_IT_EOCS) == (LL_ADC_IT_EOCS));
5068
}
5069
 
5070
/**
5071
  * @brief  Get state of interruption ADC group regular overrun
5072
  *         (0: interrupt disabled, 1: interrupt enabled).
5073
  * @rmtoll CR1      OVRIE          LL_ADC_IsEnabledIT_OVR
5074
  * @param  ADCx ADC instance
5075
  * @retval State of bit (1 or 0).
5076
  */
5077
__STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_OVR(ADC_TypeDef *ADCx)
5078
{
5079
  return (READ_BIT(ADCx->CR1, LL_ADC_IT_OVR) == (LL_ADC_IT_OVR));
5080
}
5081
 
5082
 
5083
/**
5084
  * @brief  Get state of interruption ADC group injected end of sequence conversions
5085
  *         (0: interrupt disabled, 1: interrupt enabled).
5086
  * @rmtoll CR1      JEOCIE         LL_ADC_EnableIT_JEOS
5087
  * @param  ADCx ADC instance
5088
  * @retval State of bit (1 or 0).
5089
  */
5090
__STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_JEOS(ADC_TypeDef *ADCx)
5091
{
5092
  /* Note: on this STM32 serie, there is no flag ADC group injected          */
5093
  /*       end of unitary conversion.                                         */
5094
  /*       Flag noted as "JEOC" is corresponding to flag "JEOS"               */
5095
  /*       in other STM32 families).                                          */
5096
  return (READ_BIT(ADCx->CR1, LL_ADC_IT_JEOS) == (LL_ADC_IT_JEOS));
5097
}
5098
 
5099
/**
5100
  * @brief  Get state of interruption ADC analog watchdog 1
5101
  *         (0: interrupt disabled, 1: interrupt enabled).
5102
  * @rmtoll CR1      AWDIE          LL_ADC_EnableIT_AWD1
5103
  * @param  ADCx ADC instance
5104
  * @retval State of bit (1 or 0).
5105
  */
5106
__STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_AWD1(ADC_TypeDef *ADCx)
5107
{
5108
  return (READ_BIT(ADCx->CR1, LL_ADC_IT_AWD1) == (LL_ADC_IT_AWD1));
5109
}
5110
 
5111
/**
5112
  * @}
5113
  */
5114
 
5115
#if defined(USE_FULL_LL_DRIVER)
5116
/** @defgroup ADC_LL_EF_Init Initialization and de-initialization functions
5117
  * @{
5118
  */
5119
 
5120
/* Initialization of some features of ADC common parameters and multimode */
5121
ErrorStatus LL_ADC_CommonDeInit(ADC_Common_TypeDef *ADCxy_COMMON);
5122
ErrorStatus LL_ADC_CommonInit(ADC_Common_TypeDef *ADCxy_COMMON, LL_ADC_CommonInitTypeDef *ADC_CommonInitStruct);
5123
void        LL_ADC_CommonStructInit(LL_ADC_CommonInitTypeDef *ADC_CommonInitStruct);
5124
 
5125
/* De-initialization of ADC instance, ADC group regular and ADC group injected */
5126
/* (availability of ADC group injected depends on STM32 families) */
5127
ErrorStatus LL_ADC_DeInit(ADC_TypeDef *ADCx);
5128
 
5129
/* Initialization of some features of ADC instance */
5130
ErrorStatus LL_ADC_Init(ADC_TypeDef *ADCx, LL_ADC_InitTypeDef *ADC_InitStruct);
5131
void        LL_ADC_StructInit(LL_ADC_InitTypeDef *ADC_InitStruct);
5132
 
5133
/* Initialization of some features of ADC instance and ADC group regular */
5134
ErrorStatus LL_ADC_REG_Init(ADC_TypeDef *ADCx, LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct);
5135
void        LL_ADC_REG_StructInit(LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct);
5136
 
5137
/* Initialization of some features of ADC instance and ADC group injected */
5138
ErrorStatus LL_ADC_INJ_Init(ADC_TypeDef *ADCx, LL_ADC_INJ_InitTypeDef *ADC_INJ_InitStruct);
5139
void        LL_ADC_INJ_StructInit(LL_ADC_INJ_InitTypeDef *ADC_INJ_InitStruct);
5140
 
5141
/**
5142
  * @}
5143
  */
5144
#endif /* USE_FULL_LL_DRIVER */
5145
 
5146
/**
5147
  * @}
5148
  */
5149
 
5150
/**
5151
  * @}
5152
  */
5153
 
5154
#endif /* ADC1 */
5155
 
5156
/**
5157
  * @}
5158
  */
5159
 
5160
#ifdef __cplusplus
5161
}
5162
#endif
5163
 
5164
#endif /* __STM32L1xx_LL_ADC_H */
5165
 
5166
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/