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
19#ifndef PERIPH_CONF_H
20#define PERIPH_CONF_H
21
22#include "macros/units.h"
23
24#ifndef CONFIG_BOARD_HAS_HXTAL
25#define CONFIG_BOARD_HAS_HXTAL 1
26#endif
27
28#ifndef CONFIG_BOARD_HAS_LXTAL
29#define CONFIG_BOARD_HAS_LXTAL 1
30#endif
31
32#ifndef CONFIG_CLOCK_HXTAL
33#define CONFIG_CLOCK_HXTAL MHZ(8)
34#endif
35
36#ifndef SPI_DEV_1_USED
37#if defined(BOARD_SIPEED_LONGAN_NANO_TFT)
38#define SPI_DEV_1_USED 1
39#else
40#define SPI_DEV_1_USED 0
41#endif
42#endif
43
44#ifndef I2C_DEV_1_USED
45#define I2C_DEV_1_USED 1
46#endif
47
48#include "periph_cpu.h"
49#include "periph_common_conf.h"
50
51#include "cfg_i2c_default.h"
52#include "cfg_spi_default.h"
53#include "cfg_timer_default.h"
54#include "cfg_uart_default.h"
55#include "cfg_usbdev_default.h"
56
57#ifdef __cplusplus
58extern "C" {
59#endif
60
65static const adc_conf_t adc_config[] = {
66 { .pin = GPIO_PIN(PORT_A, 0), .dev = 0, .chan = 0 },
67 { .pin = GPIO_PIN(PORT_A, 3), .dev = 0, .chan = 3 },
68 /* ADC Temperature channel */
69 { .pin = GPIO_UNDEF, .dev = 0, .chan = 16 },
70 /* ADC VREF channel */
71 { .pin = GPIO_UNDEF, .dev = 0, .chan = 17 },
72#if !MODULE_PERIPH_DAC
73 /* This conflicts with the DAC */
74 { .pin = GPIO_PIN(PORT_A, 4), .dev = 0, .chan = 4 },
75#endif
76#if !defined(BOARD_SIPEED_LONGAN_NANO_TFT)
77 /* This conflicts with TFT pins if connected. */
78 { .pin = GPIO_PIN(PORT_B, 0), .dev = 0, .chan = 8 },
79 { .pin = GPIO_PIN(PORT_B, 1), .dev = 0, .chan = 9 },
80#if !SPI_DEV_1_USED
81 /* This conflicts with the SPI0 controller which is used if TFT is connected */
82 { .pin = GPIO_PIN(PORT_A, 6), .dev = 0, .chan = 6 },
83 { .pin = GPIO_PIN(PORT_A, 7), .dev = 0, .chan = 7 },
84#if !MODULE_PERIPH_DAC
85 /* This conflicts additionally with the DAC */
86 { .pin = GPIO_PIN(PORT_A, 5), .dev = 0, .chan = 5 },
87#endif /* !MODULE_PERIPH_DAC */
88#endif /* !SPI_DEV_1_USED */
89#endif /* !defined(BOARD_SIPEED_LONGAN_NANO_TFT) */
90};
91
92#define ADC_NUMOF ARRAY_SIZE(adc_config)
99static const dac_conf_t dac_config[] = {
100 { .pin = GPIO_PIN(PORT_A, 4), .chan = 0 },
101#if !SPI_DEV_1_USED
102 { .pin = GPIO_PIN(PORT_A, 5), .chan = 1 },
103#endif /* !SPI_DEV_1_USED */
104};
105
106#define DAC_NUMOF ARRAY_SIZE(dac_config)
113static const pwm_conf_t pwm_config[] = {
114 {
115 .dev = TIMER4,
116 .rcu_mask = RCU_APB1EN_TIMER4EN_Msk,
117 .chan = {
118 { .pin = GPIO_PIN(PORT_A, 1), .cc_chan = 1 },
119 { .pin = GPIO_PIN(PORT_A, 2), .cc_chan = 2 },
120 /* unused channels have to be defined by GPIO_UNDEF */
121 { .pin = GPIO_UNDEF, .cc_chan = 0 },
122 { .pin = GPIO_UNDEF, .cc_chan = 3 },
123 },
124 .af = GPIO_AF_OUT_PP,
125 .bus = APB1,
126 },
127#if !MODULE_PERIPH_CAN
128 {
129 .dev = TIMER3,
130 .rcu_mask = RCU_APB1EN_TIMER3EN_Msk,
131 .chan = {
132 { .pin = GPIO_PIN(PORT_B, 8), .cc_chan = 2 },
133 { .pin = GPIO_PIN(PORT_B, 9), .cc_chan = 3 },
134 /* unused channels have to be defined by GPIO_UNDEF */
135 { .pin = GPIO_UNDEF, .cc_chan = 0 },
136 { .pin = GPIO_UNDEF, .cc_chan = 1 },
137 },
138 .af = GPIO_AF_OUT_PP,
139 .bus = APB1,
140 },
141#endif
142};
143
144#define PWM_NUMOF ARRAY_SIZE(pwm_config)
147#ifdef __cplusplus
148}
149#endif
150
151#endif /* PERIPH_CONF_H */
@ PORT_B
port B
Definition periph_cpu.h:48
@ PORT_A
port A
Definition periph_cpu.h:47
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition periph_cpu.h:46
#define GPIO_UNDEF
Definition of a fitting UNDEF value.
@ GPIO_AF_OUT_PP
alternate function output - push-pull
Definition periph_cpu.h:167
@ APB1
Advanced Peripheral Bus 1
Definition periph_cpu.h:79
Common peripheral configuration for GD32VF103 boards.
ADC device configuration.
Definition periph_cpu.h:379
gpio_t pin
pin connected to the channel
Definition periph_cpu.h:288
DAC line configuration data.
Definition periph_cpu.h:301
gpio_t pin
pin connected to the line
Definition periph_cpu.h:302
PWM device configuration.
mini_timer_t * dev
Timer used.
Unit helper macros.