libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
dmamux_common_all.h
Go to the documentation of this file.
1/** @addtogroup dmamux_defines
2 *
3 * @author @htmlonly © @endhtmlonly 2019
4 * Guillaume Revaillot <g.revaillot@gmail.com>
5 *
6 * @version 1.0.0
7 *
8 * LGPL License Terms @ref lgpl_license
9 */
10
11/*
12 * This file is part of the libopencm3 project.
13 *
14 * This library is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
18 *
19 * This library is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License for more details.
23 *
24 * You should have received a copy of the GNU Lesser General Public License
25 * along with this library. If not, see <http://www.gnu.org/licenses/>.
26 */
27
28#pragma once
29
30/**@{*/
31
32#define DMAMUX_CxCR(dmamux_base, dma_channel) MMIO32((dmamux_base) + 0x04 * ((dma_channel) - 1))
33#define DMAMUX1_CxCR(dma_channel) DMAMUX_CxCR(DMAMUX1, (dma_channel))
34#define DMAMUX2_CxCR(dma_channel) DMAMUX_CxCR(DMAMUX2, (dma_channel))
35
36#define DMAMUX_CSR(dmamux_base) MMIO32((dmamux_base) + 0x80)
37#define DMAMUX1_CSR DMAMUX_CSR(DMAMUX1)
38#define DMAMUX2_CSR DMAMUX_CSR(DMAMUX2)
39
40#define DMAMUX_CFR(dmamux_base) MMIO32((dmamux_base) + 0x84)
41#define DMAMUX1_CFR DMAMUX_CFR(DMAMUX1)
42#define DMAMUX2_CFR DMAMUX_CFR(DMAMUX2)
43
44#define DMAMUX_RGxCR(dmamux_base, rg_channel) MMIO32((dmamux_base) + 0x100 + 0x04 * ((rg_channel) - 1))
45#define DMAMUX1_RGxCR(rg_channel) DMAMUX_RGxCR(DMAMUX1, (rg_channel))
46#define DMAMUX2_RGxCR(rg_channel) DMAMUX_RGxCR(DMAMUX2, (rg_channel))
47
48#define DMAMUX_RGSR(dmamux_base) MMIO32((dmamux_base) + 0x140)
49#define DMAMUX1_RGSR DMAMUX_RSGR(DMAMUX1)
50#define DMAMUX2_RGSR DMAMUX_RSGR(DMAMUX2)
51
52#define DMAMUX_RGCFR(dmamux_base) MMIO32((dmamux_base) + 0x144)
53#define DMAMUX1_RGCFR DMAMUX_RGCFR(DMAMUX1)
54#define DMAMUX2_RGCFR DMAMUX_RGCFR(DMAMUX2)
55
56/** @defgroup dmamux_cxcr CxCR DMA request line multiplexer channel x control register
57@{*/
58
59/** DMAMUX_CxCR_SYNC_ID Synchronization input selected */
60#define DMAMUX_CxCR_SYNC_ID_SHIFT 24
61#define DMAMUX_CxCR_SYNC_ID_MASK 0x1f
62
63/** DMAMUX_CxCR_NBREQ Number (minus 1) of DMA requests to forward */
64#define DMAMUX_CxCR_NBREQ_SHIFT 19
65#define DMAMUX_CxCR_NBREQ_MASK 0x1f
66
67#define DMAMUX_CxCR_SPOL_SHIFT 17
68#define DMAMUX_CxCR_SPOL_MASK 0x03
69/** @defgroup dmamux_cxcr_spol SPOL Event Polarity
70* @brief Synchronization event type selector
71@{*/
72#define DMAMUX_CxCR_SPOL_NO_EVENT 0
73#define DMAMUX_CxCR_SPOL_RISING_EDGE 1
74#define DMAMUX_CxCR_SPOL_FALLING_EDEG 2
75#define DMAMUX_CxCR_SPOL_BOTH_EDGES 3
76/**@}*/
77
78/** DMAMUX_CxCR_SE Synchronous operating mode enable/disable */
79#define DMAMUX_CxCR_SE (1 << 16)
80
81/** DMAMUX_CxCR_EGE Event generation enable/disable */
82#define DMAMUX_CxCR_EGE (1 << 9)
83
84/** DMAMUX_CxCR_SOIE Interrupt enable at synchronization event overrun */
85#define DMAMUX_CxCR_SOIE (1 << 8)
86
87/** DMAMUX_CxCR_DMAREQ_ID Input DMA request line selected */
88#define DMAMUX_CxCR_DMAREQ_ID_SHIFT 0
89#define DMAMUX_CxCR_DMAREQ_ID_MASK 0xff
90
91/**@}*/
92
93/** @defgroup dmamux_csr CSR request line multiplexer interrupt channel status register
94@{*/
95
96/** DMAMUX_CSR_SOF Synchronization overrun event flag */
97#define DMAMUX_CSR_SOF(dma_channel) (1 << ((dma_channel) - 1))
98
99/**@}*/
100
101/** @defgroup dmamux_cfr CFR request line multiplexer interrupt clear flag register
102@{*/
103
104/** DMAMUX_CFR_CSOF Clear synchronization overrun event flag */
105#define DMAMUX_CFR_CSOF(dma_channel) (1 << ((dma_channel) - 1))
106
107/**@}*/
108
109/** @defgroup dmamux_rgxcr RGxCR DMA request generator channel x control register
110@{*/
111
112/** DMAMUX_RGxCR_GNBREQ GNBREQ Number (minus 1) of DMA requests to generate */
113#define DMAMUX_RGxCR_GNBREQ_SHIFT 19
114#define DMAMUX_RGxCR_GNBREQ_MASK 0x1f
115
116#define DMAMUX_RGxCR_GPOL_SHIFT 17
117#define DMAMUX_RGxCR_GPOL_MASK 0x03
118/** @defgroup dmamux_rgxcr_gpol GPOL Event Polarity
119* @brief DMA request generator trigger event type selection
120@{*/
121#define DMAMUX_RGxCR_GPOL_NO_EVENT 0
122#define DMAMUX_RGxCR_GPOL_RISING_EDGE 1
123#define DMAMUX_RGxCR_GPOL_FALLING_EDEG 2
124#define DMAMUX_RGxCR_GPOL_BOTH_EDGES 3
125/**@}*/
126
127/** DMAMUX_RGxCR_GE GE DMA request generator channel enable/disable */
128#define DMAMUX_RGxCR_GE (1 << 16)
129
130/** DMAMUX_RGxCR_OIE OIE Interrupt enable at trigger event overrun */
131#define DMAMUX_RGxCR_OIE (1 << 8)
132
133/** DMAMUX_RGxCR_SIG_ID SIG_ID DMA request trigger input selected */
134#define DMAMUX_RGxCR_SIG_ID_SHIFT 0
135#define DMAMUX_RGxCR_SIG_ID_MASK 0x1f
136
137/**@}*/
138
139/** @defgroup dmamux_rgsr RGSR DMA request generator interrupt status register
140@{*/
141
142/** DMAMUX_RGSR_OF Trigger OF event overrun flag */
143#define DMAMUX_RGSR_OF(rg_channel) (1 << ((rg_channel) - 1))
144
145/**@}*/
146
147/** @defgroup dmamux_rgcfr RGCFR DMA request generator clear flag register
148@{*/
149
150/** DMAMUX_RGCFR_COF COF Clear trigger event overrun flag */
151#define DMAMUX_RGCFR_COF(rg_channel) (1 << ((rg_channel) - 1))
152
153/**@}*/
154
155/* --- Generic values ---------------------------------------- */
156
157/** @defgroup dmamux_rg_channel DMAMUX Request Generator Channel Number
158@{*/
159#define DMAMUX_RG_CHANNEL1 1
160#define DMAMUX_RG_CHANNEL2 2
161#define DMAMUX_RG_CHANNEL3 3
162#define DMAMUX_RG_CHANNEL4 4
163/**@}*/
164
165/* --- function prototypes ------------------------------------------------- */
166
168
169void dmamux_reset_dma_channel(uint32_t dmamux, uint8_t channel);
170void dmamux_enable_dma_request_event_generation(uint32_t dmamux, uint8_t channel);
171void dmamux_disable_dma_request_event_generation(uint32_t dmamux, uint8_t channel);
172
173void dmamux_set_dma_channel_request(uint32_t dmamux, uint8_t channel, uint8_t request_id);
174uint8_t dmamux_get_dma_channel_request(uint32_t dmamux, uint8_t channel);
175
176void dmamux_enable_dma_request_sync(uint32_t dmamux, uint8_t channel);
177void dmamux_disable_dma_request_sync(uint32_t dmamux, uint8_t channel);
178
179void dmamux_set_dma_request_sync_input(uint32_t dmamux, uint8_t channel, uint8_t sync_id);
180void dmamux_set_dma_request_sync_pol(uint32_t dmamux, uint8_t channel, uint8_t polarity);
181void dmamux_set_dma_request_sync_nbreq(uint32_t dmamux, uint8_t channel, uint8_t nbreq);
182
183void dmamux_enable_dma_request_sync_overrun_interrupt(uint32_t dmamux, uint8_t channel);
184void dmamux_disable_dma_request_sync_overrun_interrupt(uint32_t dmamux, uint8_t channel);
185uint32_t dmamux_get_dma_request_sync_overrun(uint32_t dmamux, uint8_t channel);
186void dmamux_clear_dma_request_sync_overrun(uint32_t dmamux, uint8_t channel);
187
188void dmamux_reset_request_generator_channel(uint32_t dmamux, uint8_t rg_channel);
189void dmamux_enable_request_generator(uint32_t dmamux, uint8_t rg_channel);
190void dmamux_disable_request_generator(uint32_t dmamux, uint8_t rg_channel);
191
192void dmamux_set_request_generator_trigger(uint32_t dmamux, uint8_t rg_channel, uint8_t sig_id);
193void dmamux_set_request_generator_trigger_pol(uint32_t dmamux, uint8_t rg_channel, uint8_t polarity);
194void dmamux_set_request_generator_trigger_gnbreq(uint32_t dmamux, uint8_t rg_channel, uint8_t gnbreq);
195
196void dmamux_enable_request_generator_trigger_overrun_interrupt(uint32_t dmamux, uint8_t rg_channel);
197void dmamux_disable_request_generator_trigger_overrun_interrupt(uint32_t dmamux, uint8_t rg_channel);
198uint32_t dmamux_get_request_generator_trigger_overrun_interrupt(uint32_t dmamux, uint8_t rg_channel);
199void dmamux_clear_request_generator_trigger_overrun_interrupt(uint32_t dmamux, uint8_t rg_channel);
200
202
203/**@}*/
#define END_DECLS
Definition: common.h:34
#define BEGIN_DECLS
Definition: common.h:33
void dmamux_set_request_generator_trigger(uint32_t dmamux, uint8_t rg_channel, uint8_t sig_id)
DMAMUX Set Request Generator Input Trigger Signal.
Definition: dmamux.c:273
void dmamux_set_dma_request_sync_input(uint32_t dmamux, uint8_t channel, uint8_t sync_id)
DMAMUX Set DMA Request Synchronization Input.
Definition: dmamux.c:105
void dmamux_disable_dma_request_sync_overrun_interrupt(uint32_t dmamux, uint8_t channel)
DMAMUX Disable DMA Request Overrun Interrupt.
Definition: dmamux.c:192
void dmamux_enable_dma_request_sync(uint32_t dmamux, uint8_t channel)
DMAMUX Enable DMA Request Synchronization.
Definition: dmamux.c:141
void dmamux_disable_request_generator_trigger_overrun_interrupt(uint32_t dmamux, uint8_t rg_channel)
DMAMUX Disable Request Generator Trigger Overrun Interrupt.
Definition: dmamux.c:333
void dmamux_enable_request_generator_trigger_overrun_interrupt(uint32_t dmamux, uint8_t rg_channel)
DMAMUX Enable Request Generator Trigger Overrun Interrupt.
Definition: dmamux.c:322
void dmamux_enable_dma_request_sync_overrun_interrupt(uint32_t dmamux, uint8_t channel)
DMAMUX Enable DMA Request Overrun Interrupt.
Definition: dmamux.c:181
uint32_t dmamux_get_dma_request_sync_overrun(uint32_t dmamux, uint8_t channel)
DMAMUX Get DMA Request Synchronization Overrun Interrupt Flag.
Definition: dmamux.c:206
void dmamux_disable_request_generator(uint32_t dmamux, uint8_t rg_channel)
DMAMUX Disable Request Generator Channel.
Definition: dmamux.c:258
void dmamux_clear_request_generator_trigger_overrun_interrupt(uint32_t dmamux, uint8_t rg_channel)
DMAMUX Clear Request Generator Trigger Overrun Interrupt Flag.
Definition: dmamux.c:361
void dmamux_reset_dma_channel(uint32_t dmamux, uint8_t channel)
DMAMUX Reset DMA Channel.
Definition: dmamux.c:37
void dmamux_enable_dma_request_event_generation(uint32_t dmamux, uint8_t channel)
DMAMUX Enable DMA Request Event Generation.
Definition: dmamux.c:79
void dmamux_clear_dma_request_sync_overrun(uint32_t dmamux, uint8_t channel)
DMAMUX Clear DMA Request Synchronization Overrun Interrupt Flag.
Definition: dmamux.c:219
void dmamux_set_dma_channel_request(uint32_t dmamux, uint8_t channel, uint8_t request_id)
DMAMUX Set DMA Channel Request.
Definition: dmamux.c:53
uint8_t dmamux_get_dma_channel_request(uint32_t dmamux, uint8_t channel)
DMAMUX Get DMA Channel Request Selection.
Definition: dmamux.c:68
uint32_t dmamux_get_request_generator_trigger_overrun_interrupt(uint32_t dmamux, uint8_t rg_channel)
DMAMUX Get Request Generator Trigger Overrun Interrupt Flag.
Definition: dmamux.c:347
void dmamux_set_request_generator_trigger_gnbreq(uint32_t dmamux, uint8_t rg_channel, uint8_t gnbreq)
DMAMUX Set Request Generator Trigger GNBREQ.
Definition: dmamux.c:308
void dmamux_set_dma_request_sync_nbreq(uint32_t dmamux, uint8_t channel, uint8_t nbreq)
DMAMUX Set DMA Request NBREQ To Forward.
Definition: dmamux.c:167
void dmamux_disable_dma_request_sync(uint32_t dmamux, uint8_t channel)
DMAMUX Disable DMA Request Synchronization.
Definition: dmamux.c:152
void dmamux_enable_request_generator(uint32_t dmamux, uint8_t rg_channel)
DMAMUX Enable Request Generator Channel.
Definition: dmamux.c:247
void dmamux_set_dma_request_sync_pol(uint32_t dmamux, uint8_t channel, uint8_t polarity)
DMAMUX Set DMA Request Synchronization Event Polarity.
Definition: dmamux.c:123
void dmamux_reset_request_generator_channel(uint32_t dmamux, uint8_t rg_channel)
DMAMUX Reset Request Generator Channel.
Definition: dmamux.c:232
void dmamux_disable_dma_request_event_generation(uint32_t dmamux, uint8_t channel)
DMAMUX Disable DMA Request Event Generation.
Definition: dmamux.c:90
void dmamux_set_request_generator_trigger_pol(uint32_t dmamux, uint8_t rg_channel, uint8_t polarity)
DMAMUX Set Request Generator Trigger Polarity.
Definition: dmamux.c:290