libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
l4/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 STM32L4xx Analog to Digital
4 * Converter</b>
5 *
6 * @ingroup STM32L4xx_defines
7 *
8 * @version 1.0.0
9 *
10 * @date 24 Oct 2015
11 *
12 * LGPL License Terms @ref lgpl_license
13 */
14/*
15 * This file is part of the libopencm3 project.
16 *
17 * Copyright (C) 2015 Karl Palsson <karlp@tweak.net.au>
18 *
19 * This library is free software: you can redistribute it and/or modify
20 * it under the terms of the GNU Lesser General Public License as published by
21 * the Free Software Foundation, either version 3 of the License, or
22 * (at your option) any later version.
23 *
24 * This library is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU Lesser General Public License for more details.
28 *
29 * You should have received a copy of the GNU Lesser General Public License
30 * along with this library. If not, see <http://www.gnu.org/licenses/>.
31 */
32
33#ifndef LIBOPENCM3_ADC_H
34#define LIBOPENCM3_ADC_H
35
38
39/** @defgroup adc_reg_base ADC register base addresses
40 * @ingroup adc_defines
41 *
42 *@{*/
43#define ADC1 ADC1_BASE
44#define ADC2 ADC2_BASE
45#define ADC3 ADC3_BASE
46/**@}*/
47
48/** @defgroup adc_channel ADC Channel Numbers
49 * @ingroup adc_defines
50 *
51 *@{*/
52#define ADC_CHANNEL_VREF 0
53#define ADC_CHANNEL_TEMP 17
54#define ADC_CHANNEL_VBAT 18
55/**@}*/
56
57/* ADC_CR Values ------------------------------------------------------------*/
58
59/* DEEPPWD: Deep power down */
60#define ADC_CR_DEEPPWD (1 << 29)
61
62/* ADVREGEN: Voltage regulator enable bit */
63#define ADC_CR_ADVREGEN (1 << 28)
64
65/* ADC_CFGR1 Values ---------------------------------------------------------*/
66
67/** ALIGN: Data alignment */
68#define ADC_CFGR1_ALIGN (1 << 5)
69
70/* EXTSEL[2:0]: External trigger selection for regular group */
71#define ADC_CFGR1_EXTSEL_SHIFT 6
72#define ADC_CFGR1_EXTSEL_MASK (0xf << ADC_CFGR1_EXTSEL_SHIFT)
73#define ADC_CFGR1_EXTSEL_VAL(x) ((x) << ADC_CFGR1_EXTSEL_SHIFT)
74
75
76/****************************************************************************/
77/* ADC_SMPRx ADC Sample Time Selection for Channels */
78/** @defgroup adc_sample ADC Sample Time Selection values
79@ingroup adc_defines
80
81@{*/
82#define ADC_SMPR_SMP_2DOT5CYC 0x0
83#define ADC_SMPR_SMP_6DOT5CYC 0x1
84#define ADC_SMPR_SMP_12DOT5CYC 0x2
85#define ADC_SMPR_SMP_24DOT5CYC 0x3
86#define ADC_SMPR_SMP_47DOT5CYC 0x4
87#define ADC_SMPR_SMP_92DOT5CYC 0x5
88#define ADC_SMPR_SMP_247DOT5CYC 0x6
89#define ADC_SMPR_SMP_640DOT5CYC 0x7
90/**@}*/
91
92
94
95
97
98
99#endif
#define END_DECLS
Definition: common.h:34
#define BEGIN_DECLS
Definition: common.h:33