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#if defined(HAL_ADC_MODULE_ENABLED) && VSF_HAL_USE_ADC == ENABLED
26
27/*============================ INCLUDES ======================================*/
28
29#include "sthal_def.h"
30
31/*============================ MACROS ========================================*/
32
33#define HAL_ADC_STATE_RESET 0x00000000U
34#define HAL_ADC_STATE_READY 0x00000001U
35#define HAL_ADC_STATE_BUSY_INTERNAL 0x00000002U
36#define HAL_ADC_STATE_TIMEOUT 0x00000004U
37#define HAL_ADC_STATE_ERROR_INTERNAL 0x00000010U
38#define HAL_ADC_STATE_ERROR_CONFIG 0x00000020U
39#define HAL_ADC_STATE_ERROR_DMA 0x00000040U
40#define HAL_ADC_STATE_REG_BUSY 0x00000100U
41#define HAL_ADC_STATE_REG_EOC 0x00000200U
42#define HAL_ADC_STATE_REG_OVR 0x00000400U
43#define HAL_ADC_STATE_INJ_BUSY 0x00001000U
44#define HAL_ADC_STATE_INJ_EOC 0x00002000U
45#define HAL_ADC_STATE_AWD1 0x00010000U
46#define HAL_ADC_STATE_AWD2 0x00020000U
47#define HAL_ADC_STATE_AWD3 0x00040000U
48#define HAL_ADC_STATE_MULTIMODE_SLAVE 0x00100000U
49
50#define HAL_ADC_ERROR_NONE 0x00U
51#define HAL_ADC_ERROR_INTERNAL 0x01U
52#define HAL_ADC_ERROR_OVR 0x02U
53#define HAL_ADC_ERROR_DMA 0x04U
54#if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
55# define HAL_ADC_ERROR_INVALID_CALLBACK (0x10U)
56#endif
57
58/*============================ MACROFIED FUNCTIONS ===========================*/
59/*============================ TYPES =========================================*/
60
61typedef vsf_adc_t ADC_TypeDef;
62
63typedef struct {
64 uint32_t ClockPrescaler;
65 uint32_t Resolution;
66 uint32_t DataAlign;
67 uint32_t ScanConvMode;
68 uint32_t EOCSelection;
69 FunctionalState ContinuousConvMode;
70 uint32_t NbrOfConversion;
71 FunctionalState DiscontinuousConvMode;
72 uint32_t NbrOfDiscConversion;
73 uint32_t ExternalTrigConv;
74 uint32_t ExternalTrigConvEdge;
75 FunctionalState DMAContinuousRequests;
76} ADC_InitTypeDef;
77
78typedef struct {
80 uint32_t Rank;
81 uint32_t SamplingTime;
83} ADC_ChannelConfTypeDef;
84
85typedef struct {
86 uint32_t WatchdogMode;
87 uint32_t HighThreshold;
88 uint32_t LowThreshold;
90 FunctionalState ITMode;
91 uint32_t WatchdogNumber;
92} ADC_AnalogWDGConfTypeDef;
93
94#if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
95typedef struct __ADC_HandleTypeDef
96#else
97typedef struct
98#endif
99{
100 ADC_TypeDef *Instance;
101 ADC_InitTypeDef Init;
102 volatile uint32_t NbrOfCurrentConversionRank;
103 DMA_HandleTypeDef *DMA_Handle;
104 HAL_LockTypeDef Lock;
105 volatile uint32_t State;
106 volatile uint32_t ErrorCode;
107#if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
108 void (*ConvCpltCallback)(struct __ADC_HandleTypeDef *hadc);
109 void (*ConvHalfCpltCallback)(struct __ADC_HandleTypeDef *hadc);
110 void (*LevelOutOfWindowCallback)(struct __ADC_HandleTypeDef *hadc);
111 void (*ErrorCallback)(struct __ADC_HandleTypeDef *hadc);
112 void (*InjectedConvCpltCallback)(struct __ADC_HandleTypeDef *hadc);
113 void (*MspInitCallback)(struct __ADC_HandleTypeDef *hadc);
114 void (*MspDeInitCallback)(struct __ADC_HandleTypeDef *hadc);
115#endif
116} ADC_HandleTypeDef;
117
118#if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
119typedef enum {
120 HAL_ADC_CONVERSION_COMPLETE_CB_ID = 0x00U,
121 HAL_ADC_CONVERSION_HALF_CB_ID = 0x01U,
122 HAL_ADC_LEVEL_OUT_OF_WINDOW_1_CB_ID = 0x02U,
123 HAL_ADC_ERROR_CB_ID = 0x03U,
124 HAL_ADC_INJ_CONVERSION_COMPLETE_CB_ID = 0x04U,
125 HAL_ADC_MSPINIT_CB_ID = 0x05U,
126 HAL_ADC_MSPDEINIT_CB_ID = 0x06U,
127} HAL_ADC_CallbackIDTypeDef;
128typedef void (*pADC_CallbackTypeDef)(ADC_HandleTypeDef *hadc);
129#endif
130
131typedef struct {
132 uint32_t InjectedChannel;
133 uint32_t InjectedRank;
134 uint32_t InjectedSamplingTime;
135 uint32_t InjectedOffset;
136 uint32_t InjectedNbrOfConversion;
137 FunctionalState InjectedDiscontinuousConvMode;
138 FunctionalState AutoInjectedConv;
139 uint32_t ExternalTrigInjecConv;
140 uint32_t ExternalTrigInjecConvEdge;
141} ADC_InjectionConfTypeDef;
142
143typedef struct {
144 uint32_t Mode;
145 uint32_t DMAAccessMode;
146 uint32_t TwoSamplingDelay;
147} ADC_MultiModeTypeDef;
148
149/*============================ GLOBAL VARIABLES ==============================*/
150/*============================ PROTOTYPES ====================================*/
151
152HAL_StatusTypeDef HAL_ADC_Init(ADC_HandleTypeDef *hadc);
153HAL_StatusTypeDef HAL_ADC_DeInit(ADC_HandleTypeDef *hadc);
154void HAL_ADC_MspInit(ADC_HandleTypeDef *hadc);
155void HAL_ADC_MspDeInit(ADC_HandleTypeDef *hadc);
156
157#if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
158HAL_StatusTypeDef HAL_ADC_RegisterCallback(ADC_HandleTypeDef *hadc,
159 HAL_ADC_CallbackIDTypeDef CallbackID,
160 pADC_CallbackTypeDef pCallback);
161HAL_StatusTypeDef HAL_ADC_UnRegisterCallback(
162 ADC_HandleTypeDef *hadc, HAL_ADC_CallbackIDTypeDef CallbackID);
163#endif
164
165HAL_StatusTypeDef HAL_ADC_Start(ADC_HandleTypeDef *hadc);
166HAL_StatusTypeDef HAL_ADC_Stop(ADC_HandleTypeDef *hadc);
167HAL_StatusTypeDef HAL_ADC_PollForConversion(ADC_HandleTypeDef *hadc,
168 uint32_t Timeout);
169HAL_StatusTypeDef HAL_ADC_PollForEvent(ADC_HandleTypeDef *hadc,
170 uint32_t EventType, uint32_t Timeout);
171HAL_StatusTypeDef HAL_ADC_Start_IT(ADC_HandleTypeDef *hadc);
172HAL_StatusTypeDef HAL_ADC_Stop_IT(ADC_HandleTypeDef *hadc);
173void HAL_ADC_IRQHandler(ADC_HandleTypeDef *hadc);
174HAL_StatusTypeDef HAL_ADC_Start_DMA(ADC_HandleTypeDef *hadc, uint32_t *pData,
175 uint32_t Length);
176HAL_StatusTypeDef HAL_ADC_Stop_DMA(ADC_HandleTypeDef *hadc);
177uint32_t HAL_ADC_GetValue(ADC_HandleTypeDef *hadc);
178void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hadc);
179void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef *hadc);
180void HAL_ADC_LevelOutOfWindowCallback(ADC_HandleTypeDef *hadc);
181void HAL_ADC_ErrorCallback(ADC_HandleTypeDef *hadc);
182HAL_StatusTypeDef HAL_ADC_ConfigChannel(ADC_HandleTypeDef *hadc,
183 ADC_ChannelConfTypeDef *sConfig);
185 ADC_HandleTypeDef *hadc, ADC_AnalogWDGConfTypeDef *AnalogWDGConfig);
186uint32_t HAL_ADC_GetState(ADC_HandleTypeDef *hadc);
187uint32_t HAL_ADC_GetError(ADC_HandleTypeDef *hadc);
188HAL_StatusTypeDef HAL_ADCEx_InjectedStart(ADC_HandleTypeDef *hadc);
189HAL_StatusTypeDef HAL_ADCEx_InjectedStop(ADC_HandleTypeDef *hadc);
191 uint32_t Timeout);
192HAL_StatusTypeDef HAL_ADCEx_InjectedStart_IT(ADC_HandleTypeDef *hadc);
193HAL_StatusTypeDef HAL_ADCEx_InjectedStop_IT(ADC_HandleTypeDef *hadc);
194uint32_t HAL_ADCEx_InjectedGetValue(ADC_HandleTypeDef *hadc,
195 uint32_t InjectedRank);
196HAL_StatusTypeDef HAL_ADCEx_MultiModeStart_DMA(ADC_HandleTypeDef *hadc,
197 uint32_t *pData,
198 uint32_t Length);
199HAL_StatusTypeDef HAL_ADCEx_MultiModeStop_DMA(ADC_HandleTypeDef *hadc);
200uint32_t HAL_ADCEx_MultiModeGetValue(ADC_HandleTypeDef *hadc);
201void HAL_ADCEx_InjectedConvCpltCallback(ADC_HandleTypeDef *hadc);
203 ADC_HandleTypeDef *hadc, ADC_InjectionConfTypeDef *sConfigInjected);
205 ADC_HandleTypeDef *hadc, ADC_MultiModeTypeDef *multimode);
206
207#endif /* defined(HAL_ADC_MODULE_ENABLED) && VSF_HAL_USE_ADC == ENABLED */
208
209#ifdef __cplusplus
210}
211#endif
212
213#endif /*__ST_ADC_H */
struct @516 Channel
Channel.
vsf_err_t(* Init)(vsf_adc_cfg_t *pCfg)
Definition adc_interface.h:38
unsigned uint32_t
Definition stdint.h:9
FunctionalState
Definition sthal.h:55
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:61
HAL_LockTypeDef
Definition sthal_def.h:68
Definition vsf_template_adc.h:709
struct @812 Offset
Generated from commit: vsfteam/vsf@0c4049f