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 I2C_DEV_1_USED
37#define I2C_DEV_1_USED 1
38#endif
39
40#include "periph_cpu.h"
41#include "periph_common_conf.h"
42
43#include "cfg_spi_default.h"
44#include "cfg_uart_default.h"
45#include "cfg_usbdev_default.h"
46
47#ifdef __cplusplus
48extern "C" {
49#endif
50
63static const i2c_conf_t i2c_config[] = {
64 {
65 .dev = I2C1,
66 .speed = I2C_SPEED_NORMAL,
67 .scl_pin = GPIO_PIN(PORT_B, 10),
68 .sda_pin = GPIO_PIN(PORT_B, 11),
69 .rcu_mask = RCU_APB1EN_I2C1EN_Msk,
70 .irqn = I2C1_EV_IRQn,
71 }
72};
73
74#define I2C_NUMOF ARRAY_SIZE(i2c_config)
81static const adc_conf_t adc_config[] = {
82 { .pin = GPIO_PIN(PORT_A, 1), .dev = 0, .chan = 1 },
83 { .pin = GPIO_PIN(PORT_A, 2), .dev = 0, .chan = 2 },
84 { .pin = GPIO_PIN(PORT_A, 3), .dev = 0, .chan = 3 },
85 { .pin = GPIO_PIN(PORT_A, 4), .dev = 0, .chan = 4 },
86 { .pin = GPIO_PIN(PORT_A, 5), .dev = 0, .chan = 5 },
87 { .pin = GPIO_PIN(PORT_A, 6), .dev = 0, .chan = 6 },
88 /* ADC Temperature channel */
89 { .pin = GPIO_UNDEF, .dev = 0, .chan = 16 },
90 /* ADC VREF channel */
91 { .pin = GPIO_UNDEF, .dev = 0, .chan = 17 },
92};
93
94#define ADC_NUMOF ARRAY_SIZE(adc_config)
101static const timer_conf_t timer_config[] = {
102 {
103 .dev = TIMER0,
104 .max = 0x0000ffff,
105 .rcu_mask = RCU_APB2EN_TIMER0EN_Msk,
106 .bus = APB2,
107 .irqn = TIMER0_Channel_IRQn
108 },
109 {
110 .dev = TIMER1,
111 .max = 0x0000ffff,
112 .rcu_mask = RCU_APB1EN_TIMER1EN_Msk,
113 .bus = APB1,
114 .irqn = TIMER1_IRQn
115 },
116 /* TIMER2 and TIMER3 are used for PWM pins */
117 {
118 .dev = TIMER4,
119 .max = 0x0000ffff,
120 .rcu_mask = RCU_APB1EN_TIMER4EN_Msk,
121 .bus = APB1,
122 .irqn = TIMER4_IRQn
123 }
124};
125
126#define TIMER_0_IRQN TIMER0_Channel_IRQn
127#define TIMER_1_IRQN TIMER1_IRQn
128#define TIMER_2_IRQN TIMER4_IRQn
129
130#define TIMER_NUMOF ARRAY_SIZE(timer_config)
137static const pwm_conf_t pwm_config[] = {
138 {
139 .dev = TIMER2,
140 .rcu_mask = RCU_APB1EN_TIMER2EN_Msk,
141 .chan = {
142 { .pin = GPIO_PIN(PORT_B, 5), .cc_chan = 1 },
143 { .pin = GPIO_PIN(PORT_B, 0), .cc_chan = 2 },
144 /* unused channels have to be defined by GPIO_UNDEF */
145 { .pin = GPIO_UNDEF, .cc_chan = 0 },
146 { .pin = GPIO_UNDEF, .cc_chan = 3 },
147 },
148 .af = GPIO_AF_OUT_PP,
149 .bus = APB1,
150 },
151 {
152 .dev = TIMER3,
153 .rcu_mask = RCU_APB1EN_TIMER3EN_Msk,
154 .chan = {
155 { .pin = GPIO_PIN(PORT_B, 7), .cc_chan = 1 },
156 { .pin = GPIO_PIN(PORT_B, 8), .cc_chan = 2 },
157 /* unused channels have to be defined by GPIO_UNDEF */
158 { .pin = GPIO_UNDEF, .cc_chan = 0 },
159 { .pin = GPIO_UNDEF, .cc_chan = 3 },
160 },
161 .af = GPIO_AF_OUT_PP,
162 .bus = APB1,
163 },
164};
165
166#define PWM_NUMOF ARRAY_SIZE(pwm_config)
169#ifdef __cplusplus
170}
171#endif
172
173#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.
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition periph_cpu.h:278
static const i2c_conf_t i2c_config[]
PB10/PB11 (D15/D14) as I2C for Arduino UNO compatibility.
Definition periph_conf.h:63
@ GPIO_AF_OUT_PP
alternate function output - push-pull
Definition periph_cpu.h:167
@ APB1
Advanced Peripheral Bus 1
Definition periph_cpu.h:79
@ APB2
Advanced Peripheral Bus 2
Definition periph_cpu.h:80
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
I2C configuration structure.
Definition periph_cpu.h:299
TWI_t * dev
Pointer to hardware module registers.
Definition periph_cpu.h:300
PWM device configuration.
mini_timer_t * dev
Timer used.
Timer device configuration.
Definition periph_cpu.h:264
TC0_t * dev
Pointer to the used as Timer device.
Definition periph_cpu.h:265
Unit helper macros.