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 /* 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_timer_tim2.h"
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
49 static const adc_conf_t adc_config[] = {
50  { .pin = GPIO_PIN(PORT_A, 3), .dev = 0, .chan = 4 }, /* ADC1_IN4, fast */
51  { .pin = GPIO_PIN(PORT_C, 0), .dev = 1, .chan = 6 }, /* ADC12_IN6, slow */
52  { .pin = GPIO_PIN(PORT_C, 3), .dev = 1, .chan = 9 }, /* ADC12_IN9, slow */
53  { .pin = GPIO_PIN(PORT_D, 11), .dev = 2, .chan = 8 }, /* ADC34_IN8, slow */
54  { .pin = GPIO_PIN(PORT_D, 12), .dev = 3, .chan = 9 }, /* ADC34_IN9, slow */
55  { .pin = GPIO_PIN(PORT_D, 13), .dev = 3, .chan = 10 }, /* ADC34_IN10, slow */
56  { .pin = GPIO_UNDEF, .dev = 0, .chan = 17 }, /* VBAT */
57 };
58 
59 #define VBAT_ADC ADC_LINE(6)
60 #define ADC_NUMOF ARRAY_SIZE(adc_config)
67 static const uart_conf_t uart_config[] = {
68  {
69  .dev = USART3,
70  .rcc_mask = RCC_APB1ENR_USART3EN,
71  .rx_pin = GPIO_PIN(PORT_D, 9),
72  .tx_pin = GPIO_PIN(PORT_D, 8),
73  .rx_af = GPIO_AF7,
74  .tx_af = GPIO_AF7,
75  .bus = APB1,
76  .irqn = USART3_IRQn,
77 #ifdef UART_USE_DMA
78  .dma_stream = 6,
79  .dma_chan = 4
80 #endif
81  },
82  {
83  .dev = USART1,
84  .rcc_mask = RCC_APB2ENR_USART1EN,
85  .rx_pin = GPIO_PIN(PORT_C, 5),
86  .tx_pin = GPIO_PIN(PORT_C, 4),
87  .rx_af = GPIO_AF7,
88  .tx_af = GPIO_AF7,
89  .bus = APB2,
90  .irqn = USART1_IRQn,
91 #ifdef UART_USE_DMA
92  .dma_stream = 5,
93  .dma_chan = 4
94 #endif
95  },
96  {
97  .dev = USART2,
98  .rcc_mask = RCC_APB1ENR_USART2EN,
99  .rx_pin = GPIO_PIN(PORT_D, 6),
100  .tx_pin = GPIO_PIN(PORT_D, 5),
101  .rx_af = GPIO_AF7,
102  .tx_af = GPIO_AF7,
103  .bus = APB1,
104  .irqn = USART2_IRQn,
105 #ifdef UART_USE_DMA
106  .dma_stream = 4,
107  .dma_chan = 4
108 #endif
109  },
110 };
111 
112 #define UART_0_ISR (isr_usart3)
113 #define UART_0_DMA_ISR (isr_dma1_stream6)
114 #define UART_1_ISR (isr_usart1)
115 #define UART_1_DMA_ISR (isr_dma1_stream5)
116 #define UART_2_ISR (isr_usart2)
117 #define UART_2_DMA_ISR (isr_dma1_stream4)
118 
119 #define UART_NUMOF ARRAY_SIZE(uart_config)
126 static const pwm_conf_t pwm_config[] = {
127  {
128  .dev = TIM1,
129  .rcc_mask = RCC_APB2ENR_TIM1EN,
130  .chan = { { .pin = GPIO_PIN(PORT_E, 9) /* D6 */, .cc_chan = 0},
131  { .pin = GPIO_PIN(PORT_E, 11) /* D5 */, .cc_chan = 1},
132  { .pin = GPIO_PIN(PORT_E, 13) /* D3 */, .cc_chan = 2},
133  { .pin = GPIO_UNDEF, .cc_chan = 0} },
134  .af = GPIO_AF2,
135  .bus = APB2
136  },
137  {
138  .dev = TIM4,
139  .rcc_mask = RCC_APB1ENR_TIM4EN,
140  .chan = { { .pin = GPIO_PIN(PORT_D, 15) /* D9 */, .cc_chan = 3},
141  { .pin = GPIO_UNDEF, .cc_chan = 0},
142  { .pin = GPIO_UNDEF, .cc_chan = 0},
143  { .pin = GPIO_UNDEF, .cc_chan = 0} },
144  .af = GPIO_AF2,
145  .bus = APB1
146  }
147 };
148 
149 #define PWM_NUMOF ARRAY_SIZE(pwm_config)
156 static const spi_conf_t spi_config[] = {
157  {
158  .dev = SPI1,
159  .mosi_pin = GPIO_PIN(PORT_A, 7),
160  .miso_pin = GPIO_PIN(PORT_A, 6),
161  .sclk_pin = GPIO_PIN(PORT_A, 5),
162  .cs_pin = SPI_CS_UNDEF,
163  .mosi_af = GPIO_AF5,
164  .miso_af = GPIO_AF5,
165  .sclk_af = GPIO_AF5,
166  .cs_af = GPIO_AF5,
167  .rccmask = RCC_APB2ENR_SPI1EN,
168  .apbbus = APB2
169  }
170 };
171 
172 #define SPI_NUMOF ARRAY_SIZE(spi_config)
179  {
180  .base_addr = (uintptr_t)USB,
181  .rcc_mask = RCC_APB1ENR_USBEN,
182  .irqn = USB_LP_CAN_RX0_IRQn,
183  .apb = APB1,
184  .dm = GPIO_PIN(PORT_A, 11),
185  .dp = GPIO_PIN(PORT_A, 12),
186  .af = GPIO_AF14,
187  .disconn = GPIO_PIN(PORT_G, 6),
188  },
189 };
190 
194 #define USBDEV_ISR isr_usb_lp_can_rx0
195 
199 #define USBDEV_NUMOF ARRAY_SIZE(stm32_usbdev_fs_config)
200 
201 #ifdef __cplusplus
202 }
203 #endif
204 
@ PORT_G
port G
Definition: periph_cpu.h:52
@ PORT_C
port C
Definition: periph_cpu.h:48
@ PORT_E
port E
Definition: periph_cpu.h:50
@ PORT_A
port A
Definition: periph_cpu.h:46
@ PORT_D
port D
Definition: periph_cpu.h:49
#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 stm32_usbdev_fs_config_t stm32_usbdev_fs_config[]
USB device FS configuration.
Definition: periph_conf.h:178
static const pwm_conf_t pwm_config[]
Actual PWM configuration.
Definition: periph_conf.h:221
Common configuration for STM32 Timer peripheral based on TIM2.
@ GPIO_AF2
use alternate function 2
Definition: cpu_gpio.h:103
@ GPIO_AF5
use alternate function 5
Definition: cpu_gpio.h:106
@ GPIO_AF14
use alternate function 14
Definition: cpu_gpio.h:116
@ 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
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
stm32 USB device FS configuration
Definition: cpu_usbdev.h:44
uintptr_t base_addr
USB peripheral base address.
Definition: cpu_usbdev.h:45
UART device configuration.
Definition: periph_cpu.h:217
USART_t * dev
pointer to the used UART device
Definition: periph_cpu.h:218