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
20#ifndef PERIPH_CONF_H
21#define PERIPH_CONF_H
22
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_i2c1_pb8_pb9.h"
32#include "cfg_timer_tim2.h"
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
42static const dma_conf_t dma_config[] = {
43 { .stream = 1 }, /* channel 2 */
44 { .stream = 2 }, /* channel 3 */
45 { .stream = 3 }, /* channel 4 */
46 { .stream = 4 }, /* channel 5 */
47 { .stream = 5 }, /* channel 6 */
48};
49
50#define DMA_SHARED_ISR_0 isr_dma1_channel2_3
51#define DMA_SHARED_ISR_0_STREAMS { 0, 1 } /* Indexes 0 and 1 of dma_config share the same isr */
52#define DMA_SHARED_ISR_1 isr_dma1_channel4_5_6_7
53#define DMA_SHARED_ISR_1_STREAMS { 2, 3, 4 } /* Indexes 2, 3 and 4 of dma_config share the same isr */
54
55#define DMA_NUMOF ARRAY_SIZE(dma_config)
62static const uart_conf_t uart_config[] = {
63 {
64 .dev = USART2,
65 .rcc_mask = RCC_APB1ENR_USART2EN,
66 .rx_pin = GPIO_PIN(PORT_A, 3),
67 .tx_pin = GPIO_PIN(PORT_A, 2),
68 .rx_af = GPIO_AF4,
69 .tx_af = GPIO_AF4,
70 .bus = APB1,
71 .irqn = USART2_IRQn,
72 .type = STM32_USART,
73 .clk_src = 0, /* Use APB clock */
74#ifdef MODULE_PERIPH_DMA
75 .dma = 2,
76 .dma_chan = 4,
77#endif
78 },
79 {
80 .dev = USART1,
81 .rcc_mask = RCC_APB2ENR_USART1EN,
82 .rx_pin = GPIO_PIN(PORT_A, 10),
83 .tx_pin = GPIO_PIN(PORT_A, 9),
84 .rx_af = GPIO_AF4,
85 .tx_af = GPIO_AF4,
86 .bus = APB2,
87 .irqn = USART1_IRQn,
88 .type = STM32_USART,
89 .clk_src = 0, /* Use APB clock */
90#ifdef MODULE_PERIPH_DMA
91 .dma = 0,
92 .dma_chan = 3,
93#endif
94 },
95};
96
97#define UART_0_ISR (isr_usart2)
98#define UART_1_ISR (isr_usart1)
99
100#define UART_NUMOF ARRAY_SIZE(uart_config)
107static const spi_conf_t spi_config[] = {
108 {
109 .dev = SPI2,
110 .mosi_pin = GPIO_PIN(PORT_B, 15),
111 .miso_pin = GPIO_PIN(PORT_B, 14),
112 .sclk_pin = GPIO_PIN(PORT_B, 13),
113 .cs_pin = SPI_CS_UNDEF,
114 .mosi_af = GPIO_AF0,
115 .miso_af = GPIO_AF0,
116 .sclk_af = GPIO_AF0,
117 .cs_af = GPIO_AF0,
118 .rccmask = RCC_APB1ENR_SPI2EN,
119 .apbbus = APB1,
120#ifdef MODULE_PERIPH_DMA
121 .tx_dma = 3,
122 .tx_dma_chan = 2,
123 .rx_dma = 2,
124 .rx_dma_chan = 2,
125#endif
126 },
127 {
128 .dev = SPI1, /* connected to SX1276 */
129 .mosi_pin = GPIO_PIN(PORT_A, 7),
130 .miso_pin = GPIO_PIN(PORT_A, 6),
131 .sclk_pin = GPIO_PIN(PORT_B, 3),
132 .cs_pin = SPI_CS_UNDEF,
133 .mosi_af = GPIO_AF0,
134 .miso_af = GPIO_AF0,
135 .sclk_af = GPIO_AF0,
136 .cs_af = GPIO_AF0,
137 .rccmask = RCC_APB2ENR_SPI1EN,
138 .apbbus = APB2,
139#ifdef MODULE_PERIPH_DMA
140 .tx_dma = 1,
141 .tx_dma_chan = 1,
142 .rx_dma = 0,
143 .rx_dma_chan = 1,
144#endif
145 },
146};
147
148#define SPI_NUMOF ARRAY_SIZE(spi_config)
155static const adc_conf_t adc_config[] = {
156 { GPIO_PIN(PORT_A, 0), 0 },
157 { GPIO_PIN(PORT_A, 2), 2 },
158 { GPIO_PIN(PORT_A, 3), 3 },
159 { GPIO_PIN(PORT_A, 4), 4 },
160 { GPIO_PIN(PORT_A, 5), 5 }
161};
162
163#define ADC_NUMOF ARRAY_SIZE(adc_config)
166#ifdef __cplusplus
167}
168#endif
169
170#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
ADC device configuration.
Definition periph_cpu.h:379
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