Skip to content
Snippets Groups Projects
Commit 08a85fbf authored by Vincent Dupont's avatar Vincent Dupont
Browse files

boards/b-l072z-lrwan1: configure and use DMA

parent 962d81b6
No related branches found
No related tags found
No related merge requests found
FEATURES_REQUIRED += periph_dma
ifneq (,$(filter netdev_default,$(USEMODULE))) ifneq (,$(filter netdev_default,$(USEMODULE)))
USEMODULE += sx1276 USEMODULE += sx1276
endif endif
......
# Put defined MCU peripherals here (in alphabetical order) # Put defined MCU peripherals here (in alphabetical order)
FEATURES_PROVIDED += periph_dma
FEATURES_PROVIDED += periph_i2c FEATURES_PROVIDED += periph_i2c
FEATURES_PROVIDED += periph_rtc FEATURES_PROVIDED += periph_rtc
FEATURES_PROVIDED += periph_spi FEATURES_PROVIDED += periph_spi
......
...@@ -49,6 +49,28 @@ extern "C" { ...@@ -49,6 +49,28 @@ extern "C" {
#define CLOCK_APB1 (CLOCK_CORECLOCK / 1) #define CLOCK_APB1 (CLOCK_CORECLOCK / 1)
/** @} */ /** @} */
/**
* @name DMA streams configuration
* @{
*/
#ifdef MODULE_PERIPH_DMA
static const dma_conf_t dma_config[] = {
{ .stream = 1 }, /* channel 2 */
{ .stream = 2 }, /* channel 3 */
{ .stream = 3 }, /* channel 4 */
{ .stream = 4 }, /* channel 5 */
{ .stream = 5 }, /* channel 6 */
};
#define DMA_SHARED_ISR_0 isr_dma1_channel2_3
#define DMA_SHARED_ISR_0_STREAMS { 0, 1 } /* Indexes 0 and 1 of dma_config share the same isr */
#define DMA_SHARED_ISR_1 isr_dma1_channel4_5_6_7
#define DMA_SHARED_ISR_1_STREAMS { 2, 3, 4 } /* Indexes 2, 3 and 4 of dma_config share the same isr */
#define DMA_NUMOF (sizeof(dma_config) / sizeof(dma_config[0]))
#endif
/** @} */
/** /**
* @name Timer configuration * @name Timer configuration
* @{ * @{
...@@ -84,6 +106,10 @@ static const uart_conf_t uart_config[] = { ...@@ -84,6 +106,10 @@ static const uart_conf_t uart_config[] = {
.irqn = USART2_IRQn, .irqn = USART2_IRQn,
.type = STM32_USART, .type = STM32_USART,
.clk_src = 0, /* Use APB clock */ .clk_src = 0, /* Use APB clock */
#ifdef MODULE_PERIPH_DMA
.dma = 2,
.dma_chan = 4,
#endif
}, },
{ {
.dev = USART1, .dev = USART1,
...@@ -96,6 +122,10 @@ static const uart_conf_t uart_config[] = { ...@@ -96,6 +122,10 @@ static const uart_conf_t uart_config[] = {
.irqn = USART1_IRQn, .irqn = USART1_IRQn,
.type = STM32_USART, .type = STM32_USART,
.clk_src = 0, /* Use APB clock */ .clk_src = 0, /* Use APB clock */
#ifdef MODULE_PERIPH_DMA
.dma = 0,
.dma_chan = 3,
#endif
}, },
}; };
...@@ -138,7 +168,13 @@ static const spi_conf_t spi_config[] = { ...@@ -138,7 +168,13 @@ static const spi_conf_t spi_config[] = {
.cs_pin = GPIO_UNDEF, .cs_pin = GPIO_UNDEF,
.af = GPIO_AF0, .af = GPIO_AF0,
.rccmask = RCC_APB1ENR_SPI2EN, .rccmask = RCC_APB1ENR_SPI2EN,
.apbbus = APB1 .apbbus = APB1,
#ifdef MODULE_PERIPH_DMA
.tx_dma = 3,
.tx_dma_chan = 2,
.rx_dma = 2,
.rx_dma_chan = 2,
#endif
}, },
{ {
.dev = SPI1, /* connected to SX1276 */ .dev = SPI1, /* connected to SX1276 */
...@@ -148,7 +184,13 @@ static const spi_conf_t spi_config[] = { ...@@ -148,7 +184,13 @@ static const spi_conf_t spi_config[] = {
.cs_pin = GPIO_UNDEF, .cs_pin = GPIO_UNDEF,
.af = GPIO_AF0, .af = GPIO_AF0,
.rccmask = RCC_APB2ENR_SPI1EN, .rccmask = RCC_APB2ENR_SPI1EN,
.apbbus = APB2 .apbbus = APB2,
#ifdef MODULE_PERIPH_DMA
.tx_dma = 1,
.tx_dma_chan = 1,
.rx_dma = 0,
.rx_dma_chan = 1,
#endif
}, },
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment