periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Inria
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 
9 #pragma once
10 
21 /* This board provides an LSE */
22 #ifndef CONFIG_BOARD_HAS_LSE
23 #define CONFIG_BOARD_HAS_LSE 1
24 #endif
25 
26 /* This board provides an HSE */
27 #ifndef CONFIG_BOARD_HAS_HSE
28 #define CONFIG_BOARD_HAS_HSE 1
29 #endif
30 
31 #include "periph_cpu.h"
32 #include "clk_conf.h"
33 #include "cfg_i2c1_pb8_pb9.h"
34 #include "cfg_timer_tim5.h"
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
44 static const dma_conf_t dma_config[] = {
45  { .stream = 11 }, /* DMA2 Stream 3 - SPI1_TX */
46  { .stream = 10 }, /* DMA2 Stream 2 - SPI1_RX */
47 };
48 
49 #define DMA_0_ISR isr_dma2_stream3
50 #define DMA_1_ISR isr_dma2_stream2
51 
52 #define DMA_NUMOF ARRAY_SIZE(dma_config)
59 static const uart_conf_t uart_config[] = {
60  {
61  .dev = USART2,
62  .rcc_mask = RCC_APB1ENR_USART2EN,
63  .rx_pin = GPIO_PIN(PORT_A, 3),
64  .tx_pin = GPIO_PIN(PORT_A, 2),
65  .rx_af = GPIO_AF7,
66  .tx_af = GPIO_AF7,
67  .bus = APB1,
68  .irqn = USART2_IRQn,
69 #ifdef MODULE_PERIPH_DMA
70  .dma = DMA_STREAM_UNDEF,
71  .dma_chan = UINT8_MAX,
72 #endif
73  },
74  {
75  .dev = USART1,
76  .rcc_mask = RCC_APB2ENR_USART1EN,
77  .rx_pin = GPIO_PIN(PORT_A, 10),
78  .tx_pin = GPIO_PIN(PORT_A, 9),
79  .rx_af = GPIO_AF7,
80  .tx_af = GPIO_AF7,
81  .bus = APB2,
82  .irqn = USART1_IRQn,
83 #ifdef MODULE_PERIPH_DMA
84  .dma = DMA_STREAM_UNDEF,
85  .dma_chan = UINT8_MAX,
86 #endif
87  },
88  {
89  .dev = USART6,
90  .rcc_mask = RCC_APB2ENR_USART6EN,
91  .rx_pin = GPIO_PIN(PORT_A, 12),
92  .tx_pin = GPIO_PIN(PORT_A, 11),
93  .rx_af = GPIO_AF8,
94  .tx_af = GPIO_AF8,
95  .bus = APB2,
96  .irqn = USART6_IRQn,
97 #ifdef MODULE_PERIPH_DMA
98  .dma = DMA_STREAM_UNDEF,
99  .dma_chan = UINT8_MAX,
100 #endif
101  }
102 };
103 
104 /* assign ISR vector names */
105 #define UART_0_ISR (isr_usart2)
106 #define UART_1_ISR (isr_usart1)
107 #define UART_2_ISR (isr_usart6)
108 
109 /* deduct number of defined UART interfaces */
110 #define UART_NUMOF ARRAY_SIZE(uart_config)
117 static const spi_conf_t spi_config[] = {
118  {
119  .dev = SPI1,
120  .mosi_pin = GPIO_PIN(PORT_A, 7),
121  .miso_pin = GPIO_PIN(PORT_A, 6),
122  .sclk_pin = GPIO_PIN(PORT_A, 5),
123  .cs_pin = GPIO_PIN(PORT_A, 4),
124  .mosi_af = GPIO_AF5,
125  .miso_af = GPIO_AF5,
126  .sclk_af = GPIO_AF5,
127  .cs_af = GPIO_AF5,
128  .rccmask = RCC_APB2ENR_SPI1EN,
129  .apbbus = APB2,
130 #ifdef MODULE_PERIPH_DMA
131  .tx_dma = 0,
132  .tx_dma_chan = 3,
133  .rx_dma = 1,
134  .rx_dma_chan = 3,
135 #endif
136  }
137 };
138 
139 #define SPI_NUMOF ARRAY_SIZE(spi_config)
152 static const adc_conf_t adc_config[] = {
153  {GPIO_PIN(PORT_A, 0), 0, 0},
154  {GPIO_PIN(PORT_A, 1), 0, 1},
155  {GPIO_PIN(PORT_A, 4), 0, 4},
156  {GPIO_PIN(PORT_B, 0), 0, 8},
157  {GPIO_PIN(PORT_C, 1), 0, 11},
158  {GPIO_PIN(PORT_C, 0), 0, 10},
159  {GPIO_UNDEF, 0, 18}, /* VBAT */
160 };
161 
162 #define VBAT_ADC ADC_LINE(6)
163 #define ADC_NUMOF ARRAY_SIZE(adc_config)
166 #ifdef __cplusplus
167 }
168 #endif
169 
@ PORT_B
port B
Definition: periph_cpu.h:47
@ PORT_C
port C
Definition: periph_cpu.h:48
@ 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[]
UART configuration.
Definition: periph_conf.h:38
static const spi_conf_t spi_config[]
SPI configuration.
Definition: periph_conf.h:96
static const adc_conf_t adc_config[]
ADC configuration.
Definition: periph_conf.h:250
Common configuration for STM32 I2C.
Common configuration for STM32 Timer peripheral based on TIM5.
@ GPIO_AF5
use alternate function 5
Definition: cpu_gpio.h:106
@ GPIO_AF8
use alternate function 8
Definition: cpu_gpio.h:110
@ GPIO_AF7
use alternate function 7
Definition: cpu_gpio.h:108
@ APB1
Advanced Peripheral Bus 1
Definition: periph_cpu.h:78
@ APB2
Advanced Peripheral Bus 2
Definition: periph_cpu.h:79
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
SPI device configuration.
Definition: periph_cpu.h:336
SPI_t * dev
pointer to the used SPI device
Definition: periph_cpu.h:337
UART device configuration.
Definition: periph_cpu.h:217
USART_t * dev
pointer to the used UART device
Definition: periph_cpu.h:218