periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 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 /* Add specific clock configuration (HSE, LSE) for this board here */
22 #ifndef CONFIG_BOARD_HAS_LSE
23 #define CONFIG_BOARD_HAS_LSE 1
24 #endif
25 
26 #include "periph_cpu.h"
27 #include "clk_conf.h"
28 #include "cfg_i2c1_pb8_pb9.h"
29 #include "cfg_rtt_default.h"
30 #include "cfg_usb_otg_fs.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
40 static const timer_conf_t timer_config[] = {
41  {
42  .dev = TIM5,
43  .max = 0xffffffff,
44  .rcc_mask = RCC_APB1ENR1_TIM5EN,
45  .bus = APB1,
46  .irqn = TIM5_IRQn
47  }
48 };
49 
50 #define TIMER_0_ISR isr_tim5
51 
52 #define TIMER_NUMOF ARRAY_SIZE(timer_config)
59 static const uart_conf_t uart_config[] = {
60  {
61  .dev = LPUART1,
62  .rcc_mask = RCC_APB1ENR2_LPUART1EN,
63  .rx_pin = GPIO_PIN(PORT_G, 8),
64  .tx_pin = GPIO_PIN(PORT_G, 7),
65  .rx_af = GPIO_AF8,
66  .tx_af = GPIO_AF8,
67  .bus = APB12,
68  .irqn = LPUART1_IRQn,
69  .type = STM32_LPUART,
70  .clk_src = 0,
71  },
72  {
73  .dev = USART3,
74  .rcc_mask = RCC_APB1ENR1_USART3EN,
75  .rx_pin = GPIO_PIN(PORT_D, 9),
76  .tx_pin = GPIO_PIN(PORT_D, 8),
77  .rx_af = GPIO_AF7,
78  .tx_af = GPIO_AF7,
79  .bus = APB1,
80  .irqn = USART3_IRQn,
81  .type = STM32_USART,
82  .clk_src = 0, /* Use APB clock */
83 #ifdef UART_USE_DMA
84  .dma_stream = 6,
85  .dma_chan = 4
86 #endif
87  }
88 };
89 
90 #define UART_0_ISR (isr_lpuart1)
91 #define UART_1_ISR (isr_usart3)
92 
93 #define UART_NUMOF ARRAY_SIZE(uart_config)
100 static const spi_conf_t spi_config[] = {
101  {
102  .dev = SPI1,
103  .mosi_pin = GPIO_PIN(PORT_A, 7),
104  .miso_pin = GPIO_PIN(PORT_A, 6),
105  .sclk_pin = GPIO_PIN(PORT_A, 5),
106  .cs_pin = SPI_CS_UNDEF,
107  .mosi_af = GPIO_AF5,
108  .miso_af = GPIO_AF5,
109  .sclk_af = GPIO_AF5,
110  .cs_af = GPIO_AF5,
111  .rccmask = RCC_APB2ENR_SPI1EN,
112  .apbbus = APB2
113  }
114 };
115 
116 #define SPI_NUMOF ARRAY_SIZE(spi_config)
147 static const adc_conf_t adc_config[] = {
148  { .pin = GPIO_PIN(PORT_A, 3), .dev = 0, .chan = 8 }, /* ADC12_IN8 */
149  { .pin = GPIO_PIN(PORT_C, 0), .dev = 0, .chan = 1 }, /* ADC123_IN1 */
150  { .pin = GPIO_PIN(PORT_C, 3), .dev = 0, .chan = 4 }, /* ADC123_IN4 */
151  { .pin = GPIO_PIN(PORT_C, 1), .dev = 0, .chan = 2 }, /* ADC123_IN2 */
152  { .pin = GPIO_PIN(PORT_C, 4), .dev = 0, .chan = 13 }, /* ADC12_IN13 */
153  { .pin = GPIO_PIN(PORT_C, 5), .dev = 0, .chan = 14 }, /* ADC12_IN14 */
154  { .pin = GPIO_UNDEF, .dev = 0, .chan = 18 }, /* VBAT */
155 };
156 
160 #define ADC_NUMOF ARRAY_SIZE(adc_config)
161 
165 #define VBAT_ADC ADC_LINE(6)
166 
186 static const pwm_conf_t pwm_config[] = {
187  {
188  .dev = TIM2,
189  .rcc_mask = RCC_APB1ENR1_TIM2EN,
190  .chan = { { .pin = GPIO_PIN(PORT_A, 0) /* CN10 D32 */, .cc_chan = 0},
191  { .pin = GPIO_PIN(PORT_A, 1) /* CN10 A8 */, .cc_chan = 1},
192  { .pin = GPIO_PIN(PORT_A, 2) /* CN10 D26 */, .cc_chan = 2},
193  { .pin = GPIO_PIN(PORT_A, 3) /* CN9 A0 */, .cc_chan = 3} },
194  .af = GPIO_AF1,
195  .bus = APB1
196  },
197  {
198  .dev = TIM3,
199  .rcc_mask = RCC_APB1ENR1_TIM3EN,
200  .chan = { { .pin = GPIO_PIN(PORT_B, 4) /* CN7 D25 */, .cc_chan = 0},
201  { .pin = GPIO_PIN(PORT_E, 4) /* CN9 D57 */, .cc_chan = 1},
202  { .pin = GPIO_PIN(PORT_B, 0) /* CN10 D33 */, .cc_chan = 2},
203  { .pin = GPIO_PIN(PORT_B, 1) /* CN10 A6 */, .cc_chan = 3} },
204  .af = GPIO_AF2,
205  .bus = APB1
206  },
207 };
208 
209 #define PWM_NUMOF ARRAY_SIZE(pwm_config)
210 
213 #ifdef __cplusplus
214 }
215 #endif
216 
@ PORT_B
port B
Definition: periph_cpu.h:47
@ 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 timer_conf_t timer_config[]
All timers on board.
Definition: periph_conf.h:39
static const pwm_conf_t pwm_config[]
Actual PWM configuration.
Definition: periph_conf.h:221
static const adc_conf_t adc_config[]
ADC configuration.
Definition: periph_conf.h:147
Common configuration for STM32 I2C.
Common configuration for STM32 OTG FS peripheral.
@ GPIO_AF1
use alternate function 1
Definition: cpu_gpio.h:102
@ GPIO_AF2
use alternate function 2
Definition: cpu_gpio.h:103
@ 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
@ STM32_LPUART
STM32 Low-power UART (LPUART) module type.
Definition: cpu_uart.h:38
@ STM32_USART
STM32 USART module type.
Definition: cpu_uart.h:37
#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
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