periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Freie Universität Berlin
3  * 2017 Inria
4  * 2017 HAW-Hamburg
5  *
6  * This file is subject to the terms and conditions of the GNU Lesser
7  * General Public License v2.1. See the file LICENSE in the top level
8  * directory for more details.
9  */
10 
23 #ifndef PERIPH_CONF_H
24 #define PERIPH_CONF_H
25 
26 /* Add specific clock configuration (HSE, LSE) for this board here */
27 #ifndef CONFIG_BOARD_HAS_LSE
28 #define CONFIG_BOARD_HAS_LSE 1
29 #endif
30 
31 #include "periph_cpu.h"
32 #include "clk_conf.h"
33 #include "cfg_i2c1_pb8_pb9.h"
34 #include "cfg_rtt_default.h"
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
44 static const dma_conf_t dma_config[] = {
45  { .stream = 1 }, /* DMA1 Channel 2 - SPI1_RX | USART3_TX */
46  { .stream = 2 }, /* DMA1 Channel 3 - SPI1_TX */
47  { .stream = 3 }, /* DMA1 Channel 4 - USART1_TX */
48  { .stream = 6 }, /* DMA1 Channel 7 - USART2_TX */
49 };
50 
51 #define DMA_0_ISR isr_dma1_channel2
52 #define DMA_1_ISR isr_dma1_channel3
53 #define DMA_2_ISR isr_dma1_channel4
54 #define DMA_3_ISR isr_dma1_channel7
55 
56 #define DMA_NUMOF ARRAY_SIZE(dma_config)
57 
64 static const timer_conf_t timer_config[] = {
65  {
66  .dev = TIM5,
67  .max = 0xffffffff,
68  .rcc_mask = RCC_APB1ENR1_TIM5EN,
69  .bus = APB1,
70  .irqn = TIM5_IRQn
71  }
72 };
73 
74 #define TIMER_0_ISR isr_tim5
75 
76 #define TIMER_NUMOF ARRAY_SIZE(timer_config)
77 
83 static const uart_conf_t uart_config[] = {
84  {
85  .dev = USART2,
86  .rcc_mask = RCC_APB1ENR1_USART2EN,
87  .rx_pin = GPIO_PIN(PORT_A, 3),
88  .tx_pin = GPIO_PIN(PORT_A, 2),
89  .rx_af = GPIO_AF7,
90  .tx_af = GPIO_AF7,
91  .bus = APB1,
92  .irqn = USART2_IRQn,
93  .type = STM32_USART,
94  .clk_src = 0, /* Use APB clock */
95 #ifdef MODULE_PERIPH_DMA
96  .dma = 3,
97  .dma_chan = 2
98 #endif
99  },
100  {
101  .dev = USART3,
102  .rcc_mask = RCC_APB1ENR1_USART3EN,
103  .rx_pin = GPIO_PIN(PORT_C, 11),
104  .tx_pin = GPIO_PIN(PORT_C, 10),
105  .rx_af = GPIO_AF7,
106  .tx_af = GPIO_AF7,
107  .bus = APB1,
108  .irqn = USART3_IRQn,
109  .type = STM32_USART,
110  .clk_src = 0, /* Use APB clock */
111 #ifdef MODULE_PERIPH_DMA
112  .dma = 0,
113  .dma_chan = 2
114 #endif
115  },
116  {
117  .dev = USART1,
118  .rcc_mask = RCC_APB2ENR_USART1EN,
119  .rx_pin = GPIO_PIN(PORT_A, 10),
120  .tx_pin = GPIO_PIN(PORT_A, 9),
121  .rx_af = GPIO_AF7,
122  .tx_af = GPIO_AF7,
123  .bus = APB2,
124  .irqn = USART1_IRQn,
125  .type = STM32_USART,
126  .clk_src = 0, /* Use APB clock */
127 #ifdef MODULE_PERIPH_DMA
128  .dma = 2,
129  .dma_chan = 2
130 #endif
131  }
132 };
133 
134 #define UART_0_ISR (isr_usart2)
135 #define UART_1_ISR (isr_usart3)
136 #define UART_2_ISR (isr_usart1)
137 
138 #define UART_NUMOF ARRAY_SIZE(uart_config)
139 
145 static const pwm_conf_t pwm_config[] = {
146  {
147  .dev = TIM2,
148  .rcc_mask = RCC_APB1ENR1_TIM2EN,
149  .chan = { { .pin = GPIO_PIN(PORT_A, 15), .cc_chan = 0},
150  { .pin = GPIO_PIN(PORT_B, 3), .cc_chan = 1},
151  { .pin = GPIO_PIN(PORT_B, 10), .cc_chan = 2},
152  { .pin = GPIO_PIN(PORT_B, 11), .cc_chan = 3} },
153  .af = GPIO_AF1,
154  .bus = APB1
155  },
156  {
157  .dev = TIM3,
158  .rcc_mask = RCC_APB1ENR1_TIM3EN,
159  .chan = { { .pin = GPIO_PIN(PORT_B, 4), .cc_chan = 0 },
160  { .pin = GPIO_UNDEF, .cc_chan = 0 },
161  { .pin = GPIO_UNDEF, .cc_chan = 0 },
162  { .pin = GPIO_UNDEF, .cc_chan = 0 } },
163  .af = GPIO_AF2,
164  .bus = APB1
165  },
166  {
167  .dev = TIM8,
168  .rcc_mask = RCC_APB2ENR_TIM8EN,
169  .chan = { { .pin = GPIO_PIN(PORT_C, 6), .cc_chan = 0},
170  { .pin = GPIO_PIN(PORT_C, 7), .cc_chan = 1},
171  { .pin = GPIO_PIN(PORT_C, 8), .cc_chan = 2},
172  { .pin = GPIO_PIN(PORT_C, 9), .cc_chan = 3} },
173  .af = GPIO_AF3,
174  .bus = APB2
175  }
176 };
177 
178 #define PWM_NUMOF ARRAY_SIZE(pwm_config)
179 
185 static const spi_conf_t spi_config[] = {
186  {
187  .dev = SPI1,
188  .mosi_pin = GPIO_PIN(PORT_A, 7),
189  .miso_pin = GPIO_PIN(PORT_A, 6),
190  .sclk_pin = GPIO_PIN(PORT_A, 5),
191  .cs_pin = GPIO_UNDEF,
192  .mosi_af = GPIO_AF5,
193  .miso_af = GPIO_AF5,
194  .sclk_af = GPIO_AF5,
195  .cs_af = GPIO_AF5,
196  .rccmask = RCC_APB2ENR_SPI1EN,
197  .apbbus = APB2,
198 #ifdef MODULE_PERIPH_DMA
199  .tx_dma = 1,
200  .tx_dma_chan = 1,
201  .rx_dma = 0,
202  .rx_dma_chan = 1,
203 #endif
204  }
205 };
206 
207 #define SPI_NUMOF ARRAY_SIZE(spi_config)
208 
217 static const adc_conf_t adc_config[] = {
218  {GPIO_PIN(PORT_A, 0), 0, 5}, /*< ADC12_IN5 */
219  {GPIO_PIN(PORT_A, 1), 0, 6}, /*< ADC12_IN6 */
220  {GPIO_PIN(PORT_A, 4), 1, 9}, /*< ADC12_IN9 */
221  {GPIO_PIN(PORT_B, 0), 1, 15}, /*< ADC12_IN15 */
222  {GPIO_PIN(PORT_C, 1), 2, 2}, /*< ADC123_IN_2 */
223  {GPIO_PIN(PORT_C, 0), 2, 1}, /*< ADC123_IN_1 */
224 };
225 
226 #define ADC_NUMOF ARRAY_SIZE(adc_config)
227 
229 #ifdef __cplusplus
230 }
231 #endif
232 
233 #endif /* PERIPH_CONF_H */
234 
PORT_C
@ PORT_C
port C
Definition: periph_cpu.h:38
pwm_conf_t::dev
mini_timer_t * dev
Timer used.
Definition: periph_cpu_common.h:154
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
dma_conf_t::stream
int stream
DMA stream on stm32f2/4/7, channel on others STM32F2/4/7:
Definition: periph_cpu.h:443
pwm_conf_t
PWM device configuration.
Definition: periph_cpu_common.h:153
GPIO_UNDEF
#define GPIO_UNDEF
Definition of a fitting UNDEF value.
Definition: periph_cpu_common.h:52
uart_conf_t
UART device configuration.
Definition: periph_cpu.h:166
STM32_USART
@ STM32_USART
STM32 USART module type.
Definition: periph_cpu.h:583
GPIO_AF1
@ GPIO_AF1
use alternate function 1
Definition: periph_cpu_common.h:87
GPIO_AF3
@ GPIO_AF3
use alternate function 3
Definition: periph_cpu_common.h:89
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
timer_conf_t::dev
uint32_t dev
Address of timer base.
Definition: periph_cpu.h:112
cfg_i2c1_pb8_pb9.h
Common configuration for STM32 I2C.
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
APB1
@ APB1
APB1 bus.
Definition: periph_cpu.h:176