]> git.gir.st - tmk_keyboard.git/blob - tool/mbed/mbed-sdk/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F3/stm32f3xx_hal_adc.c
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[tmk_keyboard.git] / tool / mbed / mbed-sdk / libraries / mbed / targets / cmsis / TARGET_STM / TARGET_STM32F3 / stm32f3xx_hal_adc.c
1 /**
2 ******************************************************************************
3 * @file stm32f3xx_hal_adc.c
4 * @author MCD Application conversion
5 * @version V1.1.0
6 * @date 12-Sept-2014
7 * @brief This file provides firmware functions to manage the following
8 * functionalities of the Analog to Digital Convertor (ADC)
9 * peripheral:
10 * + Initialization and de-initialization functions
11 * ++ Initialization and Configuration of ADC
12 * + Operation functions
13 * ++ Start, stop, get result of conversions of regular and injected
14 * groups, using 3 possible modes: polling, interruption or DMA.
15 * + Control functions
16 * ++ Analog Watchdog configuration
17 * ++ Channels configuration on regular group
18 * + State functions
19 * ++ ADC state machine management
20 * ++ Interrupts and flags management
21 *
22 @verbatim
23 ==============================================================================
24 ##### ADC specific features #####
25 ==============================================================================
26 [..]
27 (#) 12-bit, 10-bit, 8-bit or 6-bit configurable resolution (available only on
28 STM32F30xxC devices).
29
30 (#) Interrupt generation at the end of regular conversion, end of injected
31 conversion, and in case of analog watchdog or overrun events.
32
33 (#) Single and continuous conversion modes.
34
35 (#) Scan mode for automatic conversion of channel 0 to channel 'n'.
36
37 (#) Data alignment with in-built data coherency.
38
39 (#) Channel-wise programmable sampling time.
40
41 (#) ADC conversion Regular or Injected groups.
42
43 (#) External trigger (timer or EXTI) with configurable polarity for both
44 regular and injected groups.
45
46 (#) DMA request generation for transfer of conversions data of regular group.
47
48 (#) Multimode Dual mode (available on devices with 2 ADCs or more).
49
50 (#) Configurable DMA data storage in Multimode Dual mode (available on devices
51 with 2 DCs or more).
52
53 (#) Configurable delay between conversions in Dual interleaved mode (available
54 on devices with 2 DCs or more).
55
56 (#) ADC calibration
57
58 (#) ADC channels selectable single/differential input (available only on
59 STM32F30xxC devices)
60
61 (#) ADC Injected sequencer&channels configuration context queue (available
62 only on STM32F30xxC devices)
63
64 (#) ADC offset on injected and regular groups (offset on regular group
65 available only on STM32F30xxC devices)
66
67 (#) ADC supply requirements: 2.4 V to 3.6 V at full speed and down to 1.8 V at
68 slower speed.
69
70 (#) ADC input range: from Vref\96 (connected to Vssa) to Vref+ (connected to
71 Vdda or to an external voltage reference).
72
73
74 ##### How to use this driver #####
75 ==============================================================================
76 [..]
77
78 (#) Enable the ADC interface
79 As prerequisite, into HAL_ADC_MspInit(), ADC clock must be configured
80 at RCC top level: clock source and clock prescaler.
81
82 For STM32F30x/STM32F33x devices:
83 Two possible clock sources: synchronous clock derived from AHB clock
84 or asynchronous clock derived from ADC dedicated PLL 72MHz.
85
86 For example, in case of device with a single ADC:
87 __ADC1_CLK_ENABLE() (mandatory)
88 __HAL_RCC_ADC1_CONFIG(RCC_ADC1PLLCLK_DIV1); (optional)
89
90 For example, in case of device with several ADCs:
91 if((hadc->Instance == ADC1) || (hadc->Instance == ADC2))
92 {
93 __ADC12_CLK_ENABLE() (mandatory)
94 __HAL_RCC_ADC12_CONFIG(RCC_ADC12PLLCLK_DIV1); (optional)
95 }
96 else
97 {
98 __ADC34_CLK_ENABLE() (mandatory)
99 __HAL_RCC_ADC34_CONFIG(RCC_ADC34PLLCLK_DIV1); (optional)
100 }
101
102 For STM32F37x devices:
103 Only one clock source: APB2 clock.
104 Example:
105 __HAL_RCC_ADC1_CONFIG(RCC_ADC1PCLK2_DIV2);
106
107 (#) ADC pins configuration
108 (++) Enable the clock for the ADC GPIOs using the following function:
109 __GPIOx_CLK_ENABLE();
110 (++) Configure these ADC pins in analog mode using HAL_GPIO_Init();
111
112 (#) Configure the ADC parameters (conversion resolution, data alignment,
113 continuous mode, ...) using the HAL_ADC_Init() function.
114
115 (#) Activate the ADC peripheral using one of the start functions:
116 HAL_ADC_Start(), HAL_ADC_Start_IT(), HAL_ADC_Start_DMA()
117 HAL_ADCEx_InjectedStart(), HAL_ADCEx_InjectedStart_IT() or
118 HAL_ADC_MultiModeStart_DMA().
119
120 *** Channels to regular group configuration ***
121 ============================================
122 [..]
123 (+) To configure the ADC regular group features, use
124 HAL_ADC_Init() and HAL_ADC_ConfigChannel() functions.
125 (+) To activate the continuous mode, use the HAL_ADC_Init() function.
126 (+) To read the ADC converted values, use the HAL_ADC_GetValue() function.
127
128 *** Multimode ADCs configuration ***
129 ======================================================
130 [..]
131 (+) Multimode feature is available on devices with 2 ADCs or more.
132 (+) Refer to "Channels to regular group" description to
133 configure the ADC1 and ADC2 regular groups.
134 (+) Select the Multi mode ADC features (dual mode
135 simultaneous, interleaved, ...) and configure the DMA mode using
136 HAL_ADCEx_MultiModeConfigChannel() functions.
137 (+) Read the ADCs converted values using the HAL_ADCEx_MultiModeGetValue()
138 function.
139
140 *** DMA for regular configuration ***
141 =============================================================
142 [..]
143 (+) To enable the DMA mode for regular group, use the
144 HAL_ADC_Start_DMA() function.
145 (+) To enable the generation of DMA requests continuously at the end of
146 the last DMA transfer, use the HAL_ADC_Init() function.
147
148 *** Channels to injected group configuration ***
149 =============================================
150 [..]
151 (+) To configure the ADC Injected channels group features, use
152 HAL_ADCEx_InjectedConfigChannel() functions.
153 (+) To activate the continuous mode, use the HAL_ADC_Init() function.
154 (+) To read the ADC converted values, use the HAL_ADCEx_InjectedGetValue()
155 function.
156
157 @endverbatim
158 ******************************************************************************
159 * @attention
160 *
161 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
162 *
163 * Redistribution and use in source and binary forms, with or without modification,
164 * are permitted provided that the following conditions are met:
165 * 1. Redistributions of source code must retain the above copyright notice,
166 * this list of conditions and the following disclaimer.
167 * 2. Redistributions in binary form must reproduce the above copyright notice,
168 * this list of conditions and the following disclaimer in the documentation
169 * and/or other materials provided with the distribution.
170 * 3. Neither the name of STMicroelectronics nor the names of its contributors
171 * may be used to endorse or promote products derived from this software
172 * without specific prior written permission.
173 *
174 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
175 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
176 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
177 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
178 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
179 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
180 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
181 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
182 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
183 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
184 *
185 ******************************************************************************
186 */
187
188 /* Includes ------------------------------------------------------------------*/
189 #include "stm32f3xx_hal.h"
190
191 /** @addtogroup STM32F3xx_HAL_Driver
192 * @{
193 */
194
195 /** @defgroup ADC ADC HAL module driver
196 * @brief ADC HAL module driver
197 * @{
198 */
199
200 #ifdef HAL_ADC_MODULE_ENABLED
201
202 /* Private typedef -----------------------------------------------------------*/
203 /* Private define ------------------------------------------------------------*/
204 /* Private macro -------------------------------------------------------------*/
205 /* Private variables ---------------------------------------------------------*/
206 /* Private function prototypes -----------------------------------------------*/
207 /* Exported functions --------------------------------------------------------*/
208
209 /** @defgroup ADC_Exported_Functions ADC Exported Functions
210 * @{
211 */
212
213 /** @defgroup ADC_Exported_Functions_Group1 Initialization and de-initialization functions
214 * @brief Initialization and Configuration functions
215 *
216 @verbatim
217 ===============================================================================
218 ##### Initialization and de-initialization functions #####
219 ===============================================================================
220 [..] This section provides functions allowing to:
221 (+) Initialize and configure the ADC.
222 (+) De-initialize the ADC.
223
224 @endverbatim
225 * @{
226 */
227
228 /**
229 * @brief Initializes the ADC peripheral and regular group according to
230 * parameters specified in structure "ADC_InitTypeDef".
231 * @note As prerequisite, ADC clock must be configured at RCC top level
232 * depending on both possible clock sources: PLL clock or AHB clock.
233 * See commented example code below that can be copied and uncommented
234 * into HAL_ADC_MspInit().
235 * @note Possibility to update parameters on the fly:
236 * This function initializes the ADC MSP (HAL_ADC_MspInit()) only when
237 * coming from ADC state reset. Following calls to this function can
238 * be used to reconfigure some parameters of ADC_InitTypeDef
239 * structure on the fly, without modifying MSP configuration. If ADC
240 * MSP has to be modified again, HAL_ADC_DeInit() must be called
241 * before HAL_ADC_Init().
242 * The setting of these parameters is conditioned to ADC state.
243 * For parameters constraints, see comments of structure
244 * "ADC_InitTypeDef".
245 * @note This function configures the ADC within 2 scopes: scope of entire
246 * ADC and scope of regular group. For parameters details, see comments
247 * of structure "ADC_InitTypeDef".
248 * @note For devices with several ADCs: parameters related to common ADC
249 * registers (ADC clock mode) are set only if all ADCs sharing the
250 * same common group are disabled.
251 * If this is not the case, these common parameters setting are
252 * bypassed without error reporting: it can be the intended behaviour in
253 * case of update of a parameter of ADC_InitTypeDef on the fly,
254 * without disabling the other ADCs sharing the same common group.
255 * @param hadc: ADC handle
256 * @retval HAL status
257 */
258 __weak HAL_StatusTypeDef HAL_ADC_Init(ADC_HandleTypeDef* hadc)
259 {
260 /* Note : This function is defined into this file for library reference. */
261 /* Function content is located into file stm32f3xx_hal_adc_ex.c */
262
263 /* Return function status */
264 return HAL_ERROR;
265 }
266
267 /**
268 * @brief Deinitialize the ADC peripheral registers to their default reset
269 * values, with deinitialization of the ADC MSP.
270 * @note For devices with several ADCs: reset of ADC common registers is done
271 * only if all ADCs sharing the same common group are disabled.
272 * If this is not the case, reset of these common parameters reset is
273 * bypassed without error reporting: it can be the intended behaviour in
274 * case of reset of a single ADC while the other ADCs sharing the same
275 * common group is still running.
276 * @note For devices with several ADCs: Global reset of all ADCs sharing a
277 * common group is possible.
278 * As this function is intended to reset a single ADC, to not impact
279 * other ADCs, instructions for global reset of multiple ADCs have been
280 * let commented below.
281 * If needed, the example code can be copied and uncommented into
282 * function HAL_ADC_MspDeInit().
283 * @param hadc: ADC handle
284 * @retval HAL status
285 */
286 __weak HAL_StatusTypeDef HAL_ADC_DeInit(ADC_HandleTypeDef* hadc)
287 {
288 /* Note : This function is defined into this file for library reference. */
289 /* Function content is located into file stm32f3xx_hal_adc_ex.c */
290
291 /* Return function status */
292 return HAL_ERROR;
293 }
294
295 /**
296 * @brief Initializes the ADC MSP.
297 * @param hadc: ADC handle
298 * @retval None
299 */
300 __weak void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
301 {
302 /* NOTE : This function should not be modified. When the callback is needed,
303 function HAL_ADC_MspInit must be implemented in the user file.
304 */
305 }
306
307 /**
308 * @brief DeInitializes the ADC MSP.
309 * @param hadc: ADC handle
310 * @retval None
311 */
312 __weak void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc)
313 {
314 /* NOTE : This function should not be modified. When the callback is needed,
315 function HAL_ADC_MspDeInit must be implemented in the user file.
316 */
317 }
318
319 /**
320 * @}
321 */
322
323 /** @defgroup ADC_Exported_Functions_Group2 Input and Output operation functions
324 * @brief IO operation functions
325 *
326 @verbatim
327 ===============================================================================
328 ##### IO operation functions #####
329 ===============================================================================
330 [..] This section provides functions allowing to:
331 (+) Start conversion of regular group.
332 (+) Stop conversion of regular group.
333 (+) Poll for conversion complete on regular group.
334 (+) Poll for conversion event.
335 (+) Get result of regular channel conversion.
336 (+) Start conversion of regular group and enable interruptions.
337 (+) Stop conversion of regular group and disable interruptions.
338 (+) Handle ADC interrupt request
339 (+) Start conversion of regular group and enable DMA transfer.
340 (+) Stop conversion of regular group and disable ADC DMA transfer.
341
342 @endverbatim
343 * @{
344 */
345 /**
346 * @brief Enables ADC, starts conversion of regular group.
347 * Interruptions enabled in this function: None.
348 * @note: Case of multimode enabled (for devices with several ADCs): This
349 * function must be called for ADC slave first, then ADC master.
350 * For ADC slave, ADC is enabled only (conversion is not started).
351 * For ADC master, ADC is enabled and multimode conversion is started.
352 * @param hadc: ADC handle
353 * @retval HAL status
354 */
355 __weak HAL_StatusTypeDef HAL_ADC_Start(ADC_HandleTypeDef* hadc)
356 {
357 /* Return function status */
358 return HAL_ERROR;
359 }
360
361 /**
362 * @brief Stop ADC conversion of regular group (and injected group in
363 * case of auto_injection mode), disable ADC peripheral.
364 * @note: ADC peripheral disable is forcing interruption of potential
365 * conversion on injected group. If injected group is under use, it
366 * should be preliminarily stopped using HAL_ADCEx_InjectedStop function.
367 * @note: Case of multimode enabled (for devices with several ADCs): This
368 * function must be called for ADC master first, then ADC slave.
369 * For ADC master, converson is stopped and ADC is disabled.
370 * For ADC slave, ADC is disabled only (conversion stop of ADC master
371 * has already stopped conversion of ADC slave).
372 * @param hadc: ADC handle
373 * @retval HAL status.
374 */
375 __weak HAL_StatusTypeDef HAL_ADC_Stop(ADC_HandleTypeDef* hadc)
376 {
377 /* Note : This function is defined into this file for library reference. */
378 /* Function content is located into file stm32f3xx_hal_adc_ex.c */
379
380 /* Return function status */
381 return HAL_ERROR;
382 }
383
384 /**
385 * @brief Wait for regular group conversion to be completed.
386 * @param hadc: ADC handle
387 * @param Timeout: Timeout value in millisecond.
388 * @retval HAL status
389 */
390 __weak HAL_StatusTypeDef HAL_ADC_PollForConversion(ADC_HandleTypeDef* hadc, uint32_t Timeout)
391 {
392 /* Note : This function is defined into this file for library reference. */
393 /* Function content is located into file stm32f3xx_hal_adc_ex.c */
394
395 /* Return function status */
396 return HAL_ERROR;
397 }
398
399 /**
400 * @brief Poll for conversion event.
401 * @param hadc: ADC handle
402 * @param EventType: the ADC event type.
403 * This parameter can be one of the following values:
404 * @arg AWD_EVENT: ADC Analog watchdog 1 event (main analog watchdog, present on all STM32 devices)
405 * @arg AWD2_EVENT: ADC Analog watchdog 2 event (additional analog watchdog, present only on STM32F3 devices)
406 * @arg AWD3_EVENT: ADC Analog watchdog 3 event (additional analog watchdog, present only on STM32F3 devices)
407 * @arg OVR_EVENT: ADC Overrun event
408 * @arg JQOVF_EVENT: ADC Injected context queue overflow event
409 * @param Timeout: Timeout value in millisecond.
410 * @retval HAL status
411 */
412 __weak HAL_StatusTypeDef HAL_ADC_PollForEvent(ADC_HandleTypeDef* hadc, uint32_t EventType, uint32_t Timeout)
413 {
414 /* Note : This function is defined into this file for library reference. */
415 /* Function content is located into file stm32f3xx_hal_adc_ex.c */
416
417 /* Return function status */
418 return HAL_ERROR;
419 }
420
421 /**
422 * @brief Enables ADC, starts conversion of regular group with interruption.
423 * Interruptions enabled in this function: EOC (end of conversion),
424 * overrun (if available).
425 * Each of these interruptions has its dedicated callback function.
426 * @note: Case of multimode enabled (for devices with several ADCs): This
427 * function must be called for ADC slave first, then ADC master.
428 * For ADC slave, ADC is enabled only (conversion is not started).
429 * For ADC master, ADC is enabled and multimode conversion is started.
430 * @param hadc: ADC handle
431 * @retval HAL status
432 */
433 __weak HAL_StatusTypeDef HAL_ADC_Start_IT(ADC_HandleTypeDef* hadc)
434 {
435 /* Note : This function is defined into this file for library reference. */
436 /* Function content is located into file stm32f3xx_hal_adc_ex.c */
437
438 /* Return function status */
439 return HAL_ERROR;
440 }
441
442 /**
443 * @brief Stop ADC conversion of regular group (and injected group in
444 * case of auto_injection mode), disable interruption of
445 * end-of-conversion, disable ADC peripheral.
446 * @note: ADC peripheral disable is forcing interruption of potential
447 * conversion on injected group. If injected group is under use, it
448 * should be preliminarily stopped using HAL_ADCEx_InjectedStop function.
449 * @note: Case of multimode enabled (for devices with several ADCs): This
450 * function must be called for ADC master first, then ADC slave.
451 * For ADC master, conversion is stopped and ADC is disabled.
452 * For ADC slave, ADC is disabled only (conversion stop of ADC master
453 * has already stopped conversion of ADC slave).
454 * @param hadc: ADC handle
455 * @retval HAL status.
456 */
457 __weak HAL_StatusTypeDef HAL_ADC_Stop_IT(ADC_HandleTypeDef* hadc)
458 {
459 /* Note : This function is defined into this file for library reference. */
460 /* Function content is located into file stm32f3xx_hal_adc_ex.c */
461
462 /* Return function status */
463 return HAL_ERROR;
464 }
465
466 /**
467 * @brief Enables ADC, starts conversion of regular group and transfers result
468 * through DMA.
469 * Interruptions enabled in this function:
470 * overrun (if available), DMA half transfer, DMA transfer complete.
471 * Each of these interruptions has its dedicated callback function.
472 * @note: Case of multimode enabled (for devices with several ADCs): This
473 * function is for single-ADC mode only. For multimode, use the
474 * dedicated MultimodeStart function.
475 * @param hadc: ADC handle
476 * @param pData: The destination Buffer address.
477 * @param Length: The length of data to be transferred from ADC peripheral to memory.
478 * @retval None
479 */
480 __weak HAL_StatusTypeDef HAL_ADC_Start_DMA(ADC_HandleTypeDef* hadc, uint32_t* pData, uint32_t Length)
481 {
482 /* Note : This function is defined into this file for library reference. */
483 /* Function content is located into file stm32f3xx_hal_adc_ex.c */
484
485 /* Return function status */
486 return HAL_ERROR;
487 }
488
489 /**
490 * @brief Stop ADC conversion of regular group (and injected group in
491 * case of auto_injection mode), disable ADC DMA transfer, disable
492 * ADC peripheral.
493 * @note: ADC peripheral disable is forcing interruption of potential
494 * conversion on injected group. If injected group is under use, it
495 * should be preliminarily stopped using HAL_ADCEx_InjectedStop function.
496 * @note: Case of multimode enabled (for devices with several ADCs): This
497 * function is for single-ADC mode only. For multimode, use the
498 * dedicated MultimodeStop function.
499 * @param hadc: ADC handle
500 * @retval HAL status.
501 */
502 __weak HAL_StatusTypeDef HAL_ADC_Stop_DMA(ADC_HandleTypeDef* hadc)
503 {
504 /* Note : This function is defined into this file for library reference. */
505 /* Function content is located into file stm32f3xx_hal_adc_ex.c */
506
507 /* Return function status */
508 return HAL_ERROR;
509 }
510
511 /**
512 * @brief Get ADC regular group conversion result.
513 * @param hadc: ADC handle
514 * @retval Converted value
515 */
516 __weak uint32_t HAL_ADC_GetValue(ADC_HandleTypeDef* hadc)
517 {
518 /* Note : This function is defined into this file for library reference. */
519 /* Function content is located into file stm32f3xx_hal_adc_ex.c */
520
521 /* Return ADC converted value */
522 return hadc->Instance->DR;
523 }
524
525 /**
526 * @brief Handles ADC interrupt request.
527 * @param hadc: ADC handle
528 * @retval None
529 */
530 __weak void HAL_ADC_IRQHandler(ADC_HandleTypeDef* hadc)
531 {
532 /* Note : This function is defined into this file for library reference. */
533 /* Function content is located into file stm32f3xx_hal_adc_ex.c */
534 }
535
536 /**
537 * @brief Conversion complete callback in non blocking mode
538 * @param hadc: ADC handle
539 * @retval None
540 */
541 __weak void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
542 {
543 /* NOTE : This function should not be modified. When the callback is needed,
544 function HAL_ADC_ConvCpltCallback must be implemented in the user file.
545 */
546 }
547
548 /**
549 * @brief Conversion DMA half-transfer callback in non blocking mode
550 * @param hadc: ADC handle
551 * @retval None
552 */
553 __weak void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef* hadc)
554 {
555 /* NOTE : This function should not be modified. When the callback is needed,
556 function HAL_ADC_ConvHalfCpltCallback must be implemented in the user file.
557 */
558 }
559
560 /**
561 * @brief Analog watchdog callback in non blocking mode.
562 * @note: In case of several analog watchdog enabled, if needed to know
563 which one triggered and on which ADCx, check Analog Watchdog flag
564 ADC_FLAG_AWD1/2/3 into HAL_ADC_LevelOutOfWindowCallback() function.
565 For example:"if (__HAL_ADC_GET_FLAG(hadc1, ADC_FLAG_AWD1) != RESET)"
566 * @param hadc: ADC handle
567 * @retval None
568 */
569 __weak void HAL_ADC_LevelOutOfWindowCallback(ADC_HandleTypeDef* hadc)
570 {
571 /* NOTE : This function should not be modified. When the callback is needed,
572 function HAL_ADC_LevelOoutOfWindowCallback must be implemented in the user file.
573 */
574 }
575
576 /**
577 * @brief ADC error callback in non blocking mode
578 * (ADC conversion with interruption or transfer by DMA)
579 * @param hadc: ADC handle
580 * @retval None
581 */
582 __weak void HAL_ADC_ErrorCallback(ADC_HandleTypeDef *hadc)
583 {
584 /* NOTE : This function should not be modified. When the callback is needed,
585 function HAL_ADC_ErrorCallback must be implemented in the user file.
586 */
587 }
588
589 /**
590 * @}
591 */
592
593 /** @defgroup ADC_Exported_Functions_Group3 Peripheral Control functions
594 * @brief Peripheral Control functions
595 *
596 @verbatim
597 ===============================================================================
598 ##### Peripheral Control functions #####
599 ===============================================================================
600 [..] This section provides functions allowing to:
601 (+) Configure channels on regular group
602 (+) Configure the analog watchdog
603
604 @endverbatim
605 * @{
606 */
607
608 /**
609 * @brief Configures the the selected channel to be linked to the regular
610 * group.
611 * @note In case of usage of internal measurement channels:
612 * Vbat/VrefInt/TempSensor.
613 * The recommended sampling time is at least:
614 * - For devices STM32F37x: 17.1us for temperature sensor
615 * - For the other STM32F3 devices: 2.2us for each of channels
616 * Vbat/VrefInt/TempSensor.
617 * These internal paths can be be disabled using function
618 * HAL_ADC_DeInit().
619 * @note Possibility to update parameters on the fly:
620 * This function initializes channel into regular group, following
621 * calls to this function can be used to reconfigure some parameters
622 * of structure "ADC_ChannelConfTypeDef" on the fly, without reseting
623 * the ADC.
624 * The setting of these parameters is conditioned to ADC state.
625 * For parameters constraints, see comments of structure
626 * "ADC_ChannelConfTypeDef".
627 * @param hadc: ADC handle
628 * @param sConfig: Structure of ADC channel for regular group.
629 * @retval HAL status
630 */
631 __weak HAL_StatusTypeDef HAL_ADC_ConfigChannel(ADC_HandleTypeDef* hadc, ADC_ChannelConfTypeDef* sConfig)
632 {
633 /* Note : This function is defined into this file for library reference. */
634 /* Function content is located into file stm32f3xx_hal_adc_ex.c */
635
636 /* Return function status */
637 return HAL_ERROR;
638 }
639
640 /**
641 * @brief Configures the analog watchdog.
642 * @note Possibility to update parameters on the fly:
643 * This function initializes the selected analog watchdog, following
644 * calls to this function can be used to reconfigure some parameters
645 * of structure "ADC_AnalogWDGConfTypeDef" on the fly, without reseting
646 * the ADC.
647 * The setting of these parameters is conditioned to ADC state.
648 * For parameters constraints, see comments of structure
649 * "ADC_AnalogWDGConfTypeDef".
650 * @param hadc: ADC handle
651 * @param AnalogWDGConfig: Structure of ADC analog watchdog configuration
652 * @retval HAL status
653 */
654 __weak HAL_StatusTypeDef HAL_ADC_AnalogWDGConfig(ADC_HandleTypeDef* hadc, ADC_AnalogWDGConfTypeDef* AnalogWDGConfig)
655 {
656 /* Note : This function is defined into this file for library reference. */
657 /* Function content is located into file stm32f3xx_hal_adc_ex.c */
658
659 /* Return function status */
660 return HAL_ERROR;
661 }
662
663 /**
664 * @}
665 */
666
667 /** @defgroup ADC_Exported_Functions_Group4 Peripheral State functions
668 * @brief ADC Peripheral State functions
669 *
670 @verbatim
671 ===============================================================================
672 ##### Peripheral state and errors functions #####
673 ===============================================================================
674 [..]
675 This subsection provides functions to get in run-time the status of the
676 peripheral.
677 (+) Check the ADC state
678 (+) Check the ADC error code
679
680 @endverbatim
681 * @{
682 */
683
684 /**
685 * @brief return the ADC state
686 * @param hadc: ADC handle
687 * @retval HAL state
688 */
689 HAL_ADC_StateTypeDef HAL_ADC_GetState(ADC_HandleTypeDef* hadc)
690 {
691 /* Check the parameters */
692 assert_param(IS_ADC_ALL_INSTANCE(hadc->Instance));
693
694 /* Return ADC state */
695 return hadc->State;
696 }
697
698 /**
699 * @brief Return the ADC error code
700 * @param hadc: ADC handle
701 * @retval ADC Error Code
702 */
703 uint32_t HAL_ADC_GetError(ADC_HandleTypeDef *hadc)
704 {
705 return hadc->ErrorCode;
706 }
707
708 /**
709 * @}
710 */
711
712 /**
713 * @}
714 */
715
716 #endif /* HAL_ADC_MODULE_ENABLED */
717 /**
718 * @}
719 */
720
721 /**
722 * @}
723 */
724
725 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Imprint / Impressum