RTEMS 6.1-rc4
Loading...
Searching...
No Matches
stm32h7xx_hal_adc.h
Go to the documentation of this file.
1
19/* Define to prevent recursive inclusion -------------------------------------*/
20#ifndef STM32H7xx_HAL_ADC_H
21#define STM32H7xx_HAL_ADC_H
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27/* Includes ------------------------------------------------------------------*/
28#include "stm32h7xx_hal_def.h"
29
30/* Include low level driver */
31#include "stm32h7xx_ll_adc.h"
32
41/* Exported types ------------------------------------------------------------*/
50typedef struct
51{
52 uint32_t Ratio;
53#if defined(ADC_VER_V5_V90)
54 /* On devices STM32H72xx and STM32H73xx, this parameter can be a value from 1 to 1023 for ADC1/2 or a value of @ref ADC_HAL_EC_OVS_RATIO for ADC3*/
55#else
56 /*This parameter can be a value of @ref ADC_HAL_EC_OVS_RATIO */
57#endif
58
59 uint32_t RightBitShift;
62 uint32_t TriggeredMode;
74
91typedef struct
92{
93 uint32_t ClockPrescaler;
104 uint32_t Resolution;
107#if defined(ADC_VER_V5_V90)
108 uint32_t DataAlign;
112#endif
113
114 uint32_t ScanConvMode;
122 uint32_t EOCSelection;
125 FunctionalState LowPowerAutoWait;
137 FunctionalState ContinuousConvMode;
147 FunctionalState DiscontinuousConvMode;
171#if defined(ADC_VER_V5_V90)
172 /*Note: On devices STM32H72xx and STM32H73xx, this parameter is specific to ADC3 only. */
173
174 uint32_t SamplingMode;
179 FunctionalState DMAContinuousRequests;
185#endif
186
187 uint32_t Overrun;
198 uint32_t LeftBitShift;
200 FunctionalState OversamplingMode;
208
220typedef struct
221{
222 uint32_t Channel;
226 uint32_t Rank;
231 uint32_t SamplingTime;
242 uint32_t SingleDiff;
254 uint32_t OffsetNumber;
258 uint32_t Offset;
265 FunctionalState OffsetRightShift;
268#if defined(ADC_VER_V5_V90)
269 uint32_t OffsetSign;
275 FunctionalState OffsetSaturation;
281#endif
282 FunctionalState OffsetSignedSaturation;
287
294typedef struct
295{
296 uint32_t WatchdogNumber;
301 uint32_t WatchdogMode;
306 uint32_t Channel;
311 FunctionalState ITMode;
314 uint32_t HighThreshold;
324 uint32_t LowThreshold;
333#if defined(ADC_VER_V5_V90)
334 uint32_t FilteringConfig;
339#endif
341
346typedef struct
347{
348 uint32_t ContextQueue;
352 uint32_t ChannelCount;
354
368/* States of ADC global scope */
369#define HAL_ADC_STATE_RESET (0x00000000UL)
370#define HAL_ADC_STATE_READY (0x00000001UL)
371#define HAL_ADC_STATE_BUSY_INTERNAL (0x00000002UL)
372#define HAL_ADC_STATE_TIMEOUT (0x00000004UL)
374/* States of ADC errors */
375#define HAL_ADC_STATE_ERROR_INTERNAL (0x00000010UL)
376#define HAL_ADC_STATE_ERROR_CONFIG (0x00000020UL)
377#define HAL_ADC_STATE_ERROR_DMA (0x00000040UL)
379/* States of ADC group regular */
380#define HAL_ADC_STATE_REG_BUSY (0x00000100UL)
382#define HAL_ADC_STATE_REG_EOC (0x00000200UL)
383#define HAL_ADC_STATE_REG_OVR (0x00000400UL)
384#define HAL_ADC_STATE_REG_EOSMP (0x00000800UL)
386/* States of ADC group injected */
387#define HAL_ADC_STATE_INJ_BUSY (0x00001000UL)
389#define HAL_ADC_STATE_INJ_EOC (0x00002000UL)
390#define HAL_ADC_STATE_INJ_JQOVF (0x00004000UL)
392/* States of ADC analog watchdogs */
393#define HAL_ADC_STATE_AWD1 (0x00010000UL)
394#define HAL_ADC_STATE_AWD2 (0x00020000UL)
395#define HAL_ADC_STATE_AWD3 (0x00040000UL)
397/* States of ADC multi-mode */
398#define HAL_ADC_STATE_MULTIMODE_SLAVE (0x00100000UL)
407#if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
408typedef struct __ADC_HandleTypeDef
409#else
410typedef struct
411#endif
412{
417 __IO uint32_t State;
418 __IO uint32_t ErrorCode;
420#if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
421 void (* ConvCpltCallback)(struct __ADC_HandleTypeDef *hadc);
422 void (* ConvHalfCpltCallback)(struct __ADC_HandleTypeDef *hadc);
423 void (* LevelOutOfWindowCallback)(struct __ADC_HandleTypeDef *hadc);
424 void (* ErrorCallback)(struct __ADC_HandleTypeDef *hadc);
425 void (* InjectedConvCpltCallback)(struct __ADC_HandleTypeDef *hadc);
426 void (* InjectedQueueOverflowCallback)(struct __ADC_HandleTypeDef *hadc);
427 void (* LevelOutOfWindow2Callback)(struct __ADC_HandleTypeDef *hadc);
428 void (* LevelOutOfWindow3Callback)(struct __ADC_HandleTypeDef *hadc);
429 void (* EndOfSamplingCallback)(struct __ADC_HandleTypeDef *hadc);
430 void (* MspInitCallback)(struct __ADC_HandleTypeDef *hadc);
431 void (* MspDeInitCallback)(struct __ADC_HandleTypeDef *hadc);
432#endif /* USE_HAL_ADC_REGISTER_CALLBACKS */
434
435#if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
439typedef enum
440{
441 HAL_ADC_CONVERSION_COMPLETE_CB_ID = 0x00U,
442 HAL_ADC_CONVERSION_HALF_CB_ID = 0x01U,
443 HAL_ADC_LEVEL_OUT_OF_WINDOW_1_CB_ID = 0x02U,
444 HAL_ADC_ERROR_CB_ID = 0x03U,
445 HAL_ADC_INJ_CONVERSION_COMPLETE_CB_ID = 0x04U,
446 HAL_ADC_INJ_QUEUE_OVEFLOW_CB_ID = 0x05U,
447 HAL_ADC_LEVEL_OUT_OF_WINDOW_2_CB_ID = 0x06U,
448 HAL_ADC_LEVEL_OUT_OF_WINDOW_3_CB_ID = 0x07U,
449 HAL_ADC_END_OF_SAMPLING_CB_ID = 0x08U,
450 HAL_ADC_MSPINIT_CB_ID = 0x09U,
451 HAL_ADC_MSPDEINIT_CB_ID = 0x0AU
452} HAL_ADC_CallbackIDTypeDef;
453
457typedef void (*pADC_CallbackTypeDef)(ADC_HandleTypeDef *hadc);
459#endif /* USE_HAL_ADC_REGISTER_CALLBACKS */
460
466/* Exported constants --------------------------------------------------------*/
467
477#define HAL_ADC_ERROR_NONE (0x00U)
478#define HAL_ADC_ERROR_INTERNAL (0x01U)
480#define HAL_ADC_ERROR_OVR (0x02U)
481#define HAL_ADC_ERROR_DMA (0x04U)
482#define HAL_ADC_ERROR_JQOVF (0x08U)
483#if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
484#define HAL_ADC_ERROR_INVALID_CALLBACK (0x10U)
485#endif /* USE_HAL_ADC_REGISTER_CALLBACKS */
494#define ADC_CLOCK_SYNC_PCLK_DIV1 (LL_ADC_CLOCK_SYNC_PCLK_DIV1)
495#define ADC_CLOCK_SYNC_PCLK_DIV2 (LL_ADC_CLOCK_SYNC_PCLK_DIV2)
496#define ADC_CLOCK_SYNC_PCLK_DIV4 (LL_ADC_CLOCK_SYNC_PCLK_DIV4)
498#define ADC_CLOCK_ASYNC_DIV1 (LL_ADC_CLOCK_ASYNC_DIV1)
499#define ADC_CLOCK_ASYNC_DIV2 (LL_ADC_CLOCK_ASYNC_DIV2)
500#define ADC_CLOCK_ASYNC_DIV4 (LL_ADC_CLOCK_ASYNC_DIV4)
501#define ADC_CLOCK_ASYNC_DIV6 (LL_ADC_CLOCK_ASYNC_DIV6)
502#define ADC_CLOCK_ASYNC_DIV8 (LL_ADC_CLOCK_ASYNC_DIV8)
503#define ADC_CLOCK_ASYNC_DIV10 (LL_ADC_CLOCK_ASYNC_DIV10)
504#define ADC_CLOCK_ASYNC_DIV12 (LL_ADC_CLOCK_ASYNC_DIV12)
505#define ADC_CLOCK_ASYNC_DIV16 (LL_ADC_CLOCK_ASYNC_DIV16)
506#define ADC_CLOCK_ASYNC_DIV32 (LL_ADC_CLOCK_ASYNC_DIV32)
507#define ADC_CLOCK_ASYNC_DIV64 (LL_ADC_CLOCK_ASYNC_DIV64)
508#define ADC_CLOCK_ASYNC_DIV128 (LL_ADC_CLOCK_ASYNC_DIV128)
509#define ADC_CLOCK_ASYNC_DIV256 (LL_ADC_CLOCK_ASYNC_DIV256)
518#define ADC_RESOLUTION_16B (LL_ADC_RESOLUTION_16B)
519#define ADC_RESOLUTION_14B (LL_ADC_RESOLUTION_14B)
520#define ADC_RESOLUTION_12B (LL_ADC_RESOLUTION_12B)
521#define ADC_RESOLUTION_10B (LL_ADC_RESOLUTION_10B)
522#define ADC_RESOLUTION_8B (LL_ADC_RESOLUTION_8B)
524#if defined (ADC_VER_V5_X)
525#define ADC_RESOLUTION_14B_OPT (LL_ADC_RESOLUTION_14B_OPT)
526#define ADC_RESOLUTION_12B_OPT (LL_ADC_RESOLUTION_12B_OPT)
527#endif
528
529#if defined(ADC_VER_V5_V90)
530#define ADC_RESOLUTION_6B (LL_ADC_RESOLUTION_6B)
531#endif /* ADC_VER_V5_V90 */
536#if defined(ADC_VER_V5_V90)
541#define ADC3_DATAALIGN_RIGHT (LL_ADC_DATA_ALIGN_RIGHT)
542#define ADC3_DATAALIGN_LEFT (LL_ADC_DATA_ALIGN_LEFT)
546#endif
547
552#define ADC_SCAN_DISABLE (0x00000000UL)
553#define ADC_SCAN_ENABLE (0x00000001UL)
562/* ADC group regular trigger sources for all ADC instances */
563#define ADC_SOFTWARE_START (LL_ADC_REG_TRIG_SOFTWARE)
564#define ADC_EXTERNALTRIG_T1_CC1 (LL_ADC_REG_TRIG_EXT_TIM1_CH1)
565#define ADC_EXTERNALTRIG_T1_CC2 (LL_ADC_REG_TRIG_EXT_TIM1_CH2)
566#define ADC_EXTERNALTRIG_T1_CC3 (LL_ADC_REG_TRIG_EXT_TIM1_CH3)
567#define ADC_EXTERNALTRIG_T2_CC2 (LL_ADC_REG_TRIG_EXT_TIM2_CH2)
568#define ADC_EXTERNALTRIG_T3_TRGO (LL_ADC_REG_TRIG_EXT_TIM3_TRGO)
569#define ADC_EXTERNALTRIG_T4_CC4 (LL_ADC_REG_TRIG_EXT_TIM4_CH4)
570#define ADC_EXTERNALTRIG_EXT_IT11 (LL_ADC_REG_TRIG_EXT_EXTI_LINE11)
571#define ADC_EXTERNALTRIG_T8_TRGO (LL_ADC_REG_TRIG_EXT_TIM8_TRGO)
572#define ADC_EXTERNALTRIG_T8_TRGO2 (LL_ADC_REG_TRIG_EXT_TIM8_TRGO2)
573#define ADC_EXTERNALTRIG_T1_TRGO (LL_ADC_REG_TRIG_EXT_TIM1_TRGO)
574#define ADC_EXTERNALTRIG_T1_TRGO2 (LL_ADC_REG_TRIG_EXT_TIM1_TRGO2)
575#define ADC_EXTERNALTRIG_T2_TRGO (LL_ADC_REG_TRIG_EXT_TIM2_TRGO)
576#define ADC_EXTERNALTRIG_T4_TRGO (LL_ADC_REG_TRIG_EXT_TIM4_TRGO)
577#define ADC_EXTERNALTRIG_T6_TRGO (LL_ADC_REG_TRIG_EXT_TIM6_TRGO)
578#define ADC_EXTERNALTRIG_T15_TRGO (LL_ADC_REG_TRIG_EXT_TIM15_TRGO)
579#define ADC_EXTERNALTRIG_T3_CC4 (LL_ADC_REG_TRIG_EXT_TIM3_CH4)
580#define ADC_EXTERNALTRIG_HR1_ADCTRG1 (LL_ADC_REG_TRIG_EXT_HRTIM_TRG1)
581#define ADC_EXTERNALTRIG_HR1_ADCTRG3 (LL_ADC_REG_TRIG_EXT_HRTIM_TRG3)
582#define ADC_EXTERNALTRIG_LPTIM1_OUT (LL_ADC_REG_TRIG_EXT_LPTIM1_OUT)
583#define ADC_EXTERNALTRIG_LPTIM2_OUT (LL_ADC_REG_TRIG_EXT_LPTIM2_OUT)
584#define ADC_EXTERNALTRIG_LPTIM3_OUT (LL_ADC_REG_TRIG_EXT_LPTIM3_OUT)
585#if defined(TIM23)
586#define ADC_EXTERNALTRIG_T23_TRGO (LL_ADC_REG_TRIG_EXT_TIM23_TRGO)
587#endif /*TIM23*/
588#if defined(TIM24)
589#define ADC_EXTERNALTRIG_T24_TRGO (LL_ADC_REG_TRIG_EXT_TIM24_TRGO)
590#endif /*TIM24*/
599#define ADC_EXTERNALTRIGCONVEDGE_NONE (0x00000000UL)
600#define ADC_EXTERNALTRIGCONVEDGE_RISING (LL_ADC_REG_TRIG_EXT_RISING)
601#define ADC_EXTERNALTRIGCONVEDGE_FALLING (LL_ADC_REG_TRIG_EXT_FALLING)
602#define ADC_EXTERNALTRIGCONVEDGE_RISINGFALLING (LL_ADC_REG_TRIG_EXT_RISINGFALLING)
606#if defined(ADC_VER_V5_V90)
611#define ADC_SAMPLING_MODE_NORMAL (0x00000000UL)
612#define ADC_SAMPLING_MODE_BULB (ADC3_CFGR2_BULB)
616#define ADC_SAMPLING_MODE_TRIGGER_CONTROLED (ADC3_CFGR2_SMPTRIG)
623#endif
624
629#define ADC_EOC_SINGLE_CONV (ADC_ISR_EOC)
630#define ADC_EOC_SEQ_CONV (ADC_ISR_EOS)
639#define ADC_OVR_DATA_PRESERVED (LL_ADC_REG_OVR_DATA_PRESERVED)
640#define ADC_OVR_DATA_OVERWRITTEN (LL_ADC_REG_OVR_DATA_OVERWRITTEN)
649#define ADC_REGULAR_RANK_1 (LL_ADC_REG_RANK_1)
650#define ADC_REGULAR_RANK_2 (LL_ADC_REG_RANK_2)
651#define ADC_REGULAR_RANK_3 (LL_ADC_REG_RANK_3)
652#define ADC_REGULAR_RANK_4 (LL_ADC_REG_RANK_4)
653#define ADC_REGULAR_RANK_5 (LL_ADC_REG_RANK_5)
654#define ADC_REGULAR_RANK_6 (LL_ADC_REG_RANK_6)
655#define ADC_REGULAR_RANK_7 (LL_ADC_REG_RANK_7)
656#define ADC_REGULAR_RANK_8 (LL_ADC_REG_RANK_8)
657#define ADC_REGULAR_RANK_9 (LL_ADC_REG_RANK_9)
658#define ADC_REGULAR_RANK_10 (LL_ADC_REG_RANK_10)
659#define ADC_REGULAR_RANK_11 (LL_ADC_REG_RANK_11)
660#define ADC_REGULAR_RANK_12 (LL_ADC_REG_RANK_12)
661#define ADC_REGULAR_RANK_13 (LL_ADC_REG_RANK_13)
662#define ADC_REGULAR_RANK_14 (LL_ADC_REG_RANK_14)
663#define ADC_REGULAR_RANK_15 (LL_ADC_REG_RANK_15)
664#define ADC_REGULAR_RANK_16 (LL_ADC_REG_RANK_16)
673#define ADC_SAMPLETIME_1CYCLE_5 (LL_ADC_SAMPLINGTIME_1CYCLE_5)
674#define ADC_SAMPLETIME_2CYCLES_5 (LL_ADC_SAMPLINGTIME_2CYCLES_5)
675#define ADC_SAMPLETIME_8CYCLES_5 (LL_ADC_SAMPLINGTIME_8CYCLES_5)
676#define ADC_SAMPLETIME_16CYCLES_5 (LL_ADC_SAMPLINGTIME_16CYCLES_5)
677#define ADC_SAMPLETIME_32CYCLES_5 (LL_ADC_SAMPLINGTIME_32CYCLES_5)
678#define ADC_SAMPLETIME_64CYCLES_5 (LL_ADC_SAMPLINGTIME_64CYCLES_5)
679#define ADC_SAMPLETIME_387CYCLES_5 (LL_ADC_SAMPLINGTIME_387CYCLES_5)
680#define ADC_SAMPLETIME_810CYCLES_5 (LL_ADC_SAMPLINGTIME_810CYCLES_5)
684#if defined(ADC_VER_V5_V90)
689#define ADC3_SAMPLETIME_2CYCLES_5 (LL_ADC_SAMPLINGTIME_ADC3_2CYCLES_5)
690#define ADC3_SAMPLETIME_6CYCLES_5 (LL_ADC_SAMPLINGTIME_ADC3_6CYCLES_5)
691#define ADC3_SAMPLETIME_12CYCLES_5 (LL_ADC_SAMPLINGTIME_ADC3_12CYCLES_5)
692#define ADC3_SAMPLETIME_24CYCLES_5 (LL_ADC_SAMPLINGTIME_ADC3_24CYCLES_5)
693#define ADC3_SAMPLETIME_47CYCLES_5 (LL_ADC_SAMPLINGTIME_ADC3_47CYCLES_5)
694#define ADC3_SAMPLETIME_92CYCLES_5 (LL_ADC_SAMPLINGTIME_ADC3_92CYCLES_5)
695#define ADC3_SAMPLETIME_247CYCLES_5 (LL_ADC_SAMPLINGTIME_ADC3_247CYCLES_5)
696#define ADC3_SAMPLETIME_640CYCLES_5 (LL_ADC_SAMPLINGTIME_ADC3_640CYCLES_5)
697#define ADC3_SAMPLETIME_3CYCLES_5 (ADC_SMPR1_SMPPLUS | LL_ADC_SAMPLINGTIME_ADC3_2CYCLES_5)
702#endif
703
708#define ADC_CALIB_OFFSET (LL_ADC_CALIB_OFFSET)
709#define ADC_CALIB_OFFSET_LINEARITY (LL_ADC_CALIB_OFFSET_LINEARITY)
718/* Note: VrefInt, TempSensor and Vbat internal channels are not available on */
719/* all ADC instances (refer to Reference Manual). */
720#define ADC_CHANNEL_0 (LL_ADC_CHANNEL_0)
721#define ADC_CHANNEL_1 (LL_ADC_CHANNEL_1)
722#define ADC_CHANNEL_2 (LL_ADC_CHANNEL_2)
723#define ADC_CHANNEL_3 (LL_ADC_CHANNEL_3)
724#define ADC_CHANNEL_4 (LL_ADC_CHANNEL_4)
725#define ADC_CHANNEL_5 (LL_ADC_CHANNEL_5)
726#define ADC_CHANNEL_6 (LL_ADC_CHANNEL_6)
727#define ADC_CHANNEL_7 (LL_ADC_CHANNEL_7)
728#define ADC_CHANNEL_8 (LL_ADC_CHANNEL_8)
729#define ADC_CHANNEL_9 (LL_ADC_CHANNEL_9)
730#define ADC_CHANNEL_10 (LL_ADC_CHANNEL_10)
731#define ADC_CHANNEL_11 (LL_ADC_CHANNEL_11)
732#define ADC_CHANNEL_12 (LL_ADC_CHANNEL_12)
733#define ADC_CHANNEL_13 (LL_ADC_CHANNEL_13)
734#define ADC_CHANNEL_14 (LL_ADC_CHANNEL_14)
735#define ADC_CHANNEL_15 (LL_ADC_CHANNEL_15)
736#define ADC_CHANNEL_16 (LL_ADC_CHANNEL_16)
737#define ADC_CHANNEL_17 (LL_ADC_CHANNEL_17)
738#define ADC_CHANNEL_18 (LL_ADC_CHANNEL_18)
739#define ADC_CHANNEL_19 (LL_ADC_CHANNEL_19)
740#define ADC_CHANNEL_VREFINT (LL_ADC_CHANNEL_VREFINT)
741#define ADC_CHANNEL_TEMPSENSOR (LL_ADC_CHANNEL_TEMPSENSOR)
742#define ADC_CHANNEL_VBAT (LL_ADC_CHANNEL_VBAT)
743#define ADC_CHANNEL_DAC1CH1_ADC2 (LL_ADC_CHANNEL_DAC1CH1_ADC2)
744#define ADC_CHANNEL_DAC1CH2_ADC2 (LL_ADC_CHANNEL_DAC1CH2_ADC2)
745#if defined (LL_ADC_CHANNEL_DAC2CH1_ADC2)
746#define ADC_CHANNEL_DAC2CH1_ADC2 (LL_ADC_CHANNEL_DAC2CH1_ADC2)
747#endif
756#define ADC_CONVERSIONDATA_DR ((uint32_t)0x00000000)
757#define ADC_CONVERSIONDATA_DFSDM ((uint32_t)ADC_CFGR_DMNGT_1)
758#define ADC_CONVERSIONDATA_DMA_ONESHOT ((uint32_t)ADC_CFGR_DMNGT_0)
759#define ADC_CONVERSIONDATA_DMA_CIRCULAR ((uint32_t)(ADC_CFGR_DMNGT_0 | ADC_CFGR_DMNGT_1))
767#define ADC_ANALOGWATCHDOG_1 (LL_ADC_AWD1)
768#define ADC_ANALOGWATCHDOG_2 (LL_ADC_AWD2)
769#define ADC_ANALOGWATCHDOG_3 (LL_ADC_AWD3)
774#if defined(ADC_VER_V5_V90)
779#define ADC3_AWD_FILTERING_NONE (0x00000000UL)
780#define ADC3_AWD_FILTERING_2SAMPLES ((ADC3_TR1_AWDFILT_0))
781#define ADC3_AWD_FILTERING_3SAMPLES ((ADC3_TR1_AWDFILT_1))
782#define ADC3_AWD_FILTERING_4SAMPLES ((ADC3_TR1_AWDFILT_1 | ADC3_TR1_AWDFILT_0))
783#define ADC3_AWD_FILTERING_5SAMPLES ((ADC3_TR1_AWDFILT_2))
784#define ADC3_AWD_FILTERING_6SAMPLES ((ADC3_TR1_AWDFILT_2 | ADC3_TR1_AWDFILT_0))
785#define ADC3_AWD_FILTERING_7SAMPLES ((ADC3_TR1_AWDFILT_2 | ADC3_TR1_AWDFILT_1))
786#define ADC3_AWD_FILTERING_8SAMPLES ((ADC3_TR1_AWDFILT_2 | ADC3_TR1_AWDFILT_1 | ADC3_TR1_AWDFILT_0))
790#endif
791
796#define ADC_ANALOGWATCHDOG_NONE (0x00000000UL)
797#define ADC_ANALOGWATCHDOG_SINGLE_REG (ADC_CFGR_AWD1SGL | ADC_CFGR_AWD1EN)
798#define ADC_ANALOGWATCHDOG_SINGLE_INJEC (ADC_CFGR_AWD1SGL | ADC_CFGR_JAWD1EN)
799#define ADC_ANALOGWATCHDOG_SINGLE_REGINJEC (ADC_CFGR_AWD1SGL | ADC_CFGR_AWD1EN | ADC_CFGR_JAWD1EN)
800#define ADC_ANALOGWATCHDOG_ALL_REG (ADC_CFGR_AWD1EN)
801#define ADC_ANALOGWATCHDOG_ALL_INJEC (ADC_CFGR_JAWD1EN)
802#define ADC_ANALOGWATCHDOG_ALL_REGINJEC (ADC_CFGR_AWD1EN | ADC_CFGR_JAWD1EN)
806#if defined(ADC_VER_V5_V90)
811#define ADC3_OVERSAMPLING_RATIO_2 (LL_ADC_OVS_RATIO_2)
812#define ADC3_OVERSAMPLING_RATIO_4 (LL_ADC_OVS_RATIO_4)
813#define ADC3_OVERSAMPLING_RATIO_8 (LL_ADC_OVS_RATIO_8)
814#define ADC3_OVERSAMPLING_RATIO_16 (LL_ADC_OVS_RATIO_16)
815#define ADC3_OVERSAMPLING_RATIO_32 (LL_ADC_OVS_RATIO_32)
816#define ADC3_OVERSAMPLING_RATIO_64 (LL_ADC_OVS_RATIO_64)
817#define ADC3_OVERSAMPLING_RATIO_128 (LL_ADC_OVS_RATIO_128)
818#define ADC3_OVERSAMPLING_RATIO_256 (LL_ADC_OVS_RATIO_256)
819#define ADC3_OVERSAMPLING_RATIO_512 (LL_ADC_OVS_RATIO_512)
820#define ADC3_OVERSAMPLING_RATIO_1024 (LL_ADC_OVS_RATIO_1024)
824#endif
825
830#define ADC_RIGHTBITSHIFT_NONE (LL_ADC_OVS_SHIFT_NONE)
831#define ADC_RIGHTBITSHIFT_1 (LL_ADC_OVS_SHIFT_RIGHT_1)
832#define ADC_RIGHTBITSHIFT_2 (LL_ADC_OVS_SHIFT_RIGHT_2)
833#define ADC_RIGHTBITSHIFT_3 (LL_ADC_OVS_SHIFT_RIGHT_3)
834#define ADC_RIGHTBITSHIFT_4 (LL_ADC_OVS_SHIFT_RIGHT_4)
835#define ADC_RIGHTBITSHIFT_5 (LL_ADC_OVS_SHIFT_RIGHT_5)
836#define ADC_RIGHTBITSHIFT_6 (LL_ADC_OVS_SHIFT_RIGHT_6)
837#define ADC_RIGHTBITSHIFT_7 (LL_ADC_OVS_SHIFT_RIGHT_7)
838#define ADC_RIGHTBITSHIFT_8 (LL_ADC_OVS_SHIFT_RIGHT_8)
839#define ADC_RIGHTBITSHIFT_9 (LL_ADC_OVS_SHIFT_RIGHT_9)
840#define ADC_RIGHTBITSHIFT_10 (LL_ADC_OVS_SHIFT_RIGHT_10)
841#define ADC_RIGHTBITSHIFT_11 (LL_ADC_OVS_SHIFT_RIGHT_11)
850#define ADC_LEFTBITSHIFT_NONE (LL_ADC_LEFT_BIT_SHIFT_NONE)
851#define ADC_LEFTBITSHIFT_1 (LL_ADC_LEFT_BIT_SHIFT_1)
852#define ADC_LEFTBITSHIFT_2 (LL_ADC_LEFT_BIT_SHIFT_2)
853#define ADC_LEFTBITSHIFT_3 (LL_ADC_LEFT_BIT_SHIFT_3)
854#define ADC_LEFTBITSHIFT_4 (LL_ADC_LEFT_BIT_SHIFT_4)
855#define ADC_LEFTBITSHIFT_5 (LL_ADC_LEFT_BIT_SHIFT_5)
856#define ADC_LEFTBITSHIFT_6 (LL_ADC_LEFT_BIT_SHIFT_6)
857#define ADC_LEFTBITSHIFT_7 (LL_ADC_LEFT_BIT_SHIFT_7)
858#define ADC_LEFTBITSHIFT_8 (LL_ADC_LEFT_BIT_SHIFT_8)
859#define ADC_LEFTBITSHIFT_9 (LL_ADC_LEFT_BIT_SHIFT_9)
860#define ADC_LEFTBITSHIFT_10 (LL_ADC_LEFT_BIT_SHIFT_10)
861#define ADC_LEFTBITSHIFT_11 (LL_ADC_LEFT_BIT_SHIFT_11)
862#define ADC_LEFTBITSHIFT_12 (LL_ADC_LEFT_BIT_SHIFT_12)
863#define ADC_LEFTBITSHIFT_13 (LL_ADC_LEFT_BIT_SHIFT_13)
864#define ADC_LEFTBITSHIFT_14 (LL_ADC_LEFT_BIT_SHIFT_14)
865#define ADC_LEFTBITSHIFT_15 (LL_ADC_LEFT_BIT_SHIFT_15)
874#define ADC_TRIGGEREDMODE_SINGLE_TRIGGER (LL_ADC_OVS_REG_CONT)
875#define ADC_TRIGGEREDMODE_MULTI_TRIGGER (LL_ADC_OVS_REG_DISCONT)
884#define ADC_REGOVERSAMPLING_CONTINUED_MODE (LL_ADC_OVS_GRP_REGULAR_CONTINUED)
885#define ADC_REGOVERSAMPLING_RESUMED_MODE (LL_ADC_OVS_GRP_REGULAR_RESUMED)
895#define ADC_EOSMP_EVENT (ADC_FLAG_EOSMP)
896#define ADC_AWD1_EVENT (ADC_FLAG_AWD1)
897#define ADC_AWD2_EVENT (ADC_FLAG_AWD2)
898#define ADC_AWD3_EVENT (ADC_FLAG_AWD3)
899#define ADC_OVR_EVENT (ADC_FLAG_OVR)
900#define ADC_JQOVF_EVENT (ADC_FLAG_JQOVF)
904#define ADC_AWD_EVENT ADC_AWD1_EVENT
910#define ADC_IT_RDY ADC_IER_ADRDYIE
911#define ADC_IT_EOSMP ADC_IER_EOSMPIE
912#define ADC_IT_EOC ADC_IER_EOCIE
913#define ADC_IT_EOS ADC_IER_EOSIE
914#define ADC_IT_OVR ADC_IER_OVRIE
915#define ADC_IT_JEOC ADC_IER_JEOCIE
916#define ADC_IT_JEOS ADC_IER_JEOSIE
917#define ADC_IT_AWD1 ADC_IER_AWD1IE
918#define ADC_IT_AWD2 ADC_IER_AWD2IE
919#define ADC_IT_AWD3 ADC_IER_AWD3IE
920#define ADC_IT_JQOVF ADC_IER_JQOVFIE
922#define ADC_IT_AWD ADC_IT_AWD1
932#define ADC_FLAG_RDY ADC_ISR_ADRDY
933#define ADC_FLAG_EOSMP ADC_ISR_EOSMP
934#define ADC_FLAG_EOC ADC_ISR_EOC
935#define ADC_FLAG_EOS ADC_ISR_EOS
936#define ADC_FLAG_OVR ADC_ISR_OVR
937#define ADC_FLAG_JEOC ADC_ISR_JEOC
938#define ADC_FLAG_JEOS ADC_ISR_JEOS
939#define ADC_FLAG_AWD1 ADC_ISR_AWD1
940#define ADC_FLAG_AWD2 ADC_ISR_AWD2
941#define ADC_FLAG_AWD3 ADC_ISR_AWD3
942#define ADC_FLAG_JQOVF ADC_ISR_JQOVF
943#define ADC_FLAG_LDORDY ADC_ISR_LDORDY
952/* Private macro -------------------------------------------------------------*/
953
958/* Macro reserved for internal HAL driver usage, not intended to be used in */
959/* code of final user. */
960
966#define IS_ADC_CONVERSIONDATAMGT(DATA) \
967 ((((DATA) == ADC_CONVERSIONDATA_DR)) || \
968 (((DATA) == ADC_CONVERSIONDATA_DFSDM)) || \
969 (((DATA) == ADC_CONVERSIONDATA_DMA_ONESHOT)) || \
970 (((DATA) == ADC_CONVERSIONDATA_DMA_CIRCULAR)))
971
977#define ADC_GET_RESOLUTION(__HANDLE__) \
978 (LL_ADC_GetResolution((__HANDLE__)->Instance))
979
985#define ADC_CLEAR_ERRORCODE(__HANDLE__) ((__HANDLE__)->ErrorCode = HAL_ADC_ERROR_NONE)
986
992#define ADC_IS_ENABLE(__HANDLE__) \
993 (( ((((__HANDLE__)->Instance->CR) & (ADC_CR_ADEN | ADC_CR_ADDIS)) == ADC_CR_ADEN) && \
994 ((((__HANDLE__)->Instance->ISR) & ADC_FLAG_RDY) == ADC_FLAG_RDY) \
995 ) ? SET : RESET)
996
1002#define ADC_IS_CONVERSION_ONGOING_REGULAR(__HANDLE__) \
1003 (LL_ADC_REG_IsConversionOngoing((__HANDLE__)->Instance))
1004
1010#if defined (ADC3)
1011#define ADC_IS_SYNCHRONOUS_CLOCK_MODE(__HANDLE__) \
1012 (((((__HANDLE__)->Instance) == ADC1) || (((__HANDLE__)->Instance) == ADC2))? \
1013 ((ADC12_COMMON->CCR & ADC_CCR_CKMODE) != 0UL) \
1014 :((((ADC3_COMMON)->CCR) & ADC_CCR_CKMODE) != 0UL))
1015#else
1016#define ADC_IS_SYNCHRONOUS_CLOCK_MODE(__HANDLE__) ((ADC12_COMMON->CCR & ADC_CCR_CKMODE) != 0UL)
1017
1018#endif
1019
1027#define ADC_STATE_CLR_SET MODIFY_REG
1028
1035#define IS_ADC_RANGE(__RESOLUTION__, __ADC_VALUE__) \
1036 ((__ADC_VALUE__) <= __LL_ADC_DIGITAL_SCALE(__RESOLUTION__))
1037
1038#if defined(ADC_VER_V5_V90)
1045#define IS_ADC3_RANGE(__RESOLUTION__, __ADC_VALUE__) \
1046 ((__ADC_VALUE__) <= __LL_ADC3_DIGITAL_SCALE(__RESOLUTION__))
1047#endif
1053#define IS_ADC_REGULAR_NB_CONV(__LENGTH__) (((__LENGTH__) >= (1UL)) && ((__LENGTH__) <= (16UL)))
1054
1055
1061#define IS_ADC_REGULAR_DISCONT_NUMBER(NUMBER) (((NUMBER) >= (1UL)) && ((NUMBER) <= (8UL)))
1062
1063
1069#define IS_ADC_CLOCKPRESCALER(__ADC_CLOCK__) (((__ADC_CLOCK__) == ADC_CLOCK_SYNC_PCLK_DIV1) || \
1070 ((__ADC_CLOCK__) == ADC_CLOCK_SYNC_PCLK_DIV2) || \
1071 ((__ADC_CLOCK__) == ADC_CLOCK_SYNC_PCLK_DIV4) || \
1072 ((__ADC_CLOCK__) == ADC_CLOCK_ASYNC_DIV1) || \
1073 ((__ADC_CLOCK__) == ADC_CLOCK_ASYNC_DIV2) || \
1074 ((__ADC_CLOCK__) == ADC_CLOCK_ASYNC_DIV4) || \
1075 ((__ADC_CLOCK__) == ADC_CLOCK_ASYNC_DIV6) || \
1076 ((__ADC_CLOCK__) == ADC_CLOCK_ASYNC_DIV8) || \
1077 ((__ADC_CLOCK__) == ADC_CLOCK_ASYNC_DIV10) || \
1078 ((__ADC_CLOCK__) == ADC_CLOCK_ASYNC_DIV12) || \
1079 ((__ADC_CLOCK__) == ADC_CLOCK_ASYNC_DIV16) || \
1080 ((__ADC_CLOCK__) == ADC_CLOCK_ASYNC_DIV32) || \
1081 ((__ADC_CLOCK__) == ADC_CLOCK_ASYNC_DIV64) || \
1082 ((__ADC_CLOCK__) == ADC_CLOCK_ASYNC_DIV128) || \
1083 ((__ADC_CLOCK__) == ADC_CLOCK_ASYNC_DIV256) )
1084
1090#if defined(ADC_VER_V5_V90)
1091#define IS_ADC_RESOLUTION(__RESOLUTION__) (((__RESOLUTION__) == ADC_RESOLUTION_16B) || \
1092 ((__RESOLUTION__) == ADC_RESOLUTION_14B) || \
1093 ((__RESOLUTION__) == ADC_RESOLUTION_12B) || \
1094 ((__RESOLUTION__) == ADC_RESOLUTION_10B) || \
1095 ((__RESOLUTION__) == ADC_RESOLUTION_8B) || \
1096 ((__RESOLUTION__) == ADC_RESOLUTION_6B) )
1097#elif defined (ADC_VER_V5_X)
1098#define IS_ADC_RESOLUTION(__RESOLUTION__) (((__RESOLUTION__) == ADC_RESOLUTION_16B) || \
1099 ((__RESOLUTION__) == ADC_RESOLUTION_14B) || \
1100 ((__RESOLUTION__) == ADC_RESOLUTION_14B_OPT) || \
1101 ((__RESOLUTION__) == ADC_RESOLUTION_12B) || \
1102 ((__RESOLUTION__) == ADC_RESOLUTION_12B_OPT) || \
1103 ((__RESOLUTION__) == ADC_RESOLUTION_10B) || \
1104 ((__RESOLUTION__) == ADC_RESOLUTION_8B) )
1105#else /* ADC_VER_V5_3 */
1106#define IS_ADC_RESOLUTION(__RESOLUTION__) (((__RESOLUTION__) == ADC_RESOLUTION_16B) || \
1107 ((__RESOLUTION__) == ADC_RESOLUTION_14B) || \
1108 ((__RESOLUTION__) == ADC_RESOLUTION_12B) || \
1109 ((__RESOLUTION__) == ADC_RESOLUTION_10B) || \
1110 ((__RESOLUTION__) == ADC_RESOLUTION_8B) )
1111#endif /* ADC_VER_V5_V90*/
1112
1118#define IS_ADC_RESOLUTION_8_BITS(__RESOLUTION__) (((__RESOLUTION__) == ADC_RESOLUTION_8B))
1119
1120#if defined(ADC_VER_V5_V90)
1126#define IS_ADC3_DATA_ALIGN(__ALIGN__) (((__ALIGN__) == ADC3_DATAALIGN_RIGHT) || \
1127 ((__ALIGN__) == ADC3_DATAALIGN_LEFT) )
1128
1134#define IS_ADC3_SAMPLINGMODE(__SAMPLINGMODE__) (((__SAMPLINGMODE__) == ADC_SAMPLING_MODE_NORMAL) || \
1135 ((__SAMPLINGMODE__) == ADC_SAMPLING_MODE_BULB) || \
1136 ((__SAMPLINGMODE__) == ADC_SAMPLING_MODE_TRIGGER_CONTROLED) )
1137
1138#endif
1139
1145#define IS_ADC_SCAN_MODE(__SCAN_MODE__) (((__SCAN_MODE__) == ADC_SCAN_DISABLE) || \
1146 ((__SCAN_MODE__) == ADC_SCAN_ENABLE) )
1147
1153#define IS_ADC_EXTTRIG_EDGE(__EDGE__) (((__EDGE__) == ADC_EXTERNALTRIGCONVEDGE_NONE) || \
1154 ((__EDGE__) == ADC_EXTERNALTRIGCONVEDGE_RISING) || \
1155 ((__EDGE__) == ADC_EXTERNALTRIGCONVEDGE_FALLING) || \
1156 ((__EDGE__) == ADC_EXTERNALTRIGCONVEDGE_RISINGFALLING) )
1157
1163#if defined(ADC_VER_V5_V90)
1164#define IS_ADC_EXTTRIG(__REGTRIG__) (((__REGTRIG__) == ADC_EXTERNALTRIG_T1_CC1) || \
1165 ((__REGTRIG__) == ADC_EXTERNALTRIG_T1_CC2) || \
1166 ((__REGTRIG__) == ADC_EXTERNALTRIG_T1_CC3) || \
1167 ((__REGTRIG__) == ADC_EXTERNALTRIG_T2_CC2) || \
1168 ((__REGTRIG__) == ADC_EXTERNALTRIG_T3_TRGO) || \
1169 ((__REGTRIG__) == ADC_EXTERNALTRIG_T4_CC4) || \
1170 ((__REGTRIG__) == ADC_EXTERNALTRIG_EXT_IT11) || \
1171 ((__REGTRIG__) == ADC_EXTERNALTRIG_T8_TRGO) || \
1172 ((__REGTRIG__) == ADC_EXTERNALTRIG_T8_TRGO2) || \
1173 ((__REGTRIG__) == ADC_EXTERNALTRIG_T1_TRGO) || \
1174 ((__REGTRIG__) == ADC_EXTERNALTRIG_T1_TRGO2) || \
1175 ((__REGTRIG__) == ADC_EXTERNALTRIG_T2_TRGO) || \
1176 ((__REGTRIG__) == ADC_EXTERNALTRIG_T4_TRGO) || \
1177 ((__REGTRIG__) == ADC_EXTERNALTRIG_T6_TRGO) || \
1178 ((__REGTRIG__) == ADC_EXTERNALTRIG_T15_TRGO) || \
1179 ((__REGTRIG__) == ADC_EXTERNALTRIG_T3_CC4) || \
1180 ((__REGTRIG__) == ADC_EXTERNALTRIG_HR1_ADCTRG1) || \
1181 ((__REGTRIG__) == ADC_EXTERNALTRIG_HR1_ADCTRG3) || \
1182 ((__REGTRIG__) == ADC_EXTERNALTRIG_LPTIM1_OUT) || \
1183 ((__REGTRIG__) == ADC_EXTERNALTRIG_LPTIM2_OUT) || \
1184 ((__REGTRIG__) == ADC_EXTERNALTRIG_LPTIM3_OUT) || \
1185 ((__REGTRIG__) == ADC_EXTERNALTRIG_T23_TRGO) || \
1186 ((__REGTRIG__) == ADC_EXTERNALTRIG_T24_TRGO) || \
1187 ((__REGTRIG__) == ADC_SOFTWARE_START) )
1188#else
1189#define IS_ADC_EXTTRIG(__REGTRIG__) (((__REGTRIG__) == ADC_EXTERNALTRIG_T1_CC1) || \
1190 ((__REGTRIG__) == ADC_EXTERNALTRIG_T1_CC2) || \
1191 ((__REGTRIG__) == ADC_EXTERNALTRIG_T1_CC3) || \
1192 ((__REGTRIG__) == ADC_EXTERNALTRIG_T2_CC2) || \
1193 ((__REGTRIG__) == ADC_EXTERNALTRIG_T3_TRGO) || \
1194 ((__REGTRIG__) == ADC_EXTERNALTRIG_T4_CC4) || \
1195 ((__REGTRIG__) == ADC_EXTERNALTRIG_EXT_IT11) || \
1196 ((__REGTRIG__) == ADC_EXTERNALTRIG_T8_TRGO) || \
1197 ((__REGTRIG__) == ADC_EXTERNALTRIG_T8_TRGO2) || \
1198 ((__REGTRIG__) == ADC_EXTERNALTRIG_T1_TRGO) || \
1199 ((__REGTRIG__) == ADC_EXTERNALTRIG_T1_TRGO2) || \
1200 ((__REGTRIG__) == ADC_EXTERNALTRIG_T2_TRGO) || \
1201 ((__REGTRIG__) == ADC_EXTERNALTRIG_T4_TRGO) || \
1202 ((__REGTRIG__) == ADC_EXTERNALTRIG_T6_TRGO) || \
1203 ((__REGTRIG__) == ADC_EXTERNALTRIG_T15_TRGO) || \
1204 ((__REGTRIG__) == ADC_EXTERNALTRIG_T3_CC4) || \
1205 ((__REGTRIG__) == ADC_EXTERNALTRIG_HR1_ADCTRG1) || \
1206 ((__REGTRIG__) == ADC_EXTERNALTRIG_HR1_ADCTRG3) || \
1207 ((__REGTRIG__) == ADC_EXTERNALTRIG_LPTIM1_OUT) || \
1208 ((__REGTRIG__) == ADC_EXTERNALTRIG_LPTIM2_OUT) || \
1209 ((__REGTRIG__) == ADC_EXTERNALTRIG_LPTIM3_OUT) || \
1210 ((__REGTRIG__) == ADC_SOFTWARE_START) )
1211#endif /* ADC_VER_V5_V90*/
1212
1213
1219#define IS_ADC_EOC_SELECTION(__EOC_SELECTION__) (((__EOC_SELECTION__) == ADC_EOC_SINGLE_CONV) || \
1220 ((__EOC_SELECTION__) == ADC_EOC_SEQ_CONV) )
1221
1227#define IS_ADC_OVERRUN(__OVR__) (((__OVR__) == ADC_OVR_DATA_PRESERVED) || \
1228 ((__OVR__) == ADC_OVR_DATA_OVERWRITTEN) )
1229
1235#define IS_ADC_SAMPLE_TIME(__TIME__) (((__TIME__) == ADC_SAMPLETIME_1CYCLE_5) || \
1236 ((__TIME__) == ADC_SAMPLETIME_2CYCLES_5) || \
1237 ((__TIME__) == ADC_SAMPLETIME_8CYCLES_5) || \
1238 ((__TIME__) == ADC_SAMPLETIME_16CYCLES_5) || \
1239 ((__TIME__) == ADC_SAMPLETIME_32CYCLES_5) || \
1240 ((__TIME__) == ADC_SAMPLETIME_64CYCLES_5) || \
1241 ((__TIME__) == ADC_SAMPLETIME_387CYCLES_5) || \
1242 ((__TIME__) == ADC_SAMPLETIME_810CYCLES_5) )
1243
1249#define IS_ADC_REGULAR_RANK(__CHANNEL__) (((__CHANNEL__) == ADC_REGULAR_RANK_1 ) || \
1250 ((__CHANNEL__) == ADC_REGULAR_RANK_2 ) || \
1251 ((__CHANNEL__) == ADC_REGULAR_RANK_3 ) || \
1252 ((__CHANNEL__) == ADC_REGULAR_RANK_4 ) || \
1253 ((__CHANNEL__) == ADC_REGULAR_RANK_5 ) || \
1254 ((__CHANNEL__) == ADC_REGULAR_RANK_6 ) || \
1255 ((__CHANNEL__) == ADC_REGULAR_RANK_7 ) || \
1256 ((__CHANNEL__) == ADC_REGULAR_RANK_8 ) || \
1257 ((__CHANNEL__) == ADC_REGULAR_RANK_9 ) || \
1258 ((__CHANNEL__) == ADC_REGULAR_RANK_10) || \
1259 ((__CHANNEL__) == ADC_REGULAR_RANK_11) || \
1260 ((__CHANNEL__) == ADC_REGULAR_RANK_12) || \
1261 ((__CHANNEL__) == ADC_REGULAR_RANK_13) || \
1262 ((__CHANNEL__) == ADC_REGULAR_RANK_14) || \
1263 ((__CHANNEL__) == ADC_REGULAR_RANK_15) || \
1264 ((__CHANNEL__) == ADC_REGULAR_RANK_16) )
1265
1271/* Private constants ---------------------------------------------------------*/
1272
1278/* Fixed timeout values for ADC conversion (including sampling time) */
1279/* Maximum sampling time is 810.5 ADC clock cycle */
1280/* Maximum conversion time is 16.5 + Maximum sampling time */
1281/* or 16.5 + 810.5 = 827 ADC clock cycles */
1282/* Minimum ADC Clock frequency is 0.35 MHz */
1283/* Maximum conversion time is */
1284/* 827 / 0.35 MHz = 2.36 ms */
1285
1286#define ADC_STOP_CONVERSION_TIMEOUT ( 5UL)
1288/* Delay for temperature sensor stabilization time. */
1289/* Maximum delay is 120us (refer device datasheet, parameter tSTART). */
1290/* Unit: us */
1291#define ADC_TEMPSENSOR_DELAY_US (LL_ADC_DELAY_TEMPSENSOR_STAB_US)
1292
1293/* Delay for ADC voltage regulator startup time */
1294/* Maximum delay is 10 microseconds */
1295/* (refer device RM, parameter Tadcvreg_stup). */
1296#define ADC_STAB_DELAY_US (10UL)
1302/* Exported macro ------------------------------------------------------------*/
1303
1308/* Macro for internal HAL driver usage, and possibly can be used into code of */
1309/* final user. */
1310
1320#if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
1321#define __HAL_ADC_RESET_HANDLE_STATE(__HANDLE__) \
1322 do{ \
1323 (__HANDLE__)->State = HAL_ADC_STATE_RESET; \
1324 (__HANDLE__)->MspInitCallback = NULL; \
1325 (__HANDLE__)->MspDeInitCallback = NULL; \
1326 } while(0)
1327#else
1328#define __HAL_ADC_RESET_HANDLE_STATE(__HANDLE__) \
1329 ((__HANDLE__)->State = HAL_ADC_STATE_RESET)
1330#endif
1331
1350#define __HAL_ADC_ENABLE_IT(__HANDLE__, __INTERRUPT__) \
1351 (((__HANDLE__)->Instance->IER) |= (__INTERRUPT__))
1352
1371#define __HAL_ADC_DISABLE_IT(__HANDLE__, __INTERRUPT__) \
1372 (((__HANDLE__)->Instance->IER) &= ~(__INTERRUPT__))
1373
1391#define __HAL_ADC_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) \
1392 (((__HANDLE__)->Instance->IER & (__INTERRUPT__)) == (__INTERRUPT__))
1393
1413#define __HAL_ADC_GET_FLAG(__HANDLE__, __FLAG__) \
1414 ((((__HANDLE__)->Instance->ISR) & (__FLAG__)) == (__FLAG__))
1415
1434/* Note: bit cleared bit by writing 1 (writing 0 has no effect on any bit of register ISR) */
1435#define __HAL_ADC_CLEAR_FLAG(__HANDLE__, __FLAG__) \
1436 (((__HANDLE__)->Instance->ISR) = (__FLAG__))
1437
1488#define __HAL_ADC_CHANNEL_TO_DECIMAL_NB(__CHANNEL__) \
1489 __LL_ADC_CHANNEL_TO_DECIMAL_NB((__CHANNEL__))
1490
1532#define __HAL_ADC_DECIMAL_NB_TO_CHANNEL(__DECIMAL_NB__) \
1533 __LL_ADC_DECIMAL_NB_TO_CHANNEL((__DECIMAL_NB__))
1534
1585#define __HAL_ADC_IS_CHANNEL_INTERNAL(__CHANNEL__) \
1586 __LL_ADC_IS_CHANNEL_INTERNAL((__CHANNEL__))
1587
1652#define __HAL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL(__CHANNEL__) \
1653 __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL((__CHANNEL__))
1654
1681#define __HAL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE(__ADC_INSTANCE__, __CHANNEL__) \
1682 __LL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE((__ADC_INSTANCE__), (__CHANNEL__))
1683
1697#define __HAL_ADC_MULTI_CONV_DATA_MASTER_SLAVE(__ADC_MULTI_MASTER_SLAVE__, __ADC_MULTI_CONV_DATA__) \
1698 __LL_ADC_MULTI_CONV_DATA_MASTER_SLAVE((__ADC_MULTI_MASTER_SLAVE__), (__ADC_MULTI_CONV_DATA__))
1699
1710#define __HAL_ADC_COMMON_INSTANCE(__ADCx__) \
1711 __LL_ADC_COMMON_INSTANCE((__ADCx__))
1712
1730#define __HAL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(__ADCXY_COMMON__) \
1731 __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE((__ADCXY_COMMON__))
1732
1747#define __HAL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__) \
1748 __LL_ADC_DIGITAL_SCALE((__ADC_RESOLUTION__))
1749
1770#define __HAL_ADC_CONVERT_DATA_RESOLUTION(__DATA__,\
1771 __ADC_RESOLUTION_CURRENT__,\
1772 __ADC_RESOLUTION_TARGET__) \
1773 __LL_ADC_CONVERT_DATA_RESOLUTION((__DATA__),\
1774 (__ADC_RESOLUTION_CURRENT__),\
1775 (__ADC_RESOLUTION_TARGET__))
1776
1794#define __HAL_ADC_CALC_DATA_TO_VOLTAGE(__VREFANALOG_VOLTAGE__,\
1795 __ADC_DATA__,\
1796 __ADC_RESOLUTION__) \
1797 __LL_ADC_CALC_DATA_TO_VOLTAGE((__VREFANALOG_VOLTAGE__),\
1798 (__ADC_DATA__),\
1799 (__ADC_RESOLUTION__))
1800
1827#define __HAL_ADC_CALC_VREFANALOG_VOLTAGE(__VREFINT_ADC_DATA__,\
1828 __ADC_RESOLUTION__) \
1829 __LL_ADC_CALC_VREFANALOG_VOLTAGE((__VREFINT_ADC_DATA__),\
1830 (__ADC_RESOLUTION__))
1831
1878#define __HAL_ADC_CALC_TEMPERATURE(__VREFANALOG_VOLTAGE__,\
1879 __TEMPSENSOR_ADC_DATA__,\
1880 __ADC_RESOLUTION__) \
1881 __LL_ADC_CALC_TEMPERATURE((__VREFANALOG_VOLTAGE__),\
1882 (__TEMPSENSOR_ADC_DATA__),\
1883 (__ADC_RESOLUTION__))
1884
1930#define __HAL_ADC_CALC_TEMPERATURE_TYP_PARAMS(__TEMPSENSOR_TYP_AVGSLOPE__,\
1931 __TEMPSENSOR_TYP_CALX_V__,\
1932 __TEMPSENSOR_CALX_TEMP__,\
1933 __VREFANALOG_VOLTAGE__,\
1934 __TEMPSENSOR_ADC_DATA__,\
1935 __ADC_RESOLUTION__) \
1936 __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS((__TEMPSENSOR_TYP_AVGSLOPE__),\
1937 (__TEMPSENSOR_TYP_CALX_V__),\
1938 (__TEMPSENSOR_CALX_TEMP__),\
1939 (__VREFANALOG_VOLTAGE__),\
1940 (__TEMPSENSOR_ADC_DATA__),\
1941 (__ADC_RESOLUTION__))
1942
1951/* Include ADC HAL Extended module */
1952#include "stm32h7xx_hal_adc_ex.h"
1953
1954/* Exported functions --------------------------------------------------------*/
1963/* Initialization and de-initialization functions ****************************/
1964HAL_StatusTypeDef HAL_ADC_Init(ADC_HandleTypeDef *hadc);
1965HAL_StatusTypeDef HAL_ADC_DeInit(ADC_HandleTypeDef *hadc);
1966void HAL_ADC_MspInit(ADC_HandleTypeDef *hadc);
1967void HAL_ADC_MspDeInit(ADC_HandleTypeDef *hadc);
1968
1969
1970#if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
1971/* Callbacks Register/UnRegister functions ***********************************/
1972HAL_StatusTypeDef HAL_ADC_RegisterCallback(ADC_HandleTypeDef *hadc, HAL_ADC_CallbackIDTypeDef CallbackID, pADC_CallbackTypeDef pCallback);
1973HAL_StatusTypeDef HAL_ADC_UnRegisterCallback(ADC_HandleTypeDef *hadc, HAL_ADC_CallbackIDTypeDef CallbackID);
1974#endif /* USE_HAL_ADC_REGISTER_CALLBACKS */
1983/* IO operation functions *****************************************************/
1984
1985/* Blocking mode: Polling */
1986HAL_StatusTypeDef HAL_ADC_Start(ADC_HandleTypeDef *hadc);
1987HAL_StatusTypeDef HAL_ADC_Stop(ADC_HandleTypeDef *hadc);
1988HAL_StatusTypeDef HAL_ADC_PollForConversion(ADC_HandleTypeDef *hadc, uint32_t Timeout);
1989HAL_StatusTypeDef HAL_ADC_PollForEvent(ADC_HandleTypeDef *hadc, uint32_t EventType, uint32_t Timeout);
1990
1991/* Non-blocking mode: Interruption */
1992HAL_StatusTypeDef HAL_ADC_Start_IT(ADC_HandleTypeDef *hadc);
1993HAL_StatusTypeDef HAL_ADC_Stop_IT(ADC_HandleTypeDef *hadc);
1994
1995/* Non-blocking mode: DMA */
1996HAL_StatusTypeDef HAL_ADC_Start_DMA(ADC_HandleTypeDef *hadc, uint32_t *pData, uint32_t Length);
1997HAL_StatusTypeDef HAL_ADC_Stop_DMA(ADC_HandleTypeDef *hadc);
1998
1999/* ADC retrieve conversion value intended to be used with polling or interruption */
2000uint32_t HAL_ADC_GetValue(ADC_HandleTypeDef *hadc);
2001
2002/* ADC IRQHandler and Callbacks used in non-blocking modes (Interruption and DMA) */
2003void HAL_ADC_IRQHandler(ADC_HandleTypeDef *hadc);
2004void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hadc);
2005void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef *hadc);
2006void HAL_ADC_LevelOutOfWindowCallback(ADC_HandleTypeDef *hadc);
2007void HAL_ADC_ErrorCallback(ADC_HandleTypeDef *hadc);
2016/* Peripheral Control functions ***********************************************/
2017HAL_StatusTypeDef HAL_ADC_ConfigChannel(ADC_HandleTypeDef *hadc, ADC_ChannelConfTypeDef *sConfig);
2018HAL_StatusTypeDef HAL_ADC_AnalogWDGConfig(ADC_HandleTypeDef *hadc, ADC_AnalogWDGConfTypeDef *AnalogWDGConfig);
2019
2024/* Peripheral State functions *************************************************/
2028uint32_t HAL_ADC_GetState(ADC_HandleTypeDef *hadc);
2029uint32_t HAL_ADC_GetError(ADC_HandleTypeDef *hadc);
2030
2039/* Private functions -----------------------------------------------------------*/
2043HAL_StatusTypeDef ADC_ConversionStop(ADC_HandleTypeDef *hadc, uint32_t ConversionGroup);
2044HAL_StatusTypeDef ADC_Enable(ADC_HandleTypeDef *hadc);
2045HAL_StatusTypeDef ADC_Disable(ADC_HandleTypeDef *hadc);
2046void ADC_DMAConvCplt(DMA_HandleTypeDef *hdma);
2047void ADC_DMAHalfConvCplt(DMA_HandleTypeDef *hdma);
2048void ADC_DMAError(DMA_HandleTypeDef *hdma);
2049void ADC_ConfigureBoostMode(ADC_HandleTypeDef *hadc);
2050
2063#ifdef __cplusplus
2064}
2065#endif
2066
2067
2068#endif /* STM32H7xx_HAL_ADC_H */
2069
#define __IO
Definition: core_cm4.h:239
Header file of ADC HAL extended module.
This file contains HAL common defines, enumeration, macros and structures definitions.
HAL_StatusTypeDef
HAL Status structures definition.
Definition: stm32h7xx_hal_def.h:47
HAL_LockTypeDef
HAL Lock structures definition.
Definition: stm32h7xx_hal_def.h:58
Header file of ADC LL module.
Structure definition of ADC analog watchdog.
Definition: stm32h7xx_hal_adc.h:295
uint32_t WatchdogNumber
Definition: stm32h7xx_hal_adc.h:296
FunctionalState ITMode
Definition: stm32h7xx_hal_adc.h:311
uint32_t LowThreshold
Definition: stm32h7xx_hal_adc.h:324
uint32_t HighThreshold
Definition: stm32h7xx_hal_adc.h:314
uint32_t Channel
Definition: stm32h7xx_hal_adc.h:306
uint32_t WatchdogMode
Definition: stm32h7xx_hal_adc.h:301
Structure definition of ADC channel for regular group.
Definition: stm32h7xx_hal_adc.h:221
uint32_t Rank
Definition: stm32h7xx_hal_adc.h:226
uint32_t SingleDiff
Definition: stm32h7xx_hal_adc.h:242
uint32_t Offset
Definition: stm32h7xx_hal_adc.h:258
FunctionalState OffsetRightShift
Definition: stm32h7xx_hal_adc.h:265
uint32_t Channel
Definition: stm32h7xx_hal_adc.h:222
FunctionalState OffsetSignedSaturation
Definition: stm32h7xx_hal_adc.h:282
uint32_t SamplingTime
Definition: stm32h7xx_hal_adc.h:231
uint32_t OffsetNumber
Definition: stm32h7xx_hal_adc.h:254
ADC handle Structure definition.
Definition: stm32h7xx_hal_adc.h:412
ADC_InjectionConfigTypeDef InjectionConfig
Definition: stm32h7xx_hal_adc.h:419
DMA_HandleTypeDef * DMA_Handle
Definition: stm32h7xx_hal_adc.h:415
ADC_TypeDef * Instance
Definition: stm32h7xx_hal_adc.h:413
ADC_InitTypeDef Init
Definition: stm32h7xx_hal_adc.h:414
__IO uint32_t ErrorCode
Definition: stm32h7xx_hal_adc.h:418
HAL_LockTypeDef Lock
Definition: stm32h7xx_hal_adc.h:416
__IO uint32_t State
Definition: stm32h7xx_hal_adc.h:417
Structure definition of ADC instance and ADC group regular.
Definition: stm32h7xx_hal_adc.h:92
FunctionalState ContinuousConvMode
Definition: stm32h7xx_hal_adc.h:137
uint32_t ExternalTrigConv
Definition: stm32h7xx_hal_adc.h:157
uint32_t ScanConvMode
Definition: stm32h7xx_hal_adc.h:114
uint32_t ConversionDataManagement
Definition: stm32h7xx_hal_adc.h:166
uint32_t NbrOfDiscConversion
Definition: stm32h7xx_hal_adc.h:153
uint32_t Overrun
Definition: stm32h7xx_hal_adc.h:187
FunctionalState OversamplingMode
Definition: stm32h7xx_hal_adc.h:200
uint32_t ClockPrescaler
Definition: stm32h7xx_hal_adc.h:93
uint32_t LeftBitShift
Definition: stm32h7xx_hal_adc.h:198
uint32_t NbrOfConversion
Definition: stm32h7xx_hal_adc.h:141
uint32_t Resolution
Definition: stm32h7xx_hal_adc.h:104
uint32_t EOCSelection
Definition: stm32h7xx_hal_adc.h:122
uint32_t ExternalTrigConvEdge
Definition: stm32h7xx_hal_adc.h:162
ADC_OversamplingTypeDef Oversampling
Definition: stm32h7xx_hal_adc.h:204
FunctionalState DiscontinuousConvMode
Definition: stm32h7xx_hal_adc.h:147
FunctionalState LowPowerAutoWait
Definition: stm32h7xx_hal_adc.h:125
ADC group injected contexts queue configuration.
Definition: stm32h7xx_hal_adc.h:347
uint32_t ChannelCount
Definition: stm32h7xx_hal_adc.h:352
uint32_t ContextQueue
Definition: stm32h7xx_hal_adc.h:348
ADC group regular oversampling structure definition.
Definition: stm32h7xx_hal_adc.h:51
uint32_t Ratio
Definition: stm32h7xx_hal_adc.h:52
uint32_t RightBitShift
Definition: stm32h7xx_hal_adc.h:59
uint32_t OversamplingStopReset
Definition: stm32h7xx_hal_adc.h:65
uint32_t TriggeredMode
Definition: stm32h7xx_hal_adc.h:62
Analog to Digital Converter.
Definition: stm32h723xx.h:242
DMA handle Structure definition.
Definition: stm32h7xx_hal_dma.h:138