periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 Benjamin Valentin
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 
22 /* This board provides a LSE */
23 #ifndef CONFIG_BOARD_HAS_LSE
24 #define CONFIG_BOARD_HAS_LSE 1
25 #endif
26 
27 /* This board provides an HSE */
28 #ifndef CONFIG_BOARD_HAS_HSE
29 #define CONFIG_BOARD_HAS_HSE 1
30 #endif
31 
32 #include "clk_conf.h"
33 #include "cfg_i2c1_pb8_pb9.h"
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
43 static const timer_conf_t timer_config[] = {
44  {
45  .dev = TIM1,
46  .max = 0x0000ffff,
47  .rcc_mask = RCC_APB2ENR_TIM1EN,
48  .bus = APB2,
49  .irqn = TIM1_CC_IRQn
50  },
51  {
52  .dev = TIM3,
53  .max = 0x0000ffff,
54  .rcc_mask = RCC_APB1ENR_TIM3EN,
55  .bus = APB1,
56  .irqn = TIM3_IRQn
57  },
58 };
59 
60 #define TIMER_0_ISR (isr_tim1_cc)
61 #define TIMER_1_ISR (isr_tim3)
62 
63 #define TIMER_NUMOF ARRAY_SIZE(timer_config)
70 static const uart_conf_t uart_config[] = {
71  {
72  .dev = USART1,
73  .rcc_mask = RCC_APB2ENR_USART1EN,
74  .rx_pin = GPIO_PIN(PORT_A, 10),
75  .tx_pin = GPIO_PIN(PORT_A, 9),
76  .rx_af = GPIO_AF1,
77  .tx_af = GPIO_AF1,
78  .bus = APB2,
79  .irqn = USART1_IRQn
80  }
81 };
82 
83 #define UART_0_ISR (isr_usart1)
84 
85 #define UART_NUMOF ARRAY_SIZE(uart_config)
92 static const pwm_conf_t pwm_config[] = {
93  {
94  .dev = TIM3,
95  .rcc_mask = RCC_APB1ENR_TIM3EN,
96  .chan = { { .pin = GPIO_PIN(PORT_A, 6), .cc_chan = 0},
97  { .pin = GPIO_PIN(PORT_A, 7), .cc_chan = 1},
98  { .pin = GPIO_UNDEF, .cc_chan = 0},
99  { .pin = GPIO_UNDEF, .cc_chan = 0} },
100  .af = GPIO_AF1,
101  .bus = APB1
102  }
103 };
104 
105 #define PWM_NUMOF ARRAY_SIZE(pwm_config)
112 static const spi_conf_t spi_config[] = {
113  {
114  .dev = SPI1,
115  .mosi_pin = GPIO_PIN(PORT_A, 7),
116  .miso_pin = GPIO_PIN(PORT_A, 6),
117  .sclk_pin = GPIO_PIN(PORT_A, 5),
118  .cs_pin = GPIO_PIN(PORT_B, 1),
119  .mosi_af = GPIO_AF0,
120  .miso_af = GPIO_AF0,
121  .sclk_af = GPIO_AF0,
122  .cs_af = GPIO_AF0,
123  .rccmask = RCC_APB2ENR_SPI1EN,
124  .apbbus = APB2
125  },
126 };
127 
128 #define SPI_NUMOF ARRAY_SIZE(spi_config)
135 static const adc_conf_t adc_config[] = {
136  { GPIO_PIN(PORT_A, 0), 0 },
137  { GPIO_PIN(PORT_A, 1), 1 },
138  { GPIO_PIN(PORT_A, 2), 2 },
139  { GPIO_PIN(PORT_A, 3), 3 },
140  { GPIO_PIN(PORT_A, 4), 4 },
141  { GPIO_PIN(PORT_A, 5), 5 }
142 };
143 
144 #define ADC_NUMOF ARRAY_SIZE(adc_config)
147 #ifdef __cplusplus
148 }
149 #endif
150 
@ 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 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