Skip to content

Commit 0b6bccb

Browse files
aabadieVincent Dupont
authored andcommitted
boards/iotlab-m3: configure and use DMA
Used with UART and SPI peripheral
1 parent 9ecf121 commit 0b6bccb

File tree

4 files changed

+42
-3
lines changed

4 files changed

+42
-3
lines changed

boards/common/iotlab/include/periph_conf_common.h

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,27 @@ extern "C" {
6868
#define ADC_NUMOF (3)
6969
/** @} */
7070

71+
/**
72+
* @name DMA streams configuration
73+
* @{
74+
*/
75+
#ifdef MODULE_PERIPH_DMA
76+
static const dma_conf_t dma_config[] = {
77+
{ .stream = 1 }, /* DMA1 Channel 2 - SPI1_RX */
78+
{ .stream = 2 }, /* DMA1 Channel 3 - SPI1_TX */
79+
{ .stream = 3 }, /* DMA1 Channel 4 - USART1_TX */
80+
{ .stream = 5 }, /* DMA1 Channel 6 - USART2_TX */
81+
};
82+
83+
#define DMA_0_ISR isr_dma1_channel2
84+
#define DMA_1_ISR isr_dma1_channel3
85+
#define DMA_2_ISR isr_dma1_channel4
86+
#define DMA_3_ISR isr_dma1_channel6
87+
88+
#define DMA_NUMOF (sizeof(dma_config) / sizeof(dma_config[0]))
89+
#endif
90+
/** @} */
91+
7192
/**
7293
* @name Timer configuration
7394
* @{
@@ -106,15 +127,23 @@ static const uart_conf_t uart_config[] = {
106127
.rx_pin = GPIO_PIN(PORT_A, 10),
107128
.tx_pin = GPIO_PIN(PORT_A, 9),
108129
.bus = APB2,
109-
.irqn = USART1_IRQn
130+
.irqn = USART1_IRQn,
131+
#ifdef MODULE_PERIPH_DMA
132+
.dma = 2,
133+
.dma_chan = 2
134+
#endif
110135
},
111136
{
112137
.dev = USART2,
113138
.rcc_mask = RCC_APB1ENR_USART2EN,
114139
.rx_pin = GPIO_PIN(PORT_A, 3),
115140
.tx_pin = GPIO_PIN(PORT_A, 2),
116141
.bus = APB1,
117-
.irqn = USART2_IRQn
142+
.irqn = USART2_IRQn,
143+
#ifdef MODULE_PERIPH_DMA
144+
.dma = 3,
145+
.dma_chan = 2
146+
#endif
118147
}
119148
};
120149

boards/iotlab-m3/Makefile.dep

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
include $(RIOTBOARD)/common/iotlab/Makefile.dep
22

3+
FEATURES_REQUIRED += periph_dma
4+
35
ifneq (,$(filter saul_default,$(USEMODULE)))
46
USEMODULE += isl29020
57
USEMODULE += lps331ap

boards/iotlab-m3/Makefile.features

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
include $(RIOTBOARD)/common/iotlab/Makefile.features
22

3+
FEATURES_PROVIDED += periph_dma
4+
35
include $(RIOTCPU)/stm32f1/Makefile.features

boards/iotlab-m3/include/periph_conf.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@ static const spi_conf_t spi_config[] = {
3939
.sclk_pin = GPIO_PIN(PORT_A, 5),
4040
.cs_pin = GPIO_UNDEF,
4141
.rccmask = RCC_APB2ENR_SPI1EN,
42-
.apbbus = APB2
42+
.apbbus = APB2,
43+
#ifdef MODULE_PERIPH_DMA
44+
.tx_dma = 1,
45+
.tx_dma_chan = 1,
46+
.rx_dma = 0,
47+
.rx_dma_chan = 1,
48+
#endif
4349
}
4450
};
4551

0 commit comments

Comments
 (0)