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 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
35 static const timer_conf_t timer_config[] = {
36  {
37  .dev = TIM2,
38  .max = 0xffffffff,
39  .rcc_mask = RCC_APB1ENR_TIM2EN,
40  .bus = APB1,
41  .irqn = TIM2_IRQn
42  },
43  {
44  .dev = TIM5,
45  .max = 0xffffffff,
46  .rcc_mask = RCC_APB1ENR_TIM5EN,
47  .bus = APB1,
48  .irqn = TIM5_IRQn
49  }
50 };
51 
52 #define TIMER_0_ISR isr_tim2
53 #define TIMER_1_ISR isr_tim5
54 
55 #define TIMER_NUMOF ARRAY_SIZE(timer_config)
56 
62 static const uart_conf_t uart_config[] = {
63  {
64  .dev = USART2,
65  .rcc_mask = RCC_APB1ENR_USART2EN,
66  .rx_pin = GPIO_PIN(PORT_A, 3),
67  .tx_pin = GPIO_PIN(PORT_A, 2),
68  .rx_af = GPIO_AF7,
69  .tx_af = GPIO_AF7,
70  .bus = APB1,
71  .irqn = USART2_IRQn,
72 #ifdef UART_USE_DMA
73  .dma_stream = 6,
74  .dma_chan = 4
75 #endif
76  },
77  {
78  .dev = USART3,
79  .rcc_mask = RCC_APB1ENR_USART3EN,
80  .rx_pin = GPIO_PIN(PORT_D, 9),
81  .tx_pin = GPIO_PIN(PORT_D, 8),
82  .rx_af = GPIO_AF7,
83  .tx_af = GPIO_AF7,
84  .bus = APB1,
85  .irqn = USART3_IRQn,
86 #ifdef UART_USE_DMA
87  .dma_stream = 3,
88  .dma_chan = 4
89 #endif
90  }
91 };
92 
93 #define UART_0_ISR (isr_usart2)
94 #define UART_0_DMA_ISR (isr_dma1_stream6)
95 #define UART_1_ISR (isr_usart3)
96 #define UART_1_DMA_ISR (isr_dma1_stream3)
97 
98 #define UART_NUMOF ARRAY_SIZE(uart_config)
99 
108 #define ADC_CONFIG { \
109  {GPIO_PIN(PORT_A, 1), 0, 1}, \
110  {GPIO_PIN(PORT_A, 4), 0, 4}, \
111  {GPIO_PIN(PORT_C, 1), 1, 11}, \
112  {GPIO_PIN(PORT_C, 2), 1, 12} \
113 }
114 
115 #define ADC_NUMOF (4)
116 
122 static const dac_conf_t dac_config[] = {
123  { .pin = GPIO_PIN(PORT_A, 4), .chan = 0 },
124  { .pin = GPIO_PIN(PORT_A, 5), .chan = 1 }
125 };
126 
127 #define DAC_NUMOF ARRAY_SIZE(dac_config)
128 
134 static const pwm_conf_t pwm_config[] = {
135  {
136  .dev = TIM1,
137  .rcc_mask = RCC_APB2ENR_TIM1EN,
138  .chan = { { .pin = GPIO_PIN(PORT_E, 9), .cc_chan = 0 },
139  { .pin = GPIO_PIN(PORT_E, 11), .cc_chan = 1 },
140  { .pin = GPIO_PIN(PORT_E, 11), .cc_chan = 2 },
141  { .pin = GPIO_PIN(PORT_E, 14), .cc_chan = 3 } },
142  .af = GPIO_AF1,
143  .bus = APB2
144  },
145  {
146  .dev = TIM3,
147  .rcc_mask = RCC_APB1ENR_TIM3EN,
148  .chan = { { .pin = GPIO_PIN(PORT_B, 4), .cc_chan = 0 },
149  { .pin = GPIO_PIN(PORT_B, 5), .cc_chan = 1 },
150  { .pin = GPIO_PIN(PORT_B, 0), .cc_chan = 2 },
151  { .pin = GPIO_PIN(PORT_B, 1), .cc_chan = 3 } },
152  .af = GPIO_AF2,
153  .bus = APB1
154  }
155 };
156 
157 #define PWM_NUMOF ARRAY_SIZE(pwm_config)
158 
164 static const spi_conf_t spi_config[] = {
165  {
166  .dev = SPI1,
167  .mosi_pin = GPIO_PIN(PORT_A, 7),
168  .miso_pin = GPIO_PIN(PORT_A, 6),
169  .sclk_pin = GPIO_PIN(PORT_A, 5),
170  .cs_pin = GPIO_PIN(PORT_A, 4),
171  .mosi_af = GPIO_AF5,
172  .miso_af = GPIO_AF5,
173  .sclk_af = GPIO_AF5,
174  .cs_af = GPIO_AF5,
175  .rccmask = RCC_APB2ENR_SPI1EN,
176  .apbbus = APB2
177  },
178  {
179  .dev = SPI2,
180  .mosi_pin = GPIO_PIN(PORT_B, 15),
181  .miso_pin = GPIO_PIN(PORT_B, 14),
182  .sclk_pin = GPIO_PIN(PORT_B, 13),
183  .cs_pin = GPIO_PIN(PORT_B, 12),
184  .mosi_af = GPIO_AF5,
185  .miso_af = GPIO_AF5,
186  .sclk_af = GPIO_AF5,
187  .cs_af = GPIO_AF5,
188  .rccmask = RCC_APB1ENR_SPI2EN,
189  .apbbus = APB1
190  }
191 };
192 
193 #define SPI_NUMOF ARRAY_SIZE(spi_config)
194 
200 static const i2c_conf_t i2c_config[] = {
201  {
202  .dev = I2C1,
203  .speed = I2C_SPEED_NORMAL,
204  .scl_pin = GPIO_PIN(PORT_B, 6),
205  .sda_pin = GPIO_PIN(PORT_B, 7),
206  .scl_af = GPIO_AF4,
207  .sda_af = GPIO_AF4,
208  .bus = APB1,
209  .rcc_mask = RCC_APB1ENR_I2C1EN,
210  .clk = CLOCK_APB1,
211  .irqn = I2C1_EV_IRQn
212  }
213 };
214 
215 #define I2C_0_ISR isr_i2c1_ev
216 
217 #define I2C_NUMOF ARRAY_SIZE(i2c_config)
218 
220 #ifdef __cplusplus
221 }
222 #endif
223 
224 #endif /* PERIPH_CONF_H */
225 
use alternate function 4
use alternate function 7
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
APB1 bus.
SPI_Type * dev
SPI device to use.
Definition: periph_cpu.h:435
mini_timer_t * dev
Timer used.
use alternate function 1
PWM configuration.
NRF_TIMER_Type * dev
timer device
Configure STM32F4 clock to 168MHz using PLL and without LSE.
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
APB2 bus.
use alternate function 5
UART device configuration.
Definition: periph_cpu.h:166
I2C_TypeDef * dev
USART device used.
Definition: periph_cpu.h:240
DAC line configuration data.
SPI configuration structure type.
Definition: periph_cpu.h:271
#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:286
use alternate function 2
port B
Definition: periph_cpu.h:37