periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 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 /* This board provides an LSE */
24 #ifndef CONFIG_BOARD_HAS_LSE
25 #define CONFIG_BOARD_HAS_LSE 1
26 #endif
27 
28 /* This board provides an HSE */
29 #ifndef CONFIG_BOARD_HAS_HSE
30 #define CONFIG_BOARD_HAS_HSE 1
31 #endif
32 
33 #include "periph_cpu.h"
34 #include "clk_conf.h"
35 #include "cfg_timer_tim2.h"
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
51 static const adc_conf_t adc_config[] = {
52  { .pin = GPIO_PIN(PORT_A, 0), .dev = 0, .chan = 1 }, /* ADC1_IN1, fast */
53  { .pin = GPIO_PIN(PORT_A, 1), .dev = 0, .chan = 2 }, /* ADC1_IN2, fast */
54  { .pin = GPIO_PIN(PORT_A, 4), .dev = 1, .chan = 1 }, /* ADC2_IN1, fast */
55  { .pin = GPIO_PIN(PORT_B, 0), .dev = 0, .chan = 11 }, /* ADC1_IN11, slow */
56  { .pin = GPIO_PIN(PORT_C, 1), .dev = 1, .chan = 7 }, /* ADC12_IN7, slow */
57  { .pin = GPIO_PIN(PORT_C, 0), .dev = 1, .chan = 6 }, /* ADC12_IN6, slow */
58 };
59 
60 #define ADC_NUMOF ARRAY_SIZE(adc_config)
61 
67 static const dma_conf_t dma_config[] = {
68  { .stream = 1 }, /* DMA1 Channel 2 - SPI1_RX | USART3_TX */
69  { .stream = 2 }, /* DMA1 Channel 3 - SPI1_TX */
70  { .stream = 3 }, /* DMA1 Channel 4 - USART1_TX */
71  { .stream = 6 }, /* DMA1 Channel 7 - USART2_TX */
72 };
73 
74 #define DMA_0_ISR isr_dma1_channel2
75 #define DMA_1_ISR isr_dma1_channel3
76 #define DMA_2_ISR isr_dma1_channel4
77 #define DMA_3_ISR isr_dma1_channel7
78 #define DMA_NUMOF ARRAY_SIZE(dma_config)
79 
85 static const uart_conf_t uart_config[] = {
86  {
87  .dev = USART2,
88  .rcc_mask = RCC_APB1ENR_USART2EN,
89  .rx_pin = GPIO_PIN(PORT_A, 3),
90  .tx_pin = GPIO_PIN(PORT_A, 2),
91  .rx_af = GPIO_AF7,
92  .tx_af = GPIO_AF7,
93  .bus = APB1,
94  .irqn = USART2_IRQn,
95 #ifdef MODULE_PERIPH_DMA
96  .dma = 3,
97  .dma_chan = DMA_CHAN_CONFIG_UNSUPPORTED
98 #endif
99  },
100  {
101  .dev = USART1,
102  .rcc_mask = RCC_APB2ENR_USART1EN,
103  .rx_pin = GPIO_PIN(PORT_A, 10),
104  .tx_pin = GPIO_PIN(PORT_A, 9),
105  .rx_af = GPIO_AF7,
106  .tx_af = GPIO_AF7,
107  .bus = APB2,
108  .irqn = USART1_IRQn,
109 #ifdef MODULE_PERIPH_DMA
110  .dma = 2,
111  .dma_chan = DMA_CHAN_CONFIG_UNSUPPORTED
112 #endif
113  },
114 /* SPI1 RX and USART3 are sharing the same DMA channel, so disable the
115  * third UART when both SPI and DMA features are enabled. */
116 #if !defined(MODULE_PERIPH_SPI) || !defined(MODULE_PERIPH_DMA)
117  {
118  .dev = USART3,
119  .rcc_mask = RCC_APB1ENR_USART3EN,
120  .rx_pin = GPIO_PIN(PORT_B, 11),
121  .tx_pin = GPIO_PIN(PORT_B, 10),
122  .rx_af = GPIO_AF7,
123  .tx_af = GPIO_AF7,
124  .bus = APB1,
125  .irqn = USART3_IRQn,
126 #ifdef MODULE_PERIPH_DMA
127  .dma = 0,
128  .dma_chan = DMA_CHAN_CONFIG_UNSUPPORTED
129 #endif
130  }
131 #endif /* !defined(MODULE_PERIPH_SPI) || !defined(MODULE_PERIPH_DMA) */
132 };
133 
134 #define UART_0_ISR (isr_usart2)
135 #define UART_1_ISR (isr_usart1)
136 #define UART_2_ISR (isr_usart3)
137 
138 #define UART_NUMOF ARRAY_SIZE(uart_config)
139 
145 static const pwm_conf_t pwm_config[] = {
146  {
147  .dev = TIM3,
148  .rcc_mask = RCC_APB1ENR_TIM3EN,
149  .chan = { { .pin = GPIO_PIN(PORT_C, 6), .cc_chan = 0 },
150  { .pin = GPIO_PIN(PORT_C, 7), .cc_chan = 1 },
151  { .pin = GPIO_PIN(PORT_C, 8), .cc_chan = 2 },
152  { .pin = GPIO_PIN(PORT_C, 9), .cc_chan = 3 } },
153  .af = GPIO_AF2,
154  .bus = APB1
155  }
156 };
157 
158 #define PWM_NUMOF ARRAY_SIZE(pwm_config)
159 
165 static const spi_conf_t spi_config[] = {
166  {
167  .dev = SPI1,
168  .mosi_pin = GPIO_PIN(PORT_A, 7),
169  .miso_pin = GPIO_PIN(PORT_A, 6),
170  .sclk_pin = GPIO_PIN(PORT_A, 5),
171  .cs_pin = GPIO_UNDEF,
172  .mosi_af = GPIO_AF5,
173  .miso_af = GPIO_AF5,
174  .sclk_af = GPIO_AF5,
175  .cs_af = GPIO_AF5,
176  .rccmask = RCC_APB2ENR_SPI1EN,
177  .apbbus = APB2,
178 #ifdef MODULE_PERIPH_DMA
179  .tx_dma = 1,
180  .tx_dma_chan = DMA_CHAN_CONFIG_UNSUPPORTED,
181  .rx_dma = 0,
182  .rx_dma_chan = DMA_CHAN_CONFIG_UNSUPPORTED
183 #endif
184  }
185 };
186 
187 #define SPI_NUMOF ARRAY_SIZE(spi_config)
188 
190 #ifdef __cplusplus
191 }
192 #endif
193 
194 #endif /* PERIPH_CONF_H */
195 
PORT_C
@ PORT_C
port C
Definition: periph_cpu.h:38
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
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
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
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
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
cfg_timer_tim2.h
Common configuration for STM32 Timer peripheral based on TIM2.
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
APB1
@ APB1
APB1 bus.
Definition: periph_cpu.h:176