Subversion Repositories EngineBay2

Rev

Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 28
Line 1... Line 1...
1
/**
1
/**
2
  ******************************************************************************
2
  ******************************************************************************
3
  * @file    stm32l1xx_hal_adc.h
3
  * @file    stm32l1xx_hal_adc.h
4
  * @author  MCD Application Team
4
  * @author  MCD Application Team
5
  * @version V1.2.0
-
 
6
  * @date    01-July-2016
-
 
7
  * @brief   Header file containing functions prototypes of ADC HAL library.
5
  * @brief   Header file containing functions prototypes of ADC HAL library.
8
  ******************************************************************************
6
  ******************************************************************************
9
  * @attention
7
  * @attention
10
  *
8
  *
11
  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
9
  * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
-
 
10
  * All rights reserved.</center></h2>
12
  *
11
  *
13
  * Redistribution and use in source and binary forms, with or without modification,
12
  * This software component is licensed by ST under BSD 3-Clause license,
14
  * are permitted provided that the following conditions are met:
13
  * the "License"; You may not use this file except in compliance with the
15
  *   1. Redistributions of source code must retain the above copyright notice,
-
 
16
  *      this list of conditions and the following disclaimer.
-
 
17
  *   2. Redistributions in binary form must reproduce the above copyright notice,
-
 
18
  *      this list of conditions and the following disclaimer in the documentation
-
 
19
  *      and/or other materials provided with the distribution.
14
  * License. You may obtain a copy of the License at:
20
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
-
 
21
  *      may be used to endorse or promote products derived from this software
15
  *                        opensource.org/licenses/BSD-3-Clause
22
  *      without specific prior written permission.
-
 
23
  *
-
 
24
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-
 
25
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-
 
26
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-
 
27
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-
 
28
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-
 
29
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-
 
30
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-
 
31
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-
 
32
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-
 
33
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
 
34
  *
16
  *
35
  ******************************************************************************
17
  ******************************************************************************
36
  */
18
  */
37
 
19
 
38
/* Define to prevent recursive inclusion -------------------------------------*/
20
/* Define to prevent recursive inclusion -------------------------------------*/
Line 111... Line 93...
111
                                       This parameter can be a value of @ref ADC_LowPowerAutoPowerOff. */
93
                                       This parameter can be a value of @ref ADC_LowPowerAutoPowerOff. */
112
  uint32_t ChannelsBank;          /*!< Selects the ADC channels bank.
94
  uint32_t ChannelsBank;          /*!< Selects the ADC channels bank.
113
                                       This parameter can be a value of @ref ADC_ChannelsBank.
95
                                       This parameter can be a value of @ref ADC_ChannelsBank.
114
                                       Note: Banks availability depends on devices categories.
96
                                       Note: Banks availability depends on devices categories.
115
                                       Note: To change bank selection on the fly, without going through execution of 'HAL_ADC_Init()', macro '__HAL_ADC_CHANNELS_BANK()' can be used directly. */
97
                                       Note: To change bank selection on the fly, without going through execution of 'HAL_ADC_Init()', macro '__HAL_ADC_CHANNELS_BANK()' can be used directly. */
116
  uint32_t ContinuousConvMode;    /*!< Specifies whether the conversion is performed in single mode (one conversion) or continuous mode for regular group,
98
  FunctionalState ContinuousConvMode; /*!< Specifies whether the conversion is performed in single mode (one conversion) or continuous mode for regular group,
117
                                       after the selected trigger occurred (software start or external trigger).
99
                                       after the selected trigger occurred (software start or external trigger).
118
                                       This parameter can be set to ENABLE or DISABLE. */
100
                                       This parameter can be set to ENABLE or DISABLE. */
119
#if defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
101
#if defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
120
  uint32_t NbrOfConversion;       /*!< Specifies the number of ranks that will be converted within the regular group sequencer.
102
  uint32_t NbrOfConversion;       /*!< Specifies the number of ranks that will be converted within the regular group sequencer.
121
                                       To use regular group sequencer and convert several ranks, parameter 'ScanConvMode' must be enabled.
103
                                       To use regular group sequencer and convert several ranks, parameter 'ScanConvMode' must be enabled.
Line 123... Line 105...
123
#else
105
#else
124
  uint32_t NbrOfConversion;       /*!< Specifies the number of ranks that will be converted within the regular group sequencer.
106
  uint32_t NbrOfConversion;       /*!< Specifies the number of ranks that will be converted within the regular group sequencer.
125
                                       To use regular group sequencer and convert several ranks, parameter 'ScanConvMode' must be enabled.
107
                                       To use regular group sequencer and convert several ranks, parameter 'ScanConvMode' must be enabled.
126
                                       This parameter must be a number between Min_Data = 1 and Max_Data = 27. */
108
                                       This parameter must be a number between Min_Data = 1 and Max_Data = 27. */
127
#endif /* STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
109
#endif /* STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
128
  uint32_t DiscontinuousConvMode; /*!< Specifies whether the conversions sequence of regular group is performed in Complete-sequence/Discontinuous-sequence (main sequence subdivided in successive parts).
110
  FunctionalState DiscontinuousConvMode; /*!< Specifies whether the conversions sequence of regular group is performed in Complete-sequence/Discontinuous-sequence (main sequence subdivided in successive parts).
129
                                       Discontinuous mode is used only if sequencer is enabled (parameter 'ScanConvMode'). If sequencer is disabled, this parameter is discarded.
111
                                       Discontinuous mode is used only if sequencer is enabled (parameter 'ScanConvMode'). If sequencer is disabled, this parameter is discarded.
130
                                       Discontinuous mode can be enabled only if continuous mode is disabled. If continuous mode is enabled, this parameter setting is discarded.
112
                                       Discontinuous mode can be enabled only if continuous mode is disabled. If continuous mode is enabled, this parameter setting is discarded.
131
                                       This parameter can be set to ENABLE or DISABLE. */
113
                                       This parameter can be set to ENABLE or DISABLE. */
132
  uint32_t NbrOfDiscConversion;   /*!< Specifies the number of discontinuous conversions in which the  main sequence of regular group (parameter NbrOfConversion) will be subdivided.
114
  uint32_t NbrOfDiscConversion;   /*!< Specifies the number of discontinuous conversions in which the  main sequence of regular group (parameter NbrOfConversion) will be subdivided.
133
                                       If parameter 'DiscontinuousConvMode' is disabled, this parameter is discarded.
115
                                       If parameter 'DiscontinuousConvMode' is disabled, this parameter is discarded.
Line 137... Line 119...
137
                                       If set to external trigger source, triggering is on event rising edge by default.
119
                                       If set to external trigger source, triggering is on event rising edge by default.
138
                                       This parameter can be a value of @ref ADC_External_trigger_source_Regular */
120
                                       This parameter can be a value of @ref ADC_External_trigger_source_Regular */
139
  uint32_t ExternalTrigConvEdge;  /*!< Selects the external trigger edge of regular group.
121
  uint32_t ExternalTrigConvEdge;  /*!< Selects the external trigger edge of regular group.
140
                                       If trigger is set to ADC_SOFTWARE_START, this parameter is discarded.
122
                                       If trigger is set to ADC_SOFTWARE_START, this parameter is discarded.
141
                                       This parameter can be a value of @ref ADC_External_trigger_edge_Regular */
123
                                       This parameter can be a value of @ref ADC_External_trigger_edge_Regular */
142
  uint32_t DMAContinuousRequests; /*!< Specifies whether the DMA requests are performed in one shot mode (DMA transfer stop when number of conversions is reached)
124
  FunctionalState DMAContinuousRequests; /*!< Specifies whether the DMA requests are performed in one shot mode (DMA transfer stop when number of conversions is reached)
143
                                       or in Continuous mode (DMA transfer unlimited, whatever number of conversions).
125
                                       or in Continuous mode (DMA transfer unlimited, whatever number of conversions).
144
                                       Note: In continuous mode, DMA must be configured in circular mode. Otherwise an overrun will be triggered when DMA buffer maximum pointer is reached.
126
                                       Note: In continuous mode, DMA must be configured in circular mode. Otherwise an overrun will be triggered when DMA buffer maximum pointer is reached.
145
                                       Note: This parameter must be modified when no conversion is on going on both regular and injected groups (ADC disabled, or ADC enabled without continuous mode or external trigger that could launch a conversion).
127
                                       Note: This parameter must be modified when no conversion is on going on both regular and injected groups (ADC disabled, or ADC enabled without continuous mode or external trigger that could launch a conversion).
146
                                       This parameter can be set to ENABLE or DISABLE. */
128
                                       This parameter can be set to ENABLE or DISABLE. */
147
}ADC_InitTypeDef;
129
}ADC_InitTypeDef;
Line 186... Line 168...
186
  uint32_t WatchdogMode;      /*!< Configures the ADC analog watchdog mode: single/all channels, regular/injected group.
168
  uint32_t WatchdogMode;      /*!< Configures the ADC analog watchdog mode: single/all channels, regular/injected group.
187
                                   This parameter can be a value of @ref ADC_analog_watchdog_mode. */
169
                                   This parameter can be a value of @ref ADC_analog_watchdog_mode. */
188
  uint32_t Channel;           /*!< Selects which ADC channel to monitor by analog watchdog.
170
  uint32_t Channel;           /*!< Selects which ADC channel to monitor by analog watchdog.
189
                                   This parameter has an effect only if watchdog mode is configured on single channel (parameter WatchdogMode)
171
                                   This parameter has an effect only if watchdog mode is configured on single channel (parameter WatchdogMode)
190
                                   This parameter can be a value of @ref ADC_channels. */
172
                                   This parameter can be a value of @ref ADC_channels. */
191
  uint32_t ITMode;            /*!< Specifies whether the analog watchdog is configured in interrupt or polling mode.
173
  FunctionalState ITMode;     /*!< Specifies whether the analog watchdog is configured in interrupt or polling mode.
192
                                   This parameter can be set to ENABLE or DISABLE */
174
                                   This parameter can be set to ENABLE or DISABLE */
193
  uint32_t HighThreshold;     /*!< Configures the ADC analog watchdog High threshold value.
175
  uint32_t HighThreshold;     /*!< Configures the ADC analog watchdog High threshold value.
194
                                   This parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF. */
176
                                   This parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF. */
195
  uint32_t LowThreshold;      /*!< Configures the ADC analog watchdog High threshold value.
177
  uint32_t LowThreshold;      /*!< Configures the ADC analog watchdog High threshold value.
196
                                   This parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF. */
178
                                   This parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF. */
Line 199... Line 181...
199
 
181
 
200
/**
182
/**
201
  * @brief  HAL ADC state machine: ADC states definition (bitfields)
183
  * @brief  HAL ADC state machine: ADC states definition (bitfields)
202
  */
184
  */
203
/* States of ADC global scope */
185
/* States of ADC global scope */
204
#define HAL_ADC_STATE_RESET             ((uint32_t)0x00000000)    /*!< ADC not yet initialized or disabled */
186
#define HAL_ADC_STATE_RESET             (0x00000000U)    /*!< ADC not yet initialized or disabled */
205
#define HAL_ADC_STATE_READY             ((uint32_t)0x00000001)    /*!< ADC peripheral ready for use */
187
#define HAL_ADC_STATE_READY             (0x00000001U)    /*!< ADC peripheral ready for use */
206
#define HAL_ADC_STATE_BUSY_INTERNAL     ((uint32_t)0x00000002)    /*!< ADC is busy to internal process (initialization, calibration) */
188
#define HAL_ADC_STATE_BUSY_INTERNAL     (0x00000002U)    /*!< ADC is busy to internal process (initialization, calibration) */
207
#define HAL_ADC_STATE_TIMEOUT           ((uint32_t)0x00000004)    /*!< TimeOut occurrence */
189
#define HAL_ADC_STATE_TIMEOUT           (0x00000004U)    /*!< TimeOut occurrence */
208
 
190
 
209
/* States of ADC errors */
191
/* States of ADC errors */
210
#define HAL_ADC_STATE_ERROR_INTERNAL    ((uint32_t)0x00000010)    /*!< Internal error occurrence */
192
#define HAL_ADC_STATE_ERROR_INTERNAL    (0x00000010U)    /*!< Internal error occurrence */
211
#define HAL_ADC_STATE_ERROR_CONFIG      ((uint32_t)0x00000020)    /*!< Configuration error occurrence */
193
#define HAL_ADC_STATE_ERROR_CONFIG      (0x00000020U)    /*!< Configuration error occurrence */
212
#define HAL_ADC_STATE_ERROR_DMA         ((uint32_t)0x00000040)    /*!< DMA error occurrence */
194
#define HAL_ADC_STATE_ERROR_DMA         (0x00000040U)    /*!< DMA error occurrence */
213
 
195
 
214
/* States of ADC group regular */
196
/* States of ADC group regular */
215
#define HAL_ADC_STATE_REG_BUSY          ((uint32_t)0x00000100)    /*!< A conversion on group regular is ongoing or can occur (either by continuous mode,
197
#define HAL_ADC_STATE_REG_BUSY          (0x00000100U)    /*!< A conversion on group regular is ongoing or can occur (either by continuous mode,
216
                                                                       external trigger, low power auto power-on (if feature available), multimode ADC master control (if feature available)) */
198
                                                                       external trigger, low power auto power-on (if feature available), multimode ADC master control (if feature available)) */
217
#define HAL_ADC_STATE_REG_EOC           ((uint32_t)0x00000200)    /*!< Conversion data available on group regular */
199
#define HAL_ADC_STATE_REG_EOC           (0x00000200U)    /*!< Conversion data available on group regular */
218
#define HAL_ADC_STATE_REG_OVR           ((uint32_t)0x00000400)    /*!< Overrun occurrence */
200
#define HAL_ADC_STATE_REG_OVR           (0x00000400U)    /*!< Overrun occurrence */
219
#define HAL_ADC_STATE_REG_EOSMP         ((uint32_t)0x00000800)    /*!< Not available on STM32L1 device: End Of Sampling flag raised  */
201
#define HAL_ADC_STATE_REG_EOSMP         (0x00000800U)    /*!< Not available on STM32L1 device: End Of Sampling flag raised  */
220
 
202
 
221
/* States of ADC group injected */
203
/* States of ADC group injected */
222
#define HAL_ADC_STATE_INJ_BUSY          ((uint32_t)0x00001000)    /*!< A conversion on group injected is ongoing or can occur (either by auto-injection mode,
204
#define HAL_ADC_STATE_INJ_BUSY          (0x00001000U)    /*!< A conversion on group injected is ongoing or can occur (either by auto-injection mode,
223
                                                                       external trigger, low power auto power-on (if feature available), multimode ADC master control (if feature available)) */
205
                                                                       external trigger, low power auto power-on (if feature available), multimode ADC master control (if feature available)) */
224
#define HAL_ADC_STATE_INJ_EOC           ((uint32_t)0x00002000)    /*!< Conversion data available on group injected */
206
#define HAL_ADC_STATE_INJ_EOC           (0x00002000U)    /*!< Conversion data available on group injected */
225
#define HAL_ADC_STATE_INJ_JQOVF         ((uint32_t)0x00004000)    /*!< Not available on STM32L1 device: Injected queue overflow occurrence */
207
#define HAL_ADC_STATE_INJ_JQOVF         (0x00004000U)    /*!< Not available on STM32L1 device: Injected queue overflow occurrence */
226
 
208
 
227
/* States of ADC analog watchdogs */
209
/* States of ADC analog watchdogs */
228
#define HAL_ADC_STATE_AWD1              ((uint32_t)0x00010000)    /*!< Out-of-window occurrence of analog watchdog 1 */
210
#define HAL_ADC_STATE_AWD1              (0x00010000U)    /*!< Out-of-window occurrence of analog watchdog 1 */
229
#define HAL_ADC_STATE_AWD2              ((uint32_t)0x00020000)    /*!< Not available on STM32L1 device: Out-of-window occurrence of analog watchdog 2 */
211
#define HAL_ADC_STATE_AWD2              (0x00020000U)    /*!< Not available on STM32L1 device: Out-of-window occurrence of analog watchdog 2 */
230
#define HAL_ADC_STATE_AWD3              ((uint32_t)0x00040000)    /*!< Not available on STM32L1 device: Out-of-window occurrence of analog watchdog 3 */
212
#define HAL_ADC_STATE_AWD3              (0x00040000U)    /*!< Not available on STM32L1 device: Out-of-window occurrence of analog watchdog 3 */
231
 
213
 
232
/* States of ADC multi-mode */
214
/* States of ADC multi-mode */
233
#define HAL_ADC_STATE_MULTIMODE_SLAVE   ((uint32_t)0x00100000)    /*!< Not available on STM32L1 device: ADC in multimode slave state, controlled by another ADC master ( */
215
#define HAL_ADC_STATE_MULTIMODE_SLAVE   (0x00100000U)    /*!< Not available on STM32L1 device: ADC in multimode slave state, controlled by another ADC master ( */
234
 
216
 
235
 
217
 
236
/**
218
/**
237
  * @brief  ADC handle Structure definition
219
  * @brief  ADC handle Structure definition
238
  */
220
  */
239
typedef struct
221
typedef struct __ADC_HandleTypeDef
240
{
222
{
241
  ADC_TypeDef                   *Instance;              /*!< Register base address */
223
  ADC_TypeDef                   *Instance;              /*!< Register base address */
242
 
224
 
243
  ADC_InitTypeDef               Init;                   /*!< ADC required parameters */
225
  ADC_InitTypeDef               Init;                   /*!< ADC required parameters */
244
 
226
 
Line 249... Line 231...
249
  HAL_LockTypeDef               Lock;                   /*!< ADC locking object */
231
  HAL_LockTypeDef               Lock;                   /*!< ADC locking object */
250
 
232
 
251
  __IO uint32_t                 State;                  /*!< ADC communication state (bitmap of ADC states) */
233
  __IO uint32_t                 State;                  /*!< ADC communication state (bitmap of ADC states) */
252
 
234
 
253
  __IO uint32_t                 ErrorCode;              /*!< ADC Error code */
235
  __IO uint32_t                 ErrorCode;              /*!< ADC Error code */
-
 
236
 
-
 
237
#if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
-
 
238
  void (* ConvCpltCallback)(struct __ADC_HandleTypeDef *hadc);              /*!< ADC conversion complete callback */
-
 
239
  void (* ConvHalfCpltCallback)(struct __ADC_HandleTypeDef *hadc);          /*!< ADC conversion DMA half-transfer callback */
-
 
240
  void (* LevelOutOfWindowCallback)(struct __ADC_HandleTypeDef *hadc);      /*!< ADC analog watchdog 1 callback */
-
 
241
  void (* ErrorCallback)(struct __ADC_HandleTypeDef *hadc);                 /*!< ADC error callback */
-
 
242
  void (* InjectedConvCpltCallback)(struct __ADC_HandleTypeDef *hadc);      /*!< ADC group injected conversion complete callback */       /*!< ADC end of sampling callback */
-
 
243
  void (* MspInitCallback)(struct __ADC_HandleTypeDef *hadc);               /*!< ADC Msp Init callback */
-
 
244
  void (* MspDeInitCallback)(struct __ADC_HandleTypeDef *hadc);             /*!< ADC Msp DeInit callback */
-
 
245
#endif /* USE_HAL_ADC_REGISTER_CALLBACKS */
254
}ADC_HandleTypeDef;
246
}ADC_HandleTypeDef;
-
 
247
 
-
 
248
#if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
-
 
249
/**
-
 
250
  * @brief  HAL ADC Callback ID enumeration definition
-
 
251
  */
-
 
252
typedef enum
-
 
253
{
-
 
254
  HAL_ADC_CONVERSION_COMPLETE_CB_ID     = 0x00U,  /*!< ADC conversion complete callback ID */
-
 
255
  HAL_ADC_CONVERSION_HALF_CB_ID         = 0x01U,  /*!< ADC conversion DMA half-transfer callback ID */
-
 
256
  HAL_ADC_LEVEL_OUT_OF_WINDOW_1_CB_ID   = 0x02U,  /*!< ADC analog watchdog 1 callback ID */
-
 
257
  HAL_ADC_ERROR_CB_ID                   = 0x03U,  /*!< ADC error callback ID */
-
 
258
  HAL_ADC_INJ_CONVERSION_COMPLETE_CB_ID = 0x04U,  /*!< ADC group injected conversion complete callback ID */
-
 
259
  HAL_ADC_MSPINIT_CB_ID                 = 0x09U,  /*!< ADC Msp Init callback ID          */
-
 
260
  HAL_ADC_MSPDEINIT_CB_ID               = 0x0AU   /*!< ADC Msp DeInit callback ID        */
-
 
261
} HAL_ADC_CallbackIDTypeDef;
-
 
262
 
-
 
263
/**
-
 
264
  * @brief  HAL ADC Callback pointer definition
-
 
265
  */
-
 
266
typedef  void (*pADC_CallbackTypeDef)(ADC_HandleTypeDef *hadc); /*!< pointer to a ADC callback function */
-
 
267
 
-
 
268
#endif /* USE_HAL_ADC_REGISTER_CALLBACKS */
-
 
269
 
255
/**
270
/**
256
  * @}
271
  * @}
257
  */
272
  */
258
 
273
 
259
 
274
 
Line 265... Line 280...
265
  */
280
  */
266
 
281
 
267
/** @defgroup ADC_Error_Code ADC Error Code
282
/** @defgroup ADC_Error_Code ADC Error Code
268
  * @{
283
  * @{
269
  */
284
  */
270
#define HAL_ADC_ERROR_NONE        ((uint32_t)0x00)   /*!< No error                                              */
285
#define HAL_ADC_ERROR_NONE        (0x00U)   /*!< No error                                              */
271
#define HAL_ADC_ERROR_INTERNAL    ((uint32_t)0x01)   /*!< ADC IP internal error: if problem of clocking, 
286
#define HAL_ADC_ERROR_INTERNAL    (0x01U)   /*!< ADC IP internal error: if problem of clocking, 
272
                                                          enable/disable, erroneous state                       */
287
                                                          enable/disable, erroneous state                       */
273
#define HAL_ADC_ERROR_OVR         ((uint32_t)0x02)   /*!< Overrun error                                         */
288
#define HAL_ADC_ERROR_OVR         (0x02U)   /*!< Overrun error                                         */
274
#define HAL_ADC_ERROR_DMA         ((uint32_t)0x04)   /*!< DMA transfer error                                    */
289
#define HAL_ADC_ERROR_DMA         (0x04U)   /*!< DMA transfer error                                    */
-
 
290
 
-
 
291
#if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
-
 
292
#define HAL_ADC_ERROR_INVALID_CALLBACK  (0x10U)   /*!< Invalid Callback error */
-
 
293
#endif /* USE_HAL_ADC_REGISTER_CALLBACKS */
275
/**
294
/**
276
  * @}
295
  * @}
277
  */
296
  */
278
 
297
 
279
/** @defgroup ADC_ClockPrescaler ADC ClockPrescaler
298
/** @defgroup ADC_ClockPrescaler ADC ClockPrescaler
280
  * @{
299
  * @{
281
  */
300
  */
282
#define ADC_CLOCK_ASYNC_DIV1          ((uint32_t)0x00000000)          /*!< ADC asynchronous clock derived from ADC dedicated HSI without prescaler */
301
#define ADC_CLOCK_ASYNC_DIV1          (0x00000000U)                   /*!< ADC asynchronous clock derived from ADC dedicated HSI without prescaler */
283
#define ADC_CLOCK_ASYNC_DIV2          ((uint32_t)ADC_CCR_ADCPRE_0)    /*!< ADC asynchronous clock derived from ADC dedicated HSI divided by a prescaler of 2 */
302
#define ADC_CLOCK_ASYNC_DIV2          ((uint32_t)ADC_CCR_ADCPRE_0)    /*!< ADC asynchronous clock derived from ADC dedicated HSI divided by a prescaler of 2 */
284
#define ADC_CLOCK_ASYNC_DIV4          ((uint32_t)ADC_CCR_ADCPRE_1)    /*!< ADC asynchronous clock derived from ADC dedicated HSI divided by a prescaler of 4 */
303
#define ADC_CLOCK_ASYNC_DIV4          ((uint32_t)ADC_CCR_ADCPRE_1)    /*!< ADC asynchronous clock derived from ADC dedicated HSI divided by a prescaler of 4 */
285
/**
304
/**
286
  * @}
305
  * @}
287
  */
306
  */
288
 
307
 
289
/** @defgroup ADC_Resolution ADC Resolution
308
/** @defgroup ADC_Resolution ADC Resolution
290
  * @{
309
  * @{
291
  */
310
  */
292
#define ADC_RESOLUTION_12B      ((uint32_t)0x00000000)          /*!<  ADC 12-bit resolution */
311
#define ADC_RESOLUTION_12B      (0x00000000U)                   /*!<  ADC 12-bit resolution */
293
#define ADC_RESOLUTION_10B      ((uint32_t)ADC_CR1_RES_0)       /*!<  ADC 10-bit resolution */
312
#define ADC_RESOLUTION_10B      ((uint32_t)ADC_CR1_RES_0)       /*!<  ADC 10-bit resolution */
294
#define ADC_RESOLUTION_8B       ((uint32_t)ADC_CR1_RES_1)       /*!<  ADC 8-bit resolution */
313
#define ADC_RESOLUTION_8B       ((uint32_t)ADC_CR1_RES_1)       /*!<  ADC 8-bit resolution */
295
#define ADC_RESOLUTION_6B       ((uint32_t)ADC_CR1_RES)         /*!<  ADC 6-bit resolution */
314
#define ADC_RESOLUTION_6B       ((uint32_t)ADC_CR1_RES)         /*!<  ADC 6-bit resolution */
296
/**
315
/**
297
  * @}
316
  * @}
298
  */
317
  */
299
 
318
 
300
/** @defgroup ADC_Data_align ADC Data_align
319
/** @defgroup ADC_Data_align ADC Data_align
301
  * @{
320
  * @{
302
  */
321
  */
303
#define ADC_DATAALIGN_RIGHT      ((uint32_t)0x00000000)
322
#define ADC_DATAALIGN_RIGHT      (0x00000000U)
304
#define ADC_DATAALIGN_LEFT       ((uint32_t)ADC_CR2_ALIGN)
323
#define ADC_DATAALIGN_LEFT       ((uint32_t)ADC_CR2_ALIGN)
305
/**
324
/**
306
  * @}
325
  * @}
307
  */
326
  */
308
 
327
 
309
/** @defgroup ADC_Scan_mode ADC Scan mode
328
/** @defgroup ADC_Scan_mode ADC Scan mode
310
  * @{
329
  * @{
311
  */
330
  */
312
#define ADC_SCAN_DISABLE         ((uint32_t)0x00000000)
331
#define ADC_SCAN_DISABLE         (0x00000000U)
313
#define ADC_SCAN_ENABLE          ((uint32_t)ADC_CR1_SCAN)
332
#define ADC_SCAN_ENABLE          ((uint32_t)ADC_CR1_SCAN)
314
/**
333
/**
315
  * @}
334
  * @}
316
  */
335
  */
317
 
336
 
318
/** @defgroup ADC_External_trigger_edge_Regular ADC external trigger enable for regular group
337
/** @defgroup ADC_External_trigger_edge_Regular ADC external trigger enable for regular group
319
  * @{
338
  * @{
320
  */
339
  */
321
#define ADC_EXTERNALTRIGCONVEDGE_NONE           ((uint32_t)0x00000000)
340
#define ADC_EXTERNALTRIGCONVEDGE_NONE           (0x00000000U)
322
#define ADC_EXTERNALTRIGCONVEDGE_RISING         ((uint32_t)ADC_CR2_EXTEN_0)
341
#define ADC_EXTERNALTRIGCONVEDGE_RISING         ((uint32_t)ADC_CR2_EXTEN_0)
323
#define ADC_EXTERNALTRIGCONVEDGE_FALLING        ((uint32_t)ADC_CR2_EXTEN_1)
342
#define ADC_EXTERNALTRIGCONVEDGE_FALLING        ((uint32_t)ADC_CR2_EXTEN_1)
324
#define ADC_EXTERNALTRIGCONVEDGE_RISINGFALLING  ((uint32_t)ADC_CR2_EXTEN)
343
#define ADC_EXTERNALTRIGCONVEDGE_RISINGFALLING  ((uint32_t)ADC_CR2_EXTEN)
325
/**
344
/**
326
  * @}
345
  * @}
Line 343... Line 362...
343
#define ADC_EXTERNALTRIGCONV_T4_TRGO     ADC_EXTERNALTRIG_T4_TRGO
362
#define ADC_EXTERNALTRIGCONV_T4_TRGO     ADC_EXTERNALTRIG_T4_TRGO
344
#define ADC_EXTERNALTRIGCONV_T6_TRGO     ADC_EXTERNALTRIG_T6_TRGO
363
#define ADC_EXTERNALTRIGCONV_T6_TRGO     ADC_EXTERNALTRIG_T6_TRGO
345
#define ADC_EXTERNALTRIGCONV_T9_CC2      ADC_EXTERNALTRIG_T9_CC2
364
#define ADC_EXTERNALTRIGCONV_T9_CC2      ADC_EXTERNALTRIG_T9_CC2
346
#define ADC_EXTERNALTRIGCONV_T9_TRGO     ADC_EXTERNALTRIG_T9_TRGO
365
#define ADC_EXTERNALTRIGCONV_T9_TRGO     ADC_EXTERNALTRIG_T9_TRGO
347
#define ADC_EXTERNALTRIGCONV_EXT_IT11    ADC_EXTERNALTRIG_EXT_IT11
366
#define ADC_EXTERNALTRIGCONV_EXT_IT11    ADC_EXTERNALTRIG_EXT_IT11
348
#define ADC_SOFTWARE_START               ((uint32_t)0x00000010)
367
#define ADC_SOFTWARE_START               (0x00000010U)
349
/**
368
/**
350
  * @}
369
  * @}
351
  */
370
  */
352
 
371
 
353
/** @defgroup ADC_EOCSelection ADC EOCSelection
372
/** @defgroup ADC_EOCSelection ADC EOCSelection
354
  * @{
373
  * @{
355
  */
374
  */
356
#define ADC_EOC_SEQ_CONV            ((uint32_t)0x00000000)
375
#define ADC_EOC_SEQ_CONV            (0x00000000U)
357
#define ADC_EOC_SINGLE_CONV         ((uint32_t)ADC_CR2_EOCS)
376
#define ADC_EOC_SINGLE_CONV         ((uint32_t)ADC_CR2_EOCS)
358
/**
377
/**
359
  * @}
378
  * @}
360
  */
379
  */
361
 
380
 
Line 364... Line 383...
364
  */
383
  */
365
/*!< Note : For compatibility with other STM32 devices with ADC autowait      */
384
/*!< Note : For compatibility with other STM32 devices with ADC autowait      */
366
/* feature limited to enable or disable settings:                             */
385
/* feature limited to enable or disable settings:                             */
367
/* Setting "ADC_AUTOWAIT_UNTIL_DATA_READ" is equivalent to "ENABLE".          */
386
/* Setting "ADC_AUTOWAIT_UNTIL_DATA_READ" is equivalent to "ENABLE".          */
368
 
387
 
369
#define ADC_AUTOWAIT_DISABLE                ((uint32_t)0x00000000)
388
#define ADC_AUTOWAIT_DISABLE                (0x00000000U)
370
#define ADC_AUTOWAIT_UNTIL_DATA_READ        ((uint32_t)(                                  ADC_CR2_DELS_0)) /*!< Insert a delay between ADC conversions: infinite delay, until the result of previous conversion is read */
389
#define ADC_AUTOWAIT_UNTIL_DATA_READ        ((uint32_t)(                                  ADC_CR2_DELS_0)) /*!< Insert a delay between ADC conversions: infinite delay, until the result of previous conversion is read */
371
#define ADC_AUTOWAIT_7_APBCLOCKCYCLES       ((uint32_t)(                 ADC_CR2_DELS_1                 )) /*!< Insert a delay between ADC conversions: 7 APB clock cycles */
390
#define ADC_AUTOWAIT_7_APBCLOCKCYCLES       ((uint32_t)(                 ADC_CR2_DELS_1                 )) /*!< Insert a delay between ADC conversions: 7 APB clock cycles */
372
#define ADC_AUTOWAIT_15_APBCLOCKCYCLES      ((uint32_t)(                 ADC_CR2_DELS_1 | ADC_CR2_DELS_0)) /*!< Insert a delay between ADC conversions: 15 APB clock cycles */
391
#define ADC_AUTOWAIT_15_APBCLOCKCYCLES      ((uint32_t)(                 ADC_CR2_DELS_1 | ADC_CR2_DELS_0)) /*!< Insert a delay between ADC conversions: 15 APB clock cycles */
373
#define ADC_AUTOWAIT_31_APBCLOCKCYCLES      ((uint32_t)(ADC_CR2_DELS_2                                  )) /*!< Insert a delay between ADC conversions: 31 APB clock cycles */
392
#define ADC_AUTOWAIT_31_APBCLOCKCYCLES      ((uint32_t)(ADC_CR2_DELS_2                                  )) /*!< Insert a delay between ADC conversions: 31 APB clock cycles */
374
#define ADC_AUTOWAIT_63_APBCLOCKCYCLES      ((uint32_t)(ADC_CR2_DELS_2                  | ADC_CR2_DELS_0)) /*!< Insert a delay between ADC conversions: 63 APB clock cycles */
393
#define ADC_AUTOWAIT_63_APBCLOCKCYCLES      ((uint32_t)(ADC_CR2_DELS_2                  | ADC_CR2_DELS_0)) /*!< Insert a delay between ADC conversions: 63 APB clock cycles */
Line 380... Line 399...
380
  */
399
  */
381
 
400
 
382
/** @defgroup ADC_LowPowerAutoPowerOff ADC LowPowerAutoPowerOff
401
/** @defgroup ADC_LowPowerAutoPowerOff ADC LowPowerAutoPowerOff
383
  * @{
402
  * @{
384
  */
403
  */
385
#define ADC_AUTOPOWEROFF_DISABLE            ((uint32_t)0x00000000)
404
#define ADC_AUTOPOWEROFF_DISABLE            (0x00000000U)
386
#define ADC_AUTOPOWEROFF_IDLE_PHASE         ((uint32_t)ADC_CR1_PDI)                     /*!< ADC power off when ADC is not converting (idle phase) */
405
#define ADC_AUTOPOWEROFF_IDLE_PHASE         ((uint32_t)ADC_CR1_PDI)                     /*!< ADC power off when ADC is not converting (idle phase) */
387
#define ADC_AUTOPOWEROFF_DELAY_PHASE        ((uint32_t)ADC_CR1_PDD)                     /*!< ADC power off when a delay is inserted between conversions (see parameter ADC_LowPowerAutoWait) */
406
#define ADC_AUTOPOWEROFF_DELAY_PHASE        ((uint32_t)ADC_CR1_PDD)                     /*!< ADC power off when a delay is inserted between conversions (see parameter ADC_LowPowerAutoWait) */
388
#define ADC_AUTOPOWEROFF_IDLE_DELAY_PHASES  ((uint32_t)(ADC_CR1_PDI | ADC_CR1_PDD))     /*!< ADC power off when ADC is not converting (idle phase) and when a delay is inserted between conversions */
407
#define ADC_AUTOPOWEROFF_IDLE_DELAY_PHASES  ((uint32_t)(ADC_CR1_PDI | ADC_CR1_PDD))     /*!< ADC power off when ADC is not converting (idle phase) and when a delay is inserted between conversions */
389
/**
408
/**
390
  * @}
409
  * @}
Line 393... Line 412...
393
 
412
 
394
/** @defgroup ADC_ChannelsBank ADC ChannelsBank
413
/** @defgroup ADC_ChannelsBank ADC ChannelsBank
395
  * @{
414
  * @{
396
  */
415
  */
397
#if defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
416
#if defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
398
#define ADC_CHANNELS_BANK_A                 ((uint32_t)0x00000000)
417
#define ADC_CHANNELS_BANK_A                 (0x00000000U)
399
#define ADC_CHANNELS_BANK_B                 ((uint32_t)ADC_CR2_CFG)
418
#define ADC_CHANNELS_BANK_B                 ((uint32_t)ADC_CR2_CFG)
400
 
419
 
401
#define IS_ADC_CHANNELSBANK(BANK) (((BANK) == ADC_CHANNELS_BANK_A) || \
420
#define IS_ADC_CHANNELSBANK(BANK) (((BANK) == ADC_CHANNELS_BANK_A) || \
402
                                   ((BANK) == ADC_CHANNELS_BANK_B)   )
421
                                   ((BANK) == ADC_CHANNELS_BANK_B)   )
403
#else
422
#else
404
#define ADC_CHANNELS_BANK_A                 ((uint32_t)0x00000000)
423
#define ADC_CHANNELS_BANK_A                 (0x00000000U)
405
 
424
 
406
#define IS_ADC_CHANNELSBANK(BANK) (((BANK) == ADC_CHANNELS_BANK_A))
425
#define IS_ADC_CHANNELSBANK(BANK) (((BANK) == ADC_CHANNELS_BANK_A))
407
#endif /* STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
426
#endif /* STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
408
/**
427
/**
409
  * @}
428
  * @}
Line 412... Line 431...
412
/** @defgroup ADC_channels ADC channels
431
/** @defgroup ADC_channels ADC channels
413
  * @{
432
  * @{
414
  */
433
  */
415
/* Note: Depending on devices, some channels may not be available on package  */
434
/* Note: Depending on devices, some channels may not be available on package  */
416
/*       pins. Refer to device datasheet for channels availability.           */
435
/*       pins. Refer to device datasheet for channels availability.           */
417
#define ADC_CHANNEL_0           ((uint32_t)0x00000000)                                                                            /* Channel different in bank A and bank B */
436
#define ADC_CHANNEL_0           (0x00000000U)                                                                                     /* Channel different in bank A and bank B */
418
#define ADC_CHANNEL_1           ((uint32_t)(                                                                    ADC_SQR5_SQ1_0))  /* Channel different in bank A and bank B */
437
#define ADC_CHANNEL_1           ((uint32_t)(                                                                    ADC_SQR5_SQ1_0))  /* Channel different in bank A and bank B */
419
#define ADC_CHANNEL_2           ((uint32_t)(                                                   ADC_SQR5_SQ1_1                 ))  /* Channel different in bank A and bank B */
438
#define ADC_CHANNEL_2           ((uint32_t)(                                                   ADC_SQR5_SQ1_1                 ))  /* Channel different in bank A and bank B */
420
#define ADC_CHANNEL_3           ((uint32_t)(                                                   ADC_SQR5_SQ1_1 | ADC_SQR5_SQ1_0))  /* Channel different in bank A and bank B */
439
#define ADC_CHANNEL_3           ((uint32_t)(                                                   ADC_SQR5_SQ1_1 | ADC_SQR5_SQ1_0))  /* Channel different in bank A and bank B */
421
#define ADC_CHANNEL_4           ((uint32_t)(                                  ADC_SQR5_SQ1_2                                  ))  /* Direct (fast) channel */
440
#define ADC_CHANNEL_4           ((uint32_t)(                                  ADC_SQR5_SQ1_2                                  ))  /* Direct (fast) channel */
422
#define ADC_CHANNEL_5           ((uint32_t)(                                  ADC_SQR5_SQ1_2                  | ADC_SQR5_SQ1_0))  /* Direct (fast) channel */
441
#define ADC_CHANNEL_5           ((uint32_t)(                                  ADC_SQR5_SQ1_2                  | ADC_SQR5_SQ1_0))  /* Direct (fast) channel */
Line 465... Line 484...
465
  */
484
  */
466
 
485
 
467
/** @defgroup ADC_sampling_times ADC sampling times
486
/** @defgroup ADC_sampling_times ADC sampling times
468
  * @{
487
  * @{
469
  */
488
  */
470
#define ADC_SAMPLETIME_4CYCLES      ((uint32_t)0x00000000)                            /*!< Sampling time 4 ADC clock cycles */
489
#define ADC_SAMPLETIME_4CYCLES      (0x00000000U)                                     /*!< Sampling time 4 ADC clock cycles */
471
#define ADC_SAMPLETIME_9CYCLES      ((uint32_t) ADC_SMPR3_SMP0_0)                     /*!< Sampling time 9 ADC clock cycles */
490
#define ADC_SAMPLETIME_9CYCLES      ((uint32_t) ADC_SMPR3_SMP0_0)                     /*!< Sampling time 9 ADC clock cycles */
472
#define ADC_SAMPLETIME_16CYCLES     ((uint32_t) ADC_SMPR3_SMP0_1)                     /*!< Sampling time 16 ADC clock cycles */
491
#define ADC_SAMPLETIME_16CYCLES     ((uint32_t) ADC_SMPR3_SMP0_1)                     /*!< Sampling time 16 ADC clock cycles */
473
#define ADC_SAMPLETIME_24CYCLES     ((uint32_t)(ADC_SMPR3_SMP0_1 | ADC_SMPR3_SMP0_0)) /*!< Sampling time 24 ADC clock cycles */
492
#define ADC_SAMPLETIME_24CYCLES     ((uint32_t)(ADC_SMPR3_SMP0_1 | ADC_SMPR3_SMP0_0)) /*!< Sampling time 24 ADC clock cycles */
474
#define ADC_SAMPLETIME_48CYCLES     ((uint32_t) ADC_SMPR3_SMP0_2)                     /*!< Sampling time 48 ADC clock cycles */
493
#define ADC_SAMPLETIME_48CYCLES     ((uint32_t) ADC_SMPR3_SMP0_2)                     /*!< Sampling time 48 ADC clock cycles */
475
#define ADC_SAMPLETIME_96CYCLES     ((uint32_t)(ADC_SMPR3_SMP0_2 | ADC_SMPR3_SMP0_0)) /*!< Sampling time 96 ADC clock cycles */
494
#define ADC_SAMPLETIME_96CYCLES     ((uint32_t)(ADC_SMPR3_SMP0_2 | ADC_SMPR3_SMP0_0)) /*!< Sampling time 96 ADC clock cycles */
Line 552... Line 571...
552
  */
571
  */
553
 
572
 
554
/** @defgroup ADC_regular_rank ADC rank into regular group
573
/** @defgroup ADC_regular_rank ADC rank into regular group
555
  * @{
574
  * @{
556
  */
575
  */
557
#define ADC_REGULAR_RANK_1    ((uint32_t)0x00000001)
576
#define ADC_REGULAR_RANK_1    (0x00000001U)
558
#define ADC_REGULAR_RANK_2    ((uint32_t)0x00000002)
577
#define ADC_REGULAR_RANK_2    (0x00000002U)
559
#define ADC_REGULAR_RANK_3    ((uint32_t)0x00000003)
578
#define ADC_REGULAR_RANK_3    (0x00000003U)
560
#define ADC_REGULAR_RANK_4    ((uint32_t)0x00000004)
579
#define ADC_REGULAR_RANK_4    (0x00000004U)
561
#define ADC_REGULAR_RANK_5    ((uint32_t)0x00000005)
580
#define ADC_REGULAR_RANK_5    (0x00000005U)
562
#define ADC_REGULAR_RANK_6    ((uint32_t)0x00000006)
581
#define ADC_REGULAR_RANK_6    (0x00000006U)
563
#define ADC_REGULAR_RANK_7    ((uint32_t)0x00000007)
582
#define ADC_REGULAR_RANK_7    (0x00000007U)
564
#define ADC_REGULAR_RANK_8    ((uint32_t)0x00000008)
583
#define ADC_REGULAR_RANK_8    (0x00000008U)
565
#define ADC_REGULAR_RANK_9    ((uint32_t)0x00000009)
584
#define ADC_REGULAR_RANK_9    (0x00000009U)
566
#define ADC_REGULAR_RANK_10   ((uint32_t)0x0000000A)
585
#define ADC_REGULAR_RANK_10   (0x0000000AU)
567
#define ADC_REGULAR_RANK_11   ((uint32_t)0x0000000B)
586
#define ADC_REGULAR_RANK_11   (0x0000000BU)
568
#define ADC_REGULAR_RANK_12   ((uint32_t)0x0000000C)
587
#define ADC_REGULAR_RANK_12   (0x0000000CU)
569
#define ADC_REGULAR_RANK_13   ((uint32_t)0x0000000D)
588
#define ADC_REGULAR_RANK_13   (0x0000000DU)
570
#define ADC_REGULAR_RANK_14   ((uint32_t)0x0000000E)
589
#define ADC_REGULAR_RANK_14   (0x0000000EU)
571
#define ADC_REGULAR_RANK_15   ((uint32_t)0x0000000F)
590
#define ADC_REGULAR_RANK_15   (0x0000000FU)
572
#define ADC_REGULAR_RANK_16   ((uint32_t)0x00000010)
591
#define ADC_REGULAR_RANK_16   (0x00000010U)
573
#define ADC_REGULAR_RANK_17   ((uint32_t)0x00000011)
592
#define ADC_REGULAR_RANK_17   (0x00000011U)
574
#define ADC_REGULAR_RANK_18   ((uint32_t)0x00000012)
593
#define ADC_REGULAR_RANK_18   (0x00000012U)
575
#define ADC_REGULAR_RANK_19   ((uint32_t)0x00000013)
594
#define ADC_REGULAR_RANK_19   (0x00000013U)
576
#define ADC_REGULAR_RANK_20   ((uint32_t)0x00000014)
595
#define ADC_REGULAR_RANK_20   (0x00000014U)
577
#define ADC_REGULAR_RANK_21   ((uint32_t)0x00000015)
596
#define ADC_REGULAR_RANK_21   (0x00000015U)
578
#define ADC_REGULAR_RANK_22   ((uint32_t)0x00000016)
597
#define ADC_REGULAR_RANK_22   (0x00000016U)
579
#define ADC_REGULAR_RANK_23   ((uint32_t)0x00000017)
598
#define ADC_REGULAR_RANK_23   (0x00000017U)
580
#define ADC_REGULAR_RANK_24   ((uint32_t)0x00000018)
599
#define ADC_REGULAR_RANK_24   (0x00000018U)
581
#define ADC_REGULAR_RANK_25   ((uint32_t)0x00000019)
600
#define ADC_REGULAR_RANK_25   (0x00000019U)
582
#define ADC_REGULAR_RANK_26   ((uint32_t)0x0000001A)
601
#define ADC_REGULAR_RANK_26   (0x0000001AU)
583
#define ADC_REGULAR_RANK_27   ((uint32_t)0x0000001B)
602
#define ADC_REGULAR_RANK_27   (0x0000001BU)
584
#if defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
603
#if defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
585
#define ADC_REGULAR_RANK_28   ((uint32_t)0x0000001C)
604
#define ADC_REGULAR_RANK_28   (0x0000001CU)
586
#endif /* STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
605
#endif /* STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
587
/**
606
/**
588
  * @}
607
  * @}
589
  */
608
  */
590
 
609
 
591
/** @defgroup ADC_analog_watchdog_mode ADC analog watchdog mode
610
/** @defgroup ADC_analog_watchdog_mode ADC analog watchdog mode
592
  * @{
611
  * @{
593
  */
612
  */
594
#define ADC_ANALOGWATCHDOG_NONE                 ((uint32_t)0x00000000)
613
#define ADC_ANALOGWATCHDOG_NONE                 (0x00000000U)
595
#define ADC_ANALOGWATCHDOG_SINGLE_REG           ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_AWDEN))
614
#define ADC_ANALOGWATCHDOG_SINGLE_REG           ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_AWDEN))
596
#define ADC_ANALOGWATCHDOG_SINGLE_INJEC         ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_JAWDEN))
615
#define ADC_ANALOGWATCHDOG_SINGLE_INJEC         ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_JAWDEN))
597
#define ADC_ANALOGWATCHDOG_SINGLE_REGINJEC      ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_AWDEN | ADC_CR1_JAWDEN))
616
#define ADC_ANALOGWATCHDOG_SINGLE_REGINJEC      ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_AWDEN | ADC_CR1_JAWDEN))
598
#define ADC_ANALOGWATCHDOG_ALL_REG              ((uint32_t) ADC_CR1_AWDEN)
617
#define ADC_ANALOGWATCHDOG_ALL_REG              ((uint32_t) ADC_CR1_AWDEN)
599
#define ADC_ANALOGWATCHDOG_ALL_INJEC            ((uint32_t) ADC_CR1_JAWDEN)
618
#define ADC_ANALOGWATCHDOG_ALL_INJEC            ((uint32_t) ADC_CR1_JAWDEN)
Line 661... Line 680...
661
 
680
 
662
/* List of external triggers of regular group for ADC1:                       */
681
/* List of external triggers of regular group for ADC1:                       */
663
/* (used internally by HAL driver. To not use into HAL structure parameters)  */
682
/* (used internally by HAL driver. To not use into HAL structure parameters)  */
664
 
683
 
665
/* External triggers of regular group for ADC1 */
684
/* External triggers of regular group for ADC1 */
666
#define ADC_EXTERNALTRIG_T9_CC2         ((uint32_t) 0x00000000)
685
#define ADC_EXTERNALTRIG_T9_CC2         (0x00000000U)
667
#define ADC_EXTERNALTRIG_T9_TRGO        ((uint32_t)(                                                         ADC_CR2_EXTSEL_0))
686
#define ADC_EXTERNALTRIG_T9_TRGO        ((uint32_t)(                                                         ADC_CR2_EXTSEL_0))
668
#define ADC_EXTERNALTRIG_T2_CC3         ((uint32_t)(                                      ADC_CR2_EXTSEL_1                   ))
687
#define ADC_EXTERNALTRIG_T2_CC3         ((uint32_t)(                                      ADC_CR2_EXTSEL_1                   ))
669
#define ADC_EXTERNALTRIG_T2_CC2         ((uint32_t)(                                      ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0))
688
#define ADC_EXTERNALTRIG_T2_CC2         ((uint32_t)(                                      ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0))
670
#define ADC_EXTERNALTRIG_T3_TRGO        ((uint32_t)(                   ADC_CR2_EXTSEL_2                                      ))
689
#define ADC_EXTERNALTRIG_T3_TRGO        ((uint32_t)(                   ADC_CR2_EXTSEL_2                                      ))
671
#define ADC_EXTERNALTRIG_T4_CC4         ((uint32_t)(                   ADC_CR2_EXTSEL_2 |                    ADC_CR2_EXTSEL_0))
690
#define ADC_EXTERNALTRIG_T4_CC4         ((uint32_t)(                   ADC_CR2_EXTSEL_2 |                    ADC_CR2_EXTSEL_0))
Line 786... Line 805...
786
  */
805
  */
787
#define __HAL_ADC_CLEAR_FLAG(__HANDLE__, __FLAG__)                             \
806
#define __HAL_ADC_CLEAR_FLAG(__HANDLE__, __FLAG__)                             \
788
  (((__HANDLE__)->Instance->SR) = ~(__FLAG__))
807
  (((__HANDLE__)->Instance->SR) = ~(__FLAG__))
789
 
808
 
790
/** @brief  Reset ADC handle state
809
/** @brief  Reset ADC handle state
791
  * @param  __HANDLE__: ADC handle
810
  * @param  __HANDLE__ ADC handle
792
  * @retval None
811
  * @retval None
793
  */
812
  */
-
 
813
#if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
-
 
814
#define __HAL_ADC_RESET_HANDLE_STATE(__HANDLE__)                               \
-
 
815
  do{                                                                          \
-
 
816
     (__HANDLE__)->State = HAL_ADC_STATE_RESET;                               \
-
 
817
     (__HANDLE__)->MspInitCallback = NULL;                                     \
-
 
818
     (__HANDLE__)->MspDeInitCallback = NULL;                                   \
-
 
819
    } while(0)
-
 
820
#else
794
#define __HAL_ADC_RESET_HANDLE_STATE(__HANDLE__)                               \
821
#define __HAL_ADC_RESET_HANDLE_STATE(__HANDLE__)                               \
795
  ((__HANDLE__)->State = HAL_ADC_STATE_RESET)
822
  ((__HANDLE__)->State = HAL_ADC_STATE_RESET)
-
 
823
#endif
796
   
824
   
797
/**
825
/**
798
  * @}
826
  * @}
799
  */
827
  */
800
 
828
 
Line 1198... Line 1226...
1198
  * @retval SET: ADC data is within range corresponding to ADC resolution
1226
  * @retval SET: ADC data is within range corresponding to ADC resolution
1199
  *         RESET: ADC data is not within range corresponding to ADC resolution
1227
  *         RESET: ADC data is not within range corresponding to ADC resolution
1200
  *
1228
  *
1201
  */  
1229
  */  
1202
#define IS_ADC_RANGE(__RESOLUTION__, __ADC_DATA__)                                          \
1230
#define IS_ADC_RANGE(__RESOLUTION__, __ADC_DATA__)                                          \
1203
   ((((__RESOLUTION__) == ADC_RESOLUTION_12B) && ((__ADC_DATA__) <= ((uint32_t)0x0FFF))) || \
1231
   ((((__RESOLUTION__) == ADC_RESOLUTION_12B) && ((__ADC_DATA__) <= (0x0FFFU))) || \
1204
    (((__RESOLUTION__) == ADC_RESOLUTION_10B) && ((__ADC_DATA__) <= ((uint32_t)0x03FF))) || \
1232
    (((__RESOLUTION__) == ADC_RESOLUTION_10B) && ((__ADC_DATA__) <= (0x03FFU))) || \
1205
    (((__RESOLUTION__) == ADC_RESOLUTION_8B)  && ((__ADC_DATA__) <= ((uint32_t)0x00FF))) || \
1233
    (((__RESOLUTION__) == ADC_RESOLUTION_8B)  && ((__ADC_DATA__) <= (0x00FFU))) || \
1206
    (((__RESOLUTION__) == ADC_RESOLUTION_6B)  && ((__ADC_DATA__) <= ((uint32_t)0x003F)))   )
1234
    (((__RESOLUTION__) == ADC_RESOLUTION_6B)  && ((__ADC_DATA__) <= (0x003FU)))   )
1207
 
1235
 
1208
 
1236
 
1209
#if defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
1237
#if defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
1210
#define IS_ADC_REGULAR_NB_CONV(LENGTH) (((LENGTH) >= ((uint32_t)1)) && ((LENGTH) <= ((uint32_t)28)))
1238
#define IS_ADC_REGULAR_NB_CONV(LENGTH) (((LENGTH) >= (1U)) && ((LENGTH) <= (28U)))
1211
#else
1239
#else
1212
#define IS_ADC_REGULAR_NB_CONV(LENGTH) (((LENGTH) >= ((uint32_t)1)) && ((LENGTH) <= ((uint32_t)27)))
1240
#define IS_ADC_REGULAR_NB_CONV(LENGTH) (((LENGTH) >= (1U)) && ((LENGTH) <= (27U)))
1213
#endif
1241
#endif
1214
 
1242
 
1215
#define IS_ADC_REGULAR_DISCONT_NUMBER(NUMBER) (((NUMBER) >= ((uint32_t)1)) && ((NUMBER) <= ((uint32_t)8)))
1243
#define IS_ADC_REGULAR_DISCONT_NUMBER(NUMBER) (((NUMBER) >= (1U)) && ((NUMBER) <= (8U)))
1216
 
1244
 
1217
/**
1245
/**
1218
  * @}
1246
  * @}
1219
  */
1247
  */
1220
   
1248
   
Line 1235... Line 1263...
1235
/* Initialization and de-initialization functions  **********************************/
1263
/* Initialization and de-initialization functions  **********************************/
1236
HAL_StatusTypeDef       HAL_ADC_Init(ADC_HandleTypeDef* hadc);
1264
HAL_StatusTypeDef       HAL_ADC_Init(ADC_HandleTypeDef* hadc);
1237
HAL_StatusTypeDef       HAL_ADC_DeInit(ADC_HandleTypeDef *hadc);
1265
HAL_StatusTypeDef       HAL_ADC_DeInit(ADC_HandleTypeDef *hadc);
1238
void                    HAL_ADC_MspInit(ADC_HandleTypeDef* hadc);
1266
void                    HAL_ADC_MspInit(ADC_HandleTypeDef* hadc);
1239
void                    HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc);
1267
void                    HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc);
-
 
1268
 
-
 
1269
#if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
-
 
1270
/* Callbacks Register/UnRegister functions  ***********************************/
-
 
1271
HAL_StatusTypeDef HAL_ADC_RegisterCallback(ADC_HandleTypeDef *hadc, HAL_ADC_CallbackIDTypeDef CallbackID, pADC_CallbackTypeDef pCallback);
-
 
1272
HAL_StatusTypeDef HAL_ADC_UnRegisterCallback(ADC_HandleTypeDef *hadc, HAL_ADC_CallbackIDTypeDef CallbackID);
-
 
1273
#endif /* USE_HAL_ADC_REGISTER_CALLBACKS */
-
 
1274
 
1240
/**
1275
/**
1241
  * @}
1276
  * @}
1242
  */
1277
  */
1243
 
1278
 
1244
/* IO operation functions  *****************************************************/
1279
/* IO operation functions  *****************************************************/