Loading...
Searching...
No Matches
periph_conf.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2017 Inria
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
17
18/* Add specific clock configuration (HSE, LSE) for this board here */
19#ifndef CONFIG_BOARD_HAS_LSE
20#define CONFIG_BOARD_HAS_LSE 1
21#endif
22
23#include "periph_cpu.h"
24#include "clk_conf.h"
25#include "cfg_rtt_default.h"
26#include "cfg_timer_tim2.h"
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
36static const uart_conf_t uart_config[] = {
37 {
38 .dev = LPUART1,
39 .rcc_mask = RCC_APB1ENR2_LPUART1EN,
40 .rx_pin = GPIO_PIN(PORT_A, 3),
41 .tx_pin = GPIO_PIN(PORT_A, 2),
42 .rx_af = GPIO_AF8,
43 .tx_af = GPIO_AF8,
44 .bus = APB12,
45 .irqn = LPUART1_IRQn,
46 .type = STM32_LPUART,
47 .clk_src = 0, /* Use APB clock */
48 },
49 {
50 .dev = USART1,
51 .rcc_mask = RCC_APB2ENR_USART1EN,
52 .rx_pin = GPIO_PIN(PORT_A, 10),
53 .tx_pin = GPIO_PIN(PORT_A, 9),
54 .rx_af = GPIO_AF7,
55 .tx_af = GPIO_AF7,
56 .bus = APB2,
57 .irqn = USART1_IRQn,
58 .type = STM32_USART,
59 .clk_src = 0, /* Use APB clock */
60#ifdef UART_USE_DMA
61 .dma_stream = 5,
62 .dma_chan = 4
63#endif
64 }
65};
66
67#define UART_0_ISR (isr_lpuart1)
68#define UART_1_ISR (isr_usart1)
69
70#define UART_NUMOF ARRAY_SIZE(uart_config)
72
77static const pwm_conf_t pwm_config[] = {
78 {
79 .dev = TIM1,
80 .rcc_mask = RCC_APB2ENR_TIM1EN,
81 .chan = { { .pin = GPIO_PIN(PORT_A, 8) /* D9 */, .cc_chan = 0 },
82 { .pin = GPIO_UNDEF, .cc_chan = 0 },
83 { .pin = GPIO_UNDEF, .cc_chan = 0 },
84 { .pin = GPIO_UNDEF, .cc_chan = 0 } },
85 .af = GPIO_AF1,
86 .bus = APB2
87 }
88};
89
90#define PWM_NUMOF ARRAY_SIZE(pwm_config)
92
97static const spi_conf_t spi_config[] = {
98 {
99 .dev = SPI2,
100 .mosi_pin = GPIO_PIN(PORT_B, 15),
101 .miso_pin = GPIO_PIN(PORT_B, 14),
102 .sclk_pin = GPIO_PIN(PORT_B, 13),
103 .cs_pin = SPI_CS_UNDEF,
104 .mosi_af = GPIO_AF5,
105 .miso_af = GPIO_AF5,
106 .sclk_af = GPIO_AF5,
107 .cs_af = GPIO_AF5,
108 .rccmask = RCC_APB1ENR1_SPI2EN,
109 .apbbus = APB1
110 }
111};
112
113#define SPI_NUMOF ARRAY_SIZE(spi_config)
115
120static const i2c_conf_t i2c_config[] = {
121 {
122 .dev = I2C1,
123 .speed = I2C_SPEED_NORMAL,
124 .scl_pin = GPIO_PIN(PORT_B, 8),
125 .sda_pin = GPIO_PIN(PORT_B, 7),
126 .scl_af = GPIO_AF4,
127 .sda_af = GPIO_AF4,
128 .bus = APB1,
129 .rcc_mask = RCC_APB1ENR1_I2C1EN,
130 .rcc_sw_mask = RCC_CCIPR_I2C2SEL_1, /* HSI (16 MHz) */
131 .irqn = I2C1_ER_IRQn
132 },
133};
134
135#define I2C_0_ISR isr_i2c1_er
136
137#define I2C_NUMOF ARRAY_SIZE(i2c_config)
139
140#ifdef __cplusplus
141}
142#endif
143
@ PORT_B
port B
Definition periph_cpu.h:44
@ PORT_A
port A
Definition periph_cpu.h:43
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition periph_cpu.h:42
#define GPIO_UNDEF
Definition of a fitting UNDEF value.
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition periph_cpu.h:274
Common configuration for STM32 Timer peripheral based on TIM2.
@ GPIO_AF1
use alternate function 1
Definition cpu_gpio.h:102
@ GPIO_AF5
use alternate function 5
Definition cpu_gpio.h:106
@ GPIO_AF4
use alternate function 4
Definition cpu_gpio.h:105
@ 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
I2C configuration structure.
Definition periph_cpu.h:295
PWM device configuration.
SPI device configuration.
Definition periph_cpu.h:333
UART device configuration.
Definition periph_cpu.h:214