periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 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 #include "periph_cpu.h"
22 #include "clk_conf.h"
23 #include "cfg_timer_tim2.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
39 static const adc_conf_t adc_config[] = {
40  { .pin = GPIO_PIN(PORT_A, 0), .dev = 0, .chan = 1 }, /* ADC1_IN1, fast */
41  { .pin = GPIO_PIN(PORT_A, 1), .dev = 0, .chan = 2 }, /* ADC1_IN2, fast */
42  { .pin = GPIO_PIN(PORT_A, 3), .dev = 0, .chan = 4 }, /* ADC1_IN4, fast */
43  { .pin = GPIO_PIN(PORT_A, 4), .dev = 1, .chan = 1 }, /* ADC2_IN1, fast */
44  { .pin = GPIO_PIN(PORT_A, 7), .dev = 1, .chan = 4 }, /* ADC2_IN4, fast */
45  { .pin = GPIO_UNDEF, .dev = 0, .chan = 17 }, /* VBAT */
46 };
47 
48 #define VBAT_ADC ADC_LINE(5)
49 #define ADC_NUMOF ARRAY_SIZE(adc_config)
56 static const dma_conf_t dma_config[] = {
57  { .stream = 1 }, /* DMA1 Channel 2 - SPI1_RX */
58  { .stream = 2 }, /* DMA1 Channel 3 - SPI1_TX */
59  { .stream = 3 }, /* DMA1 Channel 4 - USART1_TX */
60  { .stream = 6 }, /* DMA1 Channel 7 - USART2_TX */
61 };
62 
63 #define DMA_0_ISR isr_dma1_channel2
64 #define DMA_1_ISR isr_dma1_channel3
65 #define DMA_2_ISR isr_dma1_channel4
66 #define DMA_3_ISR isr_dma1_channel7
67 
68 #define DMA_NUMOF ARRAY_SIZE(dma_config)
75 static const uart_conf_t uart_config[] = {
76  {
77  .dev = USART2,
78  .rcc_mask = RCC_APB1ENR_USART2EN,
79  .rx_pin = GPIO_PIN(PORT_A, 15),
80  .tx_pin = GPIO_PIN(PORT_A, 2),
81  .rx_af = GPIO_AF7,
82  .tx_af = GPIO_AF7,
83  .bus = APB1,
84  .irqn = USART2_IRQn,
85 #ifdef MODULE_PERIPH_DMA
86  .dma = 3,
87  .dma_chan = DMA_CHAN_CONFIG_UNSUPPORTED
88 #endif
89  },
90  {
91  .dev = USART1,
92  .rcc_mask = RCC_APB2ENR_USART1EN,
93  .rx_pin = GPIO_PIN(PORT_A, 10),
94  .tx_pin = GPIO_PIN(PORT_A, 9),
95  .rx_af = GPIO_AF7,
96  .tx_af = GPIO_AF7,
97  .bus = APB2,
98  .irqn = USART1_IRQn,
99 #ifdef MODULE_PERIPH_DMA
100  .dma = 2,
101  .dma_chan = DMA_CHAN_CONFIG_UNSUPPORTED
102 #endif
103  }
104 };
105 
106 #define UART_0_ISR (isr_usart2)
107 #define UART_1_ISR (isr_usart1)
108 
109 #define UART_NUMOF ARRAY_SIZE(uart_config)
116 static const pwm_conf_t pwm_config[] = {
117  {
118  .dev = TIM3,
119  .rcc_mask = RCC_APB1ENR_TIM3EN,
120  .chan = { { .pin = GPIO_PIN(PORT_B, 0) /* D3 */, .cc_chan = 2 },
121  { .pin = GPIO_PIN(PORT_B, 1) /* D6 */, .cc_chan = 3 },
122  { .pin = GPIO_UNDEF, .cc_chan = 0 },
123  { .pin = GPIO_UNDEF, .cc_chan = 0 } },
124  .af = GPIO_AF2,
125  .bus = APB1
126  },
127  {
128  .dev = TIM1,
129  .rcc_mask = RCC_APB2ENR_TIM1EN,
130  .chan = { { .pin = GPIO_PIN(PORT_A, 8) /* D9 */, .cc_chan = 0 },
131  { .pin = GPIO_UNDEF, .cc_chan = 0 },
132  { .pin = GPIO_UNDEF, .cc_chan = 0 },
133  { .pin = GPIO_UNDEF, .cc_chan = 0 } },
134  .af = GPIO_AF6,
135  .bus = APB2
136  }
137 };
138 
139 #define PWM_NUMOF ARRAY_SIZE(pwm_config)
146 static const spi_conf_t spi_config[] = {
147  {
148  .dev = SPI1,
149  .mosi_pin = GPIO_PIN(PORT_B, 5),
150  .miso_pin = GPIO_PIN(PORT_B, 4),
151  .sclk_pin = GPIO_PIN(PORT_B, 3),
152  .cs_pin = SPI_CS_UNDEF,
153  .mosi_af = GPIO_AF5,
154  .miso_af = GPIO_AF5,
155  .sclk_af = GPIO_AF5,
156  .cs_af = GPIO_AF5,
157  .rccmask = RCC_APB2ENR_SPI1EN,
158  .apbbus = APB2,
159 #ifdef MODULE_PERIPH_DMA
160  .tx_dma = 1,
161  .tx_dma_chan = DMA_CHAN_CONFIG_UNSUPPORTED,
162  .rx_dma = 0,
163  .rx_dma_chan = DMA_CHAN_CONFIG_UNSUPPORTED
164 #endif
165  }
166 };
167 
168 #define SPI_NUMOF ARRAY_SIZE(spi_config)
171 #ifdef __cplusplus
172 }
173 #endif
174 
@ 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: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
static const pwm_conf_t pwm_config[]
Actual PWM configuration.
Definition: periph_conf.h:221
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