Loading...
Searching...
No Matches
periph_conf.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2023 Gunar Schorcht <gunar@schorcht.net>
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
17
18#include "macros/units.h"
19
20#ifndef CONFIG_BOARD_HAS_HXTAL
21#define CONFIG_BOARD_HAS_HXTAL 1
22#endif
23
24#ifndef CONFIG_BOARD_HAS_LXTAL
25#define CONFIG_BOARD_HAS_LXTAL 1
26#endif
27
28#ifndef CONFIG_CLOCK_HXTAL
29#define CONFIG_CLOCK_HXTAL MHZ(8)
30#endif
31
32#ifndef SPI_DEV_1_USED
33#if defined(BOARD_SIPEED_LONGAN_NANO_TFT)
34#define SPI_DEV_1_USED 1
35#else
36#define SPI_DEV_1_USED 0
37#endif
38#endif
39
40#ifndef I2C_DEV_1_USED
41#define I2C_DEV_1_USED 1
42#endif
43
44#include "periph_cpu.h"
45#include "periph_common_conf.h"
46
47#include "cfg_i2c_default.h"
48#include "cfg_spi_default.h"
49#include "cfg_timer_default.h"
50#include "cfg_uart_default.h"
51#include "cfg_usbdev_default.h"
52
53#ifdef __cplusplus
54extern "C" {
55#endif
56
61static const adc_conf_t adc_config[] = {
62 { .pin = GPIO_PIN(PORT_A, 0), .dev = 0, .chan = 0 },
63 { .pin = GPIO_PIN(PORT_A, 3), .dev = 0, .chan = 3 },
64 /* ADC Temperature channel */
65 { .pin = GPIO_UNDEF, .dev = 0, .chan = 16 },
66 /* ADC VREF channel */
67 { .pin = GPIO_UNDEF, .dev = 0, .chan = 17 },
68#if !MODULE_PERIPH_DAC
69 /* This conflicts with the DAC */
70 { .pin = GPIO_PIN(PORT_A, 4), .dev = 0, .chan = 4 },
71#endif
72#if !defined(BOARD_SIPEED_LONGAN_NANO_TFT)
73 /* This conflicts with TFT pins if connected. */
74 { .pin = GPIO_PIN(PORT_B, 0), .dev = 0, .chan = 8 },
75 { .pin = GPIO_PIN(PORT_B, 1), .dev = 0, .chan = 9 },
76#if !SPI_DEV_1_USED
77 /* This conflicts with the SPI0 controller which is used if TFT is connected */
78 { .pin = GPIO_PIN(PORT_A, 6), .dev = 0, .chan = 6 },
79 { .pin = GPIO_PIN(PORT_A, 7), .dev = 0, .chan = 7 },
80#if !MODULE_PERIPH_DAC
81 /* This conflicts additionally with the DAC */
82 { .pin = GPIO_PIN(PORT_A, 5), .dev = 0, .chan = 5 },
83#endif /* !MODULE_PERIPH_DAC */
84#endif /* !SPI_DEV_1_USED */
85#endif /* !defined(BOARD_SIPEED_LONGAN_NANO_TFT) */
86};
87
88#define ADC_NUMOF ARRAY_SIZE(adc_config)
90
95static const dac_conf_t dac_config[] = {
96 { .pin = GPIO_PIN(PORT_A, 4), .chan = 0 },
97#if !SPI_DEV_1_USED
98 { .pin = GPIO_PIN(PORT_A, 5), .chan = 1 },
99#endif /* !SPI_DEV_1_USED */
100};
101
102#define DAC_NUMOF ARRAY_SIZE(dac_config)
104
109static const pwm_conf_t pwm_config[] = {
110 {
111 .dev = TIMER4,
112 .rcu_mask = RCU_APB1EN_TIMER4EN_Msk,
113 .chan = {
114 { .pin = GPIO_PIN(PORT_A, 1), .cc_chan = 1 },
115 { .pin = GPIO_PIN(PORT_A, 2), .cc_chan = 2 },
116 /* unused channels have to be defined by GPIO_UNDEF */
117 { .pin = GPIO_UNDEF, .cc_chan = 0 },
118 { .pin = GPIO_UNDEF, .cc_chan = 3 },
119 },
120 .af = GPIO_AF_OUT_PP,
121 .bus = APB1,
122 },
123#if !MODULE_PERIPH_CAN
124 {
125 .dev = TIMER3,
126 .rcu_mask = RCU_APB1EN_TIMER3EN_Msk,
127 .chan = {
128 { .pin = GPIO_PIN(PORT_B, 8), .cc_chan = 2 },
129 { .pin = GPIO_PIN(PORT_B, 9), .cc_chan = 3 },
130 /* unused channels have to be defined by GPIO_UNDEF */
131 { .pin = GPIO_UNDEF, .cc_chan = 0 },
132 { .pin = GPIO_UNDEF, .cc_chan = 1 },
133 },
134 .af = GPIO_AF_OUT_PP,
135 .bus = APB1,
136 },
137#endif
138};
139
140#define PWM_NUMOF ARRAY_SIZE(pwm_config)
142
143#ifdef __cplusplus
144}
145#endif
146
@ 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.
@ GPIO_AF_OUT_PP
alternate function output - push-pull
Definition periph_cpu.h:166
@ APB1
Advanced Peripheral Bus 1.
Definition periph_cpu.h:78
Common peripheral configuration for GD32VF103 boards.
ADC device configuration.
Definition periph_cpu.h:374
DAC line configuration data.
Definition periph_cpu.h:300
PWM device configuration.
Unit helper macros.