VSF Documented
sthal_adc.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2024 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18#ifndef __ST_ADC_H__
19#define __ST_ADC_H__
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25/*============================ INCLUDES ======================================*/
26
27#include "sthal_def.h"
28
29/*============================ MACROS ========================================*/
30
31#define HAL_ADC_STATE_RESET 0x00000000U
32#define HAL_ADC_STATE_READY 0x00000001U
33#define HAL_ADC_STATE_BUSY_INTERNAL 0x00000002U
34#define HAL_ADC_STATE_TIMEOUT 0x00000004U
35#define HAL_ADC_STATE_ERROR_INTERNAL 0x00000010U
36#define HAL_ADC_STATE_ERROR_CONFIG 0x00000020U
37#define HAL_ADC_STATE_ERROR_DMA 0x00000040U
38#define HAL_ADC_STATE_REG_BUSY 0x00000100U
39#define HAL_ADC_STATE_REG_EOC 0x00000200U
40#define HAL_ADC_STATE_REG_OVR 0x00000400U
41#define HAL_ADC_STATE_INJ_BUSY 0x00001000U
42#define HAL_ADC_STATE_INJ_EOC 0x00002000U
43#define HAL_ADC_STATE_AWD1 0x00010000U
44#define HAL_ADC_STATE_AWD2 0x00020000U
45#define HAL_ADC_STATE_AWD3 0x00040000U
46#define HAL_ADC_STATE_MULTIMODE_SLAVE 0x00100000U
47
48#define HAL_ADC_ERROR_NONE 0x00U
49#define HAL_ADC_ERROR_INTERNAL 0x01U
50#define HAL_ADC_ERROR_OVR 0x02U
51#define HAL_ADC_ERROR_DMA 0x04U
52#if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
53# define HAL_ADC_ERROR_INVALID_CALLBACK (0x10U)
54#endif
55
56/*============================ MACROFIED FUNCTIONS ===========================*/
57/*============================ TYPES =========================================*/
58
60
61typedef struct {
75
76typedef struct {
82
83typedef struct {
91
92#if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
93typedef struct __ADC_HandleTypeDef
94#else
95typedef struct
96#endif
97{
103 volatile uint32_t State;
105#if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
106 void (*ConvCpltCallback)(struct __ADC_HandleTypeDef *hadc);
107 void (*ConvHalfCpltCallback)(struct __ADC_HandleTypeDef *hadc);
108 void (*LevelOutOfWindowCallback)(struct __ADC_HandleTypeDef *hadc);
109 void (*ErrorCallback)(struct __ADC_HandleTypeDef *hadc);
110 void (*InjectedConvCpltCallback)(struct __ADC_HandleTypeDef *hadc);
111 void (*MspInitCallback)(struct __ADC_HandleTypeDef *hadc);
112 void (*MspDeInitCallback)(struct __ADC_HandleTypeDef *hadc);
113#endif
115
116#if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
117typedef enum {
118 HAL_ADC_CONVERSION_COMPLETE_CB_ID = 0x00U,
119 HAL_ADC_CONVERSION_HALF_CB_ID = 0x01U,
120 HAL_ADC_LEVEL_OUT_OF_WINDOW_1_CB_ID = 0x02U,
121 HAL_ADC_ERROR_CB_ID = 0x03U,
122 HAL_ADC_INJ_CONVERSION_COMPLETE_CB_ID = 0x04U,
123 HAL_ADC_MSPINIT_CB_ID = 0x05U,
124 HAL_ADC_MSPDEINIT_CB_ID = 0x06U,
125} HAL_ADC_CallbackIDTypeDef;
126typedef void (*pADC_CallbackTypeDef)(ADC_HandleTypeDef *hadc);
127#endif
128
129typedef struct {
140
141typedef struct {
146
147/*============================ GLOBAL VARIABLES ==============================*/
148/*============================ PROTOTYPES ====================================*/
149
154
155#if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
156HAL_StatusTypeDef HAL_ADC_RegisterCallback(ADC_HandleTypeDef *hadc,
157 HAL_ADC_CallbackIDTypeDef CallbackID,
158 pADC_CallbackTypeDef pCallback);
159HAL_StatusTypeDef HAL_ADC_UnRegisterCallback(
160 ADC_HandleTypeDef *hadc, HAL_ADC_CallbackIDTypeDef CallbackID);
161#endif
162
166 uint32_t Timeout);
168 uint32_t EventType, uint32_t Timeout);
173 uint32_t Length);
181 ADC_ChannelConfTypeDef *sConfig);
183 ADC_HandleTypeDef *hadc, ADC_AnalogWDGConfTypeDef *AnalogWDGConfig);
189 uint32_t Timeout);
193 uint32_t InjectedRank);
195 uint32_t *pData,
196 uint32_t Length);
201 ADC_HandleTypeDef *hadc, ADC_InjectionConfTypeDef *sConfigInjected);
203 ADC_HandleTypeDef *hadc, ADC_MultiModeTypeDef *multimode);
204
205#ifdef __cplusplus
206}
207#endif
208
209#endif /*__ST_ADC_H */
unsigned uint32_t
Definition stdint.h:9
FunctionalState
Definition sthal.h:55
vsf_adc_t ADC_TypeDef
Definition sthal_adc.h:59
HAL_StatusTypeDef HAL_ADC_PollForEvent(ADC_HandleTypeDef *hadc, uint32_t EventType, uint32_t Timeout)
Definition sthal_adc.c:195
HAL_StatusTypeDef HAL_ADC_DeInit(ADC_HandleTypeDef *hadc)
Definition sthal_adc.c:43
HAL_StatusTypeDef HAL_ADC_Start(ADC_HandleTypeDef *hadc)
Definition sthal_adc.c:179
HAL_StatusTypeDef HAL_ADC_Stop(ADC_HandleTypeDef *hadc)
Definition sthal_adc.c:184
void HAL_ADC_IRQHandler(ADC_HandleTypeDef *hadc)
Definition sthal_adc.c:211
HAL_StatusTypeDef HAL_ADC_Init(ADC_HandleTypeDef *hadc)
Definition sthal_adc.c:33
void HAL_ADC_MspDeInit(ADC_HandleTypeDef *hadc)
Definition sthal_adc.c:174
uint32_t HAL_ADC_GetError(ADC_HandleTypeDef *hadc)
Definition sthal_adc.c:270
uint32_t HAL_ADC_GetValue(ADC_HandleTypeDef *hadc)
Definition sthal_adc.c:224
HAL_StatusTypeDef HAL_ADCEx_InjectedConfigChannel(ADC_HandleTypeDef *hadc, ADC_InjectionConfTypeDef *sConfigInjected)
Definition sthal_adc.c:329
uint32_t HAL_ADCEx_MultiModeGetValue(ADC_HandleTypeDef *hadc)
Definition sthal_adc.c:318
HAL_StatusTypeDef HAL_ADCEx_InjectedPollForConversion(ADC_HandleTypeDef *hadc, uint32_t Timeout)
Definition sthal_adc.c:290
HAL_StatusTypeDef HAL_ADCEx_MultiModeStop_DMA(ADC_HandleTypeDef *hadc)
Definition sthal_adc.c:313
uint32_t HAL_ADCEx_InjectedGetValue(ADC_HandleTypeDef *hadc, uint32_t InjectedRank)
Definition sthal_adc.c:301
HAL_StatusTypeDef HAL_ADC_Start_DMA(ADC_HandleTypeDef *hadc, uint32_t *pData, uint32_t Length)
Definition sthal_adc.c:213
uint32_t HAL_ADC_GetState(ADC_HandleTypeDef *hadc)
Definition sthal_adc.c:265
void HAL_ADC_LevelOutOfWindowCallback(ADC_HandleTypeDef *hadc)
Definition sthal_adc.c:242
HAL_StatusTypeDef HAL_ADCEx_InjectedStop(ADC_HandleTypeDef *hadc)
Definition sthal_adc.c:285
void HAL_ADC_MspInit(ADC_HandleTypeDef *hadc)
Definition sthal_adc.c:168
HAL_StatusTypeDef HAL_ADCEx_InjectedStart(ADC_HandleTypeDef *hadc)
Definition sthal_adc.c:275
HAL_StatusTypeDef HAL_ADCEx_MultiModeStart_DMA(ADC_HandleTypeDef *hadc, uint32_t *pData, uint32_t Length)
Definition sthal_adc.c:307
HAL_StatusTypeDef HAL_ADCEx_MultiModeConfigChannel(ADC_HandleTypeDef *hadc, ADC_MultiModeTypeDef *multimode)
Definition sthal_adc.c:335
HAL_StatusTypeDef HAL_ADC_ConfigChannel(ADC_HandleTypeDef *hadc, ADC_ChannelConfTypeDef *sConfig)
Definition sthal_adc.c:253
void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef *hadc)
Definition sthal_adc.c:236
HAL_StatusTypeDef HAL_ADC_PollForConversion(ADC_HandleTypeDef *hadc, uint32_t Timeout)
Definition sthal_adc.c:189
void HAL_ADC_ErrorCallback(ADC_HandleTypeDef *hadc)
Definition sthal_adc.c:248
HAL_StatusTypeDef HAL_ADCEx_InjectedStop_IT(ADC_HandleTypeDef *hadc)
Definition sthal_adc.c:296
HAL_StatusTypeDef HAL_ADC_Stop_DMA(ADC_HandleTypeDef *hadc)
Definition sthal_adc.c:219
HAL_StatusTypeDef HAL_ADC_Stop_IT(ADC_HandleTypeDef *hadc)
Definition sthal_adc.c:206
HAL_StatusTypeDef HAL_ADC_Start_IT(ADC_HandleTypeDef *hadc)
Definition sthal_adc.c:201
HAL_StatusTypeDef HAL_ADC_AnalogWDGConfig(ADC_HandleTypeDef *hadc, ADC_AnalogWDGConfTypeDef *AnalogWDGConfig)
Definition sthal_adc.c:259
void HAL_ADCEx_InjectedConvCpltCallback(ADC_HandleTypeDef *hadc)
Definition sthal_adc.c:324
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hadc)
Definition sthal_adc.c:230
HAL_StatusTypeDef HAL_ADCEx_InjectedStart_IT(ADC_HandleTypeDef *hadc)
Definition sthal_adc.c:280
HAL_StatusTypeDef
Definition sthal_def.h:65
HAL_LockTypeDef
Definition sthal_def.h:72
Definition sthal_dma.h:103
Definition sthal_adc.h:83
uint32_t WatchdogNumber
Definition sthal_adc.h:89
FunctionalState ITMode
Definition sthal_adc.h:88
uint32_t LowThreshold
Definition sthal_adc.h:86
uint32_t HighThreshold
Definition sthal_adc.h:85
uint32_t Channel
Definition sthal_adc.h:87
uint32_t WatchdogMode
Definition sthal_adc.h:84
Definition sthal_adc.h:76
uint32_t Rank
Definition sthal_adc.h:78
uint32_t Offset
Definition sthal_adc.h:80
uint32_t Channel
Definition sthal_adc.h:77
uint32_t SamplingTime
Definition sthal_adc.h:79
Definition sthal_adc.h:97
DMA_HandleTypeDef * DMA_Handle
Definition sthal_adc.h:101
volatile uint32_t State
Definition sthal_adc.h:103
ADC_TypeDef * Instance
Definition sthal_adc.h:98
ADC_InitTypeDef Init
Definition sthal_adc.h:99
HAL_LockTypeDef Lock
Definition sthal_adc.h:102
volatile uint32_t NbrOfCurrentConversionRank
Definition sthal_adc.h:100
volatile uint32_t ErrorCode
Definition sthal_adc.h:104
Definition sthal_adc.h:61
FunctionalState ContinuousConvMode
Definition sthal_adc.h:67
FunctionalState DMAContinuousRequests
Definition sthal_adc.h:73
uint32_t ExternalTrigConv
Definition sthal_adc.h:71
uint32_t ScanConvMode
Definition sthal_adc.h:65
uint32_t NbrOfDiscConversion
Definition sthal_adc.h:70
uint32_t ClockPrescaler
Definition sthal_adc.h:62
uint32_t NbrOfConversion
Definition sthal_adc.h:68
uint32_t Resolution
Definition sthal_adc.h:63
uint32_t EOCSelection
Definition sthal_adc.h:66
uint32_t ExternalTrigConvEdge
Definition sthal_adc.h:72
uint32_t DataAlign
Definition sthal_adc.h:64
FunctionalState DiscontinuousConvMode
Definition sthal_adc.h:69
Definition sthal_adc.h:129
FunctionalState AutoInjectedConv
Definition sthal_adc.h:136
uint32_t InjectedSamplingTime
Definition sthal_adc.h:132
uint32_t ExternalTrigInjecConvEdge
Definition sthal_adc.h:138
uint32_t InjectedChannel
Definition sthal_adc.h:130
FunctionalState InjectedDiscontinuousConvMode
Definition sthal_adc.h:135
uint32_t ExternalTrigInjecConv
Definition sthal_adc.h:137
uint32_t InjectedNbrOfConversion
Definition sthal_adc.h:134
uint32_t InjectedOffset
Definition sthal_adc.h:133
uint32_t InjectedRank
Definition sthal_adc.h:131
Definition sthal_adc.h:141
uint32_t Mode
Definition sthal_adc.h:142
uint32_t TwoSamplingDelay
Definition sthal_adc.h:144
uint32_t DMAAccessMode
Definition sthal_adc.h:143
Definition vsf_template_adc.h:267