periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 TriaGnoSys GmbH
3  * 2017 Alexander Kurth, Sören Tempel, Tristan Bruns
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 
24 #ifndef PERIPH_CONF_H
25 #define PERIPH_CONF_H
26 
27 /* blxxxpill boards provide an LSE */
28 #ifndef CONFIG_BOARD_HAS_LSE
29 #define CONFIG_BOARD_HAS_LSE 1
30 #endif
31 
32 /* blxxxpill boards provide an HSE */
33 #ifndef CONFIG_BOARD_HAS_HSE
34 #define CONFIG_BOARD_HAS_HSE 1
35 #endif
36 
37 #include "periph_cpu.h"
38 #include "clk_conf.h"
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
48 #ifndef RTT_FREQUENCY
49 #define RTT_FREQUENCY (16384) /* in Hz */
50 #endif
51 
57 static const adc_conf_t adc_config[] = {
58  { .pin = GPIO_PIN(PORT_A, 0), .dev = 0, .chan = 0 },
59  { .pin = GPIO_PIN(PORT_A, 1), .dev = 0, .chan = 1 },
60  { .pin = GPIO_PIN(PORT_A, 4), .dev = 0, .chan = 4 },
61  { .pin = GPIO_PIN(PORT_A, 5), .dev = 0, .chan = 5 },
62  { .pin = GPIO_PIN(PORT_A, 6), .dev = 0, .chan = 6 },
63  { .pin = GPIO_PIN(PORT_A, 7), .dev = 0, .chan = 7 },
64  { .pin = GPIO_PIN(PORT_B, 0), .dev = 0, .chan = 8 },
65  { .pin = GPIO_PIN(PORT_B, 1), .dev = 0, .chan = 9 },
66  /* ADC Temperature channel */
67  { .pin = GPIO_UNDEF, .dev = 0, .chan = 16 },
68  /* ADC VREF channel */
69  { .pin = GPIO_UNDEF, .dev = 0, .chan = 17 },
70 };
71 
72 #define ADC_NUMOF ARRAY_SIZE(adc_config)
73 
79 static const dma_conf_t dma_config[] = {
80  { .stream = 1 }, /* DMA1 Channel 2 - SPI1_RX / USART3_TX */
81  { .stream = 2 }, /* DMA1 Channel 3 - SPI1_TX */
82  { .stream = 3 }, /* DMA1 Channel 4 - SPI2_RX / USART1_TX */
83  { .stream = 4 }, /* DMA1 Channel 5 - SPI2_TX */
84  { .stream = 6 }, /* DMA1 Channel 7 - USART2_TX */
85 };
86 
87 #define DMA_0_ISR isr_dma1_channel2
88 #define DMA_1_ISR isr_dma1_channel3
89 #define DMA_2_ISR isr_dma1_channel4
90 #define DMA_3_ISR isr_dma1_channel5
91 #define DMA_4_ISR isr_dma1_channel7
92 
93 #define DMA_NUMOF ARRAY_SIZE(dma_config)
94 
100 static const timer_conf_t timer_config[] = {
101  {
102  .dev = TIM2,
103  .max = 0x0000ffff,
104  .rcc_mask = RCC_APB1ENR_TIM2EN,
105  .bus = APB1,
106  .irqn = TIM2_IRQn
107  },
108  {
109  .dev = TIM3,
110  .max = 0x0000ffff,
111  .rcc_mask = RCC_APB1ENR_TIM3EN,
112  .bus = APB1,
113  .irqn = TIM3_IRQn
114  },
115  {
116  .dev = TIM4,
117  .max = 0x0000ffff,
118  .rcc_mask = RCC_APB1ENR_TIM4EN,
119  .bus = APB1,
120  .irqn = TIM4_IRQn
121  }
122 };
123 
124 #define TIMER_0_ISR isr_tim2
125 #define TIMER_1_ISR isr_tim3
126 #define TIMER_2_ISR isr_tim4
127 
128 #define TIMER_NUMOF ARRAY_SIZE(timer_config)
129 
136 static const qdec_conf_t qdec_config[] = {
137  {
138  .dev = TIM1,
139  .max = 0x0000ffff,
140  .rcc_mask = RCC_APB2ENR_TIM1EN,
141  .chan = { { .pin = GPIO_PIN(PORT_A, 8), .cc_chan = 0 },
142  { .pin = GPIO_PIN(PORT_A, 9), .cc_chan = 1 } },
143  .bus = APB2,
144  .irqn = TIM1_UP_IRQn
145  },
146  {
147  .dev = TIM3,
148  .max = 0x0000ffff,
149  .rcc_mask = RCC_APB1ENR_TIM3EN,
150  .chan = { { .pin = GPIO_PIN(PORT_A, 6), .cc_chan = 0 },
151  { .pin = GPIO_PIN(PORT_A, 7), .cc_chan = 1 } },
152  .bus = APB1,
153  .irqn = TIM3_IRQn
154  },
155  {
156  .dev = TIM4,
157  .max = 0x0000ffff,
158  .rcc_mask = RCC_APB1ENR_TIM4EN,
159  .chan = { { .pin = GPIO_PIN(PORT_B, 6), .cc_chan = 0 },
160  { .pin = GPIO_PIN(PORT_B, 7), .cc_chan = 1 } },
161  .bus = APB1,
162  .irqn = TIM4_IRQn
163  }
164 };
165 
166 #define QDEC_NUMOF ARRAY_SIZE(qdec_config)
167 
173 static const uart_conf_t uart_config[] = {
174  {
175  .dev = USART1,
176  .rcc_mask = RCC_APB2ENR_USART1EN,
177  .rx_pin = GPIO_PIN(PORT_A, 10),
178  .tx_pin = GPIO_PIN(PORT_A, 9),
179  .bus = APB2,
180  .irqn = USART1_IRQn,
181 #ifdef MODULE_PERIPH_DMA
182  .dma = 2,
183  .dma_chan = DMA_CHAN_CONFIG_UNSUPPORTED
184 #endif
185  },
186  {
187  .dev = USART2,
188  .rcc_mask = RCC_APB1ENR_USART2EN,
189  .rx_pin = GPIO_PIN(PORT_A, 3),
190  .tx_pin = GPIO_PIN(PORT_A, 2),
191  .bus = APB1,
192  .irqn = USART2_IRQn,
193 #ifdef MODULE_PERIPH_DMA
194  .dma = 4,
195  .dma_chan = DMA_CHAN_CONFIG_UNSUPPORTED
196 #endif
197  },
198  {
199  .dev = USART3,
200  .rcc_mask = RCC_APB1ENR_USART3EN,
201  .rx_pin = GPIO_PIN(PORT_B, 11),
202  .tx_pin = GPIO_PIN(PORT_B, 10),
203  .bus = APB1,
204  .irqn = USART3_IRQn,
205 #ifdef MODULE_PERIPH_DMA
206  .dma = 0,
207  .dma_chan = DMA_CHAN_CONFIG_UNSUPPORTED
208 #endif
209  }
210 };
211 
212 #define UART_0_ISR (isr_usart1)
213 #define UART_1_ISR (isr_usart2)
214 #define UART_2_ISR (isr_usart3)
215 
216 #define UART_NUMOF ARRAY_SIZE(uart_config)
217 
224 static const i2c_conf_t i2c_config[] = {
225  {
226  .dev = I2C1,
227  .speed = I2C_SPEED_NORMAL,
228  .scl_pin = GPIO_PIN(PORT_B, 6),
229  .sda_pin = GPIO_PIN(PORT_B, 7),
230  .bus = APB1,
231  .rcc_mask = RCC_APB1ENR_I2C1EN,
232  .clk = CLOCK_APB1,
233  .irqn = I2C1_EV_IRQn
234  },
235  {
236  .dev = I2C2,
237  .speed = I2C_SPEED_NORMAL,
238  .scl_pin = GPIO_PIN(PORT_B, 10),
239  .sda_pin = GPIO_PIN(PORT_B, 11),
240  .bus = APB1,
241  .rcc_mask = RCC_APB1ENR_I2C2EN,
242  .clk = CLOCK_APB1,
243  .irqn = I2C2_EV_IRQn
244  }
245 };
246 
247 #define I2C_0_ISR isr_i2c1_ev
248 #define I2C_1_ISR isr_i2c2_ev
249 
250 #define I2C_NUMOF ARRAY_SIZE(i2c_config)
251 
257 static const pwm_conf_t pwm_config[] = {
258  {
259  .dev = TIM1,
260  .rcc_mask = RCC_APB2ENR_TIM1EN,
261  .chan = { { .pin = GPIO_PIN(PORT_A, 8), .cc_chan = 0 },
262  { .pin = GPIO_PIN(PORT_A, 9), .cc_chan = 1 },
263  { .pin = GPIO_PIN(PORT_A, 10), .cc_chan = 2 },
264  { .pin = GPIO_PIN(PORT_A, 11), .cc_chan = 3 } },
265  .af = GPIO_AF_OUT_PP,
266  .bus = APB2
267  }
268 };
269 
270 #define PWM_NUMOF ARRAY_SIZE(pwm_config)
271 
277 static const spi_conf_t spi_config[] = {
278  {
279  .dev = SPI1,
280  .mosi_pin = GPIO_PIN(PORT_A, 7),
281  .miso_pin = GPIO_PIN(PORT_A, 6),
282  .sclk_pin = GPIO_PIN(PORT_A, 5),
283  .cs_pin = GPIO_PIN(PORT_A, 4),
284  .rccmask = RCC_APB2ENR_SPI1EN,
285  .apbbus = APB2,
286 #ifdef MODULE_PERIPH_DMA
287  .tx_dma = 1,
288  .tx_dma_chan = DMA_CHAN_CONFIG_UNSUPPORTED,
289  .rx_dma = 0,
290  .rx_dma_chan = DMA_CHAN_CONFIG_UNSUPPORTED
291 #endif
292  },
293  {
294  .dev = SPI2,
295  .mosi_pin = GPIO_PIN(PORT_B, 15),
296  .miso_pin = GPIO_PIN(PORT_B, 14),
297  .sclk_pin = GPIO_PIN(PORT_B, 13),
298  .cs_pin = GPIO_PIN(PORT_B, 12),
299  .rccmask = RCC_APB1ENR_SPI2EN,
300  .apbbus = APB1,
301 #ifdef MODULE_PERIPH_DMA
302  .tx_dma = 3,
303  .tx_dma_chan = DMA_CHAN_CONFIG_UNSUPPORTED,
304  .rx_dma = 2,
305  .rx_dma_chan = DMA_CHAN_CONFIG_UNSUPPORTED
306 #endif
307  }
308 };
309 
310 #define SPI_NUMOF ARRAY_SIZE(spi_config)
311 
313 #ifdef __cplusplus
314 }
315 #endif
316 
317 #endif /* PERIPH_CONF_H */
318 
DMA_CHAN_CONFIG_UNSUPPORTED
#define DMA_CHAN_CONFIG_UNSUPPORTED
DMA channel/trigger configuration for DMA peripherals without channel/trigger filtering such as the s...
Definition: periph_cpu.h:464
pwm_conf_t::dev
mini_timer_t * dev
Timer used.
Definition: periph_cpu_common.h:154
I2C_SPEED_NORMAL
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition: i2c.h:177
PORT_A
@ PORT_A
port A
Definition: periph_cpu.h:36
adc_conf_t::pin
gpio_t pin
pin to use
Definition: periph_cpu.h:343
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
qdec_conf_t::dev
TIM_TypeDef * dev
Timer used.
Definition: periph_cpu.h:567
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
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
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
qdec_conf_t
QDEC configuration.
Definition: periph_cpu.h:566
dma_conf_t
DMA configuration.
Definition: periph_cpu.h:420
i2c_conf_t
I2C configuration options.
Definition: periph_cpu.h:128
timer_conf_t::dev
uint32_t dev
Address of timer base.
Definition: periph_cpu.h:112
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
i2c_conf_t::dev
I2C_TypeDef * dev
USART device used.
Definition: periph_cpu.h:247
APB1
@ APB1
APB1 bus.
Definition: periph_cpu.h:176