From 294711d9ba4be37e5b32a37b1b3d8c32b14e6277 Mon Sep 17 00:00:00 2001
From: Alexandre Abadie <alexandre.abadie@inria.fr>
Date: Mon, 7 Jan 2019 14:17:25 +0100
Subject: [PATCH] boards/nucleo-f767zi: configure and use DMA

---
 boards/nucleo-f767zi/Makefile.dep          |  2 ++
 boards/nucleo-f767zi/Makefile.features     |  1 +
 boards/nucleo-f767zi/include/periph_conf.h | 38 +++++++++++++++-------
 3 files changed, 30 insertions(+), 11 deletions(-)

diff --git a/boards/nucleo-f767zi/Makefile.dep b/boards/nucleo-f767zi/Makefile.dep
index 7294858272..a7e11adb3c 100644
--- a/boards/nucleo-f767zi/Makefile.dep
+++ b/boards/nucleo-f767zi/Makefile.dep
@@ -1 +1,3 @@
+FEATURES_REQUIRED += periph_dma
+
 include $(RIOTBOARD)/common/nucleo/Makefile.dep
diff --git a/boards/nucleo-f767zi/Makefile.features b/boards/nucleo-f767zi/Makefile.features
index 593b57950b..bfff4d4a86 100644
--- a/boards/nucleo-f767zi/Makefile.features
+++ b/boards/nucleo-f767zi/Makefile.features
@@ -1,4 +1,5 @@
 # Put defined MCU peripherals here (in alphabetical order)
+FEATURES_PROVIDED += periph_dma
 FEATURES_PROVIDED += periph_i2c
 FEATURES_PROVIDED += periph_rtc
 FEATURES_PROVIDED += periph_timer
diff --git a/boards/nucleo-f767zi/include/periph_conf.h b/boards/nucleo-f767zi/include/periph_conf.h
index c40add7f5a..1da0d7c9d1 100644
--- a/boards/nucleo-f767zi/include/periph_conf.h
+++ b/boards/nucleo-f767zi/include/periph_conf.h
@@ -59,6 +59,25 @@ extern "C" {
 #define CLOCK_PLL_Q          (9)
 /** @} */
 
+/**
+ * @name    DMA streams configuration
+ * @{
+ */
+#ifdef MODULE_PERIPH_DMA
+static const dma_conf_t dma_config[] = {
+    { .stream = 4 },    /* DMA1 Stream 4 - USART3_TX */
+    { .stream = 14 },   /* DMA2 Stream 6 - USART6_TX */
+    { .stream = 6 },    /* DMA1 Stream 6 - USART2_TX */
+};
+
+#define DMA_0_ISR  isr_dma1_stream4
+#define DMA_1_ISR  isr_dma2_stream6
+#define DMA_2_ISR  isr_dma1_stream6
+
+#define DMA_NUMOF           (sizeof(dma_config) / sizeof(dma_config[0]))
+#endif
+/** @} */
+
 /**
  * @name    Timer configuration
  * @{
@@ -92,9 +111,9 @@ static const uart_conf_t uart_config[] = {
         .tx_af      = GPIO_AF7,
         .bus        = APB1,
         .irqn       = USART3_IRQn,
-#ifdef UART_USE_DMA
-        .dma_stream = 6,
-        .dma_chan   = 4
+#ifdef MODULE_PERIPH_DMA
+        .dma        = 0,
+        .dma_chan   = 7
 #endif
     },
     {
@@ -106,9 +125,9 @@ static const uart_conf_t uart_config[] = {
         .tx_af      = GPIO_AF8,
         .bus        = APB2,
         .irqn       = USART6_IRQn,
-#ifdef UART_USE_DMA
-        .dma_stream = 5,
-        .dma_chan   = 4
+#ifdef MODULE_PERIPH_DMA
+        .dma        = 1,
+        .dma_chan   = 5
 #endif
     },
     {
@@ -120,19 +139,16 @@ static const uart_conf_t uart_config[] = {
         .tx_af      = GPIO_AF7,
         .bus        = APB1,
         .irqn       = USART2_IRQn,
-#ifdef UART_USE_DMA
-        .dma_stream = 4,
+#ifdef MODULE_PERIPH_DMA
+        .dma        = 2,
         .dma_chan   = 4
 #endif
     }
 };
 
 #define UART_0_ISR          (isr_usart3)
-#define UART_0_DMA_ISR      (isr_dma1_stream6)
 #define UART_1_ISR          (isr_usart6)
-#define UART_1_DMA_ISR      (isr_dma1_stream5)
 #define UART_2_ISR          (isr_usart2)
-#define UART_2_DMA_ISR      (isr_dma1_stream4)
 
 #define UART_NUMOF          (sizeof(uart_config) / sizeof(uart_config[0]))
 /** @} */
-- 
GitLab