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