Loading...
Searching...
No Matches
periph_conf.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2026 Hudson C. Dalpra
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
17
18#include "periph_cpu.h"
19#include "clk_conf.h"
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
29static const timer_conf_t timer_config[] = {
30 {
31 .dev = TIM3,
32 .max = 0x0000ffff,
33 .rcc_mask = RCC_APBENR1_TIM3EN,
34 .bus = APB1,
35 .irqn = TIM3_IRQn
36 }
37};
38
39#define TIMER_0_ISR isr_tim3
40
41#define TIMER_NUMOF ARRAY_SIZE(timer_config)
43
48static const uart_conf_t uart_config[] = {
49 { /* Connected to the ST-Link */
50 .dev = USART2,
51 .rcc_mask = RCC_APBENR1_USART2EN,
52 .rx_pin = GPIO_PIN(PORT_A, 3),
53 .tx_pin = GPIO_PIN(PORT_A, 2),
54 .rx_af = GPIO_AF1,
55 .tx_af = GPIO_AF1,
56 .bus = APB1,
57 .irqn = USART2_IRQn,
58 },
59 { /* Arduino pinout on D0/D1 */
60 .dev = USART1,
61 .rcc_mask = RCC_APBENR2_USART1EN,
62 .rx_pin = GPIO_PIN(PORT_B, 7),
63 .tx_pin = GPIO_PIN(PORT_B, 6),
64 .rx_af = GPIO_AF0,
65 .tx_af = GPIO_AF0,
66 .bus = APB12,
67 .irqn = USART1_IRQn,
68 }
69};
70
71#define UART_0_ISR (isr_usart2)
72#define UART_1_ISR (isr_usart1)
73
74#define UART_NUMOF ARRAY_SIZE(uart_config)
76
81static const spi_conf_t spi_config[] = {
82 {
83 .dev = SPI1,
84 .mosi_pin = GPIO_PIN(PORT_B, 5), /* Arduino D11 */
85 .miso_pin = GPIO_PIN(PORT_B, 4), /* Arduino D12 */
86 .sclk_pin = GPIO_PIN(PORT_B, 3), /* Arduino D13 */
87 .cs_pin = GPIO_UNDEF,
88 .mosi_af = GPIO_AF0,
89 .miso_af = GPIO_AF0,
90 .sclk_af = GPIO_AF0,
91 .cs_af = GPIO_AF0,
92 .rccmask = RCC_APBENR2_SPI1EN,
93 .apbbus = APB12,
94 },
95};
96
97#define SPI_NUMOF ARRAY_SIZE(spi_config)
99
104static const i2c_conf_t i2c_config[] = {
105 {
106 .dev = I2C1,
107 .speed = I2C_SPEED_NORMAL,
108 .scl_pin = GPIO_PIN(PORT_A, 9), /* Arduino D5 */
109 .sda_pin = GPIO_PIN(PORT_A, 10), /* Arduino D4 */
110 .scl_af = GPIO_AF6,
111 .sda_af = GPIO_AF6,
112 .bus = APB1,
113 .rcc_mask = RCC_APBENR1_I2C1EN,
114 .rcc_sw_mask = RCC_CCIPR_I2C1SEL_1, /* HSI (16 MHz) */
115 .irqn = I2C1_IRQn,
116 },
117 {
118 .dev = I2C2,
119 .speed = I2C_SPEED_NORMAL,
120 .scl_pin = GPIO_PIN(PORT_A, 11), /* Arduino A5 */
121 .sda_pin = GPIO_PIN(PORT_A, 12), /* Arduino A4 */
122 .scl_af = GPIO_AF6,
123 .sda_af = GPIO_AF6,
124 .bus = APB1,
125 .rcc_mask = RCC_APBENR1_I2C2EN,
126 /* I2C2 has no kernel clock mux, it is always clocked from PCLK */
127 .irqn = I2C2_IRQn,
128 }
129};
130
131#define I2C_0_ISR isr_i2c1
132#define I2C_1_ISR isr_i2c2
133
134#define I2C_NUMOF ARRAY_SIZE(i2c_config)
136
137#ifdef __cplusplus
138}
139#endif
140
@ PORT_B
port B
Definition periph_cpu.h:44
@ PORT_A
port A
Definition periph_cpu.h:43
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition periph_cpu.h:42
#define GPIO_UNDEF
Definition of a fitting UNDEF value.
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition periph_cpu.h:274
@ GPIO_AF1
use alternate function 1
Definition cpu_gpio.h:99
@ GPIO_AF6
use alternate function 6
Definition cpu_gpio.h:104
@ GPIO_AF0
use alternate function 0
Definition cpu_gpio.h:98
@ APB1
Advanced Peripheral Bus 1.
Definition periph_cpu.h:75
I2C configuration structure.
Definition periph_cpu.h:295
SPI device configuration.
Definition periph_cpu.h:333
Timer device configuration.
Definition periph_cpu.h:260
UART device configuration.
Definition periph_cpu.h:214