Loading...
Searching...
No Matches
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
20
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_rtt_default.h"
29#include "cfg_timer_tim2.h"
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
39static const uart_conf_t uart_config[] = {
40 {
41 .dev = LPUART1,
42 .rcc_mask = RCC_APB1ENR2_LPUART1EN,
43 .rx_pin = GPIO_PIN(PORT_A, 3),
44 .tx_pin = GPIO_PIN(PORT_A, 2),
45 .rx_af = GPIO_AF8,
46 .tx_af = GPIO_AF8,
47 .bus = APB12,
48 .irqn = LPUART1_IRQn,
49 .type = STM32_LPUART,
50 .clk_src = 0, /* Use APB clock */
51 },
52 {
53 .dev = USART1,
54 .rcc_mask = RCC_APB2ENR_USART1EN,
55 .rx_pin = GPIO_PIN(PORT_A, 10),
56 .tx_pin = GPIO_PIN(PORT_A, 9),
57 .rx_af = GPIO_AF7,
58 .tx_af = GPIO_AF7,
59 .bus = APB2,
60 .irqn = USART1_IRQn,
61 .type = STM32_USART,
62 .clk_src = 0, /* Use APB clock */
63#ifdef UART_USE_DMA
64 .dma_stream = 5,
65 .dma_chan = 4
66#endif
67 }
68};
69
70#define UART_0_ISR (isr_lpuart1)
71#define UART_1_ISR (isr_usart1)
72
73#define UART_NUMOF ARRAY_SIZE(uart_config)
75
80static const pwm_conf_t pwm_config[] = {
81 {
82 .dev = TIM1,
83 .rcc_mask = RCC_APB2ENR_TIM1EN,
84 .chan = { { .pin = GPIO_PIN(PORT_A, 8) /* D9 */, .cc_chan = 0 },
85 { .pin = GPIO_UNDEF, .cc_chan = 0 },
86 { .pin = GPIO_UNDEF, .cc_chan = 0 },
87 { .pin = GPIO_UNDEF, .cc_chan = 0 } },
88 .af = GPIO_AF1,
89 .bus = APB2
90 }
91};
92
93#define PWM_NUMOF ARRAY_SIZE(pwm_config)
95
100static const spi_conf_t spi_config[] = {
101 {
102 .dev = SPI2,
103 .mosi_pin = GPIO_PIN(PORT_B, 15),
104 .miso_pin = GPIO_PIN(PORT_B, 14),
105 .sclk_pin = GPIO_PIN(PORT_B, 13),
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_APB1ENR1_SPI2EN,
112 .apbbus = APB1
113 }
114};
115
116#define SPI_NUMOF ARRAY_SIZE(spi_config)
118
123static const i2c_conf_t i2c_config[] = {
124 {
125 .dev = I2C1,
126 .speed = I2C_SPEED_NORMAL,
127 .scl_pin = GPIO_PIN(PORT_B, 8),
128 .sda_pin = GPIO_PIN(PORT_B, 7),
129 .scl_af = GPIO_AF4,
130 .sda_af = GPIO_AF4,
131 .bus = APB1,
132 .rcc_mask = RCC_APB1ENR1_I2C1EN,
133 .rcc_sw_mask = RCC_CCIPR_I2C2SEL_1, /* HSI (16 MHz) */
134 .irqn = I2C1_ER_IRQn
135 },
136};
137
138#define I2C_0_ISR isr_i2c1_er
139
140#define I2C_NUMOF ARRAY_SIZE(i2c_config)
142
143#ifdef __cplusplus
144}
145#endif
146
@ 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.
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition periph_cpu.h:277
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:298
PWM device configuration.
SPI device configuration.
Definition periph_cpu.h:336
UART device configuration.
Definition periph_cpu.h:217