periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Freie Universität Berlin
3  * Copyright (C) 2015 Hamburg University of Applied Sciences
4  *
5  * This file is subject to the terms and conditions of the GNU Lesser
6  * General Public License v2.1. See the file LICENSE in the top level
7  * directory for more details.
8  */
9 
21 #ifndef PERIPH_CONF_H
22 #define PERIPH_CONF_H
23 
24 /* This board provides an LSE */
25 #ifndef CONFIG_BOARD_HAS_LSE
26 #define CONFIG_BOARD_HAS_LSE 1
27 #endif
28 
29 /* This board provides an HSE */
30 #ifndef CONFIG_BOARD_HAS_HSE
31 #define CONFIG_BOARD_HAS_HSE 1
32 #endif
33 
34 #include "periph_cpu.h"
35 #include "clk_conf.h"
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
52 static const adc_conf_t adc_config[] = {
53  { .pin = GPIO_PIN(PORT_A, 0), .dev = 0, .chan = 1 }, /* ADC1_IN1, fast */
54  { .pin = GPIO_PIN(PORT_A, 1), .dev = 0, .chan = 2 }, /* ADC1_IN2, fast */
55  { .pin = GPIO_PIN(PORT_A, 4), .dev = 1, .chan = 1 }, /* ADC2_IN1, fast */
56  { .pin = GPIO_PIN(PORT_B, 0), .dev = 2, .chan = 12 }, /* ADC3_IN12, slow */
57  { .pin = GPIO_PIN(PORT_C, 1), .dev = 1, .chan = 7 }, /* ADC12_IN7, slow */
58  { .pin = GPIO_PIN(PORT_C, 0), .dev = 1, .chan = 6 }, /* ADC12_IN6, slow */
59  { .pin = GPIO_UNDEF, .dev = 0, .chan = 17 }, /* VBAT */
60 };
61 
62 #define VBAT_ADC ADC_LINE(6)
63 #define ADC_NUMOF ARRAY_SIZE(adc_config)
70 static const uart_conf_t uart_config[] = {
71  {
72  .dev = USART2,
73  .rcc_mask = RCC_APB1ENR_USART2EN,
74  .rx_pin = GPIO_PIN(PORT_A, 3),
75  .tx_pin = GPIO_PIN(PORT_A, 2),
76  .rx_af = GPIO_AF7,
77  .tx_af = GPIO_AF7,
78  .bus = APB1,
79  .irqn = USART2_IRQn
80  },
81  {
82  .dev = USART1,
83  .rcc_mask = RCC_APB2ENR_USART1EN,
84  .rx_pin = GPIO_PIN(PORT_A, 10),
85  .tx_pin = GPIO_PIN(PORT_A, 9),
86  .rx_af = GPIO_AF7,
87  .tx_af = GPIO_AF7,
88  .bus = APB2,
89  .irqn = USART1_IRQn
90  },
91  {
92  .dev = USART3,
93  .rcc_mask = RCC_APB1ENR_USART3EN,
94  .rx_pin = GPIO_PIN(PORT_B, 11),
95  .tx_pin = GPIO_PIN(PORT_B, 10),
96  .rx_af = GPIO_AF7,
97  .tx_af = GPIO_AF7,
98  .bus = APB1,
99  .irqn = USART3_IRQn
100  }
101 };
102 
103 #define UART_0_ISR (isr_usart2)
104 #define UART_1_ISR (isr_usart1)
105 #define UART_2_ISR (isr_usart3)
106 
107 #define UART_NUMOF ARRAY_SIZE(uart_config)
114 static const pwm_conf_t pwm_config[] = {
115  {
116  .dev = TIM3,
117  .rcc_mask = RCC_APB1ENR_TIM3EN,
118  .chan = { { .pin = GPIO_PIN(PORT_C, 6), .cc_chan = 0 },
119  { .pin = GPIO_PIN(PORT_C, 7), .cc_chan = 1 },
120  { .pin = GPIO_PIN(PORT_C, 8), .cc_chan = 2 },
121  { .pin = GPIO_PIN(PORT_C, 9), .cc_chan = 3 } },
122  .af = GPIO_AF2,
123  .bus = APB1
124  }
125 };
126 
127 #define PWM_NUMOF ARRAY_SIZE(pwm_config)
134 static const spi_conf_t spi_config[] = {
135  {
136  .dev = SPI1,
137  .mosi_pin = GPIO_PIN(PORT_A, 7),
138  .miso_pin = GPIO_PIN(PORT_A, 6),
139  .sclk_pin = GPIO_PIN(PORT_A, 5),
140  .cs_pin = GPIO_PIN(PORT_A, 4),
141  .mosi_af = GPIO_AF5,
142  .miso_af = GPIO_AF5,
143  .sclk_af = GPIO_AF5,
144  .cs_af = GPIO_AF5,
145  .rccmask = RCC_APB2ENR_SPI1EN,
146  .apbbus = APB2
147  },
148  {
149  .dev = SPI2,
150  .mosi_pin = GPIO_PIN(PORT_B, 15),
151  .miso_pin = GPIO_PIN(PORT_B, 14),
152  .sclk_pin = GPIO_PIN(PORT_B, 13),
153  .cs_pin = GPIO_PIN(PORT_B, 12),
154  .mosi_af = GPIO_AF5,
155  .miso_af = GPIO_AF5,
156  .sclk_af = GPIO_AF5,
157  .cs_af = GPIO_AF5,
158  .rccmask = RCC_APB1ENR_SPI2EN,
159  .apbbus = APB1
160  },
161  {
162  .dev = SPI3,
163  .mosi_pin = GPIO_PIN(PORT_C, 12),
164  .miso_pin = GPIO_PIN(PORT_C, 11),
165  .sclk_pin = GPIO_PIN(PORT_C, 10),
166  .cs_pin = SPI_CS_UNDEF,
167  .mosi_af = GPIO_AF6,
168  .miso_af = GPIO_AF6,
169  .sclk_af = GPIO_AF6,
170  .cs_af = GPIO_AF6,
171  .rccmask = RCC_APB1ENR_SPI3EN,
172  .apbbus = APB1
173  }
174 };
175 
176 #define SPI_NUMOF ARRAY_SIZE(spi_config)
183 static const i2c_conf_t i2c_config[] = {
184  {
185  .dev = I2C1,
186  .speed = I2C_SPEED_NORMAL,
187  .scl_pin = GPIO_PIN(PORT_B, 8),
188  .sda_pin = GPIO_PIN(PORT_B, 9),
189  .scl_af = GPIO_AF4,
190  .sda_af = GPIO_AF4,
191  .bus = APB1,
192  .rcc_mask = RCC_APB1ENR_I2C1EN,
193  .rcc_sw_mask = RCC_CFGR3_I2C1SW,
194  .irqn = I2C1_ER_IRQn
195  },
196  {
197  .dev = I2C3,
198  .speed = I2C_SPEED_NORMAL,
199  .scl_pin = GPIO_PIN(PORT_A, 8),
200  .sda_pin = GPIO_PIN(PORT_B, 5),
201  .scl_af = GPIO_AF3,
202  .sda_af = GPIO_AF8,
203  .bus = APB1,
204  .rcc_mask = RCC_APB1ENR_I2C3EN,
205  .rcc_sw_mask = RCC_CFGR3_I2C3SW,
206  .irqn = I2C3_ER_IRQn
207  }
208 };
209 
210 #define I2C_0_ISR isr_i2c1_er
211 #define I2C_1_ISR isr_i2c3_er
212 
213 #define I2C_NUMOF ARRAY_SIZE(i2c_config)
216 #ifdef __cplusplus
217 }
218 #endif
219 
220 #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.
static const uart_conf_t uart_config[]
UART configuration.
Definition: periph_conf.h:39
static const spi_conf_t spi_config[]
SPI configuration.
Definition: periph_conf.h:97
static const i2c_conf_t i2c_config[]
I2C configuration.
Definition: periph_conf.h:69
static const adc_conf_t adc_config[]
ADC configuration.
Definition: periph_conf.h:251
static const pwm_conf_t pwm_config[]
Actual PWM configuration.
Definition: periph_conf.h:222
Common configuration for STM32 Timer peripheral based on TIM2, TIM15, and TIM16.
@ 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_AF8
use alternate function 8
Definition: cpu_gpio.h:111
@ GPIO_AF6
use alternate function 6
Definition: cpu_gpio.h:108
@ GPIO_AF3
use alternate function 3
Definition: cpu_gpio.h:105
@ 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
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition: periph_cpu.h:278
ADC device configuration.
Definition: periph_cpu.h:379
gpio_t pin
pin connected to the channel
Definition: periph_cpu.h:288
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