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
19#ifndef PERIPH_CONF_H
20#define PERIPH_CONF_H
21
22/* Add specific clock configuration (HSE, LSE) for this board here */
23#ifndef CONFIG_BOARD_HAS_LSE
24#define CONFIG_BOARD_HAS_LSE 1
25#endif
26
27#include "periph_cpu.h"
28#include "clk_conf.h"
29#include "cfg_rtt_default.h"
30#include "cfg_i2c1_pb8_pb9.h"
31#include "cfg_timer_tim2.h"
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
41static const dma_conf_t dma_config[] = {
42 { .stream = 1 }, /* channel 2 */
43 { .stream = 2 }, /* channel 3 */
44 { .stream = 3 }, /* channel 4 */
45 { .stream = 4 }, /* channel 5 */
46 { .stream = 5 }, /* channel 6 */
47};
48
49#define DMA_SHARED_ISR_0 isr_dma1_channel2_3
50#define DMA_SHARED_ISR_0_STREAMS { 0, 1 } /* Indexes 0 and 1 of dma_config share the same isr */
51#define DMA_SHARED_ISR_1 isr_dma1_channel4_5_6_7
52#define DMA_SHARED_ISR_1_STREAMS { 2, 3, 4 } /* Indexes 2, 3 and 4 of dma_config share the same isr */
53
54#define DMA_NUMOF ARRAY_SIZE(dma_config)
61static const uart_conf_t uart_config[] = {
62 {
63 .dev = USART2,
64 .rcc_mask = RCC_APB1ENR_USART2EN,
65 .rx_pin = GPIO_PIN(PORT_A, 3),
66 .tx_pin = GPIO_PIN(PORT_A, 2),
67 .rx_af = GPIO_AF4,
68 .tx_af = GPIO_AF4,
69 .bus = APB1,
70 .irqn = USART2_IRQn,
71 .type = STM32_USART,
72 .clk_src = 0, /* Use APB clock */
73#ifdef MODULE_PERIPH_DMA
74 .dma = 2,
75 .dma_chan = 4,
76#endif
77 },
78 {
79 .dev = USART1,
80 .rcc_mask = RCC_APB2ENR_USART1EN,
81 .rx_pin = GPIO_PIN(PORT_A, 10),
82 .tx_pin = GPIO_PIN(PORT_A, 9),
83 .rx_af = GPIO_AF4,
84 .tx_af = GPIO_AF4,
85 .bus = APB2,
86 .irqn = USART1_IRQn,
87 .type = STM32_USART,
88 .clk_src = 0, /* Use APB clock */
89#ifdef MODULE_PERIPH_DMA
90 .dma = 0,
91 .dma_chan = 3,
92#endif
93 },
94};
95
96#define UART_0_ISR (isr_usart2)
97#define UART_1_ISR (isr_usart1)
98
99#define UART_NUMOF ARRAY_SIZE(uart_config)
106static const spi_conf_t spi_config[] = {
107 {
108 .dev = SPI2,
109 .mosi_pin = GPIO_PIN(PORT_B, 15),
110 .miso_pin = GPIO_PIN(PORT_B, 14),
111 .sclk_pin = GPIO_PIN(PORT_B, 13),
112 .cs_pin = SPI_CS_UNDEF,
113 .mosi_af = GPIO_AF0,
114 .miso_af = GPIO_AF0,
115 .sclk_af = GPIO_AF0,
116 .cs_af = GPIO_AF0,
117 .rccmask = RCC_APB1ENR_SPI2EN,
118 .apbbus = APB1,
119#ifdef MODULE_PERIPH_DMA
120 .tx_dma = 3,
121 .tx_dma_chan = 2,
122 .rx_dma = 2,
123 .rx_dma_chan = 2,
124#endif
125 },
126 {
127 .dev = SPI1, /* connected to SX1276 */
128 .mosi_pin = GPIO_PIN(PORT_A, 7),
129 .miso_pin = GPIO_PIN(PORT_A, 6),
130 .sclk_pin = GPIO_PIN(PORT_B, 3),
131 .cs_pin = SPI_CS_UNDEF,
132 .mosi_af = GPIO_AF0,
133 .miso_af = GPIO_AF0,
134 .sclk_af = GPIO_AF0,
135 .cs_af = GPIO_AF0,
136 .rccmask = RCC_APB2ENR_SPI1EN,
137 .apbbus = APB2,
138#ifdef MODULE_PERIPH_DMA
139 .tx_dma = 1,
140 .tx_dma_chan = 1,
141 .rx_dma = 0,
142 .rx_dma_chan = 1,
143#endif
144 },
145};
146
147#define SPI_NUMOF ARRAY_SIZE(spi_config)
150#ifdef __cplusplus
151}
152#endif
153
154#endif /* PERIPH_CONF_H */
@ PORT_B
port B
Definition periph_cpu.h:48
@ PORT_A
port A
Definition periph_cpu.h:47
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition periph_cpu.h:46
Common configuration for STM32 I2C.
Common configuration for STM32 Timer peripheral based on TIM2.
@ GPIO_AF4
use alternate function 4
Definition cpu_gpio.h:106
@ GPIO_AF0
use alternate function 0
Definition cpu_gpio.h:102
@ STM32_USART
STM32 USART module type.
Definition cpu_uart.h:38
#define SPI_CS_UNDEF
Define value for unused CS line.
Definition periph_cpu.h:363
@ APB1
Advanced Peripheral Bus 1
Definition periph_cpu.h:79
@ APB2
Advanced Peripheral Bus 2
Definition periph_cpu.h:80
DMA configuration.
Definition cpu_dma.h:32
int stream
DMA stream on stm32f2/4/7, channel on others STM32F2/4/7:
Definition cpu_dma.h:55
SPI device configuration.
Definition periph_cpu.h:337
SPI_t * dev
pointer to the used SPI device
Definition periph_cpu.h:338
UART device configuration.
Definition periph_cpu.h:218
USART_t * dev
pointer to the used UART device
Definition periph_cpu.h:219