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 
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
41 extern "C" {
42 #endif
43 
48 static 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 = 8 }, /* DMA2 Stream 0 - ETH_TX */
53 };
54 
55 #define DMA_0_ISR isr_dma1_stream4
56 #define DMA_1_ISR isr_dma2_stream6
57 #define DMA_2_ISR isr_dma1_stream6
58 #define DMA_3_ISR isr_dma2_stream0
59 
60 #define DMA_NUMOF ARRAY_SIZE(dma_config)
61 
67 static const uart_conf_t uart_config[] = {
68  {
69  .dev = USART3,
70  .rcc_mask = RCC_APB1ENR_USART3EN,
71  .rx_pin = GPIO_PIN(PORT_D, 9),
72  .tx_pin = GPIO_PIN(PORT_D, 8),
73  .rx_af = GPIO_AF7,
74  .tx_af = GPIO_AF7,
75  .bus = APB1,
76  .irqn = USART3_IRQn,
77 #ifdef MODULE_PERIPH_DMA
78  .dma = 0,
79  .dma_chan = 7
80 #endif
81  },
82  {
83  .dev = USART6,
84  .rcc_mask = RCC_APB2ENR_USART6EN,
85  .rx_pin = GPIO_PIN(PORT_G, 9),
86  .tx_pin = GPIO_PIN(PORT_G, 14),
87  .rx_af = GPIO_AF8,
88  .tx_af = GPIO_AF8,
89  .bus = APB2,
90  .irqn = USART6_IRQn,
91 #ifdef MODULE_PERIPH_DMA
92  .dma = 1,
93  .dma_chan = 5
94 #endif
95  },
96  {
97  .dev = USART2,
98  .rcc_mask = RCC_APB1ENR_USART2EN,
99  .rx_pin = GPIO_PIN(PORT_D, 6),
100  .tx_pin = GPIO_PIN(PORT_D, 5),
101  .rx_af = GPIO_AF7,
102  .tx_af = GPIO_AF7,
103  .bus = APB1,
104  .irqn = USART2_IRQn,
105 #ifdef MODULE_PERIPH_DMA
106  .dma = 2,
107  .dma_chan = 4
108 #endif
109  }
110 };
111 
112 #define UART_0_ISR (isr_usart3)
113 #define UART_1_ISR (isr_usart6)
114 #define UART_2_ISR (isr_usart2)
115 
116 #define UART_NUMOF ARRAY_SIZE(uart_config)
117 
123 static const spi_conf_t spi_config[] = {
124  {
125  .dev = SPI1,
126  /* PA7 is the default MOSI pin, as it is required for compatibility with
127  * Arduino(ish) shields. Sadly, it is also connected to the RMII_DV of
128  * Ethernet PHY. We work around this by remapping the MOSI to PB5 when
129  * the on-board Ethernet PHY is used.
130  */
131 #ifdef MODULE_PERIPH_ETH
132  .mosi_pin = GPIO_PIN(PORT_B, 5),
133 #else
134  .mosi_pin = GPIO_PIN(PORT_A, 7),
135 #endif
136  .miso_pin = GPIO_PIN(PORT_A, 6),
137  .sclk_pin = GPIO_PIN(PORT_A, 5),
138  .cs_pin = GPIO_UNDEF,
139  .mosi_af = GPIO_AF5,
140  .miso_af = GPIO_AF5,
141  .sclk_af = GPIO_AF5,
142  .cs_af = GPIO_AF5,
143  .rccmask = RCC_APB2ENR_SPI1EN,
144  .apbbus = APB2
145  },
146  {
147  .dev = SPI4,
148  .mosi_pin = GPIO_PIN(PORT_E, 6),
149  .miso_pin = GPIO_PIN(PORT_E, 5),
150  .sclk_pin = GPIO_PIN(PORT_E, 2),
151  .cs_pin = GPIO_UNDEF,
152  .mosi_af = GPIO_AF5,
153  .miso_af = GPIO_AF5,
154  .sclk_af = GPIO_AF5,
155  .cs_af = GPIO_AF5,
156  .rccmask = RCC_APB2ENR_SPI4EN,
157  .apbbus = APB2
158  }
159 };
160 
161 #define SPI_NUMOF ARRAY_SIZE(spi_config)
162 
168 static const eth_conf_t eth_config = {
169  .mode = RMII,
170  .addr = { 0 },
172  .dma = 3,
173  .dma_chan = 8,
174  .phy_addr = 0x00,
175  .pins = {
176  GPIO_PIN(PORT_G, 13),
177  GPIO_PIN(PORT_B, 13),
178  GPIO_PIN(PORT_G, 11),
179  GPIO_PIN(PORT_C, 4),
180  GPIO_PIN(PORT_C, 5),
181  GPIO_PIN(PORT_A, 7),
182  GPIO_PIN(PORT_C, 1),
183  GPIO_PIN(PORT_A, 2),
184  GPIO_PIN(PORT_A, 1),
185  }
186 };
187 
188 #define ETH_DMA_ISR isr_dma2_stream0
189 
192 #ifdef __cplusplus
193 }
194 #endif
195 
196 #endif /* PERIPH_CONF_H */
197 
GPIO_AF8
@ GPIO_AF8
use alternate function 8
Definition: periph_cpu_common.h:94
PORT_E
@ PORT_E
port E
Definition: periph_cpu.h:40
PORT_C
@ PORT_C
port C
Definition: periph_cpu.h:38
GPIO_AF5
@ GPIO_AF5
use alternate function 5
Definition: periph_cpu_common.h:91
PORT_A
@ PORT_A
port A
Definition: periph_cpu.h:36
PORT_D
@ PORT_D
port D
Definition: periph_cpu.h:39
dma_conf_t::stream
int stream
DMA stream on stm32f2/4/7, channel on others STM32F2/4/7:
Definition: periph_cpu.h:443
cfg_usb_otg_fs.h
Common configuration for STM32 OTG FS peripheral.
eth_conf_t::mode
eth_mode_t mode
Select configuration mode.
Definition: periph_cpu.h:1051
GPIO_UNDEF
#define GPIO_UNDEF
Definition of a fitting UNDEF value.
Definition: periph_cpu_common.h:52
uart_conf_t
UART device configuration.
Definition: periph_cpu.h:166
mii.h
Interface definition for MII/RMII h.
MII_BMCR_FULL_DPLX
#define MII_BMCR_FULL_DPLX
Set for full duplex.
Definition: mii.h:68
uart_conf_t::dev
cc2538_uart_t * dev
pointer to the used UART device
Definition: periph_cpu.h:167
MII_BMCR_SPEED_100
#define MII_BMCR_SPEED_100
Set speed to 100 Mbps.
Definition: mii.h:72
eth_conf_t
Ethernet Peripheral configuration.
Definition: periph_cpu.h:1050
GPIO_AF7
@ GPIO_AF7
use alternate function 7
Definition: periph_cpu_common.h:93
GPIO_PIN
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition: periph_cpu.h:35
RMII
@ RMII
Configuration for RMII.
Definition: periph_cpu.h:1043
APB2
@ APB2
APB2 bus.
Definition: periph_cpu.h:177
dma_conf_t
DMA configuration.
Definition: periph_cpu.h:420
cfg_timer_tim2.h
Common configuration for STM32 Timer peripheral based on TIM2.
cfg_i2c1_pb8_pb9.h
Common configuration for STM32 I2C.
PORT_B
@ PORT_B
port B
Definition: periph_cpu.h:37
spi_conf_t::dev
SPI_Type * dev
SPI device to use.
Definition: periph_cpu.h:465
PORT_G
@ PORT_G
port G
Definition: periph_cpu.h:42
spi_conf_t
SPI configuration structure type.
Definition: periph_cpu.h:273
APB1
@ APB1
APB1 bus.
Definition: periph_cpu.h:176