periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014-2016 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 "clk_conf.h"
25 #include "cfg_timer_tim5.h"
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
35 static const dma_conf_t dma_config[] = {
36  { .stream = 1 }, /* DMA1 Channel 2 - SPI1_RX / USART3_TX */
37  { .stream = 2 }, /* DMA1 Channel 3 - SPI1_TX */
38  { .stream = 6 }, /* DMA1 Channel 7 - USART2_TX */
39  { .stream = 4 }, /* DMA1 Channel 4 - USART1_TX */
40 };
41 
42 #define DMA_0_ISR isr_dma1_channel2
43 #define DMA_1_ISR isr_dma1_channel3
44 #define DMA_2_ISR isr_dma1_channel7
45 #define DMA_3_ISR isr_dma1_channel4
46 
47 #define DMA_NUMOF ARRAY_SIZE(dma_config)
48 
54 static const uart_conf_t uart_config[] = {
55  {
56  .dev = USART2,
57  .rcc_mask = RCC_APB1ENR_USART2EN,
58  .rx_pin = GPIO_PIN(PORT_A, 3),
59  .tx_pin = GPIO_PIN(PORT_A, 2),
60  .rx_af = GPIO_AF7,
61  .tx_af = GPIO_AF7,
62  .bus = APB1,
63  .irqn = USART2_IRQn,
64 #ifdef MODULE_PERIPH_DMA
65  .dma = 2,
66  .dma_chan = 2
67 #endif
68  },
69  {
70  .dev = USART1,
71  .rcc_mask = RCC_APB2ENR_USART1EN,
72  .rx_pin = GPIO_PIN(PORT_A, 10),
73  .tx_pin = GPIO_PIN(PORT_A, 9),
74  .rx_af = GPIO_AF7,
75  .tx_af = GPIO_AF7,
76  .bus = APB2,
77  .irqn = USART1_IRQn,
78 #ifdef MODULE_PERIPH_DMA
79  .dma = 3,
80  .dma_chan = 2
81 #endif
82  },
83  {
84  .dev = USART3,
85  .rcc_mask = RCC_APB1ENR_USART3EN,
86  .rx_pin = GPIO_PIN(PORT_C, 11),
87  .tx_pin = GPIO_PIN(PORT_C, 10),
88  .rx_af = GPIO_AF7,
89  .tx_af = GPIO_AF7,
90  .bus = APB1,
91  .irqn = USART3_IRQn,
92 #ifdef MODULE_PERIPH_DMA
93  .dma = 0,
94  .dma_chan = 2
95 #endif
96  },
97 };
98 
99 #define UART_0_ISR (isr_usart2)
100 #define UART_1_ISR (isr_usart1)
101 #define UART_2_ISR (isr_usart3)
102 
103 #define UART_NUMOF ARRAY_SIZE(uart_config)
104 
110 static const pwm_conf_t pwm_config[] = {
111  {
112  .dev = TIM2,
113  .rcc_mask = RCC_APB1ENR_TIM2EN,
114  .chan = { { .pin = GPIO_PIN(PORT_B, 3) /* D3 */, .cc_chan = 1 },
115  { .pin = GPIO_PIN(PORT_B, 10) /* D6 */, .cc_chan = 2 },
116  { .pin = GPIO_UNDEF, .cc_chan = 0 },
117  { .pin = GPIO_UNDEF, .cc_chan = 0 } },
118  .af = GPIO_AF1,
119  .bus = APB1
120  },
121  {
122  .dev = TIM3,
123  .rcc_mask = RCC_APB1ENR_TIM3EN,
124  .chan = { { .pin = GPIO_PIN(PORT_B, 4) /* D5 */, .cc_chan = 0 },
125  { .pin = GPIO_PIN(PORT_C, 7) /* D9 */, .cc_chan = 1 },
126  { .pin = GPIO_PIN(PORT_C, 8), .cc_chan = 2 },
127  { .pin = GPIO_PIN(PORT_C, 9), .cc_chan = 3 } },
128  .af = GPIO_AF2,
129  .bus = APB1
130  }
131 };
132 
133 #define PWM_NUMOF ARRAY_SIZE(pwm_config)
134 
140 static const spi_conf_t spi_config[] = {
141  {
142  .dev = SPI1,
143  .mosi_pin = GPIO_PIN(PORT_A, 7),
144  .miso_pin = GPIO_PIN(PORT_A, 6),
145  .sclk_pin = GPIO_PIN(PORT_A, 5),
146  .cs_pin = GPIO_UNDEF,
147  .mosi_af = GPIO_AF5,
148  .miso_af = GPIO_AF5,
149  .sclk_af = GPIO_AF5,
150  .cs_af = GPIO_AF5,
151  .rccmask = RCC_APB2ENR_SPI1EN,
152  .apbbus = APB2,
153 #ifdef MODULE_PERIPH_DMA
154  .tx_dma = 1,
155  .tx_dma_chan = 1,
156  .rx_dma = 0,
157  .rx_dma_chan = 1,
158 #endif
159  }
160 };
161 
162 #define SPI_NUMOF ARRAY_SIZE(spi_config)
163 
169 static const i2c_conf_t i2c_config[] = {
170  {
171  .dev = I2C1,
172  .speed = I2C_SPEED_NORMAL,
173  .scl_pin = GPIO_PIN(PORT_B, 8),
174  .sda_pin = GPIO_PIN(PORT_B, 9),
175  .scl_af = GPIO_AF4,
176  .sda_af = GPIO_AF4,
177  .bus = APB1,
178  .rcc_mask = RCC_APB1ENR_I2C1EN,
179  .clk = CLOCK_APB1,
180  .irqn = I2C1_EV_IRQn
181  },
182  {
183  .dev = I2C2,
184  .speed = I2C_SPEED_NORMAL,
185  .scl_pin = GPIO_PIN(PORT_B, 10),
186  .sda_pin = GPIO_PIN(PORT_B, 11),
187  .scl_af = GPIO_AF4,
188  .sda_af = GPIO_AF4,
189  .bus = APB1,
190  .rcc_mask = RCC_APB1ENR_I2C2EN,
191  .clk = CLOCK_APB1,
192  .irqn = I2C2_EV_IRQn
193  }
194 };
195 
196 #define I2C_0_ISR isr_i2c1_ev
197 #define I2C_1_ISR isr_i2c2_ev
198 
199 #define I2C_NUMOF ARRAY_SIZE(i2c_config)
200 
206 static const adc_conf_t adc_config[] = {
207  { GPIO_PIN(PORT_A, 0), 0 },
208  { GPIO_PIN(PORT_A, 1), 1 },
209  { GPIO_PIN(PORT_A, 4), 4 },
210  { GPIO_PIN(PORT_B, 0), 8 },
211  { GPIO_PIN(PORT_C, 1), 11 },
212  { GPIO_PIN(PORT_C, 0), 10 },
213 };
214 
215 #define ADC_NUMOF ARRAY_SIZE(adc_config)
216 
222 static const dac_conf_t dac_config[] = {
223  { .pin = GPIO_PIN(PORT_A, 4), .chan = 0 },
224  { .pin = GPIO_PIN(PORT_A, 5), .chan = 1 }
225 };
226 
227 #define DAC_NUMOF ARRAY_SIZE(dac_config)
228 
231 #ifdef __cplusplus
232 }
233 #endif
234 
235 #endif /* PERIPH_CONF_H */
236 
GPIO_AF4
@ GPIO_AF4
use alternate function 4
Definition: periph_cpu_common.h:90
PORT_C
@ PORT_C
port C
Definition: periph_cpu.h:38
dac_conf_t::pin
gpio_t pin
pin connected to the line
Definition: periph_cpu.h:519
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
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
cfg_timer_tim5.h
Common configuration for STM32 Timer peripheral based on TIM5.
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
GPIO_AF1
@ GPIO_AF1
use alternate function 1
Definition: periph_cpu_common.h:87
dac_conf_t
DAC line configuration data.
Definition: periph_cpu.h:518
uart_conf_t::dev
cc2538_uart_t * dev
pointer to the used UART device
Definition: periph_cpu.h:167
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
i2c_conf_t
I2C configuration options.
Definition: periph_cpu.h:128
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