periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Inria
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser General
5  * Public License v2.1. See the file LICENSE in the top level directory for more
6  * details.
7  */
8 
9 #pragma once
10 
21 #include "periph_cpu.h"
22 #include "clk_conf.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
32 static const timer_conf_t timer_config[] = {
33  {
34  .dev = TIM2,
35  .max = 0x0000ffff,
36  .rcc_mask = RCC_APB1ENR_TIM2EN,
37  .bus = APB1,
38  .irqn = TIM2_IRQn
39  }
40 };
41 
42 #define TIMER_0_ISR isr_tim2
43 
44 #define TIMER_NUMOF ARRAY_SIZE(timer_config)
51 static const uart_conf_t uart_config[] = {
52  {
53  .dev = USART1,
54  .rcc_mask = RCC_APB2ENR_USART1EN,
55  .rx_pin = GPIO_PIN(PORT_A, 10),
56  .tx_pin = GPIO_PIN(PORT_A, 9),
57  .rx_af = GPIO_AF4,
58  .tx_af = GPIO_AF4,
59  .bus = APB2,
60  .irqn = USART1_IRQn,
61  .type = STM32_USART,
62  .clk_src = 0, /* Use APB clock */
63  }
64 };
65 
66 #define UART_0_ISR (isr_usart1)
67 
68 #define UART_NUMOF ARRAY_SIZE(uart_config)
75 static const spi_conf_t spi_config[] = {
76  {
77  .dev = SPI1,
78  .mosi_pin = GPIO_PIN(PORT_B, 5),
79  .miso_pin = GPIO_PIN(PORT_B, 4),
80  .sclk_pin = GPIO_PIN(PORT_B, 3),
81  .cs_pin = SPI_CS_UNDEF,
82  .mosi_af = GPIO_AF0,
83  .miso_af = GPIO_AF0,
84  .sclk_af = GPIO_AF0,
85  .cs_af = GPIO_AF0,
86  .rccmask = RCC_APB2ENR_SPI1EN,
87  .apbbus = APB2
88  },
89  {
90  .dev = SPI2,
91  .mosi_pin = GPIO_PIN(PORT_B, 15),
92  .miso_pin = GPIO_PIN(PORT_B, 14),
93  .sclk_pin = GPIO_PIN(PORT_B, 13),
94  .cs_pin = GPIO_PIN(PORT_B, 12),
95  .mosi_af = GPIO_AF0,
96  .miso_af = GPIO_AF0,
97  .sclk_af = GPIO_AF0,
98  .cs_af = GPIO_AF0,
99  .rccmask = RCC_APB1ENR_SPI2EN,
100  .apbbus = APB1
101  },
102 };
103 
104 #define SPI_NUMOF ARRAY_SIZE(spi_config)
107 #ifdef __cplusplus
108 }
109 #endif
110 
@ 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
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
@ GPIO_AF4
use alternate function 4
Definition: cpu_gpio.h:105
@ GPIO_AF0
use alternate function 0
Definition: cpu_gpio.h:101
@ 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
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