periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Frits Kuipers
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 #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  .dev = TIM3,
42  .max = 0x0000ffff,
43  .rcc_mask = RCC_APB1ENR_TIM3EN,
44  .bus = APB1,
45  .irqn = TIM3_IRQn
46  }
47 };
48 
49 #define TIMER_0_ISR isr_tim2
50 #define TIMER_1_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_APB1ENR_USART2EN,
63  .rx_pin = GPIO_PIN(PORT_A, 3),
64  .tx_pin = GPIO_PIN(PORT_A, 2),
65  .bus = APB1,
66  .irqn = USART2_IRQn
67  },
68  {
69  .dev = USART1,
70  .rcc_mask = RCC_APB2ENR_USART1EN,
71  .rx_pin = GPIO_PIN(PORT_A, 10),
72  .tx_pin = GPIO_PIN(PORT_A, 9),
73  .bus = APB2,
74  .irqn = USART1_IRQn
75  },
76  {
77  .dev = USART3,
78  .rcc_mask = RCC_APB1ENR_USART3EN,
79  .rx_pin = GPIO_PIN(PORT_B, 11),
80  .tx_pin = GPIO_PIN(PORT_B, 10),
81  .bus = APB1,
82  .irqn = USART3_IRQn
83  }
84 };
85 
86 #define UART_0_ISR isr_usart2
87 #define UART_1_ISR isr_usart1
88 #define UART_2_ISR isr_usart3
89 
90 #define UART_NUMOF ARRAY_SIZE(uart_config)
97 static const i2c_conf_t i2c_config[] = {
98  {
99  .dev = I2C1,
100  .speed = I2C_SPEED_NORMAL,
101  .scl_pin = GPIO_PIN(PORT_B, 8), /* D15 */
102  .sda_pin = GPIO_PIN(PORT_B, 9), /* D16 */
103  .bus = APB1,
104  .rcc_mask = RCC_APB1ENR_I2C1EN,
105  .clk = CLOCK_APB1,
106  .irqn = I2C1_EV_IRQn
107  },
108  {
109  .dev = I2C2,
110  .speed = I2C_SPEED_NORMAL,
111  .scl_pin = GPIO_PIN(PORT_B, 10), /* D1 */
112  .sda_pin = GPIO_PIN(PORT_B, 11), /* D0 */
113  .bus = APB1,
114  .rcc_mask = RCC_APB1ENR_I2C2EN,
115  .clk = CLOCK_APB1,
116  .irqn = I2C2_EV_IRQn
117  }
118 };
119 
120 #define I2C_0_ISR isr_i2c1_ev
121 #define I2C_1_ISR isr_i2c2_ev
122 
123 #define I2C_NUMOF ARRAY_SIZE(i2c_config)
130 static const spi_conf_t spi_config[] = {
131  {
132  .dev = SPI1,
133  .mosi_pin = GPIO_PIN(PORT_A, 7),
134  .miso_pin = GPIO_PIN(PORT_A, 6),
135  .sclk_pin = GPIO_PIN(PORT_A, 5),
136  .cs_pin = SPI_CS_UNDEF,
137  .rccmask = RCC_APB2ENR_SPI1EN,
138  .apbbus = APB2
139  },
140  {
141  .dev = SPI2,
142  .mosi_pin = GPIO_PIN(PORT_B, 15),
143  .miso_pin = GPIO_PIN(PORT_B, 14),
144  .sclk_pin = GPIO_PIN(PORT_B, 13),
145  .cs_pin = SPI_CS_UNDEF,
146  .rccmask = RCC_APB1ENR_SPI2EN,
147  .apbbus = APB1
148  }
149 };
150 
151 #define SPI_NUMOF ARRAY_SIZE(spi_config)
154 #ifdef __cplusplus
155 }
156 #endif
157 
@ 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 i2c_conf_t i2c_config[]
I2C configuration.
Definition: periph_conf.h:68
static const timer_conf_t timer_config[]
All timers on board.
Definition: periph_conf.h:39
#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
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition: periph_cpu.h:277
#define CLOCK_APB1
Half AHB clock.
I2C configuration structure.
Definition: periph_cpu.h:298
TWI_t * dev
Pointer to hardware module registers.
Definition: periph_cpu.h:299
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