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_i2c1_pb6_pb7.h"
31 #include "cfg_rtt_default.h"
32 #include "cfg_timer_tim2.h"
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
42 static const uart_conf_t uart_config[] = {
43  {
44  .dev = USART2,
45  .rcc_mask = RCC_APB1ENR_USART2EN,
46  .rx_pin = GPIO_PIN(PORT_A, 15),
47  .tx_pin = GPIO_PIN(PORT_A, 2),
48  .rx_af = GPIO_AF4,
49  .tx_af = GPIO_AF4,
50  .bus = APB1,
51  .irqn = USART2_IRQn,
52  .type = STM32_USART,
53  .clk_src = 0, /* Use APB clock */
54  }
55 };
56 
57 #define UART_0_ISR (isr_usart2)
58 
59 #define UART_NUMOF ARRAY_SIZE(uart_config)
66 static const pwm_conf_t pwm_config[] = {
67  {
68  .dev = TIM21,
69  .rcc_mask = RCC_APB2ENR_TIM21EN,
70  .chan = { { .pin = GPIO_PIN(PORT_B, 6) /* D5 */, .cc_chan = 0 },
71  { .pin = GPIO_UNDEF, .cc_chan = 0 },
72  { .pin = GPIO_UNDEF, .cc_chan = 0 },
73  { .pin = GPIO_UNDEF, .cc_chan = 0 } },
74  .af = GPIO_AF5,
75  .bus = APB2
76  }
77 };
78 
79 #define PWM_NUMOF ARRAY_SIZE(pwm_config)
86 static const spi_conf_t spi_config[] = {
87  {
88  .dev = SPI1,
89  .mosi_pin = GPIO_PIN(PORT_B, 5),
90  .miso_pin = GPIO_PIN(PORT_B, 4),
91  .sclk_pin = GPIO_PIN(PORT_B, 3),
92  .cs_pin = SPI_CS_UNDEF,
93  .mosi_af = GPIO_AF0,
94  .miso_af = GPIO_AF0,
95  .sclk_af = GPIO_AF0,
96  .cs_af = GPIO_AF0,
97  .rccmask = RCC_APB2ENR_SPI1EN,
98  .apbbus = APB2
99  }
100 };
101 
102 #define SPI_NUMOF ARRAY_SIZE(spi_config)
109 static const adc_conf_t adc_config[] = {
110  { GPIO_PIN(PORT_A, 0), 0 }, /* Pin A0 */
111  { GPIO_PIN(PORT_A, 1), 1 }, /* Pin A1 */
112  { GPIO_PIN(PORT_A, 3), 3 }, /* Pin A2 */
113  { GPIO_PIN(PORT_A, 4), 4 }, /* Pin A3 */
114  { GPIO_PIN(PORT_A, 5), 5 }, /* Pin A4 */
115  { GPIO_PIN(PORT_A, 6), 6 }, /* Pin A5 */
116  { GPIO_PIN(PORT_A, 7), 7 }, /* Pin A6 */
117 };
118 
119 #define ADC_NUMOF ARRAY_SIZE(adc_config)
122 #ifdef __cplusplus
123 }
124 #endif
125 
@ 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 I2C.
Common configuration for STM32 Timer peripheral based on TIM2.
@ GPIO_AF5
use alternate function 5
Definition: cpu_gpio.h:106
@ 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
ADC device configuration.
Definition: periph_cpu.h:377
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