2
2
* Copyright (c) 2014, Kevin Läufer
3
3
* Copyright (c) 2014-2017, Niklas Hauser
4
4
* Copyright (c) 2020, Mike Wolfram
5
+ * Copyright (c) 2021, Raphael Lehmann
5
6
*
6
7
* This file is part of the modm project.
7
8
*
15
16
#define MODM_STM32_DMA_BASE_HPP
16
17
17
18
#include <stdint.h>
19
+ #include <cstddef>
20
+
18
21
#include "../device.hpp"
19
22
20
23
#include <modm/architecture/interface/assert.hpp>
23
26
24
27
%% if target["family"] == "f4"
25
28
%% set reg_prefix = "DMA_SxCR"
26
- %% elif target["family"] in ["f3 ", "l4 "]
29
+ %% elif dmaType in ["stm32-channel-request ", "stm32-channel "]
27
30
%% set reg_prefix = "DMA_CCR"
28
31
%% endif
29
32
@@ -81,7 +84,7 @@ public:
81
84
Dma = 0,
82
85
Peripheral = DMA_SxCR_PFCTRL, ///< the peripheral is the flow controller
83
86
};
84
- %% elif target["family"] in ["f3 ", "l4 "]
87
+ %% elif dmaType in ["stm32-channel-request ", "stm32-channel "]
85
88
%% set channel_count = namespace(max_channels = 0)
86
89
%% for controller in dmaController
87
90
%% if channel_count.max_channels < controller.channels
@@ -96,7 +99,7 @@ public:
96
99
%% endfor
97
100
};
98
101
99
- %% if target["family"] == "l4"
102
+ %% if dmaType in ["stm32-channel-request"]
100
103
%% set request_count = namespace(max_requests = 0)
101
104
%% for channels in dma["channels"]
102
105
%% for channel in channels.channel
@@ -114,6 +117,14 @@ public:
114
117
Request{{ request }}{% if request == 0 %} = 0{% endif %},
115
118
%% endfor
116
119
};
120
+ %% else
121
+ enum class
122
+ Request
123
+ {
124
+ // Nothing to see here. This controller has no request mux, instead
125
+ // all requests are OR-ed together.
126
+ Any
127
+ };
117
128
%% endif
118
129
%% endif
119
130
@@ -181,7 +192,7 @@ public:
181
192
MemoryToPeripheral = DMA_SxCR_DIR_0,
182
193
/// Source: DMA_SxPAR; Sink: DMA_SxM0AR
183
194
MemoryToMemory = DMA_SxCR_DIR_1,
184
- %% elif target["family"] in ["f3 ", "l4 "]
195
+ %% elif dmaType in ["stm32-channel-request ", "stm32-channel "]
185
196
/// Source: DMA_CPARx; Sink: DMA_CMARx
186
197
PeripheralToMemory = 0,
187
198
/// Source: DMA_CMARx; Sink: DMA_CPARx
@@ -219,7 +230,7 @@ protected:
219
230
DMA_SxCR_PL_1 | DMA_SxCR_PL_0 | // Priority
220
231
DMA_SxCR_CIRC | // CircularMode
221
232
DMA_SxCR_PFCTRL; // FlowControl
222
- %% elif target["family"] in ["f3 ", "l4 "]
233
+ %% elif dmaType in ["stm32-channel-request ", "stm32-channel "]
223
234
static constexpr uint32_t memoryMask =
224
235
DMA_CCR_MSIZE_0 | DMA_CCR_MSIZE_1 | // MemoryDataSize
225
236
DMA_CCR_MINC | // MemoryIncrementMode
@@ -248,13 +259,15 @@ protected:
248
259
struct Nvic;
249
260
};
250
261
251
- %% for channels in dma["channels"]
262
+ %% for instance, irqs in irqList.items()
252
263
template <>
253
- struct DmaBase::Nvic<{{ channels. instance }}>
264
+ struct DmaBase::Nvic<{{ instance }}>
254
265
{
255
266
static constexpr IRQn_Type DmaIrqs[] {
256
- %% for channel in channels.channel
257
- DMA{{ channels.instance }}_Channel{{ channel.position }}_IRQn,
267
+ %% for channels in irqs
268
+ %% for i in range(channels | length)
269
+ DMA{{ instance }}_Channel{{ channels | join("_") }}_IRQn,
270
+ %% endfor
258
271
%% endfor
259
272
};
260
273
};
0 commit comments