32 #ifndef __STC8x_ADC_H_
33 #define __STC8x_ADC_H_
44 #if (PER_LIB_MCU_MUODEL == STC8Ax)
46 #elif (PER_LIB_MCU_MUODEL == STC8Cx)
48 #elif (PER_LIB_MCU_MUODEL == STC8Fx)
50 #elif (PER_LIB_MCU_MUODEL == STC8Gx)
52 #elif (PER_LIB_MCU_MUODEL == STC8Hx)
60 #ifndef PER_LIB_MCU_MUODEL
63 #define PER_LIB_MCU_MUODEL STC8Ax
67 #ifndef PER_LIB_ADC_CTRL
70 #define PER_LIB_ADC_CTRL 1
74 #ifndef PER_LIB_ADC_INIT_CTRL
77 #define PER_LIB_ADC_INIT_CTRL 1
81 #ifndef PER_LIB_ADC_NVIC_CTRL
84 #define PER_LIB_ADC_NVIC_CTRL 1
88 #ifndef PER_LIB_ADC_WORK_CTRL
91 #define PER_LIB_ADC_WORK_CTRL 1
96 #define ADC_Channel_REV 0x0F
99 #define ADC_Channel_P10_8Ax 0x00
100 #define ADC_Channel_P11_8Ax 0x01
101 #define ADC_Channel_P12_8Ax 0x02
102 #define ADC_Channel_P13_8Ax 0x03
103 #define ADC_Channel_P14_8Ax 0x04
104 #define ADC_Channel_P15_8Ax 0x05
105 #define ADC_Channel_P16_8Ax 0x06
106 #define ADC_Channel_P17_8Ax 0x07
107 #define ADC_Channel_P00_8Ax 0x08
108 #define ADC_Channel_P01_8Ax 0x09
109 #define ADC_Channel_P02_8Ax 0x0A
110 #define ADC_Channel_P03_8Ax 0x0B
111 #define ADC_Channel_P04_8Ax 0x0C
112 #define ADC_Channel_P05_8Ax 0x0D
113 #define ADC_Channel_P06_8Ax 0x0E
116 #define ADC_Channel_P30_8G1K08A 0x00
117 #define ADC_Channel_P31_8G1K08A 0x01
118 #define ADC_Channel_P32_8G1K08A 0x02
119 #define ADC_Channel_P33_8G1K08A 0x03
120 #define ADC_Channel_P54_8G1K08A 0x04
121 #define ADC_Channel_P55_8G1K08A 0x05
124 #define ADC_Channel_P10_8G1K08_T 0x00
125 #define ADC_Channel_P11_8G1K08_T 0x01
126 #define ADC_Channel_P12_8G1K08_T 0x02
127 #define ADC_Channel_P13_8G1K08_T 0x03
128 #define ADC_Channel_P14_8G1K08_T 0x04
129 #define ADC_Channel_P15_8G1K08_T 0x05
130 #define ADC_Channel_P16_8G1K08_T 0x06
131 #define ADC_Channel_P17_8G1K08_T 0x07
132 #define ADC_Channel_P30_8G1K08_T 0x08
133 #define ADC_Channel_P31_8G1K08_T 0x09
134 #define ADC_Channel_P32_8G1K08_T 0x0A
135 #define ADC_Channel_P33_8G1K08_T 0x0B
136 #define ADC_Channel_P34_8G1K08_T 0x0C
137 #define ADC_Channel_P35_8G1K08_T 0x0D
138 #define ADC_Channel_P36_8G1K08_T 0x0E
141 #define ADC_Channel_P10_8G2K64S2_S4 0x00
142 #define ADC_Channel_P11_8G2K64S2_S4 0x01
143 #define ADC_Channel_P12_8G2K64S2_S4 0x02
144 #define ADC_Channel_P13_8G2K64S2_S4 0x03
145 #define ADC_Channel_P14_8G2K64S2_S4 0x04
146 #define ADC_Channel_P15_8G2K64S2_S4 0x05
147 #define ADC_Channel_P16_8G2K64S2_S4 0x06
148 #define ADC_Channel_P17_8G2K64S2_S4 0x07
149 #define ADC_Channel_P00_8G2K64S2_S4 0x08
150 #define ADC_Channel_P01_8G2K64S2_S4 0x09
151 #define ADC_Channel_P02_8G2K64S2_S4 0x0A
152 #define ADC_Channel_P03_8G2K64S2_S4 0x0B
153 #define ADC_Channel_P04_8G2K64S2_S4 0x0C
154 #define ADC_Channel_P05_8G2K64S2_S4 0x0D
155 #define ADC_Channel_P06_8G2K64S2_S4 0x0E
158 #define ADC_Channel_P10_8H1K28 0x00
159 #define ADC_Channel_P11_8H1K28 0x01
160 #define ADC_Channel_P12_8H1K28 0x02
161 #define ADC_Channel_P13_8H1K28 0x03
162 #define ADC_Channel_P14_8H1K28 0x04
163 #define ADC_Channel_P15_8H1K28 0x05
164 #define ADC_Channel_P16_8H1K28 0x06
165 #define ADC_Channel_P17_8H1K28 0x07
166 #define ADC_Channel_P00_8H1K28 0x08
167 #define ADC_Channel_P01_8H1K28 0x09
168 #define ADC_Channel_P02_8H1K28 0x0A
169 #define ADC_Channel_P03_8H1K28 0x0B
172 #define ADC_Channel_P10_8H1K08 0x00
173 #define ADC_Channel_P11_8H1K08 0x01
174 #define ADC_Channel_P30_8H1K08 0x08
175 #define ADC_Channel_P31_8H1K08 0x09
176 #define ADC_Channel_P32_8H1K08 0x0A
177 #define ADC_Channel_P33_8H1K08 0x0B
178 #define ADC_Channel_P34_8H1K08 0x0C
179 #define ADC_Channel_P35_8H1K08 0x0D
180 #define ADC_Channel_P36_8H1K08 0x0E
183 #define ADC_Channel_P10_8H3K64S2_S4 0x00
184 #define ADC_Channel_P11_8H3K64S2_S4 0x01
185 #define ADC_Channel_P12_8H3K64S2_S4 0x02
186 #define ADC_Channel_P16_8H3K64S2_S4 0x06
187 #define ADC_Channel_P17_8H3K64S2_S4 0x07
188 #define ADC_Channel_P00_8H3K64S2_S4 0x08
189 #define ADC_Channel_P01_8H3K64S2_S4 0x09
190 #define ADC_Channel_P02_8H3K64S2_S4 0x0A
191 #define ADC_Channel_P03_8H3K64S2_S4 0x0B
192 #define ADC_Channel_P04_8H3K64S2_S4 0x0C
193 #define ADC_Channel_P05_8H3K64S2_S4 0x0D
194 #define ADC_Channel_P06_8H3K64S2_S4 0x0E
197 #define ADC_Channel_P10_8H8K64U_2K64T 0x00
198 #define ADC_Channel_P11_8H8K64U_2K64T 0x01
199 #define ADC_Channel_P54_8H8K64U_2K64T 0x02
200 #define ADC_Channel_P13_8H8K64U_2K64T 0x03
201 #define ADC_Channel_P14_8H8K64U_2K64T 0x04
202 #define ADC_Channel_P15_8H8K64U_2K64T 0x05
203 #define ADC_Channel_P16_8H8K64U_2K64T 0x06
204 #define ADC_Channel_P17_8H8K64U_2K64T 0x07
205 #define ADC_Channel_P00_8H8K64U_2K64T 0x08
206 #define ADC_Channel_P01_8H8K64U_2K64T 0x09
207 #define ADC_Channel_P02_8H8K64U_2K64T 0x0A
208 #define ADC_Channel_P03_8H8K64U_2K64T 0x0B
209 #define ADC_Channel_P04_8H8K64U_2K64T 0x0C
210 #define ADC_Channel_P05_8H8K64U_2K64T 0x0D
211 #define ADC_Channel_P06_8H8K64U_2K64T 0x0E
220 #if (PER_LIB_MCU_MUODEL == STC8Ax || PER_LIB_MCU_MUODEL == STC8Hx )
226 #elif (PER_LIB_MCU_MUODEL == STC8Gx )
228 ADC_Acc_09Bits = 0x01,
229 ADC_Acc_08Bits = 0x02
264 #if (PER_LIB_ADC_CTRL == 1)
266 #if (PER_LIB_MCU_MUODEL == STC8Ax || PER_LIB_MCU_MUODEL == STC8Gx || PER_LIB_MCU_MUODEL == STC8Hx)
268 #if (PER_LIB_ADC_INIT_CTRL == 1)
284 #if (PER_LIB_ADC_WORK_CTRL == 1)
320 #define ADC_GET_CHANNEL() (ADC_CONTR & 0x0F)
332 #define ADC_CHANGE_CHANNEL(channel) \
334 ADC_CONTR = (ADC_CONTR & 0xF0) | (channel); \
339 #if (PER_LIB_ADC_NVIC_CTRL == 1)
358 #define ADC_GET_FLAG() (ADC_CONTR & 0x20)
366 #define ADC_CLEAR_FLAG() do{ADC_CONTR &= 0xDF;}while(0)
374 #define NVIC_ADC_CTRL(run) do{EADC = run;}while(0)
382 #define NVIC_ADC_PRI(pri) \
384 IPH = (IPH & 0xDF) | ((pri & 0x02) << 4); \
385 IP = (IP & 0xDF) | ((pri & 0x01) << 5); \
NVICPri_Type
Definition: ELL_CORE.h:99
BOOL
Definition: ELL_CORE.h:50
FSCSTATE
Definition: ELL_CORE.h:65
unsigned int uint16_t
Definition: ELL_TYPE.h:73
unsigned char uint8_t
Definition: ELL_TYPE.h:72
ADCAlign_Type
ADC输出结果对齐方向枚举体。
Definition: STC8x_ADC.h:239
@ ADC_Right
Definition: STC8x_ADC.h:241
@ ADC_Left
Definition: STC8x_ADC.h:240
uint16_t ADC_Get_Sample(uint8_t channel, ADCAcc_Type acc)
ADC获取采集结果函数(查询法)。
FSCSTATE ADC_Init(const ADC_InitType *adcx)
ADC外设初始化函数。
uint16_t ADC_Get_Sample_Interrupt(ADCAcc_Type acc)
ADC获取采集结果函数(中断法)。
FSCSTATE NVIC_ADC_Init(NVICPri_Type pri, BOOL run)
ADC中断初始化函数。
ADCAcc_Type
ADC采集精度枚举体。
Definition: STC8x_ADC.h:219
@ ADC_Acc_8Bits
Definition: STC8x_ADC.h:225
@ ADC_Acc_11Bits
Definition: STC8x_ADC.h:222
@ ADC_Acc_9Bits
Definition: STC8x_ADC.h:224
@ ADC_Acc_12Bits
Definition: STC8x_ADC.h:221
@ ADC_Acc_10Bits
Definition: STC8x_ADC.h:223
ADC初始化结构体句柄,初始化时请定义该句柄,并用其地址来传参。
Definition: STC8x_ADC.h:251
uint8_t Channel
Definition: STC8x_ADC.h:253
BOOL Power
Definition: STC8x_ADC.h:252
BOOL Run
Definition: STC8x_ADC.h:257
uint8_t Speed
Definition: STC8x_ADC.h:254
ADCAlign_Type Align
Definition: STC8x_ADC.h:256