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 
19 #ifndef PERIPH_CONF_H
20 #define PERIPH_CONF_H
21 
22 /* HSE available on this board */
23 #ifndef CONFIG_BOARD_HAS_HSE
24 #define CONFIG_BOARD_HAS_HSE 1
25 #endif
26 
27 /* This board provides an LSE */
28 #ifndef CONFIG_BOARD_HAS_LSE
29 #define CONFIG_BOARD_HAS_LSE 1
30 #endif
31 
32 #include "periph_cpu.h"
33 #include "f0/cfg_clock_default.h"
34 #include "cfg_i2c1_pb8_pb9.h"
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
44 static const dma_conf_t dma_config[] = {
45  { .stream = 1 },
46  { .stream = 2 },
47 };
48 
49 #define DMA_SHARED_ISR_0 isr_dma1_ch2_3_dma2_ch1_2
50 #define DMA_SHARED_ISR_0_STREAMS { 0, 1 } /* Indexes 0 and 1 of dma_config share the same isr */
51 
52 #define DMA_NUMOF ARRAY_SIZE(dma_config)
53 
59 static const timer_conf_t timer_config[] = {
60  {
61  .dev = TIM1,
62  .max = 0x0000ffff,
63  .rcc_mask = RCC_APB2ENR_TIM1EN,
64  .bus = APB2,
65  .irqn = TIM1_CC_IRQn
66  }
67 };
68 
69 #define TIMER_0_ISR isr_tim1_cc
70 
71 #define TIMER_NUMOF ARRAY_SIZE(timer_config)
72 
78 static const uart_conf_t uart_config[] = {
79  {
80  .dev = USART2,
81  .rcc_mask = RCC_APB1ENR_USART2EN,
82  .rx_pin = GPIO_PIN(PORT_A, 3),
83  .tx_pin = GPIO_PIN(PORT_A, 2),
84  .rx_af = GPIO_AF1,
85  .tx_af = GPIO_AF1,
86  .bus = APB1,
87  .irqn = USART2_IRQn,
88 #ifdef MODULE_PERIPH_DMA
89  .dma = 0,
90  .dma_chan = 0x9,
91 #endif
92  },
93  {
94  .dev = USART1,
95  .rcc_mask = RCC_APB2ENR_USART1EN,
96  .rx_pin = GPIO_PIN(PORT_A, 10),
97  .tx_pin = GPIO_PIN(PORT_A, 9),
98  .rx_af = GPIO_AF1,
99  .tx_af = GPIO_AF1,
100  .bus = APB2,
101  .irqn = USART1_IRQn,
102 #ifdef MODULE_PERIPH_DMA
103  .dma = 0,
104  .dma_chan = 0x8,
105 #endif
106  },
107  {
108  .dev = USART3,
109  .rcc_mask = RCC_APB1ENR_USART3EN,
110  .rx_pin = GPIO_PIN(PORT_C, 11),
111  .tx_pin = GPIO_PIN(PORT_C, 10),
112  .rx_af = GPIO_AF1,
113  .tx_af = GPIO_AF1,
114  .bus = APB1,
115  .irqn = USART3_8_IRQn,
116 #ifdef MODULE_PERIPH_DMA
117  .dma = 0,
118  .dma_chan = 0xA,
119 #endif
120  },
121 };
122 
123 #define UART_0_ISR (isr_usart2)
124 #define UART_1_ISR (isr_usart1)
125 #define UART_2_ISR (isr_usart3_8)
126 
127 #define UART_NUMOF ARRAY_SIZE(uart_config)
128 
135 static const spi_conf_t spi_config[] = {
136  {
137  .dev = SPI1,
138  .mosi_pin = GPIO_PIN(PORT_A, 7),
139  .miso_pin = GPIO_PIN(PORT_A, 6),
140  .sclk_pin = GPIO_PIN(PORT_A, 5),
141  .cs_pin = GPIO_PIN(PORT_B, 6),
142  .mosi_af = GPIO_AF0,
143  .miso_af = GPIO_AF0,
144  .sclk_af = GPIO_AF0,
145  .cs_af = GPIO_AF0,
146  .rccmask = RCC_APB2ENR_SPI1EN,
147  .apbbus = APB2,
148 #ifdef MODULE_PERIPH_DMA
149  .tx_dma = 1,
150  .tx_dma_chan = 0,
151  .rx_dma = 0,
152  .rx_dma_chan = 0,
153 #endif
154  }
155 };
156 
157 #define SPI_NUMOF ARRAY_SIZE(spi_config)
158 
164 static const pwm_conf_t pwm_config[] = {
165  {
166  .dev = TIM2,
167  .rcc_mask = RCC_APB1ENR_TIM2EN,
168  .chan = { { .pin = GPIO_PIN(PORT_B, 3) /* D3 */, .cc_chan = 1 },
169  { .pin = GPIO_PIN(PORT_B, 10) /* D6 */, .cc_chan = 2 },
170  { .pin = GPIO_PIN(PORT_B, 11) , .cc_chan = 3 },
171  { .pin = GPIO_UNDEF, .cc_chan = 0 } },
172  .af = GPIO_AF2,
173  .bus = APB1
174  },
175  {
176  .dev = TIM3,
177  .rcc_mask = RCC_APB1ENR_TIM3EN,
178  .chan = { { .pin = GPIO_PIN(PORT_B, 4) /* D5 */, .cc_chan = 0 },
179  { .pin = GPIO_PIN(PORT_C, 7) /* D9 */, .cc_chan = 1 },
180  { .pin = GPIO_PIN(PORT_C, 8), .cc_chan = 2 },
181  { .pin = GPIO_PIN(PORT_C, 9), .cc_chan = 3 } },
182  .af = GPIO_AF0,
183  .bus = APB1
184  }
185 };
186 
187 #define PWM_NUMOF ARRAY_SIZE(pwm_config)
188 
194 static const adc_conf_t adc_config[] = {
195  { GPIO_PIN(PORT_A, 0), 0 },
196  { GPIO_PIN(PORT_A, 1), 1 },
197  { GPIO_PIN(PORT_A, 4), 4 },
198  { GPIO_PIN(PORT_B, 0), 8 },
199  { GPIO_PIN(PORT_C, 1), 11 },
200  { GPIO_PIN(PORT_C, 0), 10 }
201 };
202 
203 #define ADC_NUMOF ARRAY_SIZE(adc_config)
204 
206 #ifdef __cplusplus
207 }
208 #endif
209 
210 #endif /* PERIPH_CONF_H */
211 
PORT_C
@ PORT_C
port C
Definition: periph_cpu.h:38
pwm_conf_t::dev
mini_timer_t * dev
Timer used.
Definition: periph_cpu_common.h:154
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
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
uart_conf_t::dev
cc2538_uart_t * dev
pointer to the used UART device
Definition: periph_cpu.h:167
timer_conf_t
Timer configuration.
Definition: periph_cpu.h:288
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
cfg_clock_default.h
Default clock configuration for STM32F0.
dma_conf_t
DMA configuration.
Definition: periph_cpu.h:420
GPIO_AF2
@ GPIO_AF2
use alternate function 2
Definition: periph_cpu_common.h:88
GPIO_AF0
@ GPIO_AF0
use alternate function 0
Definition: periph_cpu_common.h:86
timer_conf_t::dev
uint32_t dev
Address of timer base.
Definition: periph_cpu.h:112
cfg_i2c1_pb8_pb9.h
Common configuration for STM32 I2C.
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