periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 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 
21 /* Add specific clock configuration (HSE, LSE) for this board here */
22 #ifndef CONFIG_BOARD_HAS_LSE
23 #define CONFIG_BOARD_HAS_LSE 1
24 #endif
25 
26 #ifndef CONFIG_BOARD_HAS_HSE
27 #define CONFIG_BOARD_HAS_HSE 1
28 #endif
29 
30 #ifndef CONFIG_CLOCK_HSE
31 #define CONFIG_CLOCK_HSE MHZ(32)
32 #endif
33 
34 /* EXTAHB (HCLK2) max freq 32 Mhz*/
35 #define CLOCK_EXTAHB_DIV RCC_EXTCFGR_C2HPRE_3
36 #define CLOCK_EXTAHB (CLOCK_CORECLOCK / 2)
37 
38 #include "periph_cpu.h"
39 #include "clk_conf.h"
40 #include "cfg_i2c1_pb8_pb9.h"
41 #include "cfg_rtt_default.h"
42 #include "cfg_timer_tim2.h"
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
52 static const uart_conf_t uart_config[] = {
53  {
54  .dev = USART1,
55  .rcc_mask = RCC_APB2ENR_USART1EN,
56  .rx_pin = GPIO_PIN(PORT_B, 7),
57  .tx_pin = GPIO_PIN(PORT_B, 6),
58  .rx_af = GPIO_AF7,
59  .tx_af = GPIO_AF7,
60  .bus = APB2,
61  .irqn = USART1_IRQn,
62  .type = STM32_USART,
63  .clk_src = 0, /* Use APB clock */
64  },
65  {
66  .dev = LPUART1,
67  .rcc_mask = RCC_APB1ENR2_LPUART1EN,
68  .rx_pin = GPIO_PIN(PORT_A, 3),
69  .tx_pin = GPIO_PIN(PORT_A, 2),
70  .rx_af = GPIO_AF8,
71  .tx_af = GPIO_AF8,
72  .bus = APB12,
73  .irqn = LPUART1_IRQn,
74  .type = STM32_LPUART,
75  .clk_src = 0, /* Use APB clock */
76  },
77 };
78 
79 #define UART_0_ISR (isr_usart1)
80 #define UART_1_ISR (isr_lpuart1)
81 
82 #define UART_NUMOF ARRAY_SIZE(uart_config)
89 static const spi_conf_t spi_config[] = {
90  {
91  .dev = SPI1,
92  .mosi_pin = GPIO_PIN(PORT_A, 7),
93  .miso_pin = GPIO_PIN(PORT_A, 6),
94  .sclk_pin = GPIO_PIN(PORT_A, 5),
95  .cs_pin = SPI_CS_UNDEF,
96  .mosi_af = GPIO_AF5,
97  .miso_af = GPIO_AF5,
98  .sclk_af = GPIO_AF5,
99  .cs_af = GPIO_AF5,
100  .rccmask = RCC_APB2ENR_SPI1EN,
101  .apbbus = APB2,
102  }
103 };
104 
105 #define SPI_NUMOF ARRAY_SIZE(spi_config)
123 static const pwm_conf_t pwm_config[] = {
124  {
125  .dev = TIM1,
126  .rcc_mask = RCC_APB2ENR_TIM1EN,
127  .chan = { { .pin = GPIO_PIN(PORT_A, 8) /* CN9 D6 */, .cc_chan = 0},
128  { .pin = GPIO_PIN(PORT_A, 9) /* CN5 D9 */, .cc_chan = 1},
129  { .pin = GPIO_PIN(PORT_A, 10) /* CN9 D3 */, .cc_chan = 2},
130  { .pin = GPIO_PIN(PORT_A, 11) /* CC10 14 */, .cc_chan = 3} },
131  .af = GPIO_AF1,
132  .bus = APB2
133  },
134 };
135 
136 #define PWM_NUMOF ARRAY_SIZE(pwm_config)
137 
144  {
145  .base_addr = (uintptr_t)USB,
146  .rcc_mask = RCC_APB1ENR1_USBEN | RCC_APB1ENR1_CRSEN,
147  .irqn = USB_LP_IRQn,
148  .apb = APB1,
149  .dm = GPIO_PIN(PORT_A, 11),
150  .dp = GPIO_PIN(PORT_A, 12),
151  .af = GPIO_AF10,
152  .disconn = GPIO_UNDEF,
153  },
154 };
155 
159 #define USBDEV_ISR isr_usb_lp
160 
164 #define USBDEV_NUMOF ARRAY_SIZE(stm32_usbdev_fs_config)
165 
194 static const adc_conf_t adc_config[] = {
195  {GPIO_PIN(PORT_C, 0), 0, 1}, /*< ADC1_IN1 */
196  {GPIO_PIN(PORT_C, 1), 0, 2}, /*< ADC1_IN2 */
197  {GPIO_PIN(PORT_A, 1), 0, 6}, /*< ADC1_IN6 */
198  {GPIO_PIN(PORT_A, 0), 0, 5}, /*< ADC1_IN5 */
199  {GPIO_PIN(PORT_C, 3), 0, 4}, /*< ADC1_IN4 */
200  {GPIO_PIN(PORT_C, 2), 0, 3}, /*< ADC1_IN3 */
201  {GPIO_UNDEF, 0, 18}, /* VBAT */
202 };
203 
204 #define VBAT_ADC ADC_LINE(6)
205 #define ADC_NUMOF ARRAY_SIZE(adc_config)
208 #ifdef __cplusplus
209 }
210 #endif
211 
@ 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 pwm_conf_t pwm_config[]
Actual PWM configuration.
Definition: periph_conf.h:221
static const stm32_usbdev_fs_config_t stm32_usbdev_fs_config[]
USB device FS configuration.
Definition: periph_conf.h:143
static const adc_conf_t adc_config[]
ADC configuration.
Definition: periph_conf.h:194
Common configuration for STM32 I2C.
Common configuration for STM32 Timer peripheral based on TIM2.
@ GPIO_AF1
use alternate function 1
Definition: cpu_gpio.h:102
@ GPIO_AF5
use alternate function 5
Definition: cpu_gpio.h:106
@ GPIO_AF8
use alternate function 8
Definition: cpu_gpio.h:110
@ GPIO_AF10
use alternate function 10
Definition: cpu_gpio.h:112
@ GPIO_AF7
use alternate function 7
Definition: cpu_gpio.h:108
@ STM32_LPUART
STM32 Low-power UART (LPUART) module type.
Definition: cpu_uart.h:38
@ 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
stm32 USB device FS configuration
Definition: cpu_usbdev.h:44
uintptr_t base_addr
USB peripheral base address.
Definition: cpu_usbdev.h:45
UART device configuration.
Definition: periph_cpu.h:217
USART_t * dev
pointer to the used UART device
Definition: periph_cpu.h:218