periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Freie Universit├Ąt Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
20 #ifndef PERIPH_CONF_H
21 #define PERIPH_CONF_H
22 
23 #include "periph_cpu.h"
24 #include "f4/cfg_clock_168_8_0.h"
25 #include "cfg_spi_divtable.h"
26 #include "cfg_usb_otg_fs.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
36 static const dma_conf_t dma_config[] = {
37  { .stream = 11 }, /* DMA2 Stream 3 - SPI1_TX */
38  { .stream = 10 }, /* DMA2 Stream 2 - SPI1_RX */
39  { .stream = 4 }, /* DMA1 Stream 4 - SPI2_TX */
40  { .stream = 3 }, /* DMA1 Stream 3 - SPI2_RX */
41 };
42 
43 #define DMA_0_ISR isr_dma2_stream3
44 #define DMA_1_ISR isr_dma2_stream2
45 #define DMA_2_ISR isr_dma1_stream4
46 #define DMA_3_ISR isr_dma1_stream3
47 
48 #define DMA_NUMOF ARRAY_SIZE(dma_config)
49 
55 static const timer_conf_t timer_config[] = {
56  {
57  .dev = TIM2,
58  .max = 0xffffffff,
59  .rcc_mask = RCC_APB1ENR_TIM2EN,
60  .bus = APB1,
61  .irqn = TIM2_IRQn
62  },
63  {
64  .dev = TIM5,
65  .max = 0xffffffff,
66  .rcc_mask = RCC_APB1ENR_TIM5EN,
67  .bus = APB1,
68  .irqn = TIM5_IRQn
69  }
70 };
71 
72 #define TIMER_0_ISR isr_tim2
73 #define TIMER_1_ISR isr_tim5
74 
75 #define TIMER_NUMOF ARRAY_SIZE(timer_config)
76 
82 static const uart_conf_t uart_config[] = {
83  {
84  .dev = USART2,
85  .rcc_mask = RCC_APB1ENR_USART2EN,
86  .rx_pin = GPIO_PIN(PORT_A, 3),
87  .tx_pin = GPIO_PIN(PORT_A, 2),
88  .rx_af = GPIO_AF7,
89  .tx_af = GPIO_AF7,
90  .bus = APB1,
91  .irqn = USART2_IRQn,
92 #ifdef MODULE_PERIPH_DMA
93  .dma = DMA_STREAM_UNDEF,
94  .dma_chan = UINT8_MAX,
95 #endif
96  },
97  {
98  .dev = USART3,
99  .rcc_mask = RCC_APB1ENR_USART3EN,
100  .rx_pin = GPIO_PIN(PORT_D, 9),
101  .tx_pin = GPIO_PIN(PORT_D, 8),
102  .rx_af = GPIO_AF7,
103  .tx_af = GPIO_AF7,
104  .bus = APB1,
105  .irqn = USART3_IRQn,
106 #ifdef MODULE_PERIPH_DMA
107  .dma = DMA_STREAM_UNDEF,
108  .dma_chan = UINT8_MAX,
109 #endif
110  }
111 };
112 
113 #define UART_0_ISR (isr_usart2)
114 #define UART_1_ISR (isr_usart3)
115 
116 #define UART_NUMOF ARRAY_SIZE(uart_config)
117 
126 #define ADC_CONFIG { \
127  {GPIO_PIN(PORT_A, 1), 0, 1}, \
128  {GPIO_PIN(PORT_A, 4), 0, 4}, \
129  {GPIO_PIN(PORT_C, 1), 1, 11}, \
130  {GPIO_PIN(PORT_C, 2), 1, 12} \
131 }
132 
133 #define ADC_NUMOF (4)
134 
140 static const dac_conf_t dac_config[] = {
141  { .pin = GPIO_PIN(PORT_A, 4), .chan = 0 },
142  { .pin = GPIO_PIN(PORT_A, 5), .chan = 1 }
143 };
144 
145 #define DAC_NUMOF ARRAY_SIZE(dac_config)
146 
152 static const pwm_conf_t pwm_config[] = {
153  {
154  .dev = TIM1,
155  .rcc_mask = RCC_APB2ENR_TIM1EN,
156  .chan = { { .pin = GPIO_PIN(PORT_E, 9), .cc_chan = 0 },
157  { .pin = GPIO_PIN(PORT_E, 11), .cc_chan = 1 },
158  { .pin = GPIO_PIN(PORT_E, 11), .cc_chan = 2 },
159  { .pin = GPIO_PIN(PORT_E, 14), .cc_chan = 3 } },
160  .af = GPIO_AF1,
161  .bus = APB2
162  },
163  {
164  .dev = TIM3,
165  .rcc_mask = RCC_APB1ENR_TIM3EN,
166  .chan = { { .pin = GPIO_PIN(PORT_B, 4), .cc_chan = 0 },
167  { .pin = GPIO_PIN(PORT_B, 5), .cc_chan = 1 },
168  { .pin = GPIO_PIN(PORT_B, 0), .cc_chan = 2 },
169  { .pin = GPIO_PIN(PORT_B, 1), .cc_chan = 3 } },
170  .af = GPIO_AF2,
171  .bus = APB1
172  }
173 };
174 
175 #define PWM_NUMOF ARRAY_SIZE(pwm_config)
176 
182 static const spi_conf_t spi_config[] = {
183  {
184  .dev = SPI1,
185  .mosi_pin = GPIO_PIN(PORT_A, 7),
186  .miso_pin = GPIO_PIN(PORT_A, 6),
187  .sclk_pin = GPIO_PIN(PORT_A, 5),
188  .cs_pin = GPIO_PIN(PORT_A, 4),
189  .mosi_af = GPIO_AF5,
190  .miso_af = GPIO_AF5,
191  .sclk_af = GPIO_AF5,
192  .cs_af = GPIO_AF5,
193  .rccmask = RCC_APB2ENR_SPI1EN,
194  .apbbus = APB2,
195 #ifdef MODULE_PERIPH_DMA
196  .tx_dma = 0,
197  .tx_dma_chan = 3,
198  .rx_dma = 1,
199  .rx_dma_chan = 3,
200 #endif
201  },
202  {
203  .dev = SPI2,
204  .mosi_pin = GPIO_PIN(PORT_B, 15),
205  .miso_pin = GPIO_PIN(PORT_B, 14),
206  .sclk_pin = GPIO_PIN(PORT_B, 13),
207  .cs_pin = GPIO_PIN(PORT_B, 12),
208  .mosi_af = GPIO_AF5,
209  .miso_af = GPIO_AF5,
210  .sclk_af = GPIO_AF5,
211  .cs_af = GPIO_AF5,
212  .rccmask = RCC_APB1ENR_SPI2EN,
213  .apbbus = APB1,
214 #ifdef MODULE_PERIPH_DMA
215  .tx_dma = 2,
216  .tx_dma_chan = 0,
217  .rx_dma = 3,
218  .rx_dma_chan = 0,
219 #endif
220  },
221 };
222 
223 #define SPI_NUMOF ARRAY_SIZE(spi_config)
224 
230 static const i2c_conf_t i2c_config[] = {
231  {
232  .dev = I2C1,
233  .speed = I2C_SPEED_NORMAL,
234  .scl_pin = GPIO_PIN(PORT_B, 6),
235  .sda_pin = GPIO_PIN(PORT_B, 9),
236  .scl_af = GPIO_AF4,
237  .sda_af = GPIO_AF4,
238  .bus = APB1,
239  .rcc_mask = RCC_APB1ENR_I2C1EN,
240  .clk = CLOCK_APB1,
241  .irqn = I2C1_EV_IRQn
242  }
243 };
244 
245 #define I2C_0_ISR isr_i2c1_ev
246 
247 #define I2C_NUMOF ARRAY_SIZE(i2c_config)
248 
250 #ifdef __cplusplus
251 }
252 #endif
253 
254 #endif /* PERIPH_CONF_H */
255 
DMA configuration.
Definition: periph_cpu.h:395
cc2538_uart_t * dev
pointer to the used UART device
Definition: periph_cpu.h:167
I2C configuration options.
Definition: periph_cpu.h:128
gpio_t pin
pin connected to the line
Definition: periph_cpu.h:488
SPI_Type * dev
SPI device to use.
Definition: periph_cpu.h:458
mini_timer_t * dev
Timer used.
PWM device configuration.
NRF_TIMER_Type * dev
timer device
Common configuration for STM32 OTG FS peripheral.
use alternate function 1
use alternate function 5
Configure STM32F4 clock to 168MHz using PLL and without LSE.
use alternate function 2
port E
Definition: periph_cpu.h:40
port D
Definition: periph_cpu.h:39
Collection of pre-computed bus pre-scalers for SPI configuration.
port A
Definition: periph_cpu.h:36
use alternate function 4
APB1 bus.
Definition: periph_cpu.h:167
UART device configuration.
Definition: periph_cpu.h:166
APB2 bus.
Definition: periph_cpu.h:168
I2C_TypeDef * dev
USART device used.
Definition: periph_cpu.h:240
DAC line configuration data.
Definition: periph_cpu.h:487
int stream
DMA stream on stm32f2/4/7, channel on others STM32F2/4/7:
Definition: periph_cpu.h:418
SPI configuration structure type.
Definition: periph_cpu.h:273
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition: periph_cpu.h:35
normal mode: ~100 kbit/s
Definition: i2c.h:183
Timer configuration.
Definition: periph_cpu.h:288
use alternate function 7
port B
Definition: periph_cpu.h:37