libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
l0/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 STM32L0xx Analog to Digital
4 * Converter</b>
5 *
6 * @ingroup STM32L0xx_defines
7 *
8 * @version 1.0.0
9 *
10 * @date 16 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/**@}*/
45
46
47/** @defgroup adc_channel ADC Channel Numbers
48 * @ingroup adc_defines
49 *
50 *@{*/
51#define ADC_CHANNEL_VLCD 16
52#define ADC_CHANNEL_VREF 17
53#define ADC_CHANNEL_TEMP 18
54/**@}*/
55
56/* Calibration Factors */
57#define ADC_CALFACT(adc) MMIO32((adc) + 0xB4)
58
59/* Register values */
60/* ADC_CFGR1 Values ---------------------------------------------------------*/
61
62/** ALIGN: Data alignment */
63#define ADC_CFGR1_ALIGN (1 << 5)
64
65/* EXTSEL[2:0]: External trigger selection for regular group */
66#define ADC_CFGR1_EXTSEL_SHIFT 6
67#define ADC_CFGR1_EXTSEL (0x7 << ADC_CFGR1_EXTSEL_SHIFT)
68#define ADC_CFGR1_EXTSEL_VAL(x) ((x) << ADC_CFGR1_EXTSEL_SHIFT)
69
70/** @defgroup adc_cfgr1_extsel ADC external trigger selection values
71 *@{*/
72#define ADC_CFGR1_EXTSEL_TIM6_TRGO 0x0
73#define ADC_CFGR1_EXTSEL_TIM21_CH2 0x1
74#define ADC_CFGR1_EXTSEL_TIM2_TRGO 0x2
75#define ADC_CFGR1_EXTSEL_TIM2_CH4 0x3
76#define ADC_CFGR1_EXTSEL_TIM21_TRGO 0x4
77#define ADC_CFGR1_EXTSEL_TIM22_TRGO 0x4
78#define ADC_CFGR1_EXTSEL_TIM2_CH3 0x5
79#define ADC_CFGR1_EXTSEL_TIM3_TRGO 0x6
80#define ADC_CFGR1_EXTSEL_EXTI11 0x7
81/**@}*/
82
83/* ADC_CFGR2 Values ---------------------------------------------------------*/
84
85#define ADC_CFGR2_CKMODE_SHIFT 30
86#define ADC_CFGR2_CKMODE (3 << ADC_CFGR2_CKMODE_SHIFT)
87#define ADC_CFGR2_CKMODE_CK_ADC (0 << ADC_CFGR2_CKMODE_SHIFT)
88#define ADC_CFGR2_CKMODE_PCLK_DIV2 (1 << ADC_CFGR2_CKMODE_SHIFT)
89#define ADC_CFGR2_CKMODE_PCLK_DIV4 (2 << ADC_CFGR2_CKMODE_SHIFT)
90#define ADC_CFGR2_CKMODE_PCLK (3 << ADC_CFGR2_CKMODE_SHIFT)
91
92/** @defgroup adc_sample_rg ADC Sample Time Selection for All Channels
93@ingroup adc_defines
94
95@{*/
96#define ADC_SMPR_SMP_1DOT5CYC 0x0
97#define ADC_SMPR_SMP_3DOT5CYC 0x1
98#define ADC_SMPR_SMP_7DOT5CYC 0x2
99#define ADC_SMPR_SMP_12DOT5CYC 0x3
100#define ADC_SMPR_SMP_19DOT5CYC 0x4
101#define ADC_SMPR_SMP_39DOT5CYC 0x5
102#define ADC_SMPR_SMP_79DOT5CYC 0x6
103#define ADC_SMPR_SMP_160DOT5CYC 0x7
104/**@}*/
105
107
108
110
111
112#endif
#define END_DECLS
Definition: common.h:34
#define BEGIN_DECLS
Definition: common.h:33