periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Freie Universität Berlin
3  * 2017 Inria
4  *
5  * This file is subject to the terms and conditions of the GNU Lesser
6  * General Public License v2.1. See the file LICENSE in the top level
7  * directory for more details.
8  */
9 
10 #pragma once
11 
23 /* Add specific clock configuration (HSE, LSE) for this board here */
24 #ifndef CONFIG_BOARD_HAS_LSE
25 #define CONFIG_BOARD_HAS_LSE 1
26 #endif
27 
28 #include "periph_cpu.h"
29 #include "clk_conf.h"
30 #include "cfg_rtt_default.h"
31 #include "cfg_timer_tim2.h"
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
41 static const uart_conf_t uart_config[] = {
42  {
43  .dev = USART2,
44  .rcc_mask = RCC_APB1ENR_USART2EN,
45  .rx_pin = GPIO_PIN(PORT_A, 3),
46  .tx_pin = GPIO_PIN(PORT_A, 2),
47  .rx_af = GPIO_AF4,
48  .tx_af = GPIO_AF4,
49  .bus = APB1,
50  .irqn = USART2_IRQn,
51  .type = STM32_USART,
52  .clk_src = 0, /* Use APB clock */
53  },
54  {
55  .dev = USART1,
56  .rcc_mask = RCC_APB2ENR_USART1EN,
57  .rx_pin = GPIO_PIN(PORT_A, 10),
58  .tx_pin = GPIO_PIN(PORT_A, 9),
59  .rx_af = GPIO_AF4,
60  .tx_af = GPIO_AF4,
61  .bus = APB2,
62  .irqn = USART1_IRQn,
63  .type = STM32_USART,
64  .clk_src = 0, /* Use APB clock */
65  }
66 };
67 
68 #define UART_0_ISR (isr_usart2)
69 #define UART_1_ISR (isr_usart1)
70 
71 #define UART_NUMOF ARRAY_SIZE(uart_config)
78 static const pwm_conf_t pwm_config[] = {
79  {
80  .dev = TIM22,
81  .rcc_mask = RCC_APB2ENR_TIM22EN,
82  .chan = { { .pin = GPIO_PIN(PORT_B, 4) /* D5 */, .cc_chan = 0 },
83  { .pin = GPIO_PIN(PORT_B, 5), .cc_chan = 1 },
84  { .pin = GPIO_UNDEF, .cc_chan = 0 },
85  { .pin = GPIO_UNDEF, .cc_chan = 0 } },
86  .af = GPIO_AF4,
87  .bus = APB2
88  }
89 };
90 
91 #define PWM_NUMOF ARRAY_SIZE(pwm_config)
98 static const spi_conf_t spi_config[] = {
99  {
100  .dev = SPI1,
101  .mosi_pin = GPIO_PIN(PORT_A, 7),
102  .miso_pin = GPIO_PIN(PORT_A, 6),
103  .sclk_pin = GPIO_PIN(PORT_A, 5),
104  .cs_pin = SPI_CS_UNDEF,
105  .mosi_af = GPIO_AF0,
106  .miso_af = GPIO_AF0,
107  .sclk_af = GPIO_AF0,
108  .cs_af = GPIO_AF0,
109  .rccmask = RCC_APB2ENR_SPI1EN,
110  .apbbus = APB2
111  }
112 };
113 
114 #define SPI_NUMOF ARRAY_SIZE(spi_config)
117 #ifdef __cplusplus
118 }
119 #endif
120 
@ 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 pwm_conf_t pwm_config[]
Actual PWM configuration.
Definition: periph_conf.h:221
Common configuration for STM32 Timer peripheral based on TIM2.
@ GPIO_AF4
use alternate function 4
Definition: cpu_gpio.h:105
@ GPIO_AF0
use alternate function 0
Definition: cpu_gpio.h:101
@ 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
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