periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 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 HSE */
24 #ifndef CONFIG_BOARD_HAS_HSE
25 #define CONFIG_BOARD_HAS_HSE 1
26 #endif
27 
28 #include "periph_cpu.h"
29 #include "clk_conf.h"
30 #include "cfg_usb_otg_fs.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
40 static const dma_conf_t dma_config[] = {
41  { .stream = 11 }, /* DMA2 Stream 3 - SPI1_TX */
42  { .stream = 10 }, /* DMA2 Stream 2 - SPI1_RX */
43  { .stream = 4 }, /* DMA1 Stream 4 - SPI2_TX */
44  { .stream = 3 }, /* DMA1 Stream 3 - SPI2_RX */
45 };
46 
47 #define DMA_0_ISR isr_dma2_stream3
48 #define DMA_1_ISR isr_dma2_stream2
49 #define DMA_2_ISR isr_dma1_stream4
50 #define DMA_3_ISR isr_dma1_stream3
51 
52 #define DMA_NUMOF ARRAY_SIZE(dma_config)
53 
59 static const timer_conf_t timer_config[] = {
60  {
61  .dev = TIM2,
62  .max = 0xffffffff,
63  .rcc_mask = RCC_APB1ENR_TIM2EN,
64  .bus = APB1,
65  .irqn = TIM2_IRQn
66  },
67  {
68  .dev = TIM5,
69  .max = 0xffffffff,
70  .rcc_mask = RCC_APB1ENR_TIM5EN,
71  .bus = APB1,
72  .irqn = TIM5_IRQn
73  }
74 };
75 
76 #define TIMER_0_ISR isr_tim2
77 #define TIMER_1_ISR isr_tim5
78 
79 #define TIMER_NUMOF ARRAY_SIZE(timer_config)
80 
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 = DMA_STREAM_UNDEF,
98  .dma_chan = UINT8_MAX,
99 #endif
100  },
101  {
102  .dev = USART3,
103  .rcc_mask = RCC_APB1ENR_USART3EN,
104  .rx_pin = GPIO_PIN(PORT_D, 9),
105  .tx_pin = GPIO_PIN(PORT_D, 8),
106  .rx_af = GPIO_AF7,
107  .tx_af = GPIO_AF7,
108  .bus = APB1,
109  .irqn = USART3_IRQn,
110 #ifdef MODULE_PERIPH_DMA
111  .dma = DMA_STREAM_UNDEF,
112  .dma_chan = UINT8_MAX,
113 #endif
114  }
115 };
116 
117 #define UART_0_ISR (isr_usart2)
118 #define UART_1_ISR (isr_usart3)
119 
120 #define UART_NUMOF ARRAY_SIZE(uart_config)
121 
130 static const adc_conf_t adc_config[] = {
131  {GPIO_PIN(PORT_A, 1), 0, 1},
132  {GPIO_PIN(PORT_A, 4), 0, 4},
133  {GPIO_PIN(PORT_C, 1), 1, 11},
134  {GPIO_PIN(PORT_C, 2), 1, 12}
135 };
136 
137 #define ADC_NUMOF ARRAY_SIZE(adc_config)
138 
144 static const dac_conf_t dac_config[] = {
145  { .pin = GPIO_PIN(PORT_A, 4), .chan = 0 },
146  { .pin = GPIO_PIN(PORT_A, 5), .chan = 1 }
147 };
148 
149 #define DAC_NUMOF ARRAY_SIZE(dac_config)
150 
156 static const pwm_conf_t pwm_config[] = {
157  {
158  .dev = TIM1,
159  .rcc_mask = RCC_APB2ENR_TIM1EN,
160  .chan = { { .pin = GPIO_PIN(PORT_E, 9), .cc_chan = 0 },
161  { .pin = GPIO_PIN(PORT_E, 11), .cc_chan = 1 },
162  { .pin = GPIO_PIN(PORT_E, 11), .cc_chan = 2 },
163  { .pin = GPIO_PIN(PORT_E, 14), .cc_chan = 3 } },
164  .af = GPIO_AF1,
165  .bus = APB2
166  },
167  {
168  .dev = TIM3,
169  .rcc_mask = RCC_APB1ENR_TIM3EN,
170  .chan = { { .pin = GPIO_PIN(PORT_B, 4), .cc_chan = 0 },
171  { .pin = GPIO_PIN(PORT_B, 5), .cc_chan = 1 },
172  { .pin = GPIO_PIN(PORT_B, 0), .cc_chan = 2 },
173  { .pin = GPIO_PIN(PORT_B, 1), .cc_chan = 3 } },
174  .af = GPIO_AF2,
175  .bus = APB1
176  }
177 };
178 
179 #define PWM_NUMOF ARRAY_SIZE(pwm_config)
180 
186 static const spi_conf_t spi_config[] = {
187  {
188  .dev = SPI1,
189  .mosi_pin = GPIO_PIN(PORT_A, 7),
190  .miso_pin = GPIO_PIN(PORT_A, 6),
191  .sclk_pin = GPIO_PIN(PORT_A, 5),
192  .cs_pin = GPIO_PIN(PORT_A, 4),
193  .mosi_af = GPIO_AF5,
194  .miso_af = GPIO_AF5,
195  .sclk_af = GPIO_AF5,
196  .cs_af = GPIO_AF5,
197  .rccmask = RCC_APB2ENR_SPI1EN,
198  .apbbus = APB2,
199 #ifdef MODULE_PERIPH_DMA
200  .tx_dma = 0,
201  .tx_dma_chan = 3,
202  .rx_dma = 1,
203  .rx_dma_chan = 3,
204 #endif
205  },
206  {
207  .dev = SPI2,
208  .mosi_pin = GPIO_PIN(PORT_B, 15),
209  .miso_pin = GPIO_PIN(PORT_B, 14),
210  .sclk_pin = GPIO_PIN(PORT_B, 13),
211  .cs_pin = GPIO_PIN(PORT_B, 12),
212  .mosi_af = GPIO_AF5,
213  .miso_af = GPIO_AF5,
214  .sclk_af = GPIO_AF5,
215  .cs_af = GPIO_AF5,
216  .rccmask = RCC_APB1ENR_SPI2EN,
217  .apbbus = APB1,
218 #ifdef MODULE_PERIPH_DMA
219  .tx_dma = 2,
220  .tx_dma_chan = 0,
221  .rx_dma = 3,
222  .rx_dma_chan = 0,
223 #endif
224  },
225 };
226 
227 #define SPI_NUMOF ARRAY_SIZE(spi_config)
228 
234 static const i2c_conf_t i2c_config[] = {
235  {
236  .dev = I2C1,
237  .speed = I2C_SPEED_NORMAL,
238  .scl_pin = GPIO_PIN(PORT_B, 6),
239  .sda_pin = GPIO_PIN(PORT_B, 9),
240  .scl_af = GPIO_AF4,
241  .sda_af = GPIO_AF4,
242  .bus = APB1,
243  .rcc_mask = RCC_APB1ENR_I2C1EN,
244  .clk = CLOCK_APB1,
245  .irqn = I2C1_EV_IRQn
246  }
247 };
248 
249 #define I2C_0_ISR isr_i2c1_ev
250 
251 #define I2C_NUMOF ARRAY_SIZE(i2c_config)
252 
254 #ifdef __cplusplus
255 }
256 #endif
257 
258 #endif /* PERIPH_CONF_H */
259 
PORT_E
@ PORT_E
port E
Definition: periph_cpu.h:40
GPIO_AF4
@ GPIO_AF4
use alternate function 4
Definition: periph_cpu_common.h:90
PORT_C
@ PORT_C
port C
Definition: periph_cpu.h:38
dac_conf_t::pin
gpio_t pin
pin connected to the line
Definition: periph_cpu.h:519
pwm_conf_t::dev
mini_timer_t * dev
Timer used.
Definition: periph_cpu_common.h:154
I2C_SPEED_NORMAL
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition: i2c.h:177
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.
pwm_conf_t
PWM device configuration.
Definition: periph_cpu_common.h:153
uart_conf_t
UART device configuration.
Definition: periph_cpu.h:166
GPIO_AF1
@ GPIO_AF1
use alternate function 1
Definition: periph_cpu_common.h:87
dac_conf_t
DAC line configuration data.
Definition: periph_cpu.h:518
uart_conf_t::dev
cc2538_uart_t * dev
pointer to the used UART device
Definition: periph_cpu.h:167
timer_conf_t
Timer configuration.
Definition: periph_cpu.h:288
GPIO_AF7
@ GPIO_AF7
use alternate function 7
Definition: periph_cpu_common.h:93
adc_conf_t
ADC device configuration.
Definition: periph_cpu.h:74
GPIO_PIN
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition: periph_cpu.h:35
APB2
@ APB2
APB2 bus.
Definition: periph_cpu.h:177
dma_conf_t
DMA configuration.
Definition: periph_cpu.h:420
GPIO_AF2
@ GPIO_AF2
use alternate function 2
Definition: periph_cpu_common.h:88
i2c_conf_t
I2C configuration options.
Definition: periph_cpu.h:128
timer_conf_t::dev
uint32_t dev
Address of timer base.
Definition: periph_cpu.h:112
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
spi_conf_t
SPI configuration structure type.
Definition: periph_cpu.h:273
i2c_conf_t::dev
I2C_TypeDef * dev
USART device used.
Definition: periph_cpu.h:247
APB1
@ APB1
APB1 bus.
Definition: periph_cpu.h:176