boards/stm32f4discovery/include/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_1.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 (sizeof(timer_config) / sizeof(timer_config[0]))
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 (sizeof(uart_config) / sizeof(uart_config[0]))
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 (sizeof(dac_config) / sizeof(dac_config[0]))
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 (sizeof(pwm_config) / sizeof(pwm_config[0]))
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  .af = GPIO_AF5,
172  .rccmask = RCC_APB2ENR_SPI1EN,
173  .apbbus = APB2
174  },
175  {
176  .dev = SPI2,
177  .mosi_pin = GPIO_PIN(PORT_B, 15),
178  .miso_pin = GPIO_PIN(PORT_B, 14),
179  .sclk_pin = GPIO_PIN(PORT_B, 13),
180  .cs_pin = GPIO_PIN(PORT_B, 12),
181  .af = GPIO_AF5,
182  .rccmask = RCC_APB1ENR_SPI2EN,
183  .apbbus = APB1
184  }
185 };
186 
187 #define SPI_NUMOF (sizeof(spi_config) / sizeof(spi_config[0]))
188 
194 #define I2C_NUMOF (1U)
195 #define I2C_0_EN 1
196 #define I2C_IRQ_PRIO 1
197 #define I2C_APBCLK (CLOCK_APB1)
198 
199 /* I2C 0 device configuration */
200 #define I2C_0_DEV I2C1
201 #define I2C_0_CLKEN() (periph_clk_en(APB1, RCC_APB1ENR_I2C1EN))
202 #define I2C_0_CLKDIS() (periph_clk_dis(APB1, RCC_APB1ENR_I2C1EN))
203 #define I2C_0_EVT_IRQ I2C1_EV_IRQn
204 #define I2C_0_EVT_ISR isr_i2c1_ev
205 #define I2C_0_ERR_IRQ I2C1_ER_IRQn
206 #define I2C_0_ERR_ISR isr_i2c1_er
207 /* I2C 0 pin configuration */
208 #define I2C_0_SCL_PORT GPIOB
209 #define I2C_0_SCL_PIN 6
210 #define I2C_0_SCL_AF 4
211 #define I2C_0_SCL_CLKEN() (periph_clk_en(AHB1, RCC_AHB1ENR_GPIOBEN))
212 #define I2C_0_SDA_PORT GPIOB
213 #define I2C_0_SDA_PIN 7
214 #define I2C_0_SDA_AF 4
215 #define I2C_0_SDA_CLKEN() (periph_clk_en(AHB1, RCC_AHB1ENR_GPIOBEN))
216 
218 #ifdef __cplusplus
219 }
220 #endif
221 
222 #endif /* PERIPH_CONF_H */
223 
use alternate function 7
cc2538_uart_t * dev
pointer to the used UART device
TIMER_TypeDef * dev
TIMER device used.
Configure STM32F4 clock to 168MHz using PLL.
gpio_t pin
pin connected to the line
use alternate function 1
PWM device configuration.
NRF_TIMER_Type * dev
timer device
Collection of pre-computed bus pre-scalers for SPI configuration.
use alternate function 5
UART device configuration.
DAC line configuration data.
SPI module configuration options.
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Timer configuration.
use alternate function 2
cc2538_ssi_t * dev
SSI device.