periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Inria
3  * 2017 OTA keys
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"
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_APB1ENR1_USART2EN,
46  .rx_pin = GPIO_PIN(PORT_A, 15),
47  .tx_pin = GPIO_PIN(PORT_A, 2),
48  .rx_af = GPIO_AF3,
49  .tx_af = GPIO_AF7,
50  .bus = APB1,
51  .irqn = USART2_IRQn,
52  .type = STM32_USART,
53  .clk_src = 0, /* Use APB clock */
54  },
55  {
56  .dev = USART1,
57  .rcc_mask = RCC_APB2ENR_USART1EN,
58  .rx_pin = GPIO_PIN(PORT_A, 10),
59  .tx_pin = GPIO_PIN(PORT_A, 9),
60  .rx_af = GPIO_AF7,
61  .tx_af = GPIO_AF7,
62  .bus = APB2,
63  .irqn = USART1_IRQn,
64  .type = STM32_USART,
65  .clk_src = 0, /* Use APB clock */
66  },
67 };
68 
69 #define UART_0_ISR (isr_usart2)
70 #define UART_1_ISR (isr_usart1)
71 
72 #define UART_NUMOF ARRAY_SIZE(uart_config)
79 static const pwm_conf_t pwm_config[] = {
80  {
81  .dev = TIM1,
82  .rcc_mask = RCC_APB2ENR_TIM1EN,
83  .chan = { { .pin = GPIO_PIN(PORT_A, 8) /* D9 */, .cc_chan = 0 },
84  { .pin = GPIO_UNDEF, .cc_chan = 0 },
85  { .pin = GPIO_UNDEF, .cc_chan = 0 },
86  { .pin = GPIO_UNDEF, .cc_chan = 0 } },
87  .af = GPIO_AF1,
88  .bus = APB2
89  }
90 };
91 
92 #define PWM_NUMOF ARRAY_SIZE(pwm_config)
99 static const spi_conf_t spi_config[] = {
100  {
101  .dev = SPI1,
102  .mosi_pin = GPIO_PIN(PORT_B, 5),
103  .miso_pin = GPIO_PIN(PORT_B, 4),
104  .sclk_pin = GPIO_PIN(PORT_B, 3),
105  .cs_pin = SPI_CS_UNDEF,
106  .mosi_af = GPIO_AF5,
107  .miso_af = GPIO_AF5,
108  .sclk_af = GPIO_AF5,
109  .cs_af = GPIO_AF5,
110  .rccmask = RCC_APB2ENR_SPI1EN,
111  .apbbus = APB2
112  }
113 };
114 
115 #define SPI_NUMOF ARRAY_SIZE(spi_config)
141 static const adc_conf_t adc_config[] = {
142  {GPIO_PIN(PORT_A, 0), .dev = 0, .chan = 5}, /* ADC12_IN5 */
143  {GPIO_PIN(PORT_A, 1), .dev = 0, .chan = 6}, /* ADC12_IN6 */
144  {GPIO_PIN(PORT_A, 3), .dev = 0, .chan = 8}, /* ADC12_IN8 */
145  {GPIO_PIN(PORT_A, 4), .dev = 0, .chan = 9}, /* ADC12_IN9 */
146  {GPIO_PIN(PORT_A, 7), .dev = 0, .chan = 12}, /* ADC12_IN12 */
147 };
148 
152 #define ADC_NUMOF ARRAY_SIZE(adc_config)
153 
156 #ifdef __cplusplus
157 }
158 #endif
159 
@ 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 pwm_conf_t pwm_config[]
Actual PWM configuration.
Definition: periph_conf.h:221
static const adc_conf_t adc_config[]
ADC configuration.
Definition: periph_conf.h:141
Common configuration for STM32 I2C.
Common configuration for STM32 Timer peripheral based on TIM2, TIM15, and TIM16.
@ GPIO_AF1
use alternate function 1
Definition: cpu_gpio.h:102
@ GPIO_AF5
use alternate function 5
Definition: cpu_gpio.h:106
@ GPIO_AF3
use alternate function 3
Definition: cpu_gpio.h:104
@ GPIO_AF7
use alternate function 7
Definition: cpu_gpio.h:108
@ 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