From 962d81b65298076ac2d2afcfccab79dca5a8826d Mon Sep 17 00:00:00 2001 From: Vincent Dupont <vincent@otakeys.com> Date: Wed, 23 May 2018 19:08:37 +0200 Subject: [PATCH] boards/nucleo-f091rc: configure and use DMA --- boards/nucleo-f091rc/Makefile.dep | 2 ++ boards/nucleo-f091rc/Makefile.features | 1 + boards/nucleo-f091rc/include/periph_conf.h | 42 +++++++++++++++++++--- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/boards/nucleo-f091rc/Makefile.dep b/boards/nucleo-f091rc/Makefile.dep index 7294858272..a7e11adb3c 100644 --- a/boards/nucleo-f091rc/Makefile.dep +++ b/boards/nucleo-f091rc/Makefile.dep @@ -1 +1,3 @@ +FEATURES_REQUIRED += periph_dma + include $(RIOTBOARD)/common/nucleo/Makefile.dep diff --git a/boards/nucleo-f091rc/Makefile.features b/boards/nucleo-f091rc/Makefile.features index 2597c39f40..95ac5acc7a 100644 --- a/boards/nucleo-f091rc/Makefile.features +++ b/boards/nucleo-f091rc/Makefile.features @@ -1,5 +1,6 @@ # Put defined MCU peripherals here (in alphabetical order) FEATURES_PROVIDED += periph_adc +FEATURES_PROVIDED += periph_dma FEATURES_PROVIDED += periph_i2c FEATURES_PROVIDED += periph_pwm FEATURES_PROVIDED += periph_rtc diff --git a/boards/nucleo-f091rc/include/periph_conf.h b/boards/nucleo-f091rc/include/periph_conf.h index 60c864f953..9938038ac8 100644 --- a/boards/nucleo-f091rc/include/periph_conf.h +++ b/boards/nucleo-f091rc/include/periph_conf.h @@ -56,6 +56,22 @@ extern "C" { #define CLOCK_PLL_MUL (6) /** @} */ +/** + * @name DMA streams configuration + * @{ + */ +#ifdef MODULE_PERIPH_DMA +static const dma_conf_t dma_config[] = { + { .stream = 1 }, + { .stream = 2 }, +}; + +#define DMA_SHARED_ISR_0 isr_dma1_ch2_3_dma2_ch1_2 +#define DMA_SHARED_ISR_0_STREAMS { 0, 1 } /* Indexes 0 and 1 of dma_config share the same isr */ + +#define DMA_NUMOF (sizeof(dma_config) / sizeof(dma_config[0])) +#endif + /** * @name Timer configuration * @{ @@ -88,7 +104,11 @@ static const uart_conf_t uart_config[] = { .rx_af = GPIO_AF1, .tx_af = GPIO_AF1, .bus = APB1, - .irqn = USART2_IRQn + .irqn = USART2_IRQn, +#ifdef MODULE_PERIPH_DMA + .dma = 0, + .dma_chan = 0x9, +#endif }, { .dev = USART1, @@ -98,7 +118,11 @@ static const uart_conf_t uart_config[] = { .rx_af = GPIO_AF1, .tx_af = GPIO_AF1, .bus = APB2, - .irqn = USART1_IRQn + .irqn = USART1_IRQn, +#ifdef MODULE_PERIPH_DMA + .dma = 0, + .dma_chan = 0x8, +#endif }, { .dev = USART3, @@ -108,7 +132,11 @@ static const uart_conf_t uart_config[] = { .rx_af = GPIO_AF1, .tx_af = GPIO_AF1, .bus = APB1, - .irqn = USART3_8_IRQn + .irqn = USART3_8_IRQn, +#ifdef MODULE_PERIPH_DMA + .dma = 0, + .dma_chan = 0xA, +#endif }, }; @@ -153,7 +181,13 @@ static const spi_conf_t spi_config[] = { .cs_pin = GPIO_PIN(PORT_B, 6), .af = GPIO_AF0, .rccmask = RCC_APB2ENR_SPI1EN, - .apbbus = APB2 + .apbbus = APB2, +#ifdef MODULE_PERIPH_DMA + .tx_dma = 1, + .tx_dma_chan = 0, + .rx_dma = 0, + .rx_dma_chan = 0, +#endif } }; -- GitLab