periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 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 #include "periph_cpu.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 "clk_conf.h"
29 #include "cfg_i2c1_pb8_pb9.h"
30 #include "cfg_rtt_default.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
40 static const timer_conf_t timer_config[] = {
41  {
42  .dev = TIM3,
43  .max = 0x0000ffff,
44  .rcc_mask = RCC_APBENR1_TIM3EN,
45  .bus = APB1,
46  .irqn = TIM3_IRQn
47  }
48 };
49 
50 #define TIMER_0_ISR isr_tim3
51 
52 #define TIMER_NUMOF ARRAY_SIZE(timer_config)
59 static const uart_conf_t uart_config[] = {
60  {
61  .dev = USART2,
62  .rcc_mask = RCC_APBENR1_USART2EN,
63  .rx_pin = GPIO_PIN(PORT_A, 3),
64  .tx_pin = GPIO_PIN(PORT_A, 2),
65  .rx_af = GPIO_AF1,
66  .tx_af = GPIO_AF1,
67  .bus = APB1,
68  .irqn = USART2_IRQn,
69  },
70  { /* Arduino pinout on D0/D1 */
71  .dev = USART1,
72  .rcc_mask = RCC_APBENR2_USART1EN,
73  .rx_pin = GPIO_PIN(PORT_C, 5),
74  .tx_pin = GPIO_PIN(PORT_C, 4),
75  .rx_af = GPIO_AF1,
76  .tx_af = GPIO_AF1,
77  .bus = APB12,
78  .irqn = USART1_IRQn,
79  },
80 };
81 
82 #define UART_0_ISR (isr_usart2)
83 #define UART_1_ISR (isr_usart1)
84 
85 #define UART_NUMOF ARRAY_SIZE(uart_config)
115 static const adc_conf_t adc_config[] = {
116  { .pin = GPIO_PIN(PORT_A, 0), .dev = 0, .chan = 0 }, /* ARD_A0_IN0 */
117  { .pin = GPIO_PIN(PORT_A, 1), .dev = 0, .chan = 1 }, /* ARD_A1_IN1 */
118  { .pin = GPIO_PIN(PORT_A, 4), .dev = 0, .chan = 4 }, /* ARD_A2_IN4 */
119  { .pin = GPIO_PIN(PORT_B, 1), .dev = 0, .chan = 9 }, /* ARD_A3_IN9 */
120  { .pin = GPIO_PIN(PORT_B, 11), .dev = 0, .chan = 15 }, /* ARD_A4_IN15 */
121  { .pin = GPIO_PIN(PORT_B, 12), .dev = 0, .chan = 16 }, /* ARD_A5_IN16 */
122  { .pin = GPIO_UNDEF, .dev = 0, .chan = 14}, /* VBAT */
123 };
124 
125 #define VBAT_ADC ADC_LINE(6)
126 #define ADC_NUMOF ARRAY_SIZE(adc_config)
133 static const spi_conf_t spi_config[] = {
134  {
135  .dev = SPI1,
136  .mosi_pin = GPIO_PIN(PORT_A, 7), /* Arduino D11 */
137  .miso_pin = GPIO_PIN(PORT_A, 6), /* Arduino D12 */
138  .sclk_pin = GPIO_PIN(PORT_A, 5), /* Arduino D13 */
139  .cs_pin = GPIO_UNDEF,
140  .mosi_af = GPIO_AF0,
141  .miso_af = GPIO_AF0,
142  .sclk_af = GPIO_AF0,
143  .cs_af = GPIO_AF0,
144  .rccmask = RCC_APBENR2_SPI1EN,
145  .apbbus = APB12,
146  },
147 };
148 
149 #define SPI_NUMOF ARRAY_SIZE(spi_config)
152 #ifdef __cplusplus
153 }
154 #endif
155 
@ 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:115
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
ADC device configuration.
Definition: periph_cpu.h:377
gpio_t pin
pin connected to the channel
Definition: periph_cpu.h:287
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