libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
f3/adc.h
Go to the documentation of this file.
1/** @defgroup adc_defines ADC Defines
2 *
3 * @brief <b>Defined Constants and Types for the STM32F37x Analog to Digital
4 * converter</b>
5 *
6 * @ingroup STM32F3xx_defines
7 *
8 * @version 1.0.0
9 *
10 * @date 11 July 2013
11 *
12 * LGPL License Terms @ref lgpl_license
13 */
14/*
15 * This file is part of the libopencm3 project.
16 *
17 * Copyright (C) 2013 ARCOS-Lab UCR
18 * Copyright (C) 2013 Fernando Cortes <fernando.corcam@gmail.com>
19 *
20 * This library is free software: you can redistribute it and/or modify
21 * it under the terms of the GNU Lesser General Public License as published by
22 * the Free Software Foundation, either version 3 of the License, or
23 * (at your option) any later version.
24 *
25 * This library is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU Lesser General Public License for more details.
29 *
30 * You should have received a copy of the GNU Lesser General Public License
31 * along with this library. If not, see <http://www.gnu.org/licenses/>.
32 */
33
34#ifndef LIBOPENCM3_ADC_H
35#define LIBOPENCM3_ADC_H
36
39
40/**@{*/
41
42/** @defgroup adc_reg_base ADC register base addresses
43@ingroup STM32xx_adc_defines
44@{*/
45#define ADC1 ADC1_BASE
46#define ADC2 ADC2_BASE
47#define ADC3 ADC3_BASE
48#define ADC4 ADC4_BASE
49/**@}*/
50
51/* Master and slave ADCs common registers (ADC12 or ADC34) */
52
53
54/*----------- ADC registers -------------------------------------- */
55
56#define ADC1_ISR ADC_ISR(ADC1_BASE)
57#define ADC2_ISR ADC_ISR(ADC2_BASE)
58#define ADC3_ISR ADC_ISR(ADC3_BASE)
59#define ADC4_ISR ADC_ISR(ADC4_BASE)
60
61#define ADC1_IER ADC_IER(ADC1_BASE)
62#define ADC2_IER ADC_IER(ADC2_BASE)
63#define ADC3_IER ADC_IER(ADC3_BASE)
64#define ADC4_IER ADC_IER(ADC4_BASE)
65
66#define ADC1_CR ADC_CR(ADC1_BASE)
67#define ADC2_CR ADC_CR(ADC2_BASE)
68#define ADC3_CR ADC_CR(ADC3_BASE)
69#define ADC4_CR ADC_CR(ADC4_BASE)
70
71#define ADC1_CFGR1 ADC_CFGR1(ADC1_BASE)
72#define ADC2_CFGR1 ADC_CFGR1(ADC2_BASE)
73#define ADC3_CFGR1 ADC_CFGR1(ADC3_BASE)
74#define ADC4_CFGR1 ADC_CFGR1(ADC4_BASE)
75/* Compatibility with original ref man names */
76#define ADC_CFGR(adc) ADC_CFGR1(adc)
77#define ADC1_CFGR ADC_CFGR1(ADC1_BASE)
78#define ADC2_CFGR ADC_CFGR1(ADC2_BASE)
79#define ADC3_CFGR ADC_CFGR1(ADC3_BASE)
80#define ADC4_CFGR ADC_CFGR1(ADC4_BASE)
81
82#define ADC1_SMPR1 ADC_SMPR1(ADC1_BASE)
83#define ADC2_SMPR1 ADC_SMPR1(ADC2_BASE)
84#define ADC3_SMPR1 ADC_SMPR1(ADC3_BASE)
85#define ADC4_SMPR1 ADC_SMPR1(ADC4_BASE)
86
87#define ADC1_SMPR2 ADC_SMPR2(ADC1_BASE)
88#define ADC2_SMPR2 ADC_SMPR2(ADC2_BASE)
89#define ADC3_SMPR2 ADC_SMPR2(ADC3_BASE)
90#define ADC4_SMPR2 ADC_SMPR2(ADC4_BASE)
91
92#define ADC1_TR1 ADC_TR1(ADC1_BASE)
93#define ADC2_TR1 ADC_TR1(ADC2_BASE)
94#define ADC3_TR1 ADC_TR1(ADC3_BASE)
95#define ADC4_TR1 ADC_TR1(ADC4_BASE)
96
97#define ADC1_TR2 ADC_TR2(ADC1_BASE)
98#define ADC2_TR2 ADC_TR2(ADC2_BASE)
99#define ADC3_TR2 ADC_TR2(ADC3_BASE)
100#define ADC4_TR2 ADC_TR2(ADC4_BASE)
101
102#define ADC1_TR3 ADC_TR3(ADC1_BASE)
103#define ADC2_TR3 ADC_TR3(ADC2_BASE)
104#define ADC3_TR3 ADC_TR3(ADC3_BASE)
105#define ADC4_TR3 ADC_TR3(ADC4_BASE)
106
107#define ADC1_SQR1 ADC_SQR1(ADC1_BASE)
108#define ADC2_SQR1 ADC_SQR1(ADC2_BASE)
109#define ADC3_SQR1 ADC_SQR1(ADC3_BASE)
110#define ADC4_SQR1 ADC_SQR1(ADC4_BASE)
111
112#define ADC1_SQR2 ADC_SQR2(ADC1_BASE)
113#define ADC2_SQR2 ADC_SQR2(ADC2_BASE)
114#define ADC3_SQR2 ADC_SQR2(ADC3_BASE)
115#define ADC4_SQR2 ADC_SQR2(ADC4_BASE)
116
117#define ADC1_SQR3 ADC_SQR3(ADC1_BASE)
118#define ADC2_SQR3 ADC_SQR3(ADC2_BASE)
119#define ADC3_SQR3 ADC_SQR3(ADC3_BASE)
120#define ADC4_SQR3 ADC_SQR3(ADC4_BASE)
121
122#define ADC1_SQR4 ADC_SQR4(ADC1_BASE)
123#define ADC2_SQR4 ADC_SQR4(ADC2_BASE)
124#define ADC3_SQR4 ADC_SQR4(ADC3_BASE)
125#define ADC4_SQR4 ADC_SQR4(ADC4_BASE)
126
127#define ADC1_DR ADC_DR(ADC1_BASE)
128#define ADC2_DR ADC_DR(ADC2_BASE)
129#define ADC3_DR ADC_DR(ADC3_BASE)
130#define ADC4_DR ADC_DR(ADC4_BASE)
131
132#define ADC1_JSQR ADC_JSQR(ADC1_BASE)
133#define ADC2_JSQR ADC_JSQR(ADC2_BASE)
134#define ADC3_JSQR ADC_JSQR(ADC3_BASE)
135#define ADC4_JSQR ADC_JSQR(ADC4_BASE)
136
137#define ADC1_OFR1 ADC_OFR1(ADC1_BASE)
138#define ADC2_OFR1 ADC_OFR1(ADC2_BASE)
139#define ADC3_OFR1 ADC_OFR1(ADC3_BASE)
140#define ADC4_OFR1 ADC_OFR1(ADC4_BASE)
141
142#define ADC1_OFR2 ADC_OFR2(ADC1_BASE)
143#define ADC2_OFR2 ADC_OFR2(ADC2_BASE)
144#define ADC3_OFR2 ADC_OFR2(ADC3_BASE)
145#define ADC4_OFR2 ADC_OFR2(ADC4_BASE)
146
147#define ADC1_OFR3 ADC_OFR3(ADC1_BASE)
148#define ADC2_OFR3 ADC_OFR3(ADC2_BASE)
149#define ADC3_OFR3 ADC_OFR3(ADC3_BASE)
150#define ADC4_OFR3 ADC_OFR3(ADC4_BASE)
151
152#define ADC1_OFR4 ADC_OFR4(ADC1_BASE)
153#define ADC2_OFR4 ADC_OFR4(ADC2_BASE)
154#define ADC3_OFR4 ADC_OFR4(ADC3_BASE)
155#define ADC4_OFR4 ADC_OFR4(ADC4_BASE)
156
157#define ADC1_JDR1 ADC_JDR1(ADC1_BASE)
158#define ADC2_JDR1 ADC_JDR1(ADC2_BASE)
159#define ADC3_JDR1 ADC_JDR1(ADC3_BASE)
160#define ADC4_JDR1 ADC_JDR1(ADC4_BASE)
161
162#define ADC1_JDR2 ADC_JDR2(ADC1_BASE)
163#define ADC2_JDR2 ADC_JDR2(ADC2_BASE)
164#define ADC3_JDR2 ADC_JDR2(ADC3_BASE)
165#define ADC4_JDR2 ADC_JDR2(ADC4_BASE)
166
167#define ADC1_JDR3 ADC_JDR3(ADC1_BASE)
168#define ADC2_JDR3 ADC_JDR3(ADC2_BASE)
169#define ADC3_JDR3 ADC_JDR3(ADC3_BASE)
170#define ADC4_JDR3 ADC_JDR3(ADC4_BASE)
171
172#define ADC1_JDR4 ADC_JDR4(ADC1_BASE)
173#define ADC2_JDR4 ADC_JDR4(ADC2_BASE)
174#define ADC3_JDR4 ADC_JDR4(ADC3_BASE)
175#define ADC4_JDR4 ADC_JDR4(ADC4_BASE)
176
177#define ADC1_AWD2CR ADC_AWD2CR(ADC1_BASE)
178#define ADC2_AWD2CR ADC_AWD2CR(ADC2_BASE)
179#define ADC3_AWD2CR ADC_AWD2CR(ADC3_BASE)
180#define ADC4_AWD2CR ADC_AWD2CR(ADC4_BASE)
181
182#define ADC1_AWD3CR ADC_AWD3CR(ADC1_BASE)
183#define ADC2_AWD3CR ADC_AWD3CR(ADC2_BASE)
184#define ADC3_AWD3CR ADC_AWD3CR(ADC3_BASE)
185#define ADC4_AWD3CR ADC_AWD3CR(ADC4_BASE)
186
187#define ADC1_DIFSEL ADC_DIFSEL(ADC1_BASE)
188#define ADC2_DIFSEL ADC_DIFSEL(ADC2_BASE)
189#define ADC3_DIFSEL ADC_DIFSEL(ADC3_BASE)
190#define ADC4_DIFSEL ADC_DIFSEL(ADC4_BASE)
191
192#define ADC1_CALFACT ADC_CALFACT(ADC1_BASE)
193#define ADC2_CALFACT ADC_CALFACT(ADC2_BASE)
194#define ADC3_CALFACT ADC_CALFACT(ADC3_BASE)
195#define ADC4_CALFACT ADC_CALFACT(ADC4_BASE)
196
197#define ADC12_CSR ADC_CSR(ADC1)
198#define ADC12_CCR ADC_CCR(ADC1)
199#define ADC12_CDR ADC_CDR(ADC1)
200#define ADC34_CSR ADC_CSR(ADC3)
201#define ADC34_CCR ADC_CCR(ADC3)
202#define ADC34_CDR ADC_CDR(ADC3)
203
204
205/*------- ADC_CR values ---------*/
206
207/** ADVREGEN: ADC voltage regulator enable */
208#define ADC_CR_ADVREGEN_ENABLE (0x1 << 28)
209#define ADC_CR_ADVREGEN_DISABLE (0x2 << 28)
210#define ADC_CR_ADVREGEN_MASK (0x3 << 28)
211
212/* ADC_CFGR1 Values ---------------------------------------------------------*/
213
214/** ALIGN: Data alignment */
215#define ADC_CFGR1_ALIGN (1 << 5)
216
217/* EXTSEL[2:0]: External trigger selection for regular group */
218#define ADC_CFGR1_EXTSEL_SHIFT 6
219#define ADC_CFGR1_EXTSEL_MASK (0xf << ADC_CFGR1_EXTSEL_SHIFT)
220#define ADC_CFGR1_EXTSEL_VAL(x) ((x) << ADC_CFGR1_EXTSEL_SHIFT)
221
222/****************************************************************************/
223/* ADC_SMPRx ADC Sample Time Selection for Channels */
224/** @defgroup adc_sample ADC Sample Time Selection values
225@ingroup adc_defines
226
227@{*/
228#define ADC_SMPR_SMP_1DOT5CYC 0x0
229#define ADC_SMPR_SMP_2DOT5CYC 0x1
230#define ADC_SMPR_SMP_4DOT5CYC 0x2
231#define ADC_SMPR_SMP_7DOT5CYC 0x3
232#define ADC_SMPR_SMP_19DOT5CYC 0x4
233#define ADC_SMPR_SMP_61DOT5CYC 0x5
234#define ADC_SMPR_SMP_181DOT5CYC 0x6
235#define ADC_SMPR_SMP_601DOT5CYC 0x7
236/**@}*/
237
238/* SMPx[2:0]: Channel x sampling time selection */
239
240/*------- ADC_T2 values ---------*/
241
242/* Bits 23:16 HT2[7:0]: Analog watchdog 2 higher threshold */
243
244/* Bit 7:0 LT2[7:0]: Analog watchdog 2 lower threshold */
245
246
247/*------- ADC_T3 values ---------*/
248
249/* Bits 23:16 HT3[7:0]: Analog watchdog 3 higher threshold */
250
251/* Bit 7:0 LT3[7:0]: Analog watchdog 3 lower threshold */
252
253
254/*------- ADC_DR values ---------*/
255
256/* Bits 15:0 RDATA[15:0]: Regular Data converted */
257
258
259/*------- ADC_JSQR values ---------*/
260
261#define ADC_JSQR_JL_LSB 0
262#define ADC_JSQR_JL_SHIFT 0
263#define ADC_JSQR_JSQ4_LSB 26
264#define ADC_JSQR_JSQ3_LSB 20
265#define ADC_JSQR_JSQ2_LSB 14
266#define ADC_JSQR_JSQ1_LSB 8
267
268#define ADC_JSQR_JSQ_VAL(n, val) ((val) << (((n) - 1) * 6 + 8))
269#define ADC_JSQR_JL_VAL(val) (((val) - 1) << ADC_JSQR_JL_SHIFT)
270
271/* Bits 30:26 JSQ4[4:0]: 4th conversion in the injected sequence */
272
273/* Bits 24:20 JSQ3[4:0]: 3rd conversion in the injected sequence */
274
275/* Bits 18:14 JSQ2[4:0]: 2nd conversion in the injected sequence */
276
277/* Bits 12:8 JSQ1[4:0]: 1st conversion in the injected sequence */
278
279/*
280 * JEXTEN[1:0]: External Trigger Enable and Polarity Selection for injected
281 * channels
282 */
283#define ADC_JSQR_JEXTEN_DISABLED (0x0 << 6)
284#define ADC_JSQR_JEXTEN_RISING_EDGE (0x1 << 6)
285#define ADC_JSQR_JEXTEN_FALLING_EDGE (0x2 << 6)
286#define ADC_JSQR_JEXTEN_BOTH_EDGES (0x3 << 6)
287
288#define ADC_JSQR_JEXTEN_MASK (0x3 << 6)
289
290/* JEXTSEL[3:0]: External Trigger Selection for injected group */
291#define ADC_JSQR_JEXTSEL_EVENT_0 (0x0 << 2)
292#define ADC_JSQR_JEXTSEL_EVENT_1 (0x1 << 2)
293#define ADC_JSQR_JEXTSEL_EVENT_2 (0x2 << 2)
294#define ADC_JSQR_JEXTSEL_EVENT_3 (0x3 << 2)
295#define ADC_JSQR_JEXTSEL_EVENT_4 (0x4 << 2)
296#define ADC_JSQR_JEXTSEL_EVENT_5 (0x5 << 2)
297#define ADC_JSQR_JEXTSEL_EVENT_6 (0x6 << 2)
298#define ADC_JSQR_JEXTSEL_EVENT_7 (0x7 << 2)
299#define ADC_JSQR_JEXTSEL_EVENT_8 (0x8 << 2)
300#define ADC_JSQR_JEXTSEL_EVENT_9 (0x9 << 2)
301#define ADC_JSQR_JEXTSEL_EVENT_10 (0xA << 2)
302#define ADC_JSQR_JEXTSEL_EVENT_11 (0xB << 2)
303#define ADC_JSQR_JEXTSEL_EVENT_12 (0xC << 2)
304#define ADC_JSQR_JEXTSEL_EVENT_13 (0xD << 2)
305#define ADC_JSQR_JEXTSEL_EVENT_14 (0xE << 2)
306#define ADC_JSQR_JEXTSEL_EVENT_15 (0xF << 2)
307
308#define ADC_JSQR_JEXTSEL_MASK (0xF << 2)
309
310/* JL[1:0]: Injected channel sequence length */
311#define ADC_JSQR_JL_1_CONVERSION (0x0 << 0)
312#define ADC_JSQR_JL_2_CONVERSIONS (0x1 << 0)
313#define ADC_JSQR_JL_3_CONVERSIONS (0x2 << 0)
314#define ADC_JSQR_JL_4_CONVERSIONS (0x3 << 0)
315
316
317/*------- ADC_OFR1 values ---------*/
318
319/* OFFSET1_EN: Offset 1 Enable */
320#define ADC_OFR1_OFFSET1_EN (1 << 31)
321
322/* Bits 30:26 OFFSET1_CH[4:0]: Channel selection for the Data offset 1 */
323
324/*
325 * Bits 11:0 OFFSET1[11:0]: Data offset y for the channel programmed into bits
326 * OFFSET1_CH[4:0]
327 */
328
329
330/*------- ADC_OFR2 values ---------*/
331
332/* OFFSET2_EN: Offset 2 Enable */
333#define ADC_OFR2_OFFSET2_EN (1 << 31)
334
335/* Bits 30:26 OFFSET2_CH[4:0]: Channel selection for the Data offset 2 */
336
337/*
338 * Bits 11:0 OFFSET2[11:0]: Data offset y for the channel programmed into bits
339 * OFFSET2_CH[4:0]
340 */
341
342
343/*------- ADC_OFR3 values ---------*/
344
345/* OFFSET3_EN: Offset 3 Enable */
346#define ADC_OFR3_OFFSET3_EN (1 << 31)
347
348/* Bits 30:26 OFFSET3_CH[4:0]: Channel selection for the Data offset 3 */
349
350/*
351 * Bits 11:0 OFFSET3[11:0]: Data offset y for the channel programmed into bits
352 * OFFSET3_CH[4:0]
353 */
354
355
356/*------- ADC_OFR4 values ---------*/
357
358/* OFFSET4_EN: Offset 4 Enable */
359#define ADC_OFR4_OFFSET4_EN (1 << 31)
360
361/* Bits 30:26 OFFSET4_CH[4:0]: Channel selection for the Data offset 4 */
362
363/*
364 * Bits 11:0 OFFSET4[11:0]: Data offset y for the channel programmed into bits
365 * OFFSET4_CH[4:0]
366 */
367
368
369/*------- ADC_JDRy, y= 1..4 values -------*/
370
371/* Bits 15:0 JDATA[15:0]: Injected data */
372
373
374/*------- ADC_AWD2CR values ---------*/
375
376/* Bits 18:1 AWD2CH[18:1]: Analog watchdog 2 channel selection */
377
378
379/*------- ADC_AWD3CR values ---------*/
380
381/* Bits 18:1 AWD3CH[18:1]: Analog watchdog 3 channel selection */
382
383
384/*------- ADC_DIFSEL values ---------*/
385
386/* DIFSEL[18:16]: Differential mode for channels 18 to 16. */
387
388/* Bits 15:1 DIFSEL[15:1]: Differential mode for channels 15 to 1 */
389
390
391/*------- ADC_CALFACT values ---------*/
392
393/* Bits 22:16 CALFACT_D[6:0]: Calibration Factors in differential mode */
394
395/* Bits 6:0 CALFACT_S[6:0]: Calibration Factors In Single-Ended mode */
396
397
398/*--------------- ADC_CSR values ------------------------*/
399
400/* Bit 26 JQOVF_SLV: Injected Context Queue Overflow flag of the slave ADC */
401#define ADC_CSR_JQOVF_SLV (1 << 26)
402
403/* Bit 25 AWD3_SLV: Analog watchdog 3 flag of the slave ADC */
404#define ADC_CSR_AWD3_SLV (1 << 25)
405
406/* Bit 24 AWD2_SLV: Analog watchdog 2 flag of the slave ADC */
407#define ADC_CSR_AWD2_SLV (1 << 24)
408
409/* Bit 23 AWD1_SLV: Analog watchdog 1 flag of the slave ADC */
410#define ADC_CSR_AWD1_SLV (1 << 23)
411
412/* Bit 22 JEOS_SLV: End of injected sequence flag of the slave ADC */
413#define ADC_CSR_JEOS_SLV (1 << 22)
414
415/* Bit 21 JEOC_SLV: End of injected conversion flag of the slave ADC */
416#define ADC_CSR_JEOC_SLV (1 << 21)
417
418/* Bit 20 OVR_SLV: Overrun flag of the slave ADC */
419#define ADC_CSR_OVR_SLV (1 << 20)
420
421/* Bit 19 EOS_SLV: End of regular sequence flag of the slave ADC */
422#define ADC_CSR_EOS_SLV (1 << 19)
423
424/* Bit 18 EOC_SLV: End of regular conversion of the slave ADC */
425#define ADC_CSR_EOC_SLV (1 << 18)
426
427/* Bit 17 EOSMP_SLV: End of Sampling phase flag of the slave ADC */
428#define ADC_CSR_EOSMP_SLV (1 << 17)
429
430/* Bit 16 ADRDY_SLV: Slave ADC ready */
431#define ADC_CSR_ADRDY_SLV (1 << 16)
432
433/* Bit 10 JQOVF_MST: Injected Context Queue Overflow flag of the master ADC */
434#define ADC_CSR_JQOVF_MST (1 << 10)
435
436/* Bit 9 AWD3_MST: Analog watchdog 3 flag of the master ADC */
437#define ADC_CSR_AWD3_MST (1 << 9)
438
439/* Bit 8 AWD2_MST: Analog watchdog 2 flag of the master ADC */
440#define ADC_CSR_AWD2_MST (1 << 8)
441
442/* Bit 7 AWD1_MST: Analog watchdog 1 flag of the master ADC */
443#define ADC_CSR_AWD1_MST (1 << 7)
444
445/* Bit 6 JEOS_MST: End of injected sequence flag of the master ADC */
446#define ADC_CSR_JEOS_MST (1 << 6)
447
448/* Bit 5 JEOC_MST: End of injected conversion flag of the master ADC */
449#define ADC_CSR_JEOC_MST (1 << 5)
450
451/* Bit 4 OVR_MST: Overrun flag of the master ADC */
452#define ADC_CSR_OVR_MST (1 << 4)
453
454/* Bit 3 EOS_MST: End of regular sequence flag of the master ADC */
455#define ADC_CSR_EOS_MST (1 << 3)
456
457/* Bit 2 EOC_MST: End of regular conversion of the master ADC */
458#define ADC_CSR_EOC_MST (1 << 2)
459
460/* Bit 1 EOSMP_MST: End of Sampling phase flag of the master ADC */
461#define ADC_CSR_EOSMP_MST (1 << 1)
462
463/* Bit 0 ADRDY_MST: Master ADC ready */
464#define ADC_CSR_ADRDY_MST (1 << 0)
465
466
467/*-------- ADC_CCR values ------------*/
468
469/* VBATEN: VBAT enable */
470#define ADC_CCR_VBATEN (1 << 24)
471
472/* TSEN: Temperature sensor enable */
473#define ADC_CCR_TSEN (1 << 23)
474
475/* VREFEN: VREFINT enable */
476#define ADC_CCR_VREFEN (1 << 22)
477
478/* CKMODE[1:0]: ADC clock mode */
479#define ADC_CCR_CKMODE_CKX (0x0 << 16)
480#define ADC_CCR_CKMODE_DIV1 (0x1 << 16)
481#define ADC_CCR_CKMODE_DIV2 (0x2 << 16)
482#define ADC_CCR_CKMODE_DIV4 (0x3 << 16)
483
484#define ADC_CCR_CKMODE_MASK (0x3 << 16)
485
486/* MDMA[1:0]: Direct memory access mode for dual ADC mode */
487#define ADC_CCR_MDMA_DISABLE (0x0 << 14)
488/*#define ADC_CCR_MDMA_RESERVED (0x1 << 14)*/
489#define ADC_CCR_MDMA_12_10_BIT (0x2 << 14)
490#define ADC_CCR_MDMA_8_6_BIT (0x3 << 14)
491
492/* DMACFG: DMA configuration (for dual ADC mode) */
493#define ADC_CCR_DMACFG (1 << 13)
494
495/* DELAY: Delay between 2 sampling phases */
496#define ADC_CCR_DELAY_SHIFT 8
497
498/* DUAL[4:0]: Dual ADC mode selection */
499/****************************************************************************/
500/** @defgroup adc_multi_mode ADC Multi mode selection
501@ingroup adc_defines
502
503@{*/
504
505/** All ADCs independent */
506#define ADC_CCR_DUAL_INDEPENDENT 0x0
507
508/* Dual modes: (ADC1 master + ADC2 slave or ADC3 master + ADC4 slave) */
509/**
510 * Dual modes combined regular simultaneous +
511 * injected simultaneous mode.
512 */
513#define ADC_CCR_DUAL_REG_SIMUL_AND_INJECTED_SIMUL 0x1
514/**
515 * Dual mode Combined regular simultaneous +
516 * alternate trigger mode.
517 */
518#define ADC_CCR_DUAL_REG_SIMUL_AND_ALTERNATE_TRIG 0x2
519/**
520 * Dual mode Combined interleaved mode +
521 * injected simultaneous mode.
522 */
523#define ADC_CCR_DUAL_REG_INTERLEAVED_AND_INJECTED_SIMUL 0x3
524
525/** Dual mode Injected simultaneous mode only. */
526#define ADC_CCR_DUAL_INJECTED_SIMUL 0x5
527/** Dual mode Regular simultaneous mode only. */
528#define ADC_CCR_DUAL_REGULAR_SIMUL 0x6
529/** Dual mode Interleaved mode only. */
530#define ADC_CCR_DUAL_INTERLEAVED 0x7
531/** Dual mode Alternate trigger mode only. */
532#define ADC_CCR_DUAL_ALTERNATE_TRIG 0x9
533/**@}*/
534
535#define ADC_CCR_DUAL_MASK (0x1f)
536#define ADC_CCR_DUAL_SHIFT 0
537
538
539/*---------------- ADC_CDR values -----------------*/
540
541/* Bits 31:16 RDATA_SLV[15:0]: Regular data of the slave ADC */
542
543/* Bits 15:0 RDATA_MST[15:0]: Regular data of the master ADC. */
544
545/** @defgroup adc_channel ADC Channel Numbers
546 * @ingroup adc_defines
547 *
548 *@{*/
549#define ADC_CHANNEL_TEMP 16
550#define ADC_CHANNEL_VBAT 17
551#define ADC_CHANNEL_VREF 18
552/**@}*/
553
554
556
557void adc_enable_analog_watchdog_regular(uint32_t adc);
558void adc_disable_analog_watchdog_regular(uint32_t adc);
559void adc_enable_analog_watchdog_injected(uint32_t adc);
560void adc_disable_analog_watchdog_injected(uint32_t adc);
561void adc_enable_discontinuous_mode_regular(uint32_t adc, uint8_t length);
569 uint8_t channel);
570/*void adc_enable_scan_mode(uint32_t adc);*/
571/*void adc_disable_scan_mode(uint32_t adc);*/
572void adc_enable_eoc_interrupt_injected(uint32_t adc);
573void adc_disable_eoc_interrupt_injected(uint32_t adc);
574void adc_enable_eos_interrupt_injected(uint32_t adc);
575void adc_disable_eos_interrupt_injected(uint32_t adc);
576void adc_enable_all_awd_interrupt(uint32_t adc);
577void adc_disable_all_awd_interrupt(uint32_t adc);
578void adc_enable_eos_interrupt(uint32_t adc);
579void adc_disable_eos_interrupt(uint32_t adc);
580void adc_start_conversion_injected(uint32_t adc);
581void adc_disable_external_trigger_regular(uint32_t adc);
583void adc_set_watchdog_high_threshold(uint32_t adc, uint16_t threshold);
584void adc_set_watchdog_low_threshold(uint32_t adc, uint16_t threshold);
585void adc_set_injected_sequence(uint32_t adc, uint8_t length, uint8_t channel[]);
586bool adc_eoc_injected(uint32_t adc);
587bool adc_eos_injected(uint32_t adc);
588uint32_t adc_read_injected(uint32_t adc, uint8_t reg);
589void adc_set_injected_offset(uint32_t adc, uint8_t reg, uint32_t offset);
590
591void adc_set_clk_prescale(uint32_t adc, uint32_t prescaler);
592void adc_set_multi_mode(uint32_t adc, uint32_t mode);
593void adc_enable_external_trigger_regular(uint32_t adc, uint32_t trigger,
594 uint32_t polarity);
595void adc_enable_external_trigger_injected(uint32_t adc, uint32_t trigger,
596 uint32_t polarity);
597bool adc_awd(uint32_t adc);
598/*void adc_set_dma_continue(uint32_t adc);*/
599/*void adc_set_dma_terminate(uint32_t adc);*/
600
602
603/**@}*/
604
605#endif
#define END_DECLS
Definition: common.h:34
#define BEGIN_DECLS
Definition: common.h:33
void adc_disable_automatic_injected_group_conversion(uint32_t adc)
ADC Disable Automatic Injected Conversions.
Definition: adc.c:234
void adc_set_watchdog_high_threshold(uint32_t adc, uint16_t threshold)
ADC Set Analog Watchdog Upper Threshold.
Definition: adc.c:416
void adc_enable_discontinuous_mode_injected(uint32_t adc)
ADC Enable Discontinuous Mode for Injected Conversions.
Definition: adc.c:193
void adc_disable_eos_interrupt(uint32_t adc)
ADC Disable Regular End-Of-Sequence Interrupt.
Definition: adc.c:386
void adc_disable_discontinuous_mode_regular(uint32_t adc)
ADC Disable Discontinuous Mode for Regular Conversions.
Definition: adc.c:177
void adc_enable_all_awd_interrupt(uint32_t adc)
ADC Enable Analog Watchdog Interrupt.
Definition: adc.c:346
void adc_enable_eos_interrupt(uint32_t adc)
ADC Enable Regular End-Of-Sequence Interrupt.
Definition: adc.c:374
void adc_start_conversion_injected(uint32_t adc)
ADC Software Triggered Conversion on Injected Channels.
Definition: adc.c:404
void adc_enable_discontinuous_mode_regular(uint32_t adc, uint8_t length)
ADC Enable Discontinuous Mode for Regular Conversions.
Definition: adc.c:161
void adc_disable_eoc_interrupt_injected(uint32_t adc)
ADC Disable Injected End-Of-Conversion Interrupt.
Definition: adc.c:309
void adc_set_injected_sequence(uint32_t adc, uint8_t length, uint8_t channel[])
ADC Set an Injected Channel Conversion Sequence.
Definition: adc.c:461
void adc_enable_analog_watchdog_on_all_channels(uint32_t adc)
ADC Enable Analog Watchdog for All Regular and/or Injected Channels.
Definition: adc.c:256
void adc_enable_external_trigger_regular(uint32_t adc, uint32_t trigger, uint32_t polarity)
ADC Enable an External Trigger for Regular Channels.
Definition: adc.c:626
void adc_disable_all_awd_interrupt(uint32_t adc)
ADC Disable Analog Watchdog Interrupt.
Definition: adc.c:360
void adc_enable_external_trigger_injected(uint32_t adc, uint32_t trigger, uint32_t polarity)
ADC Enable an External Trigger for Injected Channels.
Definition: adc.c:662
void adc_disable_external_trigger_injected(uint32_t adc)
ADC Disable an External Trigger for Injected Channels.
Definition: adc.c:679
void adc_enable_eos_interrupt_injected(uint32_t adc)
ADC Enable Injected End-Of-Sequence Interrupt.
Definition: adc.c:321
void adc_enable_automatic_injected_group_conversion(uint32_t adc)
ADC Enable Automatic Injected Conversions.
Definition: adc.c:221
void adc_set_multi_mode(uint32_t adc, uint32_t mode)
ADC set multi mode.
Definition: adc.c:605
bool adc_awd(uint32_t adc)
ADC Read the Analog Watchdog Flag.
Definition: adc.c:696
void adc_enable_eoc_interrupt_injected(uint32_t adc)
ADC Enable Injected End-Of-Conversion Interrupt.
Definition: adc.c:297
void adc_set_clk_prescale(uint32_t adc, uint32_t prescaler)
ADC Set Clock Prescale.
Definition: adc.c:585
void adc_enable_analog_watchdog_injected(uint32_t adc)
ADC Enable Analog Watchdog for Injected Conversions.
Definition: adc.c:130
uint32_t adc_read_injected(uint32_t adc, uint8_t reg)
ADC Read from an Injected Conversion Result Register.
Definition: adc.c:526
void adc_disable_eos_interrupt_injected(uint32_t adc)
ADC Disable Injected End-Of-Sequence Interrupt.
Definition: adc.c:333
void adc_set_injected_offset(uint32_t adc, uint8_t reg, uint32_t offset)
ADC Set the Injected Channel Data Offset.
Definition: adc.c:554
void adc_enable_analog_watchdog_on_selected_channel(uint32_t adc, uint8_t channel)
ADC Enable Analog Watchdog for a Selected Channel.
Definition: adc.c:280
void adc_disable_analog_watchdog_injected(uint32_t adc)
ADC Disable Analog Watchdog for Injected Conversions.
Definition: adc.c:142
void adc_enable_analog_watchdog_regular(uint32_t adc)
ADC Enable Analog Watchdog for Regular Conversions.
Definition: adc.c:99
bool adc_eoc_injected(uint32_t adc)
ADC Read the End-of-Conversion Flag for Injected Conversion.
Definition: adc.c:491
void adc_set_watchdog_low_threshold(uint32_t adc, uint16_t threshold)
ADC Set Analog Watchdog Lower Threshold.
Definition: adc.c:434
bool adc_eos_injected(uint32_t adc)
ADC Read the End-of-Sequence Flag for Injected Conversions.
Definition: adc.c:506
void adc_disable_external_trigger_regular(uint32_t adc)
ADC Disable an External Trigger for Regular Channels.
Definition: adc.c:643
void adc_disable_discontinuous_mode_injected(uint32_t adc)
ADC Disable Discontinuous Mode for Injected Conversions.
Definition: adc.c:205
void adc_disable_analog_watchdog_regular(uint32_t adc)
ADC Enable Analog Watchdog for Regular Conversions.
Definition: adc.c:114