periph_conf_common.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 General
5  * Public License v2.1. See the file LICENSE in the top level directory for more
6  * details.
7  */
8 
20 #ifndef PERIPH_CONF_COMMON_H
21 #define PERIPH_CONF_COMMON_H
22 
23 /* iotlab boards provide an LSE */
24 #ifndef CONFIG_BOARD_HAS_LSE
25 #define CONFIG_BOARD_HAS_LSE 1
26 #endif
27 
28 /* HSE is clocked at 16MHz */
29 #ifndef CONFIG_BOARD_HAS_HSE
30 #define CONFIG_BOARD_HAS_HSE 1
31 #endif
32 #define CLOCK_HSE MHZ(16)
33 
34 #include "periph_cpu.h"
35 #include "clk_conf.h"
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
45 static const adc_conf_t adc_config[] = {
46  { GPIO_PIN(PORT_A,3), 0, 3 },
47  { GPIO_UNDEF , 0, 16 },
48  { GPIO_UNDEF , 0, 17 }
49 };
50 
51 #define ADC_NUMOF ARRAY_SIZE(adc_config)
52 
58 static const dma_conf_t dma_config[] = {
59  { .stream = 3 }, /* DMA1 Channel 4 - USART1_TX */
60  { .stream = 5 }, /* DMA1 Channel 6 - USART2_TX */
61 };
62 
63 #define DMA_0_ISR isr_dma1_channel4
64 #define DMA_1_ISR isr_dma1_channel6
65 
66 #define DMA_NUMOF ARRAY_SIZE(dma_config)
67 
73 static const timer_conf_t timer_config[] = {
74  {
75  .dev = TIM2,
76  .max = 0x0000ffff,
77  .rcc_mask = RCC_APB1ENR_TIM2EN,
78  .bus = APB1,
79  .irqn = TIM2_IRQn
80  },
81  {
82  .dev = TIM3,
83  .max = 0x0000ffff,
84  .rcc_mask = RCC_APB1ENR_TIM3EN,
85  .bus = APB1,
86  .irqn = TIM3_IRQn
87  }
88 };
89 
90 #define TIMER_0_ISR isr_tim2
91 #define TIMER_1_ISR isr_tim3
92 
93 #define TIMER_NUMOF ARRAY_SIZE(timer_config)
94 
100 static const uart_conf_t uart_config[] = {
101  {
102  .dev = USART1,
103  .rcc_mask = RCC_APB2ENR_USART1EN,
104  .rx_pin = GPIO_PIN(PORT_A, 10),
105  .tx_pin = GPIO_PIN(PORT_A, 9),
106  .bus = APB2,
107  .irqn = USART1_IRQn,
108 #ifdef MODULE_PERIPH_DMA
109  .dma = 0,
110  .dma_chan = 2
111 #endif
112  },
113  {
114  .dev = USART2,
115  .rcc_mask = RCC_APB1ENR_USART2EN,
116  .rx_pin = GPIO_PIN(PORT_A, 3),
117  .tx_pin = GPIO_PIN(PORT_A, 2),
118  .bus = APB1,
119  .irqn = USART2_IRQn,
120 #ifdef MODULE_PERIPH_DMA
121  .dma = 1,
122  .dma_chan = 2
123 #endif
124  }
125 };
126 
127 #define UART_0_ISR (isr_usart1)
128 #define UART_1_ISR (isr_usart2)
129 
130 #define UART_NUMOF ARRAY_SIZE(uart_config)
131 
137 #ifndef RTT_FREQUENCY
138 #define RTT_FREQUENCY (1) /* in Hz */
139 #endif
140 
146 static const i2c_conf_t i2c_config[] = {
147  {
148  .dev = I2C1,
149  .speed = I2C_SPEED_NORMAL,
150  .scl_pin = GPIO_PIN(PORT_B, 6),
151  .sda_pin = GPIO_PIN(PORT_B, 7),
152  .bus = APB1,
153  .rcc_mask = RCC_APB1ENR_I2C1EN,
154  .clk = CLOCK_APB1,
155  .irqn = I2C1_EV_IRQn
156  }
157 };
158 
159 #define I2C_0_ISR isr_i2c1_ev
160 
161 #define I2C_NUMOF ARRAY_SIZE(i2c_config)
162 
164 #ifdef __cplusplus
165 }
166 #endif
167 
168 #endif /* PERIPH_CONF_COMMON_H */
169 
I2C_SPEED_NORMAL
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition: i2c.h:177
PORT_A
@ PORT_A
port A
Definition: periph_cpu.h:36
uart_config
static const uart_conf_t uart_config[]
Static array with configuration for declared UART devices.
Definition: periph_conf_common.h:225
dma_conf_t::stream
int stream
DMA stream on stm32f2/4/7, channel on others STM32F2/4/7:
Definition: periph_cpu.h:443
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
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
i2c_config
static const i2c_conf_t i2c_config[]
Static array with configuration for declared I2C devices.
Definition: periph_conf_common.h:106
dma_conf_t
DMA configuration.
Definition: periph_cpu.h:420
i2c_conf_t
I2C configuration options.
Definition: periph_cpu.h:128
timer_conf_t::dev
uint32_t dev
Address of timer base.
Definition: periph_cpu.h:112
PORT_B
@ PORT_B
port B
Definition: periph_cpu.h:37
i2c_conf_t::dev
I2C_TypeDef * dev
USART device used.
Definition: periph_cpu.h:247
APB1
@ APB1
APB1 bus.
Definition: periph_cpu.h:176