periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Inria
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 
21 /* This board provides an LSE */
22 #ifndef CONFIG_BOARD_HAS_LSE
23 #define CONFIG_BOARD_HAS_LSE 1
24 #endif
25 
26 /* This board provides an HSE */
27 #ifndef CONFIG_BOARD_HAS_HSE
28 #define CONFIG_BOARD_HAS_HSE 1
29 #endif
30 
31 #include "periph_cpu.h"
32 #include "clk_conf.h"
33 #include "cfg_i2c1_pb8_pb9.h"
34 #include "cfg_rtt_default.h"
35 #include "cfg_timer_tim2.h"
36 #include "cfg_usb_otg_fs.h"
37 #include "mii.h"
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
47 static const dma_conf_t dma_config[] = {
48  { .stream = 4 }, /* DMA1 Stream 4 - USART3_TX */
49  { .stream = 14 }, /* DMA2 Stream 6 - USART6_TX */
50  { .stream = 6 }, /* DMA1 Stream 6 - USART2_TX */
51  { .stream = 8 }, /* DMA2 Stream 0 - ETH_TX */
52 };
53 
54 #define DMA_0_ISR isr_dma1_stream4
55 #define DMA_1_ISR isr_dma2_stream6
56 #define DMA_2_ISR isr_dma1_stream6
57 #define DMA_3_ISR isr_dma2_stream0
58 
59 #define DMA_NUMOF ARRAY_SIZE(dma_config)
66 static const uart_conf_t uart_config[] = {
67  {
68  .dev = USART3,
69  .rcc_mask = RCC_APB1ENR_USART3EN,
70  .rx_pin = GPIO_PIN(PORT_D, 9),
71  .tx_pin = GPIO_PIN(PORT_D, 8),
72  .rx_af = GPIO_AF7,
73  .tx_af = GPIO_AF7,
74  .bus = APB1,
75  .irqn = USART3_IRQn,
76 #ifdef MODULE_PERIPH_DMA
77  .dma = 0,
78  .dma_chan = 7
79 #endif
80  },
81  {
82  .dev = USART6,
83  .rcc_mask = RCC_APB2ENR_USART6EN,
84  .rx_pin = GPIO_PIN(PORT_G, 9),
85  .tx_pin = GPIO_PIN(PORT_G, 14),
86  .rx_af = GPIO_AF8,
87  .tx_af = GPIO_AF8,
88  .bus = APB2,
89  .irqn = USART6_IRQn,
90 #ifdef MODULE_PERIPH_DMA
91  .dma = 1,
92  .dma_chan = 5
93 #endif
94  },
95  {
96  .dev = USART2,
97  .rcc_mask = RCC_APB1ENR_USART2EN,
98  .rx_pin = GPIO_PIN(PORT_D, 6),
99  .tx_pin = GPIO_PIN(PORT_D, 5),
100  .rx_af = GPIO_AF7,
101  .tx_af = GPIO_AF7,
102  .bus = APB1,
103  .irqn = USART2_IRQn,
104 #ifdef MODULE_PERIPH_DMA
105  .dma = 2,
106  .dma_chan = 4
107 #endif
108  }
109 };
110 
111 #define UART_0_ISR (isr_usart3)
112 #define UART_1_ISR (isr_usart6)
113 #define UART_2_ISR (isr_usart2)
114 
115 #define UART_NUMOF ARRAY_SIZE(uart_config)
122 static const spi_conf_t spi_config[] = {
123  {
124  .dev = SPI1,
125  /* PA7 is the default MOSI pin, as it is required for compatibility with
126  * Arduino(ish) shields. Sadly, it is also connected to the RMII_DV of
127  * Ethernet PHY. We work around this by remapping the MOSI to PB5 when
128  * the on-board Ethernet PHY is used.
129  */
130 #ifdef MODULE_PERIPH_ETH
131  .mosi_pin = GPIO_PIN(PORT_B, 5),
132 #else
133  .mosi_pin = GPIO_PIN(PORT_A, 7),
134 #endif
135  .miso_pin = GPIO_PIN(PORT_A, 6),
136  .sclk_pin = GPIO_PIN(PORT_A, 5),
137  .cs_pin = SPI_CS_UNDEF,
138  .mosi_af = GPIO_AF5,
139  .miso_af = GPIO_AF5,
140  .sclk_af = GPIO_AF5,
141  .cs_af = GPIO_AF5,
142  .rccmask = RCC_APB2ENR_SPI1EN,
143  .apbbus = APB2
144  },
145  {
146  .dev = SPI4,
147  .mosi_pin = GPIO_PIN(PORT_E, 6),
148  .miso_pin = GPIO_PIN(PORT_E, 5),
149  .sclk_pin = GPIO_PIN(PORT_E, 2),
150  .cs_pin = SPI_CS_UNDEF,
151  .mosi_af = GPIO_AF5,
152  .miso_af = GPIO_AF5,
153  .sclk_af = GPIO_AF5,
154  .cs_af = GPIO_AF5,
155  .rccmask = RCC_APB2ENR_SPI4EN,
156  .apbbus = APB2
157  }
158 };
159 
160 #define SPI_NUMOF ARRAY_SIZE(spi_config)
167 static const eth_conf_t eth_config = {
168  .mode = RMII,
170  .dma = 3,
171  .dma_chan = 8,
172  .phy_addr = 0x00,
173  .pins = {
174  GPIO_PIN(PORT_G, 13),
175  GPIO_PIN(PORT_B, 13),
176  GPIO_PIN(PORT_G, 11),
177  GPIO_PIN(PORT_C, 4),
178  GPIO_PIN(PORT_C, 5),
179  GPIO_PIN(PORT_A, 7),
180  GPIO_PIN(PORT_C, 1),
181  GPIO_PIN(PORT_A, 2),
182  GPIO_PIN(PORT_A, 1),
183  }
184 };
185 
186 #define ETH_DMA_ISR isr_dma2_stream0
199 static const adc_conf_t adc_config[] = {
200  {GPIO_PIN(PORT_A, 3), 2, 3},
201  {GPIO_PIN(PORT_C, 0), 2, 10},
202  {GPIO_PIN(PORT_C, 3), 2, 13},
203  {GPIO_PIN(PORT_F, 3), 2, 9},
204  {GPIO_PIN(PORT_F, 5), 2, 15},
205  {GPIO_PIN(PORT_F, 10), 2, 8},
206  {GPIO_UNDEF, 0, 18}, /* VBAT */
207 };
208 
209 #define VBAT_ADC ADC_LINE(6)
210 #define ADC_CLK_MAX MHZ(36)
211 #define ADC_NUMOF ARRAY_SIZE(adc_config)
221 static const pwm_conf_t pwm_config[] = {
222  {
223  .dev = TIM1,
224  .rcc_mask = RCC_APB2ENR_TIM1EN,
225  .chan = { { .pin = GPIO_PIN(PORT_E, 9) /* D6 CN10-4 */, .cc_chan = 0},
226  { .pin = GPIO_PIN(PORT_E, 11) /* D5 CN10-6 */, .cc_chan = 1},
227  { .pin = GPIO_PIN(PORT_E, 13) /* D3 CN10-10 */, .cc_chan = 2},
228  { .pin = GPIO_PIN(PORT_E, 14) /* D38 CN10-28 */, .cc_chan = 3} },
229  .af = GPIO_AF1,
230  .bus = APB2
231  },
232  {
233  .dev = TIM4,
234  .rcc_mask = RCC_APB1ENR_TIM4EN,
235  .chan = { { .pin = GPIO_PIN(PORT_D, 12) /* D29 CN10-21 */, .cc_chan = 0},
236  { .pin = GPIO_PIN(PORT_D, 13) /* D28 CN10-19 */, .cc_chan = 1},
237  { .pin = GPIO_PIN(PORT_D, 14) /* D10 CN7-16 */, .cc_chan = 2},
238  { .pin = GPIO_PIN(PORT_D, 15) /* D9 CN7-18 */, .cc_chan = 3} },
239  .af = GPIO_AF2,
240  .bus = APB1
241  },
242 };
243 
247 #define PWM_NUMOF ARRAY_SIZE(pwm_config)
250 #ifdef __cplusplus
251 }
252 #endif
253 
@ PORT_B
port B
Definition: periph_cpu.h:47
@ PORT_G
port G
Definition: periph_cpu.h:52
@ PORT_C
port C
Definition: periph_cpu.h:48
@ PORT_F
port F
Definition: periph_cpu.h:51
@ PORT_E
port E
Definition: periph_cpu.h:50
@ PORT_A
port A
Definition: periph_cpu.h:46
@ PORT_D
port D
Definition: periph_cpu.h:49
#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 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:36
@ GPIO_AF1
use alternate function 1
Definition: cpu_gpio.h:102
@ GPIO_AF2
use alternate function 2
Definition: cpu_gpio.h:103
@ GPIO_AF5
use alternate function 5
Definition: cpu_gpio.h:106
@ GPIO_AF8
use alternate function 8
Definition: cpu_gpio.h:110
@ GPIO_AF7
use alternate function 7
Definition: cpu_gpio.h:108
#define SPI_CS_UNDEF
Define value for unused CS line.
Definition: periph_cpu.h:362
@ APB1
Advanced Peripheral Bus 1
Definition: periph_cpu.h:78
@ APB2
Advanced Peripheral Bus 2
Definition: periph_cpu.h:79
#define MII_BMCR_FULL_DPLX
Set for full duplex.
Definition: mii.h:68
#define MII_BMCR_SPEED_100
Set speed to 100 Mbps.
Definition: mii.h:72
Interface definition for MII/RMII h.
ADC device configuration.
Definition: periph_cpu.h:377
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
Ethernet Peripheral configuration.
Definition: cpu_eth.h:43
eth_mode_t mode
Select configuration mode.
Definition: cpu_eth.h:44
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