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