periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Freie Universität Berlin
3  * 2016 Inria
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 /* HSE available on this board */
24 #ifndef CONFIG_BOARD_HAS_HSE
25 #define CONFIG_BOARD_HAS_HSE 1
26 #endif
27 
28 /* This board provides an LSE */
29 #ifndef CONFIG_BOARD_HAS_LSE
30 #define CONFIG_BOARD_HAS_LSE 1
31 #endif
32 
33 #include "periph_cpu.h"
34 #include "clk_conf.h"
35 #include "cfg_i2c1_pb8_pb9.h"
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
45 static const timer_conf_t timer_config[] = {
46  {
47  .dev = TIM1,
48  .max = 0x0000ffff,
49  .rcc_mask = RCC_APB2ENR_TIM1EN,
50  .bus = APB2,
51  .irqn = TIM1_CC_IRQn
52  }
53 };
54 
55 #define TIMER_0_ISR isr_tim1_cc
56 
57 #define TIMER_NUMOF ARRAY_SIZE(timer_config)
64 static const uart_conf_t uart_config[] = {
65  {
66  .dev = USART2,
67  .rcc_mask = RCC_APB1ENR_USART2EN,
68  .rx_pin = GPIO_PIN(PORT_A, 3),
69  .tx_pin = GPIO_PIN(PORT_A, 2),
70  .rx_af = GPIO_AF1,
71  .tx_af = GPIO_AF1,
72  .bus = APB1,
73  .irqn = USART2_IRQn
74  },
75  {
76  .dev = USART1,
77  .rcc_mask = RCC_APB2ENR_USART1EN,
78  .rx_pin = GPIO_PIN(PORT_A, 10),
79  .tx_pin = GPIO_PIN(PORT_A, 9),
80  .rx_af = GPIO_AF1,
81  .tx_af = GPIO_AF1,
82  .bus = APB2,
83  .irqn = USART1_IRQn
84  },
85  {
86  .dev = USART3,
87  .rcc_mask = RCC_APB1ENR_USART3EN,
88  .rx_pin = GPIO_PIN(PORT_C, 11),
89  .tx_pin = GPIO_PIN(PORT_C, 10),
90  .rx_af = GPIO_AF1,
91  .tx_af = GPIO_AF1,
92  .bus = APB1,
93  .irqn = USART3_4_IRQn
94  }
95 };
96 
97 #define UART_0_ISR (isr_usart2)
98 #define UART_1_ISR (isr_usart1)
99 #define UART_2_ISR (isr_usart3_8)
100 
101 #define UART_NUMOF ARRAY_SIZE(uart_config)
108 static const dma_conf_t dma_config[] = {
109  { .stream = 1 },
110  { .stream = 2 },
111 };
112 
113 #define DMA_SHARED_ISR_0 isr_dma1_ch2_3_dma2_ch1_2
114 #define DMA_SHARED_ISR_0_STREAMS { 0, 1 } /* Indexes 0 and 1 of dma_config share the same isr */
115 
116 #define DMA_NUMOF ARRAY_SIZE(dma_config)
123 static const pwm_conf_t pwm_config[] = {
124  {
125  .dev = TIM3,
126  .rcc_mask = RCC_APB1ENR_TIM3EN,
127  .chan = { { .pin = GPIO_PIN(PORT_B, 4) /* D5 */, .cc_chan = 0 },
128  { .pin = GPIO_PIN(PORT_B, 5) /* D4 */, .cc_chan = 1 },
129  { .pin = GPIO_UNDEF, .cc_chan = 0 },
130  { .pin = GPIO_UNDEF, .cc_chan = 0 } },
131  .af = GPIO_AF1,
132  .bus = APB1
133  },
134  {
135  .dev = TIM15,
136  .rcc_mask = RCC_APB2ENR_TIM15EN,
137  .chan = { { .pin = GPIO_PIN(PORT_B, 14), .cc_chan = 0 },
138  { .pin = GPIO_PIN(PORT_B, 15), .cc_chan = 1 },
139  { .pin = GPIO_UNDEF, .cc_chan = 0 },
140  { .pin = GPIO_UNDEF, .cc_chan = 0 } },
141  .af = GPIO_AF1,
142  .bus = APB2
143  }
144 };
145 
146 #define PWM_NUMOF ARRAY_SIZE(pwm_config)
153 static const adc_conf_t adc_config[] = {
154  { GPIO_PIN(PORT_A, 0), 0 },
155  { GPIO_PIN(PORT_A, 1), 1 },
156  { GPIO_PIN(PORT_A, 4), 4 },
157  { GPIO_PIN(PORT_B, 0), 8 },
158  { GPIO_PIN(PORT_C, 1), 11 },
159  { GPIO_PIN(PORT_C, 0), 10 }
160 };
161 
162 #define ADC_NUMOF ARRAY_SIZE(adc_config)
176 static const spi_conf_t spi_config[] = {
177  {
178  .dev = SPI1,
179  .mosi_pin = GPIO_PIN(PORT_A, 7),
180  .miso_pin = GPIO_PIN(PORT_A, 6),
181  .sclk_pin = GPIO_PIN(PORT_A, 5),
182  .cs_pin = GPIO_UNDEF,
183  .mosi_af = GPIO_AF0,
184  .miso_af = GPIO_AF0,
185  .sclk_af = GPIO_AF0,
186  .cs_af = GPIO_AF0,
187  .rccmask = RCC_APB2ENR_SPI1EN,
188  .apbbus = APB2,
189 #ifdef MODULE_PERIPH_DMA
190  .tx_dma = 1,
191  .tx_dma_chan = 0,
192  .rx_dma = 0,
193  .rx_dma_chan = 0,
194 #endif
195  }
196 };
197 
198 #define SPI_NUMOF ARRAY_SIZE(spi_config)
201 #ifdef __cplusplus
202 }
203 #endif
204 
@ 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 timer_conf_t timer_config[]
All timers on board.
Definition: periph_conf.h:39
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 I2C.
@ GPIO_AF1
use alternate function 1
Definition: cpu_gpio.h:102
@ GPIO_AF0
use alternate function 0
Definition: cpu_gpio.h:101
@ APB1
Advanced Peripheral Bus 1
Definition: periph_cpu.h:78
@ APB2
Advanced Peripheral Bus 2
Definition: periph_cpu.h:79
ADC device configuration.
Definition: periph_cpu.h:377
DMA configuration.
Definition: cpu_dma.h:31
int stream
DMA stream on stm32f2/4/7, channel on others STM32F2/4/7:
Definition: cpu_dma.h:54
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
Timer device configuration.
Definition: periph_cpu.h:263
TC0_t * dev
Pointer to the used as Timer device.
Definition: periph_cpu.h:264
UART device configuration.
Definition: periph_cpu.h:217
USART_t * dev
pointer to the used UART device
Definition: periph_cpu.h:218