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 
9 #pragma once
10 
22 /* iotlab boards provide an LSE */
23 #ifndef CONFIG_BOARD_HAS_LSE
24 #define CONFIG_BOARD_HAS_LSE 1
25 #endif
26 
27 /* HSE is clocked at 16MHz */
28 #ifndef CONFIG_BOARD_HAS_HSE
29 #define CONFIG_BOARD_HAS_HSE 1
30 #endif
31 
32 #ifndef CONFIG_CLOCK_HSE
33 #define CONFIG_CLOCK_HSE MHZ(16)
34 #endif
35 
36 #include "periph_cpu.h"
37 #include "clk_conf.h"
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
47 static const adc_conf_t adc_config[] = {
48  { GPIO_PIN(PORT_A,3), 0, 3 },
49  { GPIO_UNDEF , 0, 16 },
50  { GPIO_UNDEF , 0, 17 }
51 };
52 
53 #define ADC_NUMOF ARRAY_SIZE(adc_config)
60 static const dma_conf_t dma_config[] = {
61  { .stream = 3 }, /* DMA1 Channel 4 - USART1_TX */
62  { .stream = 5 }, /* DMA1 Channel 6 - USART2_TX */
63 };
64 
65 #define DMA_0_ISR isr_dma1_channel4
66 #define DMA_1_ISR isr_dma1_channel6
67 
68 #define DMA_NUMOF ARRAY_SIZE(dma_config)
75 static const timer_conf_t timer_config[] = {
76  {
77  .dev = TIM2,
78  .max = 0x0000ffff,
79  .rcc_mask = RCC_APB1ENR_TIM2EN,
80  .bus = APB1,
81  .irqn = TIM2_IRQn
82  },
83  {
84  .dev = TIM3,
85  .max = 0x0000ffff,
86  .rcc_mask = RCC_APB1ENR_TIM3EN,
87  .bus = APB1,
88  .irqn = TIM3_IRQn
89  }
90 };
91 
92 #define TIMER_0_ISR isr_tim2
93 #define TIMER_1_ISR isr_tim3
94 
95 #define TIMER_NUMOF ARRAY_SIZE(timer_config)
102 static const uart_conf_t uart_config[] = {
103  {
104  .dev = USART1,
105  .rcc_mask = RCC_APB2ENR_USART1EN,
106  .rx_pin = GPIO_PIN(PORT_A, 10),
107  .tx_pin = GPIO_PIN(PORT_A, 9),
108  .bus = APB2,
109  .irqn = USART1_IRQn,
110 #ifdef MODULE_PERIPH_DMA
111  .dma = 0,
112  .dma_chan = 2
113 #endif
114  },
115  {
116  .dev = USART2,
117  .rcc_mask = RCC_APB1ENR_USART2EN,
118  .rx_pin = GPIO_PIN(PORT_A, 3),
119  .tx_pin = GPIO_PIN(PORT_A, 2),
120  .bus = APB1,
121  .irqn = USART2_IRQn,
122 #ifdef MODULE_PERIPH_DMA
123  .dma = 1,
124  .dma_chan = 2
125 #endif
126  }
127 };
128 
129 #define UART_0_ISR (isr_usart1)
130 #define UART_1_ISR (isr_usart2)
131 
132 #define UART_NUMOF ARRAY_SIZE(uart_config)
139 #ifndef RTT_FREQUENCY
140 #define RTT_FREQUENCY (RTT_MAX_FREQUENCY) /* in Hz */
141 #endif
148 static const i2c_conf_t i2c_config[] = {
149  {
150  .dev = I2C1,
151  .speed = I2C_SPEED_NORMAL,
152  .scl_pin = GPIO_PIN(PORT_B, 6),
153  .sda_pin = GPIO_PIN(PORT_B, 7),
154  .bus = APB1,
155  .rcc_mask = RCC_APB1ENR_I2C1EN,
156  .clk = CLOCK_APB1,
157  .irqn = I2C1_EV_IRQn
158  }
159 };
160 
161 #define I2C_0_ISR isr_i2c1_ev
162 
163 #define I2C_NUMOF ARRAY_SIZE(i2c_config)
166 #ifdef __cplusplus
167 }
168 #endif
169 
@ PORT_B
port B
Definition: periph_cpu.h:47
@ PORT_A
port A
Definition: periph_cpu.h:46
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition: periph_cpu.h:45
#define GPIO_UNDEF
Definition of a fitting UNDEF value.
static const uart_conf_t uart_config[]
Static array with configuration for declared UART devices.
static const i2c_conf_t i2c_config[]
Static array with configuration for declared I2C devices.
@ APB1
Advanced Peripheral Bus 1
Definition: periph_cpu.h:78
@ APB2
Advanced Peripheral Bus 2
Definition: periph_cpu.h:79
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition: periph_cpu.h:277
#define CLOCK_APB1
Half AHB clock.
ADC device configuration.
Definition: periph_cpu.h:377
DMA configuration.
Definition: cpu_dma.h:31
int stream
DMA stream on stm32f2/4/7, channel on others STM32F2/4/7:
Definition: cpu_dma.h:54
I2C configuration structure.
Definition: periph_cpu.h:298
TWI_t * dev
Pointer to hardware module registers.
Definition: periph_cpu.h:299
Timer device configuration.
Definition: periph_cpu.h:263
TC0_t * dev
Pointer to the used as Timer device.
Definition: periph_cpu.h:264
UART device configuration.
Definition: periph_cpu.h:217
USART_t * dev
pointer to the used UART device
Definition: periph_cpu.h:218