periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Freie Universität Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
20 #ifndef PERIPH_CONF_H
21 #define PERIPH_CONF_H
22 
23 /* This board provides an LSE */
24 #ifndef CONFIG_BOARD_HAS_LSE
25 #define CONFIG_BOARD_HAS_LSE 1
26 #endif
27 
28 /* This board provides an HSE */
29 #ifndef CONFIG_BOARD_HAS_HSE
30 #define CONFIG_BOARD_HAS_HSE 1
31 #endif
32 
33 #include "periph_cpu.h"
34 #include "clk_conf.h"
35 #include "cfg_timer_tim2.h"
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
51 static const adc_conf_t adc_config[] = {
52  { .pin = GPIO_PIN(PORT_A, 0), .dev = 0, .chan = 1 }, /* ADC1_IN1, fast */
53  { .pin = GPIO_PIN(PORT_A, 1), .dev = 0, .chan = 2 }, /* ADC1_IN2, fast */
54  { .pin = GPIO_PIN(PORT_A, 4), .dev = 1, .chan = 1 }, /* ADC2_IN1, fast */
55  { .pin = GPIO_PIN(PORT_B, 0), .dev = 0, .chan = 11 }, /* ADC1_IN11, slow */
56  { .pin = GPIO_PIN(PORT_C, 1), .dev = 1, .chan = 7 }, /* ADC12_IN7, slow */
57  { .pin = GPIO_PIN(PORT_C, 0), .dev = 1, .chan = 6 }, /* ADC12_IN6, slow */
58  { .pin = GPIO_UNDEF, .dev = 0, .chan = 17 }, /* VBAT */
59 };
60 
61 #define VBAT_ADC ADC_LINE(6)
62 #define ADC_NUMOF ARRAY_SIZE(adc_config)
69 static const dma_conf_t dma_config[] = {
70  { .stream = 1 }, /* DMA1 Channel 2 - SPI1_RX | USART3_TX */
71  { .stream = 2 }, /* DMA1 Channel 3 - SPI1_TX */
72  { .stream = 3 }, /* DMA1 Channel 4 - USART1_TX */
73  { .stream = 6 }, /* DMA1 Channel 7 - USART2_TX */
74 };
75 
76 #define DMA_0_ISR isr_dma1_channel2
77 #define DMA_1_ISR isr_dma1_channel3
78 #define DMA_2_ISR isr_dma1_channel4
79 #define DMA_3_ISR isr_dma1_channel7
80 #define DMA_NUMOF ARRAY_SIZE(dma_config)
87 static const uart_conf_t uart_config[] = {
88  {
89  .dev = USART2,
90  .rcc_mask = RCC_APB1ENR_USART2EN,
91  .rx_pin = GPIO_PIN(PORT_A, 3),
92  .tx_pin = GPIO_PIN(PORT_A, 2),
93  .rx_af = GPIO_AF7,
94  .tx_af = GPIO_AF7,
95  .bus = APB1,
96  .irqn = USART2_IRQn,
97 #ifdef MODULE_PERIPH_DMA
98  .dma = 3,
99  .dma_chan = DMA_CHAN_CONFIG_UNSUPPORTED
100 #endif
101  },
102  {
103  .dev = USART1,
104  .rcc_mask = RCC_APB2ENR_USART1EN,
105  .rx_pin = GPIO_PIN(PORT_A, 10),
106  .tx_pin = GPIO_PIN(PORT_A, 9),
107  .rx_af = GPIO_AF7,
108  .tx_af = GPIO_AF7,
109  .bus = APB2,
110  .irqn = USART1_IRQn,
111 #ifdef MODULE_PERIPH_DMA
112  .dma = 2,
113  .dma_chan = DMA_CHAN_CONFIG_UNSUPPORTED
114 #endif
115  },
116 /* SPI1 RX and USART3 are sharing the same DMA channel, so disable the
117  * third UART when both SPI and DMA features are enabled. */
118 #if !defined(MODULE_PERIPH_SPI) || !defined(MODULE_PERIPH_DMA)
119  {
120  .dev = USART3,
121  .rcc_mask = RCC_APB1ENR_USART3EN,
122  .rx_pin = GPIO_PIN(PORT_B, 11),
123  .tx_pin = GPIO_PIN(PORT_B, 10),
124  .rx_af = GPIO_AF7,
125  .tx_af = GPIO_AF7,
126  .bus = APB1,
127  .irqn = USART3_IRQn,
128 #ifdef MODULE_PERIPH_DMA
129  .dma = 0,
130  .dma_chan = DMA_CHAN_CONFIG_UNSUPPORTED
131 #endif
132  }
133 #endif /* !defined(MODULE_PERIPH_SPI) || !defined(MODULE_PERIPH_DMA) */
134 };
135 
136 #define UART_0_ISR (isr_usart2)
137 #define UART_1_ISR (isr_usart1)
138 #define UART_2_ISR (isr_usart3)
139 
140 #define UART_NUMOF ARRAY_SIZE(uart_config)
147 static const pwm_conf_t pwm_config[] = {
148  {
149  .dev = TIM3,
150  .rcc_mask = RCC_APB1ENR_TIM3EN,
151  .chan = { { .pin = GPIO_PIN(PORT_C, 6), .cc_chan = 0 },
152  { .pin = GPIO_PIN(PORT_C, 7), .cc_chan = 1 },
153  { .pin = GPIO_PIN(PORT_C, 8), .cc_chan = 2 },
154  { .pin = GPIO_PIN(PORT_C, 9), .cc_chan = 3 } },
155  .af = GPIO_AF2,
156  .bus = APB1
157  }
158 };
159 
160 #define PWM_NUMOF ARRAY_SIZE(pwm_config)
167 static const spi_conf_t spi_config[] = {
168  {
169  .dev = SPI1,
170  .mosi_pin = GPIO_PIN(PORT_A, 7),
171  .miso_pin = GPIO_PIN(PORT_A, 6),
172  .sclk_pin = GPIO_PIN(PORT_A, 5),
173  .cs_pin = GPIO_UNDEF,
174  .mosi_af = GPIO_AF5,
175  .miso_af = GPIO_AF5,
176  .sclk_af = GPIO_AF5,
177  .cs_af = GPIO_AF5,
178  .rccmask = RCC_APB2ENR_SPI1EN,
179  .apbbus = APB2,
180 #ifdef MODULE_PERIPH_DMA
181  .tx_dma = 1,
182  .tx_dma_chan = DMA_CHAN_CONFIG_UNSUPPORTED,
183  .rx_dma = 0,
184  .rx_dma_chan = DMA_CHAN_CONFIG_UNSUPPORTED
185 #endif
186  }
187 };
188 
189 #define SPI_NUMOF ARRAY_SIZE(spi_config)
192 #ifdef __cplusplus
193 }
194 #endif
195 
196 #endif /* PERIPH_CONF_H */
@ PORT_B
port B
Definition: periph_cpu.h:48
@ PORT_C
port C
Definition: periph_cpu.h:49
@ PORT_A
port A
Definition: periph_cpu.h:47
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition: periph_cpu.h:46
#define GPIO_UNDEF
Definition of a fitting UNDEF value.
static const uart_conf_t uart_config[]
UART configuration.
Definition: periph_conf.h:39
static const spi_conf_t spi_config[]
SPI configuration.
Definition: periph_conf.h:97
static const adc_conf_t adc_config[]
ADC configuration.
Definition: periph_conf.h:251
static const pwm_conf_t pwm_config[]
Actual PWM configuration.
Definition: periph_conf.h:222
Common configuration for STM32 Timer peripheral based on TIM2.
#define DMA_CHAN_CONFIG_UNSUPPORTED
DMA channel/trigger configuration for DMA peripherals without channel/trigger filtering such as the s...
Definition: cpu_dma.h:96
@ GPIO_AF2
use alternate function 2
Definition: cpu_gpio.h:104
@ GPIO_AF5
use alternate function 5
Definition: cpu_gpio.h:107
@ GPIO_AF7
use alternate function 7
Definition: cpu_gpio.h:109
@ APB1
Advanced Peripheral Bus 1
Definition: periph_cpu.h:79
@ APB2
Advanced Peripheral Bus 2
Definition: periph_cpu.h:80
ADC device configuration.
Definition: periph_cpu.h:379
gpio_t pin
pin connected to the channel
Definition: periph_cpu.h:288
DMA configuration.
Definition: cpu_dma.h:32
int stream
DMA stream on stm32f2/4/7, channel on others STM32F2/4/7:
Definition: cpu_dma.h:55
PWM device configuration.
mini_timer_t * dev
Timer used.
SPI device configuration.
Definition: periph_cpu.h:337
SPI_t * dev
pointer to the used SPI device
Definition: periph_cpu.h:338
UART device configuration.
Definition: periph_cpu.h:218
USART_t * dev
pointer to the used UART device
Definition: periph_cpu.h:219