libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
acmp_common.h
Go to the documentation of this file.
1/** @addtogroup acmp_defines
2 */
3/*
4 * This file is part of the libopencm3 project.
5 *
6 * Copyright (C) 2015 Kuldeep Singh Dhaka <kuldeepdhaka9@gmail.com>
7 *
8 * This library is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this library. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#pragma once
23
24/**@{*/
25
28
29#define ACMP_CTRL(base) ((base) + 0x000)
30#define ACMP_INPUTSEL(base) ((base) + 0x004)
31#define ACMP_STATUS(base) ((base) + 0x008)
32#define ACMP_IEN(base) ((base) + 0x00C)
33#define ACMP_IF(base) ((base) + 0x010)
34#define ACMP_IFS(base) ((base) + 0x014)
35#define ACMP_IFC(base) ((base) + 0x018)
36#define ACMP_ROUTE(base) ((base) + 0x01C)
37
38/* ACMP_CTRL */
39#define ACMP_CTRL_FULLBIAS (1 << 31)
40#define ACMP_CTRL_HALFBIAS (1 << 30)
41
42#define ACMP_CTRL_BIASPROG_SHIFT (24)
43#define ACMP_CTRL_BIASPROG_MASK (0xF << ACMP_CTRL_BIASPROG_SHIFT)
44#define ACMP_CTRL_BIASPROG(v) \
45 (((v) << ACMP_CTRL_BIASPROG_SHIFT) & ACMP_CTRL_BIASPROG_MASK)
46
47#define ACMP_CTRL_IFALL (1 << 17)
48#define ACMP_CTRL_IRISE (1 << 16)
49
50#define ACMP_CTRL_WARMTIME_SHIFT (8)
51#define ACMP_CTRL_WARMTIME_MASK (0x7 << ACMP_CTRL_WARMTIME_SHIFT)
52#define ACMP_CTRL_WARMTIME(v) \
53 (((v) << ACMP_CTRL_WARMTIME_SHIFT) & ACMP_CTRL_WARMTIME_MASK)
54#define ACMP_CTRL_WARMTIME_4CYCLES 0
55#define ACMP_CTRL_WARMTIME_8CYCLES 1
56#define ACMP_CTRL_WARMTIME_16CYCLES 2
57#define ACMP_CTRL_WARMTIME_32CYCLES 3
58#define ACMP_CTRL_WARMTIME_64CYCLES 4
59#define ACMP_CTRL_WARMTIME_128CYCLES 5
60#define ACMP_CTRL_WARMTIME_256CYCLES 6
61#define ACMP_CTRL_WARMTIME_512CYCLES 7
62
63#define ACMP_CTRL_HYSTSEL_SHIFT (8)
64#define ACMP_CTRL_HYSTSEL_MASK (0x7 << ACMP_CTRL_HYSTSEL_SHIFT)
65#define ACMP_CTRL_HYSTSEL(v) \
66 (((v) << ACMP_CTRL_HYSTSEL_SHIFT) & ACMP_CTRL_HYSTSEL_MASK)
67#define ACMP_CTRL_HYSTSEL_HYSTx(x) ACMP_CTRL_HYSTSEL(x)
68#define ACMP_CTRL_HYSTSEL_HYST0 0
69#define ACMP_CTRL_HYSTSEL_HYST1 1
70#define ACMP_CTRL_HYSTSEL_HYST2 2
71#define ACMP_CTRL_HYSTSEL_HYST3 3
72#define ACMP_CTRL_HYSTSEL_HYST4 4
73#define ACMP_CTRL_HYSTSEL_HYST5 5
74#define ACMP_CTRL_HYSTSEL_HYST6 6
75#define ACMP_CTRL_HYSTSEL_HYST7 7
76
77#define ACMP_CTRL_GPIOINV (1 << 3)
78#define ACMP_CTRL_INACTVAL (1 << 2)
79#define ACMP_CTRL_MUXEN (1 << 1)
80#define ACMP_CTRL_EN (1 << 0)
81
82/* ACMP_INPUTSEL */
83#define ACMP_INPUTSEL_CSRESSEL_SHIFT (28)
84#define ACMP_INPUTSEL_CSRESSEL_MASK (0x3 << ACMP_INPUTSEL_CSRESSEL_SHIFT)
85#define ACMP_INPUTSEL_CSRESSEL(v) \
86 (((v) << ACMP_INPUTSEL_CSRESSEL_SHIFT) & ACMP_INPUTSEL_CSRESSEL_MASK)
87#define ACMP_INPUTSEL_CSRESSEL_RESx(x) ACMP_INPUTSEL_CSRESSEL_RES(x)
88#define ACMP_INPUTSEL_CSRESSEL_RES0 ACMP_INPUTSEL_CSRESSEL_RESx(0)
89#define ACMP_INPUTSEL_CSRESSEL_RES1 ACMP_INPUTSEL_CSRESSEL_RESx(1)
90#define ACMP_INPUTSEL_CSRESSEL_RES2 ACMP_INPUTSEL_CSRESSEL_RESx(2)
91#define ACMP_INPUTSEL_CSRESSEL_RES3 ACMP_INPUTSEL_CSRESSEL_RESx(3)
92
93#define ACMP_INPUTSEL_CSRESEN (1 << 24)
94#define ACMP_INPUTSEL_LPREF (1 << 16)
95
96#define ACMP_INPUTSEL_VDDLEVEL_SHIFT (8)
97#define ACMP_INPUTSEL_VDDLEVEL_MASK (0x3F << ACMP_INPUTSEL_VDDLEVEL_SHIFT)
98#define ACMP_INPUTSEL_VDDLEVEL(v) \
99 (((v) << ACMP_INPUTSEL_VDDLEVEL_SHIFT) & ACMP_INPUTSEL_VDDLEVEL_MASK)
100
101#define ACMP_INPUTSEL_NEGSEL_SHIFT (8)
102#define ACMP_INPUTSEL_NEGSEL_MASK (0x3F << ACMP_INPUTSEL_NEGSEL_SHIFT)
103#define ACMP_INPUTSEL_NEGSEL(v) \
104 (((v) << ACMP_INPUTSEL_NEGSEL_SHIFT) & ACMP_INPUTSEL_NEGSEL_MASK)
105#define ACMP_INPUTSEL_NEGSEL_CHx(x) ACMP_INPUTSEL_NEGSEL(x)
106#define ACMP_INPUTSEL_NEGSEL_CH0 0
107#define ACMP_INPUTSEL_NEGSEL_CH1 1
108#define ACMP_INPUTSEL_NEGSEL_CH2 2
109#define ACMP_INPUTSEL_NEGSEL_CH3 3
110#define ACMP_INPUTSEL_NEGSEL_CH4 4
111#define ACMP_INPUTSEL_NEGSEL_CH5 5
112#define ACMP_INPUTSEL_NEGSEL_CH6 6
113#define ACMP_INPUTSEL_NEGSEL_CH7 7
114#define ACMP_INPUTSEL_NEGSEL_1V25 8
115#define ACMP_INPUTSEL_NEGSEL_2V5 9
116#define ACMP_INPUTSEL_NEGSEL_VDD 10
117#define ACMP_INPUTSEL_NEGSEL_CAPSENSE 11
118#define ACMP_INPUTSEL_NEGSEL_DAC0CH0 12
119#define ACMP_INPUTSEL_NEGSEL_DAC0CH1 13
120
121#define ACMP_INPUTSEL_POSSEL_SHIFT (0)
122#define ACMP_INPUTSEL_POSSEL_MASK (0x7 << ACMP_INPUTSEL_POSSEL_SHIFT)
123#define ACMP_INPUTSEL_POSSEL(v) \
124 (((v) << ACMP_INPUTSEL_LPOSSELL_SHIFT) & ACMP_INPUTSEL_LPOSSELL_MASK)
125#define ACMP_INPUTSEL_POSSEL_CHx(x) ACMP_INPUTSEL_POSSEL(x)
126#define ACMP_INPUTSEL_POSSEL_CH0 0
127#define ACMP_INPUTSEL_POSSEL_CH1 1
128#define ACMP_INPUTSEL_POSSEL_CH2 2
129#define ACMP_INPUTSEL_POSSEL_CH3 3
130#define ACMP_INPUTSEL_POSSEL_CH4 4
131#define ACMP_INPUTSEL_POSSEL_CH5 5
132#define ACMP_INPUTSEL_POSSEL_CH6 6
133#define ACMP_INPUTSEL_POSSEL_CH7 7
134
135/* ACMP_STATUS */
136#define ACMP_STATUS_ACMPOUT (1 << 1)
137#define ACMP_STATUS_ACMPACT (1 << 0)
138
139/* ACMP_IEN */
140#define ACMP_IEN_WARMUP (1 << 1)
141#define ACMP_IEN_EDGE (1 << 0)
142
143/* ACMP_IF */
144#define ACMP_IF_WARMUP (1 << 1)
145#define ACMP_IF_EDGE (1 << 0)
146
147/* ACMP_IFS */
148#define ACMP_IFS_WARMUP (1 << 1)
149#define ACMP_IFS_EDGE (1 << 0)
150
151/* ACMP_IFC */
152#define ACMP_IFC_WARMUP (1 << 1)
153#define ACMP_IFC_EDGE (1 << 0)
154
155/* ACMP_ROUTE */
156#define ACMP_ROUTE_LOCATION_SHIFT (8)
157#define ACMP_ROUTE_LOCATION_MASK (0x7 << ACMP_ROUTE_LOCATION_SHIFT)
158#define ACMP_ROUTE_LOCATION(v) \
159 (((v) << ACMP_ROUTE_LOCATION_SHIFT) & ACMP_ROUTE_LOCATION_MASK)
160#define ACMP_ROUTE_LOCATION_LOCx(x) ACMP_ROUTE_LOCATION(x)
161#define ACMP_ROUTE_LOCATION_LOC0 ACMP_ROUTE_LOCATIONx(0)
162#define ACMP_ROUTE_LOCATION_LOC1 ACMP_ROUTE_LOCATIONx(1)
163#define ACMP_ROUTE_LOCATION_LOC2 ACMP_ROUTE_LOCATIONx(2)
164
165#define ACMP_ROUTE_ACMPPEN (1 << 0)
166
167#define ACMP0 ACMP0_BASE
168#define ACMP0_CTRL ACMP_CTRL(ACMP0)
169#define ACMP0_INPUTSEL ACMP_INPUTSEL(ACMP0)
170#define ACMP0_STATUS ACMP_STATUS(ACMP0)
171#define ACMP0_IEN ACMP_IEN(ACMP0)
172#define ACMP0_IF ACMP_IF(ACMP0)
173#define ACMP0_IFS ACMP_IFS(ACMP0)
174#define ACMP0_IFC ACMP_IFC(ACMP0)
175#define ACMP0_ROUTE ACMP_ROUTE(ACMP0)
176
177#define ACMP1 ACMP1_BASE
178#define ACMP1_CTRL ACMP_CTRL(ACMP1)
179#define ACMP1_INPUTSEL ACMP_INPUTSEL(ACMP1)
180#define ACMP1_STATUS ACMP_STATUS(ACMP1)
181#define ACMP1_IEN ACMP_IEN(ACMP1)
182#define ACMP1_IF ACMP_IF(ACMP1)
183#define ACMP1_IFS ACMP_IFS(ACMP1)
184#define ACMP1_IFC ACMP_IFC(ACMP1)
185#define ACMP1_ROUTE ACMP_ROUTE(ACMP1)
186
187/**@}*/
Dispatcher for the base address definitions, depending on the particular Gecko family.