Loading...
Searching...
No Matches
periph_conf.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2017 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
19#ifndef PERIPH_CONF_H
20#define PERIPH_CONF_H
21
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_i2c1_pb8_pb9.h"
35#include "cfg_rtt_default.h"
36#include "cfg_timer_tim2.h"
37#include "cfg_usb_otg_fs.h"
38#include "mii.h"
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
48static const dma_conf_t dma_config[] = {
49 { .stream = 4 }, /* DMA1 Stream 4 - USART3_TX */
50 { .stream = 14 }, /* DMA2 Stream 6 - USART6_TX */
51 { .stream = 6 }, /* DMA1 Stream 6 - USART2_TX */
52 { .stream = 10 }, /* DMA2 Stream 2 - SPI1_RX */
53 { .stream = 13 }, /* DMA2 Stream 5 - SPI1_TX */
54 { .stream = 11 }, /* DMA2 Stream 3 - SPI4_RX */
55 { .stream = 12 }, /* DMA2 Stream 4 - SPI4_TX */
56 { .stream = 8 }, /* DMA2 Stream 0 - ETH_TX */
57};
58
59#define DMA_0_ISR isr_dma1_stream4
60#define DMA_1_ISR isr_dma2_stream6
61#define DMA_2_ISR isr_dma1_stream6
62
63#define DMA_3_ISR isr_dma2_stream2
64#define DMA_4_ISR isr_dma2_stream5
65#define DMA_5_ISR isr_dma2_stream3
66#define DMA_6_ISR isr_dma2_stream4
67
68#define DMA_7_ISR isr_dma2_stream0
69
70#define DMA_NUMOF ARRAY_SIZE(dma_config)
77static const pwm_conf_t pwm_config[] = {
78 {
79 .dev = TIM1,
80 .rcc_mask = RCC_APB2ENR_TIM1EN,
81 .chan = { { .pin = GPIO_PIN(PORT_E, 9) /* D6 CN10-4 */, .cc_chan = 0},
82 { .pin = GPIO_PIN(PORT_E, 11) /* D5 CN10-6 */, .cc_chan = 1},
83 { .pin = GPIO_PIN(PORT_E, 13) /* D3 CN10-10 */, .cc_chan = 2},
84 { .pin = GPIO_PIN(PORT_E, 14) /* D38 CN10-28 */, .cc_chan = 3} },
85 .af = GPIO_AF1,
86 .bus = APB2
87 },
88 {
89 .dev = TIM4,
90 .rcc_mask = RCC_APB1ENR_TIM4EN,
91 .chan = { { .pin = GPIO_PIN(PORT_D, 12) /* D29 CN10-21 */, .cc_chan = 0},
92 { .pin = GPIO_PIN(PORT_D, 13) /* D28 CN10-19 */, .cc_chan = 1},
93 { .pin = GPIO_PIN(PORT_D, 14) /* D10 CN7-16 */, .cc_chan = 2},
94 { .pin = GPIO_PIN(PORT_D, 15) /* D9 CN7-18 */, .cc_chan = 3} },
95 .af = GPIO_AF2,
96 .bus = APB1
97 },
98};
99
100#define PWM_NUMOF ARRAY_SIZE(pwm_config)
107static const uart_conf_t uart_config[] = {
108 {
109 .dev = USART3,
110 .rcc_mask = RCC_APB1ENR_USART3EN,
111 .rx_pin = GPIO_PIN(PORT_D, 9),
112 .tx_pin = GPIO_PIN(PORT_D, 8),
113 .rx_af = GPIO_AF7,
114 .tx_af = GPIO_AF7,
115 .bus = APB1,
116 .irqn = USART3_IRQn,
117#ifdef MODULE_PERIPH_DMA
118 .dma = 0,
119 .dma_chan = 7
120#endif
121 },
122 {
123 .dev = USART6,
124 .rcc_mask = RCC_APB2ENR_USART6EN,
125 .rx_pin = GPIO_PIN(PORT_G, 9),
126 .tx_pin = GPIO_PIN(PORT_G, 14),
127 .rx_af = GPIO_AF8,
128 .tx_af = GPIO_AF8,
129 .bus = APB2,
130 .irqn = USART6_IRQn,
131#ifdef MODULE_PERIPH_DMA
132 .dma = 1,
133 .dma_chan = 5
134#endif
135 },
136 {
137 .dev = USART2,
138 .rcc_mask = RCC_APB1ENR_USART2EN,
139 .rx_pin = GPIO_PIN(PORT_D, 6),
140 .tx_pin = GPIO_PIN(PORT_D, 5),
141 .rx_af = GPIO_AF7,
142 .tx_af = GPIO_AF7,
143 .bus = APB1,
144 .irqn = USART2_IRQn,
145#ifdef MODULE_PERIPH_DMA
146 .dma = 2,
147 .dma_chan = 4
148#endif
149 }
150};
151
152#define UART_0_ISR (isr_usart3)
153#define UART_1_ISR (isr_usart6)
154#define UART_2_ISR (isr_usart2)
155
156#define UART_NUMOF ARRAY_SIZE(uart_config)
163static const spi_conf_t spi_config[] = {
164 {
165 .dev = SPI1,
166 /* PA7 is the default MOSI pin, as it is required for compatibility with
167 * Arduino(ish) shields. Sadly, it is also connected to the RMII_DV of
168 * Ethernet PHY. We work around this by remapping the MOSI to PB5 when
169 * the on-board Ethernet PHY is used.
170 */
171#ifdef MODULE_PERIPH_ETH
172 .mosi_pin = GPIO_PIN(PORT_B, 5),
173#else
174 .mosi_pin = GPIO_PIN(PORT_A, 7),
175#endif
176 .miso_pin = GPIO_PIN(PORT_A, 6),
177 .sclk_pin = GPIO_PIN(PORT_A, 5),
178 .cs_pin = SPI_CS_UNDEF,
179 .mosi_af = GPIO_AF5,
180 .miso_af = GPIO_AF5,
181 .sclk_af = GPIO_AF5,
182 .cs_af = GPIO_AF5,
183 .rccmask = RCC_APB2ENR_SPI1EN,
184 .apbbus = APB2,
185#ifdef MODULE_PERIPH_DMA
186 .tx_dma = 4,
187 .tx_dma_chan = 3,
188 .rx_dma = 3,
189 .rx_dma_chan = 3,
190#endif
191 },
192 {
193 .dev = SPI4,
194 .mosi_pin = GPIO_PIN(PORT_E, 6),
195 .miso_pin = GPIO_PIN(PORT_E, 5),
196 .sclk_pin = GPIO_PIN(PORT_E, 2),
197 .cs_pin = SPI_CS_UNDEF,
198 .mosi_af = GPIO_AF5,
199 .miso_af = GPIO_AF5,
200 .sclk_af = GPIO_AF5,
201 .cs_af = GPIO_AF5,
202 .rccmask = RCC_APB2ENR_SPI4EN,
203 .apbbus = APB2,
204#ifdef MODULE_PERIPH_DMA
205 .tx_dma = 6,
206 .tx_dma_chan = 5,
207 .rx_dma = 5,
208 .rx_dma_chan = 5,
209#endif
210 }
211};
212
213#define SPI_NUMOF ARRAY_SIZE(spi_config)
220static const eth_conf_t eth_config = {
221 .mode = RMII,
223 .dma = 7,
224 .dma_chan = 8,
225 .phy_addr = 0x00,
226 .pins = {
227 GPIO_PIN(PORT_G, 13),
228 GPIO_PIN(PORT_B, 13),
229 GPIO_PIN(PORT_G, 11),
230 GPIO_PIN(PORT_C, 4),
231 GPIO_PIN(PORT_C, 5),
232 GPIO_PIN(PORT_A, 7),
233 GPIO_PIN(PORT_C, 1),
234 GPIO_PIN(PORT_A, 2),
235 GPIO_PIN(PORT_A, 1),
236 }
237};
238
239#define ETH_DMA_ISR isr_dma2_stream0
240
243#ifdef __cplusplus
244}
245#endif
246
247#endif /* PERIPH_CONF_H */
@ PORT_B
port B
Definition periph_cpu.h:48
@ PORT_G
port G
Definition periph_cpu.h:53
@ PORT_C
port C
Definition periph_cpu.h:49
@ PORT_E
port E
Definition periph_cpu.h:51
@ PORT_A
port A
Definition periph_cpu.h:47
@ PORT_D
port D
Definition periph_cpu.h:50
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition periph_cpu.h:46
Common configuration for STM32 I2C.
Common configuration for STM32 Timer peripheral based on TIM2.
Common configuration for STM32 OTG FS peripheral.
@ RMII
Configuration for RMII.
Definition cpu_eth.h:37
@ GPIO_AF1
use alternate function 1
Definition cpu_gpio.h:103
@ GPIO_AF2
use alternate function 2
Definition cpu_gpio.h:104
@ GPIO_AF5
use alternate function 5
Definition cpu_gpio.h:107
@ GPIO_AF8
use alternate function 8
Definition cpu_gpio.h:111
@ GPIO_AF7
use alternate function 7
Definition cpu_gpio.h:109
#define SPI_CS_UNDEF
Define value for unused CS line.
Definition periph_cpu.h:363
@ APB1
Advanced Peripheral Bus 1
Definition periph_cpu.h:79
@ APB2
Advanced Peripheral Bus 2
Definition periph_cpu.h:80
#define MII_BMCR_FULL_DPLX
Set for full duplex.
Definition mii.h:69
#define MII_BMCR_SPEED_100
Set speed to 100 Mbps.
Definition mii.h:73
Interface definition for MII/RMII h.
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
Ethernet Peripheral configuration.
Definition cpu_eth.h:44
eth_mode_t mode
Select configuration mode.
Definition cpu_eth.h:45
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