libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
letimer_common.h
Go to the documentation of this file.
1/** @addtogroup letimer_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
26
27/**@{*/
28
29#define LETIMER_CTRL(base) ((base) + 0x000)
30#define LETIMER_CMD(base) ((base) + 0x004)
31#define LETIMER_STATUS(base) ((base) + 0x008)
32#define LETIMER_CNT(base) ((base) + 0x00C)
33#define LETIMER_COMP0(base) ((base) + 0x010)
34#define LETIMER_COMP1(base) ((base) + 0x014)
35#define LETIMER_REP0(base) ((base) + 0x018)
36#define LETIMER_REP1(base) ((base) + 0x01C)
37#define LETIMER_IF(base) ((base) + 0x020)
38#define LETIMER_IFS(base) ((base) + 0x024)
39#define LETIMER_IFC(base) ((base) + 0x028)
40#define LETIMER_IEN(base) ((base) + 0x02C)
41#define LETIMER_FREEZE(base) ((base) + 0x030)
42#define LETIMER_SYNCBUSY(base) ((base) + 0x034)
43#define LETIMER_ROUTE(base) ((base) + 0x040)
44
45/* LETIMER_CTRL */
46#define LETIMER_CTRL_DEBUG (1 << 12)
47#define LETIMER_CTRL_RTCC1TEN (1 << 11)
48#define LETIMER_CTRL_RTCC0TEN (1 << 10)
49#define LETIMER_CTRL_COMP0TOP (1 << 9)
50#define LETIMER_CTRL_BUFTOP (1 << 8)
51#define LETIMER_CTRL_OPOL1 (1 << 7)
52#define LETIMER_CTRL_OPOL0 (1 << 6)
53
54#define LETIMER_CTRL_UFOA1_SHIFT (4)
55#define LETIMER_CTRL_UFOA1_MASK (0x3 << LETIMER_CTRL_UFOA1_SHIFT)
56#define LETIMER_CTRL_UFOA1(v) \
57 (((v) << LETIMER_CTRL_UFOA1_SHIFT) & LETIMER_CTRL_UFOA1_MASK)
58#define LETIMER_CTRL_UFOA1_NONE 0
59#define LETIMER_CTRL_UFOA1_TOGGLE 1
60#define LETIMER_CTRL_UFOA1_PULSE 2
61#define LETIMER_CTRL_UFOA1_PWM 3
62
63#define LETIMER_CTRL_UFOA0_SHIFT (2)
64#define LETIMER_CTRL_UFOA0_MASK (0x3 << LETIMER_CTRL_UFOA0_SHIFT)
65#define LETIMER_CTRL_UFOA0(v) \
66 (((v) << LETIMER_CTRL_UFOA0_SHIFT) & LETIMER_CTRL_UFOA0_MASK)
67#define LETIMER_CTRL_UFOA0_NONE 0
68#define LETIMER_CTRL_UFOA0_TOGGLE 1
69#define LETIMER_CTRL_UFOA0_PULSE 2
70#define LETIMER_CTRL_UFOA0_PWM 3
71
72#define LETIMER_CTRL_REPMODE_SHIFT (2)
73#define LETIMER_CTRL_REPMODE_MASK (0x3 << LETIMER_CTRL_REPMODE_SHIFT)
74#define LETIMER_CTRL_REPMODE(v) \
75 (((v) << LETIMER_CTRL_REPMODE_SHIFT) & LETIMER_CTRL_REPMODE_MASK)
76#define LETIMER_CTRL_REPMODE_FREE 0
77#define LETIMER_CTRL_REPMODE_ONESHOT 1
78#define LETIMER_CTRL_REPMODE_BUFFERED 2
79#define LETIMER_CTRL_REPMODE_DOUBLE 3
80#define LETIMER_CTRL_REPMODE_ONE_SHOT LETIMER_CTRL_REPMODE_ONESHOT
81
82/* LETIMER_CMD */
83#define LETIMER_CMD_CTO1 (1 << 4)
84#define LETIMER_CMD_CTO0 (1 << 3)
85#define LETIMER_CMD_CLEAR (1 << 2)
86#define LETIMER_CMD_STOP (1 << 1)
87#define LETIMER_CMD_START (1 << 0)
88
89/* LETIMER_STATUS */
90#define LETIMER_STATUS_RUNNING (1 << 0)
91
92/* LETIMER_IF */
93#define LETIMER_IF_REP1 (1 << 4)
94#define LETIMER_IF_REP0 (1 << 3)
95#define LETIMER_IF_UF (1 << 2)
96#define LETIMER_IF_COMP1 (1 << 1)
97#define LETIMER_IF_COMP0 (1 << 0)
98
99/* LETIMER_IFS */
100#define LETIMER_IFS_REP1 (1 << 4)
101#define LETIMER_IFS_REP0 (1 << 3)
102#define LETIMER_IFS_UF (1 << 2)
103#define LETIMER_IFS_COMP1 (1 << 1)
104#define LETIMER_IFS_COMP0 (1 << 0)
105
106/* LETIMER_IFC */
107#define LETIMER_IFC_REP1 (1 << 4)
108#define LETIMER_IFC_REP0 (1 << 3)
109#define LETIMER_IFC_UF (1 << 2)
110#define LETIMER_IFC_COMP1 (1 << 1)
111#define LETIMER_IFC_COMP0 (1 << 0)
112
113/* LETIMER_IFE */
114#define LETIMER_IFE_REP1 (1 << 4)
115#define LETIMER_IFE_REP0 (1 << 3)
116#define LETIMER_IFE_UF (1 << 2)
117#define LETIMER_IFE_COMP1 (1 << 1)
118#define LETIMER_IFE_COMP0 (1 << 0)
119
120/* LETIMER_FREEZE */
121#define LETIMER_FREEZE_REGFREEZE (1 << 0)
122
123/* LETIMER_SYNCBUSY */
124#define LETIMER_SYNCBUSY_REP1 (1 << 5)
125#define LETIMER_SYNCBUSY_REP0 (1 << 4)
126#define LETIMER_SYNCBUSY_COMP1 (1 << 3)
127#define LETIMER_SYNCBUSY_COMP0 (1 << 2)
128#define LETIMER_SYNCBUSY_CMD (1 << 1)
129#define LETIMER_SYNCBUSY_CTRL (1 << 0)
130
131/* LETIMER_ROUTE */
132#define LETIMER_ROUTE_LOCATION_SHIFT (8)
133#define LETIMER_ROUTE_LOCATION_MASK (0x7 << LETIMER_ROUTE_LOCATION_SHIFT)
134#define LETIMER_ROUTE_LOCATION(v) \
135 (((v) << LETIMER_ROUTE_LOCATION_SHIFT) & LETIMER_ROUTE_LOCATION_MASK)
136#define LETIMER_ROUTE_LOCATION_LOCx(x) LETIMER_ROUTE_LOCATION(x)
137#define LETIMER_ROUTE_LOCATION_LOC0 0
138#define LETIMER_ROUTE_LOCATION_LOC1 1
139#define LETIMER_ROUTE_LOCATION_LOC2 2
140#define LETIMER_ROUTE_LOCATION_LOC3 3
141#define LETIMER_ROUTE_LOCATION_LOC4 4
142#define LETIMER_ROUTE_LOCATION_LOC5 5
143#define LETIMER_ROUTE_LOCATION_LOC6 6
144#define LETIMER_ROUTE_LOCATION_LOC7 7
145
146#define LETIMER_ROUTE_OUT1PEN (1 << 1)
147#define LETIMER_ROUTE_OUT0PEN (1 << 0)
148
149/* LETIMER0 */
150#define LETIMER0 LETIMER0_BASE
151#define LETIMER0_CTRL LETIMER_CTRL(LETIMER0)
152#define LETIMER0_CMD LETIMER_CMD(LETIMER0)
153#define LETIMER0_STATUS LETIMER_STATUS(LETIMER0)
154#define LETIMER0_CNT LETIMER_CNT(LETIMER0)
155#define LETIMER0_COMP0 LETIMER_COMP0(LETIMER0)
156#define LETIMER0_COMP1 LETIMER_COMP1(LETIMER0)
157#define LETIMER0_REP0 LETIMER_REP0(LETIMER0)
158#define LETIMER0_REP1 LETIMER_REP1(LETIMER0)
159#define LETIMER0_IF LETIMER_IF(LETIMER0)
160#define LETIMER0_IFS LETIMER_IFS(LETIMER0)
161#define LETIMER0_IFC LETIMER_IFC(LETIMER0)
162#define LETIMER0_IEN LETIMER_IEN(LETIMER0)
163#define LETIMER0_FREEZE LETIMER_FREEZE(LETIMER0)
164#define LETIMER0_SYNCBUSY LETIMER_SYNCBUSY(LETIMER0)
165#define LETIMER0_ROUTE LETIMER_ROUTE(LETIMER0)
166
167/**@}*/
Dispatcher for the base address definitions, depending on the particular Gecko family.