15#ifndef LIBBSP_ARM_STM32F4_STM32F4XXXX_ADC_H
16#define LIBBSP_ARM_STM32F4_STM32F4XXXX_ADC_H
22#define STM32F4_ADC_SR_OVR BSP_BIT32(5)
23#define STM32F4_ADC_SR_STRT BSP_BIT32(4)
24#define STM32F4_ADC_SR_JSTRT BSP_BIT32(3)
25#define STM32F4_ADC_SR_JEOC BSP_BIT32(2)
26#define STM32F4_ADC_SR_EOC BSP_BIT32(1)
27#define STM32F4_ADC_SR_AWD BSP_BIT32(0)
30#define STM32F4_ADC_CR1_OVRIE BSP_BIT32(26)
31#define STM32F4_ADC_CR1_RES(val) BSP_FLD32(val, 24, 25)
32#define STM32F4_ADC_CR1_RES_GET(reg) BSP_FLD32GET(reg, 24, 25)
33#define STM32F4_ADC_CR1_RES_SET(reg, val) BSP_FLD32SET(reg, val, 24, 25)
34#define ADC_CR1_RES_12BIT 0
35#define ADC_CR1_RES_10BIT 1
36#define ADC_CR1_RES_8BIT 2
37#define ADC_CR1_RES_6BIT 3
38#define STM32F4_ADC_CR1_AWDEN BSP_BIT32(23)
39#define STM32F4_ADC_CR1_JAWDEN BSP_BIT32(22)
40#define STM32F4_ADC_CR1_DISCNUM(val) BSP_FLD32(val, 13, 15)
41#define STM32F4_ADC_CR1_DISCNUM_GET(reg) BSP_FLD32GET(reg, 13, 15)
42#define STM32F4_ADC_CR1_DISCNUM_SET(reg, val) BSP_FLD32SET(reg, val, 13, 15)
43#define STM32F4_ADC_CR1_JDISCEN BSP_BIT32(12)
44#define STM32F4_ADC_CR1_DISCEN BSP_BIT32(11)
45#define STM32F4_ADC_CR1_JAUTO BSP_BIT32(10)
46#define STM32F4_ADC_CR1_AWDSGL BSP_BIT32(9)
47#define STM32F4_ADC_CR1_SCAN BSP_BIT32(8)
48#define STM32F4_ADC_CR1_JEOCIE BSP_BIT32(7)
49#define STM32F4_ADC_CR1_AWDIE BSP_BIT32(6)
50#define STM32F4_ADC_CR1_EOCIE BSP_BIT32(5)
51#define STM32F4_ADC_CR1_AWDCH(val) BSP_FLD32(val, 0, 4)
52#define STM32F4_ADC_CR1_AWDCH_GET(reg) BSP_FLD32GET(reg, 0, 4)
53#define STM32F4_ADC_CR1_AWDCH_SET(reg, val) BSP_FLD32SET(reg, val, 0, 4)
56#define STM32F4_ADC_CR2_SWSTART BSP_BIT32(30)
57#define STM32F4_ADC_CR2_EXTEN(val) BSP_FLD32(val, 28, 29)
58#define STM32F4_ADC_CR2_EXTEN_GET(reg) BSP_FLD32GET(reg, 28, 29)
59#define STM32F4_ADC_CR2_EXTEN_SET(reg, val) BSP_FLD32SET(reg, val, 28, 29)
60#define STM32F4_ADC_CR2_JEXTEN(val) BSP_FLD32(val, 20, 21)
61#define STM32F4_ADC_CR2_JEXTEN_GET(reg) BSP_FLD32GET(reg, 20, 21)
62#define STM32F4_ADC_CR2_JEXTEN_SET(reg, val) BSP_FLD32SET(reg, val, 20, 21)
63#define ADC_CR2_TRIGGER_DISABLE 0
64#define ADC_CR2_TRIGGER_RISING 1
65#define ADC_CR2_TRIGGER_FALLING 2
66#define ADC_CR2_TRIGGER_BOTH 3
67#define STM32F4_ADC_CR2_EXTSEL(val) BSP_FLD32(val, 24, 27)
68#define STM32F4_ADC_CR2_EXTSEL_GET(reg) BSP_FLD32GET(reg, 24, 27)
69#define STM32F4_ADC_CR2_EXTSEL_SET(reg, val) BSP_FLD32SET(reg, val, 24, 27)
70#define ADC_CR2_EVT_TIMER1_CC1 0x0
71#define ADC_CR2_EVT_TIMER1_CC2 0x1
72#define ADC_CR2_EVT_TIMER1_CC3 0x2
73#define ADC_CR2_EVT_TIMER2_CC2 0x3
74#define ADC_CR2_EVT_TIMER2_CC3 0x4
75#define ADC_CR2_EVT_TIMER2_CC4 0x5
76#define ADC_CR2_EVT_TIMER2_TRGO 0x6
77#define ADC_CR2_EVT_TIMER3_CC1 0x7
78#define ADC_CR2_EVT_TIMER3_TRGO 0x8
79#define ADC_CR2_EVT_TIMER4_CC1 0x9
80#define ADC_CR2_EVT_TIMER5_CC1 0xa
81#define ADC_CR2_EVT_TIMER5_CC2 0xb
82#define ADC_CR2_EVT_TIMER5_CC3 0xc
83#define ADC_CR2_EVT_TIMER8_CC1 0xd
84#define ADC_CR2_EVT_TIMER8_TRGO 0xe
85#define ADC_CR2_EVT_EXTI_11 0xf
86#define STM32F4_ADC_CR2_JSWSTART BSP_BIT32(22)
87#define STM32F4_ADC_CR2_JEXTSEL(val) BSP_FLD32(val, 16, 19)
88#define STM32F4_ADC_CR2_JEXTSEL_GET(reg) BSP_FLD32GET(reg, 16, 19)
89#define STM32F4_ADC_CR2_JEXTSEL_SET(reg, val) BSP_FLD32SET(reg, val, 16, 19)
90#define ADC_CR2_JEVT_TIMER1_CC4 0x0
91#define ADC_CR2_JEVT_TIMER1_TRGO 0x1
92#define ADC_CR2_JEVT_TIMER2_CC1 0x2
93#define ADC_CR2_JEVT_TIMER2_TRGO 0x3
94#define ADC_CR2_JEVT_TIMER3_CC2 0x4
95#define ADC_CR2_JEVT_TIMER3_CC4 0x5
96#define ADC_CR2_JEVT_TIMER4_CC1 0x6
97#define ADC_CR2_JEVT_TIMER4_CC2 0x7
98#define ADC_CR2_JEVT_TIMER4_CC3 0x8
99#define ADC_CR2_JEVT_TIMER4_TRGO 0x9
100#define ADC_CR2_JEVT_TIMER5_CC4 0xa
101#define ADC_CR2_JEVT_TIMER5_TRGO 0xb
102#define ADC_CR2_JEVT_TIMER8_CC2 0xc
103#define ADC_CR2_JEVT_TIMER8_CC3 0xd
104#define ADC_CR2_JEVT_TIMER8_CC4 0xe
105#define ADC_CR2_JEVT_EXTI_15 0xf
106#define STM32F4_ADC_CR2_ALIGN BSP_BIT32(11)
107#define STM32F4_ADC_CR2_ALIGN_RIGHT 0
108#define STM32F4_ADC_CR2_ALIGN_LEFT STM32F4_ADC_CR2_ALIGN
109#define STM32F4_ADC_CR2_EOCS BSP_BIT32(10)
110#define STM32F4_ADC_CR2_DDS BSP_BIT32(9)
111#define STM32F4_ADC_CR2_DMA BSP_BIT32(8)
112#define STM32F4_ADC_CR2_CONT BSP_BIT32(1)
113#define STM32F4_ADC_CR2_ADON BSP_BIT32(0)
116#define ADC_SAMPLE_3CYCLE 0
117#define ADC_SAMPLE_15CYCLE 1
118#define ADC_SAMPLE_28CYCLE 2
119#define ADC_SAMPLE_56CYCLE 3
120#define ADC_SAMPLE_84CYCLE 4
121#define ADC_SAMPLE_112CYCLE 5
122#define ADC_SAMPLE_144CYCLE 6
123#define ADC_SAMPLE_480CYCLE 7
124#define STM32F4_ADC_SMP18(val) BSP_FLD32(val, 24, 26)
125#define STM32F4_ADC_SMP18_GET(reg) BSP_FLD32GET(reg, 24, 26)
126#define STM32F4_ADC_SMP18_SET(reg, val) BSP_FLD32SET(reg, val, 24, 26)
127#define STM32F4_ADC_SMP17(val) BSP_FLD32(val, 21, 23)
128#define STM32F4_ADC_SMP17_GET(reg) BSP_FLD32GET(reg, 21, 23)
129#define STM32F4_ADC_SMP17_SET(reg, val) BSP_FLD32SET(reg, val, 21, 23)
130#define STM32F4_ADC_SMP16(val) BSP_FLD32(val, 18, 20)
131#define STM32F4_ADC_SMP16_GET(reg) BSP_FLD32GET(reg, 18, 20)
132#define STM32F4_ADC_SMP16_SET(reg, val) BSP_FLD32SET(reg, val, 18, 20)
133#define STM32F4_ADC_SMP15(val) BSP_FLD32(val, 15, 17)
134#define STM32F4_ADC_SMP15_GET(reg) BSP_FLD32GET(reg, 15, 17)
135#define STM32F4_ADC_SMP15_SET(reg, val) BSP_FLD32SET(reg, val, 15, 17)
136#define STM32F4_ADC_SMP14(val) BSP_FLD32(val, 12, 14)
137#define STM32F4_ADC_SMP14_GET(reg) BSP_FLD32GET(reg, 12, 14)
138#define STM32F4_ADC_SMP14_SET(reg, val) BSP_FLD32SET(reg, val, 12, 14)
139#define STM32F4_ADC_SMP13(val) BSP_FLD32(val, 9, 11)
140#define STM32F4_ADC_SMP13_GET(reg) BSP_FLD32GET(reg, 9, 11)
141#define STM32F4_ADC_SMP13_SET(reg, val) BSP_FLD32SET(reg, val, 9, 11)
142#define STM32F4_ADC_SMP12(val) BSP_FLD32(val, 6, 8)
143#define STM32F4_ADC_SMP12_GET(reg) BSP_FLD32GET(reg, 6, 8)
144#define STM32F4_ADC_SMP12_SET(reg, val) BSP_FLD32SET(reg, val, 6, 8)
145#define STM32F4_ADC_SMP11(val) BSP_FLD32(val, 3, 5)
146#define STM32F4_ADC_SMP11_GET(reg) BSP_FLD32GET(reg, 3, 5)
147#define STM32F4_ADC_SMP11_SET(reg, val) BSP_FLD32SET(reg, val, 3, 5)
148#define STM32F4_ADC_SMP10(val) BSP_FLD32(val, 0, 2)
149#define STM32F4_ADC_SMP10_GET(reg) BSP_FLD32GET(reg, 0, 2)
150#define STM32F4_ADC_SMP10_SET(reg, val) BSP_FLD32SET(reg, val, 0, 2)
153#define STM32F4_ADC_SMP9(val) BSP_FLD32(val, 27, 29)
154#define STM32F4_ADC_SMP9_GET(reg) BSP_FLD32GET(reg, 27, 29)
155#define STM32F4_ADC_SMP9_SET(reg, val) BSP_FLD32SET(reg, val, 27, 29)
156#define STM32F4_ADC_SMP8(val) BSP_FLD32(val, 24, 26)
157#define STM32F4_ADC_SMP8_GET(reg) BSP_FLD32GET(reg, 24, 26)
158#define STM32F4_ADC_SMP8_SET(reg, val) BSP_FLD32SET(reg, val, 24, 26)
159#define STM32F4_ADC_SMP7(val) BSP_FLD32(val, 21, 23)
160#define STM32F4_ADC_SMP7_GET(reg) BSP_FLD32GET(reg, 21, 23)
161#define STM32F4_ADC_SMP7_SET(reg, val) BSP_FLD32SET(reg, val, 21, 23)
162#define STM32F4_ADC_SMP6(val) BSP_FLD32(val, 18, 20)
163#define STM32F4_ADC_SMP6_GET(reg) BSP_FLD32GET(reg, 18, 20)
164#define STM32F4_ADC_SMP6_SET(reg, val) BSP_FLD32SET(reg, val, 18, 20)
165#define STM32F4_ADC_SMP5(val) BSP_FLD32(val, 15, 17)
166#define STM32F4_ADC_SMP5_GET(reg) BSP_FLD32GET(reg, 15, 17)
167#define STM32F4_ADC_SMP5_SET(reg, val) BSP_FLD32SET(reg, val, 15, 17)
168#define STM32F4_ADC_SMP4(val) BSP_FLD32(val, 12, 14)
169#define STM32F4_ADC_SMP4_GET(reg) BSP_FLD32GET(reg, 12, 14)
170#define STM32F4_ADC_SMP4_SET(reg, val) BSP_FLD32SET(reg, val, 12, 14)
171#define STM32F4_ADC_SMP3(val) BSP_FLD32(val, 9, 11)
172#define STM32F4_ADC_SMP3_GET(reg) BSP_FLD32GET(reg, 9, 11)
173#define STM32F4_ADC_SMP3_SET(reg, val) BSP_FLD32SET(reg, val, 9, 11)
174#define STM32F4_ADC_SMP2(val) BSP_FLD32(val, 6, 8)
175#define STM32F4_ADC_SMP2_GET(reg) BSP_FLD32GET(reg, 6, 8)
176#define STM32F4_ADC_SMP2_SET(reg, val) BSP_FLD32SET(reg, val, 6, 8)
177#define STM32F4_ADC_SMP1(val) BSP_FLD32(val, 3, 5)
178#define STM32F4_ADC_SMP1_GET(reg) BSP_FLD32GET(reg, 3, 5)
179#define STM32F4_ADC_SMP1_SET(reg, val) BSP_FLD32SET(reg, val, 3, 5)
180#define STM32F4_ADC_SMP0(val) BSP_FLD32(val, 0, 2)
181#define STM32F4_ADC_SMP0_GET(reg) BSP_FLD32GET(reg, 0, 2)
182#define STM32F4_ADC_SMP0_SET(reg, val) BSP_FLD32SET(reg, val, 0, 2)
185#define STM32F4_ADC_JOFFSET(val) BSP_FLD32(val, 0, 11)
186#define STM32F4_ADC_JOFFSET_GET(reg) BSP_FLD32GET(reg, 0, 11)
187#define STM32F4_ADC_JOFFSET_SET(reg, val) BSP_FLD32SET(reg, val, 0, 11)
190#define STM32F4_ADC_HT(val) BSP_FLD32(val, 0, 11)
191#define STM32F4_ADC_HT_GET(reg) BSP_FLD32GET(reg, 0, 11)
192#define STM32F4_ADC_HT_SET(reg, val) BSP_FLD32SET(reg, val, 0, 11)
195#define STM32F4_ADC_LT(val) BSP_FLD32(val, 0, 11)
196#define STM32F4_ADC_LT_GET(reg) BSP_FLD32GET(reg, 0, 11)
197#define STM32F4_ADC_LT_SET(reg, val) BSP_FLD32SET(reg, val, 0, 11)
200#define STM32F4_ADC_SQR_L(val) BSP_FLD32(val, 20, 23)
201#define STM32F4_ADC_SQR_L_GET(reg) BSP_FLD32GET(reg, 20, 23)
202#define STM32F4_ADC_SQR_L_SET(reg, val) BSP_FLD32SET(reg, val, 20, 23)
205#define STM32F4_ADC_JSQR_JL(val) BSP_FLD32(val, 20, 21)
206#define STM32F4_ADC_JSQR_JL_GET(reg) BSP_FLD32GET(reg, 20, 21)
207#define STM32F4_ADC_JSQR_JL_SET(reg, val) BSP_FLD32SET(reg, val, 20, 21)
208#define STM32F4_ADC_JSQR_JSQ4(val) BSP_FLD32(val, 15, 19)
209#define STM32F4_ADC_JSQR_JSQ4_GET(reg) BSP_FLD32GET(reg, 15, 19)
210#define STM32F4_ADC_JSQR_JSQ4_SET(reg, val) BSP_FLD32SET(reg, val, 15, 19)
211#define STM32F4_ADC_JSQR_JSQ3(val) BSP_FLD32(val, 10, 14)
212#define STM32F4_ADC_JSQR_JSQ3_GET(reg) BSP_FLD32GET(reg, 10, 14)
213#define STM32F4_ADC_JSQR_JSQ3_SET(reg, val) BSP_FLD32SET(reg, val, 10, 14)
214#define STM32F4_ADC_JSQR_JSQ2(val) BSP_FLD32(val, 5, 9)
215#define STM32F4_ADC_JSQR_JSQ2_GET(reg) BSP_FLD32GET(reg, 5, 9)
216#define STM32F4_ADC_JSQR_JSQ2_SET(reg, val) BSP_FLD32SET(reg, val, 5, 9)
217#define STM32F4_ADC_JSQR_JSQ1(val) BSP_FLD32(val, 0, 4)
218#define STM32F4_ADC_JSQR_JSQ1_GET(reg) BSP_FLD32GET(reg, 0, 4)
219#define STM32F4_ADC_JSQR_JSQ1_SET(reg, val) BSP_FLD32SET(reg, val, 0, 4)
222#define STM32F4_ADC_JDATA(val) BSP_FLD32(val, 0, 15)
223#define STM32F4_ADC_JDATA_GET(reg) BSP_FLD32GET(reg, 0, 15)
224#define STM32F4_ADC_JDATA_SET(reg, val) BSP_FLD32SET(reg, val, 0, 15)
227#define STM32F4_ADC_DATA(val) BSP_FLD32(val, 0, 15)
228#define STM32F4_ADC_DATA_GET(reg) BSP_FLD32GET(reg, 0, 15)
229#define STM32F4_ADC_DATA_SET(reg, val) BSP_FLD32SET(reg, val, 0, 15)
236#define STM32F4_ADC_CSR_OVR3 BSP_BIT32(21)
237#define STM32F4_ADC_CSR_STRT3 BSP_BIT32(20)
238#define STM32F4_ADC_CSR_JSTRT3 BSP_BIT32(19)
239#define STM32F4_ADC_CSR_JEOC3 BSP_BIT32(18)
240#define STM32F4_ADC_CSR_EOC3 BSP_BIT32(17)
241#define STM32F4_ADC_CSR_AWD3 BSP_BIT32(16)
242#define STM32F4_ADC_CSR_OVR2 BSP_BIT32(13)
243#define STM32F4_ADC_CSR_STRT2 BSP_BIT32(12)
244#define STM32F4_ADC_CSR_JSTRT2 BSP_BIT32(11)
245#define STM32F4_ADC_CSR_JEOC2 BSP_BIT32(10)
246#define STM32F4_ADC_CSR_EOC2 BSP_BIT32(9)
247#define STM32F4_ADC_CSR_AWD2 BSP_BIT32(8)
248#define STM32F4_ADC_CSR_OVR1 BSP_BIT32(5)
249#define STM32F4_ADC_CSR_STRT1 BSP_BIT32(4)
250#define STM32F4_ADC_CSR_JSTRT1 BSP_BIT32(3)
251#define STM32F4_ADC_CSR_JEOC1 BSP_BIT32(2)
252#define STM32F4_ADC_CSR_EOC1 BSP_BIT32(1)
253#define STM32F4_ADC_CSR_AWD1 BSP_BIT32(0)
256#define STM32F4_ADC_CCR_TSVREFE BSP_BIT32(23)
257#define STM32F4_ADC_CCR_VBATE BSP_BIT32(22)
258#define STM32F4_ADC_CCR_ADCPRE(val) BSP_FLD32(val, 16, 17)
259#define STM32F4_ADC_CCR_ADCPRE_GET(reg) BSP_FLD32GET(reg, 16, 17)
260#define STM32F4_ADC_CCR_ADCPRE_SET(reg, val) BSP_FLD32SET(reg, val, 16, 17)
261#define ADC_ADCPRE_PCLK2_2 0
262#define ADC_ADCPRE_PCLK2_4 1
263#define ADC_ADCPRE_PCLK2_6 2
264#define ADC_ADCPRE_PCLK2_8 3
265#define STM32F4_ADC_CCR_DMA(val) BSP_FLD32(val, 14, 15)
266#define STM32F4_ADC_CCR_DMA_GET(reg) BSP_FLD32GET(reg, 14, 15)
267#define STM32F4_ADC_CCR_DMA_SET(reg, val) BSP_FLD32SET(reg, val, 14, 15)
268#define ADC_DMA_DISABLE 0
269#define ADC_DMA_MODE1 1
270#define ADC_DMA_MODE2 2
271#define ADC_DMA_MODE3 3
272#define STM32F4_ADC_CCR_DDS BSP_BIT32(13)
273#define STM32F4_ADC_CCR_DELAY(val) BSP_FLD32(val, 8, 11)
274#define STM32F4_ADC_CCR_DELAY_GET(reg) BSP_FLD32GET(reg, 8, 11)
275#define STM32F4_ADC_CCR_DELAY_SET(reg, val) BSP_FLD32SET(reg, val, 8, 11)
276#define ADC_DELAY_5T 0
277#define ADC_DELAY_6T 1
278#define ADC_DELAY_7T 2
279#define ADC_DELAY_8T 3
280#define ADC_DELAY_9T 4
281#define ADC_DELAY_10T 5
282#define ADC_DELAY_11T 6
283#define ADC_DELAY_12T 7
284#define ADC_DELAY_13T 8
285#define ADC_DELAY_14T 9
286#define ADC_DELAY_15T 10
287#define ADC_DELAY_16T 11
288#define ADC_DELAY_17T 12
289#define ADC_DELAY_18T 13
290#define ADC_DELAY_19T 14
291#define ADC_DELAY_20T 15
292#define STM32F4_ADC_CCR_MULTI(val) BSP_FLD32(val, 0, 4)
293#define STM32F4_ADC_CCR_MULTI_GET(reg) BSP_FLD32GET(reg, 0, 4)
294#define STM32F4_ADC_CCR_MULTI_SET(reg, val) BSP_FLD32SET(reg, val, 0, 4)
295#define ADC_MULTI_INDEPENDENT 0x00
296#define ADC_MULTI_DUAL_REG_INJ 0x01
297#define ADC_MULTI_DUAL_REG_ALT 0x02
298#define ADC_MULTI_DUAL_INJ 0x05
299#define ADC_MULTI_DUAL_REG 0x06
300#define ADC_MULTI_DUAL_INTRL 0x07
301#define ADC_MULTI_DUAL_ALT_TRIG 0x09
302#define ADC_MULTI_TRIPLE_REG_INJ 0x11
303#define ADC_MULTI_TRIPLE_REG_ALT 0x12
304#define ADC_MULTI_TRIPLE_INJ 0x15
305#define ADC_MULTI_TRIPLE_REG 0x16
306#define ADC_MULTI_TRIPLE_INTRL 0x17
307#define ADC_MULTI_TRIPLE_ALT_TRIG 0x19
310#define STM32F4_ADC_CDR_DATA2(val) BSP_FLD32(val, 16, 31)
311#define STM32F4_ADC_CDR_DATA2_GET(reg) BSP_FLD32GET(reg, 16, 31)
312#define STM32F4_ADC_CDR_DATA2_SET(reg, val) BSP_FLD32SET(reg, val, 16, 31)
313#define STM32F4_ADC_CDR_DATA1(val) BSP_FLD32(val, 0, 15)
314#define STM32F4_ADC_CDR_DATA1_GET(reg) BSP_FLD32GET(reg, 0, 15)
315#define STM32F4_ADC_CDR_DATA1_SET(reg, val) BSP_FLD32SET(reg, val, 0, 15)
This header file provides utility macros for BSPs.
Definition: xnandpsu_onfi.h:185
Definition: stm32f4xxxx_adc.h:20
Definition: stm32f4xxxx_adc.h:234