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