Loading...
Searching...
No Matches
periph_conf.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2014-2016 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#include "periph_cpu.h"
24#include "clk_conf.h"
25#include "cfg_timer_tim5.h"
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
35static const dma_conf_t dma_config[] = {
36 { .stream = 1 }, /* DMA1 Channel 2 - SPI1_RX / USART3_TX */
37 { .stream = 2 }, /* DMA1 Channel 3 - SPI1_TX */
38 { .stream = 6 }, /* DMA1 Channel 7 - USART2_TX */
39 { .stream = 4 }, /* DMA1 Channel 4 - USART1_TX */
40};
41
42#define DMA_0_ISR isr_dma1_channel2
43#define DMA_1_ISR isr_dma1_channel3
44#define DMA_2_ISR isr_dma1_channel7
45#define DMA_3_ISR isr_dma1_channel4
46
47#define DMA_NUMOF ARRAY_SIZE(dma_config)
54static const uart_conf_t uart_config[] = {
55 {
56 .dev = USART2,
57 .rcc_mask = RCC_APB1ENR_USART2EN,
58 .rx_pin = GPIO_PIN(PORT_A, 3),
59 .tx_pin = GPIO_PIN(PORT_A, 2),
60 .rx_af = GPIO_AF7,
61 .tx_af = GPIO_AF7,
62 .bus = APB1,
63 .irqn = USART2_IRQn,
64#ifdef MODULE_PERIPH_DMA
65 .dma = 2,
66 .dma_chan = 2
67#endif
68 },
69 {
70 .dev = USART1,
71 .rcc_mask = RCC_APB2ENR_USART1EN,
72 .rx_pin = GPIO_PIN(PORT_A, 10),
73 .tx_pin = GPIO_PIN(PORT_A, 9),
74 .rx_af = GPIO_AF7,
75 .tx_af = GPIO_AF7,
76 .bus = APB2,
77 .irqn = USART1_IRQn,
78#ifdef MODULE_PERIPH_DMA
79 .dma = 3,
80 .dma_chan = 2
81#endif
82 },
83 {
84 .dev = USART3,
85 .rcc_mask = RCC_APB1ENR_USART3EN,
86 .rx_pin = GPIO_PIN(PORT_C, 11),
87 .tx_pin = GPIO_PIN(PORT_C, 10),
88 .rx_af = GPIO_AF7,
89 .tx_af = GPIO_AF7,
90 .bus = APB1,
91 .irqn = USART3_IRQn,
92#ifdef MODULE_PERIPH_DMA
93 .dma = 0,
94 .dma_chan = 2
95#endif
96 },
97};
98
99#define UART_0_ISR (isr_usart2)
100#define UART_1_ISR (isr_usart1)
101#define UART_2_ISR (isr_usart3)
102
103#define UART_NUMOF ARRAY_SIZE(uart_config)
110static const pwm_conf_t pwm_config[] = {
111 {
112 .dev = TIM2,
113 .rcc_mask = RCC_APB1ENR_TIM2EN,
114 .chan = { { .pin = GPIO_PIN(PORT_B, 3) /* D3 */, .cc_chan = 1 },
115 { .pin = GPIO_PIN(PORT_B, 10) /* D6 */, .cc_chan = 2 },
116 { .pin = GPIO_UNDEF, .cc_chan = 0 },
117 { .pin = GPIO_UNDEF, .cc_chan = 0 } },
118 .af = GPIO_AF1,
119 .bus = APB1
120 },
121 {
122 .dev = TIM3,
123 .rcc_mask = RCC_APB1ENR_TIM3EN,
124 .chan = { { .pin = GPIO_PIN(PORT_B, 4) /* D5 */, .cc_chan = 0 },
125 { .pin = GPIO_PIN(PORT_C, 7) /* D9 */, .cc_chan = 1 },
126 { .pin = GPIO_PIN(PORT_C, 8), .cc_chan = 2 },
127 { .pin = GPIO_PIN(PORT_C, 9), .cc_chan = 3 } },
128 .af = GPIO_AF2,
129 .bus = APB1
130 }
131};
132
133#define PWM_NUMOF ARRAY_SIZE(pwm_config)
140static const spi_conf_t spi_config[] = {
141 {
142 .dev = SPI1,
143 .mosi_pin = GPIO_PIN(PORT_A, 7),
144 .miso_pin = GPIO_PIN(PORT_A, 6),
145 .sclk_pin = GPIO_PIN(PORT_A, 5),
146 .cs_pin = SPI_CS_UNDEF,
147 .mosi_af = GPIO_AF5,
148 .miso_af = GPIO_AF5,
149 .sclk_af = GPIO_AF5,
150 .cs_af = GPIO_AF5,
151 .rccmask = RCC_APB2ENR_SPI1EN,
152 .apbbus = APB2,
153#ifdef MODULE_PERIPH_DMA
154 .tx_dma = 1,
155 .tx_dma_chan = 1,
156 .rx_dma = 0,
157 .rx_dma_chan = 1,
158#endif
159 }
160};
161
162#define SPI_NUMOF ARRAY_SIZE(spi_config)
169static const i2c_conf_t i2c_config[] = {
170 {
171 .dev = I2C1,
172 .speed = I2C_SPEED_NORMAL,
173 .scl_pin = GPIO_PIN(PORT_B, 8),
174 .sda_pin = GPIO_PIN(PORT_B, 9),
175 .scl_af = GPIO_AF4,
176 .sda_af = GPIO_AF4,
177 .bus = APB1,
178 .rcc_mask = RCC_APB1ENR_I2C1EN,
179 .clk = CLOCK_APB1,
180 .irqn = I2C1_EV_IRQn
181 },
182 {
183 .dev = I2C2,
184 .speed = I2C_SPEED_NORMAL,
185 .scl_pin = GPIO_PIN(PORT_B, 10),
186 .sda_pin = GPIO_PIN(PORT_B, 11),
187 .scl_af = GPIO_AF4,
188 .sda_af = GPIO_AF4,
189 .bus = APB1,
190 .rcc_mask = RCC_APB1ENR_I2C2EN,
191 .clk = CLOCK_APB1,
192 .irqn = I2C2_EV_IRQn
193 }
194};
195
196#define I2C_0_ISR isr_i2c1_ev
197#define I2C_1_ISR isr_i2c2_ev
198
199#define I2C_NUMOF ARRAY_SIZE(i2c_config)
206static const adc_conf_t adc_config[] = {
207 { GPIO_PIN(PORT_A, 0), 0 },
208 { GPIO_PIN(PORT_A, 1), 1 },
209 { GPIO_PIN(PORT_A, 4), 4 },
210 { GPIO_PIN(PORT_B, 0), 8 },
211 { GPIO_PIN(PORT_C, 1), 11 },
212 { GPIO_PIN(PORT_C, 0), 10 },
213};
214
215#define ADC_NUMOF ARRAY_SIZE(adc_config)
222static const dac_conf_t dac_config[] = {
223 { .pin = GPIO_PIN(PORT_A, 4), .chan = 0 },
224 { .pin = GPIO_PIN(PORT_A, 5), .chan = 1 }
225};
226
227#define DAC_NUMOF ARRAY_SIZE(dac_config)
230#ifdef __cplusplus
231}
232#endif
233
234#endif /* PERIPH_CONF_H */
@ PORT_B
port B
Definition periph_cpu.h:48
@ PORT_C
port C
Definition periph_cpu.h:49
@ PORT_A
port A
Definition periph_cpu.h:47
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition periph_cpu.h:46
#define GPIO_UNDEF
Definition of a fitting UNDEF value.
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition periph_cpu.h:278
Common configuration for STM32 Timer peripheral based on TIM5.
@ 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_AF4
use alternate function 4
Definition cpu_gpio.h:106
@ 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
ADC device configuration.
Definition periph_cpu.h:379
DAC line configuration data.
Definition periph_cpu.h:301
gpio_t pin
pin connected to the line
Definition periph_cpu.h:302
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
I2C configuration structure.
Definition periph_cpu.h:299
TWI_t * dev
Pointer to hardware module registers.
Definition periph_cpu.h:300
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