periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 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 
23 /* This board provides an LSE */
24 #ifndef CONFIG_BOARD_HAS_LSE
25 #define CONFIG_BOARD_HAS_LSE 1
26 #endif
27 
28 /* This board provides an HSE */
29 #ifndef CONFIG_BOARD_HAS_HSE
30 #define CONFIG_BOARD_HAS_HSE 1
31 #endif
32 
33 #include "periph_cpu.h"
34 #include "clk_conf.h"
35 #include "cfg_i2c1_pb8_pb9.h"
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
45 static const timer_conf_t timer_config[] = {
46  {
47  .dev = TIM1,
48  .max = 0x0000ffff,
49  .rcc_mask = RCC_APB2ENR_TIM1EN,
50  .bus = APB2,
51  .irqn = TIM1_CC_IRQn
52  }
53 };
54 
55 #define TIMER_0_ISR (isr_tim1_cc)
56 
57 #define TIMER_NUMOF ARRAY_SIZE(timer_config)
64 static const uart_conf_t uart_config[] = {
65  {
66  .dev = USART2,
67  .rcc_mask = RCC_APB1ENR_USART2EN,
68  .rx_pin = GPIO_PIN(PORT_A, 3),
69  .tx_pin = GPIO_PIN(PORT_A, 2),
70  .rx_af = GPIO_AF1,
71  .tx_af = GPIO_AF1,
72  .bus = APB1,
73  .irqn = USART2_IRQn
74  },
75  {
76  .dev = USART1,
77  .rcc_mask = RCC_APB2ENR_USART1EN,
78  .rx_pin = GPIO_PIN(PORT_A, 10),
79  .tx_pin = GPIO_PIN(PORT_A, 9),
80  .rx_af = GPIO_AF1,
81  .tx_af = GPIO_AF1,
82  .bus = APB2,
83  .irqn = USART1_IRQn
84  }
85 };
86 
87 #define UART_0_ISR (isr_usart2)
88 #define UART_1_ISR (isr_usart1)
89 
90 #define UART_NUMOF ARRAY_SIZE(uart_config)
97 static const pwm_conf_t pwm_config[] = {
98  {
99  .dev = TIM3,
100  .rcc_mask = RCC_APB1ENR_TIM3EN,
101  .chan = { { .pin = GPIO_PIN(PORT_B, 4) /* D5 */, .cc_chan = 0},
102  { .pin = GPIO_PIN(PORT_B, 5) /* D4 */, .cc_chan = 1},
103  { .pin = GPIO_UNDEF, .cc_chan = 0},
104  { .pin = GPIO_UNDEF, .cc_chan = 0} },
105  .af = GPIO_AF1,
106  .bus = APB1
107  },
108  {
109  .dev = TIM15,
110  .rcc_mask = RCC_APB2ENR_TIM15EN,
111  .chan = { { .pin = GPIO_PIN(PORT_B, 14), .cc_chan = 0},
112  { .pin = GPIO_PIN(PORT_B, 15), .cc_chan = 1},
113  { .pin = GPIO_UNDEF, .cc_chan = 0},
114  { .pin = GPIO_UNDEF, .cc_chan = 0} },
115  .af = GPIO_AF1,
116  .bus = APB2
117  }
118 };
119 
120 #define PWM_NUMOF ARRAY_SIZE(pwm_config)
127 static const spi_conf_t spi_config[] = {
128  {
129  .dev = SPI1,
130  .mosi_pin = GPIO_PIN(PORT_A, 7),
131  .miso_pin = GPIO_PIN(PORT_A, 6),
132  .sclk_pin = GPIO_PIN(PORT_A, 5),
133  .cs_pin = GPIO_PIN(PORT_A, 4),
134  .mosi_af = GPIO_AF0,
135  .miso_af = GPIO_AF0,
136  .sclk_af = GPIO_AF0,
137  .cs_af = GPIO_AF0,
138  .rccmask = RCC_APB2ENR_SPI1EN,
139  .apbbus = APB2
140  },
141  {
142  .dev = SPI2,
143  .mosi_pin = GPIO_PIN(PORT_B, 15),
144  .miso_pin = GPIO_PIN(PORT_B, 14),
145  .sclk_pin = GPIO_PIN(PORT_B, 13),
146  .cs_pin = GPIO_PIN(PORT_B, 12),
147  .mosi_af = GPIO_AF0,
148  .miso_af = GPIO_AF0,
149  .sclk_af = GPIO_AF0,
150  .cs_af = GPIO_AF0,
151  .rccmask = RCC_APB1ENR_SPI2EN,
152  .apbbus = APB1
153  },
154 };
155 
156 #define SPI_NUMOF ARRAY_SIZE(spi_config)
163 static const adc_conf_t adc_config[] = {
164  { GPIO_PIN(PORT_A, 0), 0 },
165  { GPIO_PIN(PORT_A, 1), 1 },
166  { GPIO_PIN(PORT_A, 4), 4 },
167  { GPIO_PIN(PORT_B, 0), 8 },
168  { GPIO_PIN(PORT_C, 1), 11 },
169  { GPIO_PIN(PORT_C, 0), 10 }
170 };
171 
172 #define ADC_NUMOF ARRAY_SIZE(adc_config)
175 #ifdef __cplusplus
176 }
177 #endif
178 
@ PORT_B
port B
Definition: periph_cpu.h:47
@ PORT_C
port C
Definition: periph_cpu.h:48
@ 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 timer_conf_t timer_config[]
All timers on board.
Definition: periph_conf.h:39
static const adc_conf_t adc_config[]
ADC configuration.
Definition: periph_conf.h:250
static const pwm_conf_t pwm_config[]
Actual PWM configuration.
Definition: periph_conf.h:221
Common configuration for STM32 I2C.
@ GPIO_AF1
use alternate function 1
Definition: cpu_gpio.h:102
@ GPIO_AF0
use alternate function 0
Definition: cpu_gpio.h:101
@ 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
Timer device configuration.
Definition: periph_cpu.h:263
TC0_t * dev
Pointer to the used as Timer device.
Definition: periph_cpu.h:264
UART device configuration.
Definition: periph_cpu.h:217
USART_t * dev
pointer to the used UART device
Definition: periph_cpu.h:218