@@ -181,20 +181,29 @@ public:
181181 * @param[in] circularMode Transfer data in circular mode?
182182 */
183183 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+ )
190195 {
191196 stop();
192197
193198 DMA_Channel_TypeDef *Base = (DMA_Channel_TypeDef *) CHANNEL_BASE;
194199 Base->{{ cr }} = uint32_t(direction) | uint32_t(memoryDataSize) |
195200 uint32_t(peripheralDataSize) | uint32_t(memoryIncrement) |
196201 uint32_t(peripheralIncrement) | uint32_t(priority) |
197- uint32_t(circularMode);
202+ uint32_t(circularMode)
203+ %% if doubleBuffer
204+ | uint32_t(doubleBufferMode)
205+ %% endif
206+ ;
198207 }
199208
200209 /**
@@ -232,6 +241,38 @@ public:
232241%% endif
233242 }
234243
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+
235276 /**
236277 * Set the peripheral address of the DMA channel
237278 *
0 commit comments