periph_conf.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2017 Inria
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
18 #include "periph_cpu.h"
19 #include "clk_conf.h"
20 #include "cfg_timer_tim2.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
36 static const adc_conf_t adc_config[] = {
37  { .pin = GPIO_PIN(PORT_A, 0), .dev = 0, .chan = 1 }, /* ADC1_IN1, fast */
38  { .pin = GPIO_PIN(PORT_A, 1), .dev = 0, .chan = 2 }, /* ADC1_IN2, fast */
39  { .pin = GPIO_PIN(PORT_A, 3), .dev = 0, .chan = 4 }, /* ADC1_IN4, fast */
40  { .pin = GPIO_PIN(PORT_A, 4), .dev = 1, .chan = 1 }, /* ADC2_IN1, fast */
41  { .pin = GPIO_PIN(PORT_A, 7), .dev = 1, .chan = 4 }, /* ADC2_IN4, fast */
42  { .pin = GPIO_UNDEF, .dev = 0, .chan = 17 }, /* VBAT */
43 };
44 
45 #define VBAT_ADC ADC_LINE(5)
46 #define ADC_NUMOF ARRAY_SIZE(adc_config)
53 static const dma_conf_t dma_config[] = {
54  { .stream = 1 }, /* DMA1 Channel 2 - SPI1_RX */
55  { .stream = 2 }, /* DMA1 Channel 3 - SPI1_TX */
56  { .stream = 3 }, /* DMA1 Channel 4 - USART1_TX */
57  { .stream = 6 }, /* DMA1 Channel 7 - USART2_TX */
58 };
59 
60 #define DMA_0_ISR isr_dma1_channel2
61 #define DMA_1_ISR isr_dma1_channel3
62 #define DMA_2_ISR isr_dma1_channel4
63 #define DMA_3_ISR isr_dma1_channel7
64 
65 #define DMA_NUMOF ARRAY_SIZE(dma_config)
72 static const uart_conf_t uart_config[] = {
73  {
74  .dev = USART2,
75  .rcc_mask = RCC_APB1ENR_USART2EN,
76  .rx_pin = GPIO_PIN(PORT_A, 15),
77  .tx_pin = GPIO_PIN(PORT_A, 2),
78  .rx_af = GPIO_AF7,
79  .tx_af = GPIO_AF7,
80  .bus = APB1,
81  .irqn = USART2_IRQn,
82 #ifdef MODULE_PERIPH_DMA
83  .dma = 3,
84  .dma_chan = DMA_CHAN_CONFIG_UNSUPPORTED
85 #endif
86  },
87  {
88  .dev = USART1,
89  .rcc_mask = RCC_APB2ENR_USART1EN,
90  .rx_pin = GPIO_PIN(PORT_A, 10),
91  .tx_pin = GPIO_PIN(PORT_A, 9),
92  .rx_af = GPIO_AF7,
93  .tx_af = GPIO_AF7,
94  .bus = APB2,
95  .irqn = USART1_IRQn,
96 #ifdef MODULE_PERIPH_DMA
97  .dma = 2,
98  .dma_chan = DMA_CHAN_CONFIG_UNSUPPORTED
99 #endif
100  }
101 };
102 
103 #define UART_0_ISR (isr_usart2)
104 #define UART_1_ISR (isr_usart1)
105 
106 #define UART_NUMOF ARRAY_SIZE(uart_config)
113 static const pwm_conf_t pwm_config[] = {
114  {
115  .dev = TIM3,
116  .rcc_mask = RCC_APB1ENR_TIM3EN,
117  .chan = { { .pin = GPIO_PIN(PORT_B, 0) /* D3 */, .cc_chan = 2 },
118  { .pin = GPIO_PIN(PORT_B, 1) /* D6 */, .cc_chan = 3 },
119  { .pin = GPIO_UNDEF, .cc_chan = 0 },
120  { .pin = GPIO_UNDEF, .cc_chan = 0 } },
121  .af = GPIO_AF2,
122  .bus = APB1
123  },
124  {
125  .dev = TIM1,
126  .rcc_mask = RCC_APB2ENR_TIM1EN,
127  .chan = { { .pin = GPIO_PIN(PORT_A, 8) /* D9 */, .cc_chan = 0 },
128  { .pin = GPIO_UNDEF, .cc_chan = 0 },
129  { .pin = GPIO_UNDEF, .cc_chan = 0 },
130  { .pin = GPIO_UNDEF, .cc_chan = 0 } },
131  .af = GPIO_AF6,
132  .bus = APB2
133  }
134 };
135 
136 #define PWM_NUMOF ARRAY_SIZE(pwm_config)
143 static const spi_conf_t spi_config[] = {
144  {
145  .dev = SPI1,
146  .mosi_pin = GPIO_PIN(PORT_B, 5),
147  .miso_pin = GPIO_PIN(PORT_B, 4),
148  .sclk_pin = GPIO_PIN(PORT_B, 3),
149  .cs_pin = SPI_CS_UNDEF,
150  .mosi_af = GPIO_AF5,
151  .miso_af = GPIO_AF5,
152  .sclk_af = GPIO_AF5,
153  .cs_af = GPIO_AF5,
154  .rccmask = RCC_APB2ENR_SPI1EN,
155  .apbbus = APB2,
156 #ifdef MODULE_PERIPH_DMA
157  .tx_dma = 1,
158  .tx_dma_chan = DMA_CHAN_CONFIG_UNSUPPORTED,
159  .rx_dma = 0,
160  .rx_dma_chan = DMA_CHAN_CONFIG_UNSUPPORTED
161 #endif
162  }
163 };
164 
165 #define SPI_NUMOF ARRAY_SIZE(spi_config)
168 #ifdef __cplusplus
169 }
170 #endif
171 
@ 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[]
UART configuration.
Definition: periph_conf.h:35
static const spi_conf_t spi_config[]
SPI configuration.
Definition: periph_conf.h:93
static const adc_conf_t adc_config[]
ADC configuration.
Definition: periph_conf.h:247
static const pwm_conf_t pwm_config[]
Actual PWM configuration.
Definition: periph_conf.h:218
Common configuration for STM32 Timer peripheral based on TIM2.
#define DMA_CHAN_CONFIG_UNSUPPORTED
DMA channel/trigger configuration for DMA peripherals without channel/trigger filtering such as the s...
Definition: cpu_dma.h:95
@ GPIO_AF2
use alternate function 2
Definition: cpu_gpio.h:103
@ GPIO_AF5
use alternate function 5
Definition: cpu_gpio.h:106
@ GPIO_AF6
use alternate function 6
Definition: cpu_gpio.h:107
@ GPIO_AF7
use alternate function 7
Definition: cpu_gpio.h:108
#define SPI_CS_UNDEF
Define value for unused CS line.
Definition: periph_cpu.h:362
@ 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
gpio_t pin
pin connected to the channel
Definition: periph_cpu.h:287
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
PWM device configuration.
mini_timer_t * dev
Timer used.
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