@@ -181,20 +181,29 @@ public:
181
181
* @param[in] circularMode Transfer data in circular mode?
182
182
*/
183
183
static void
184
- configure(DataTransferDirection direction, MemoryDataSize memoryDataSize,
185
- PeripheralDataSize peripheralDataSize,
186
- MemoryIncrementMode memoryIncrement,
187
- PeripheralIncrementMode peripheralIncrement,
188
- Priority priority = Priority::Medium,
189
- CircularMode circularMode = CircularMode::Disabled)
184
+ configure(DataTransferDirection direction,
185
+ MemoryDataSize memoryDataSize,
186
+ PeripheralDataSize peripheralDataSize,
187
+ MemoryIncrementMode memoryIncrement,
188
+ PeripheralIncrementMode peripheralIncrement,
189
+ Priority priority = Priority::Medium,
190
+ CircularMode circularMode = CircularMode::Disabled
191
+ %% if doubleBuffer
192
+ , DoubleBufferMode doubleBufferMode = DoubleBufferMode::Disabled
193
+ %% endif
194
+ )
190
195
{
191
196
stop();
192
197
193
198
DMA_Channel_TypeDef *Base = (DMA_Channel_TypeDef *) CHANNEL_BASE;
194
199
Base->{{ cr }} = uint32_t(direction) | uint32_t(memoryDataSize) |
195
200
uint32_t(peripheralDataSize) | uint32_t(memoryIncrement) |
196
201
uint32_t(peripheralIncrement) | uint32_t(priority) |
197
- uint32_t(circularMode);
202
+ uint32_t(circularMode)
203
+ %% if doubleBuffer
204
+ | uint32_t(doubleBufferMode)
205
+ %% endif
206
+ ;
198
207
}
199
208
200
209
/**
@@ -232,6 +241,38 @@ public:
232
241
%% endif
233
242
}
234
243
244
+ %% if doubleBuffer
245
+ /**
246
+ * Set the secondary memory address of the DMA channel
247
+ *
248
+ * Only used in double buffer mode
249
+ *
250
+ * @param[in] address Source address
251
+ */
252
+ static void
253
+ setMemoryAddress2(uintptr_t address)
254
+ {
255
+ DMA_Channel_TypeDef *Base = (DMA_Channel_TypeDef *) CHANNEL_BASE;
256
+ %% if dmaType in ["stm32-stream-channel"]
257
+ Base->M1AR = address;
258
+ %% endif
259
+ }
260
+
261
+ /**
262
+ * Detect which buffer is currently in use
263
+ *
264
+ * Only meaningful in double buffer mode
265
+ */
266
+ static bool
267
+ isPrimaryBufferActive()
268
+ {
269
+ DMA_Channel_TypeDef *Base = (DMA_Channel_TypeDef *) CHANNEL_BASE;
270
+ %% if dmaType in ["stm32-stream-channel"]
271
+ return (Base->CR & DMA_SxCR_CT);
272
+ %% endif
273
+ }
274
+ %% endif
275
+
235
276
/**
236
277
* Set the peripheral address of the DMA channel
237
278
*
0 commit comments