Skip to content

Commit 542e984

Browse files
committed
bsp: gd32/risc-v: add gd32 i2c driver for gd32vw553xx device
1 parent f556099 commit 542e984

5 files changed

Lines changed: 848 additions & 0 deletions

File tree

bsp/gd32/risc-v/gd32vw553h-eval/board/Kconfig

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,63 @@ menu "On-chip Peripheral Drivers"
7777
select RT_SERIAL_USING_DMA
7878
default n
7979
endif
80+
menuconfig BSP_USING_HW_I2C
81+
bool "Enable Hardware I2C"
82+
default n
83+
select RT_USING_I2C
84+
if BSP_USING_HW_I2C
85+
config BSP_USING_HW_I2C0
86+
bool "Enable Hardware I2C0"
87+
default n
88+
89+
# config i2c0 pins
90+
choice
91+
prompt "Select I2C0 pins"
92+
depends on BSP_USING_HW_I2C0
93+
config BSP_HW_I2C0_PIN_PA2_PA3
94+
bool "SCL=PA2, SDA=PA3"
95+
config BSP_HW_I2C0_PIN_PA15_PC8
96+
bool "SCL=PA15, SDA=PC8"
97+
config BSP_HW_I2C0_PIN_PB0_PB1
98+
bool "SCL=PB0, SDA=PB1"
99+
config BSP_HW_I2C0_PIN_PB15_PA8
100+
bool "SCL=PB15, SDA=PA8"
101+
endchoice
102+
103+
# config i2c0 clock
104+
config BSP_HW_I2C0_CLK
105+
int "I2C0 clock frequency(KHz)"
106+
default 100
107+
depends on BSP_USING_HW_I2C0
108+
range 50 400
109+
110+
config BSP_USING_HW_I2C1
111+
bool "Enable Hardware I2C1"
112+
default n
113+
114+
# config i2c1 pins
115+
choice
116+
prompt "Select I2C1 pins"
117+
depends on BSP_USING_HW_I2C1
118+
config BSP_HW_I2C1_PIN_PA6_PA7
119+
bool "SCL=PA6, SDA=PA7"
120+
config BSP_HW_I2C1_PIN_PA13_PA14
121+
bool "SCL=PA13, SDA=PA14"
122+
config BSP_HW_I2C1_PIN_PA15_PC8
123+
bool "SCL=PA15, SDA=PC8"
124+
config BSP_HW_I2C1_PIN_PB12_PB13
125+
bool "SCL=PB12, SDA=PB13"
126+
config BSP_HW_I2C1_PIN_PB15_PA8
127+
bool "SCL=PB15, SDA=PA8"
128+
endchoice
129+
130+
# config i2c1 clock
131+
config BSP_HW_I2C1_CLK
132+
int "I2C1 clock frequency(KHz)"
133+
default 100
134+
depends on BSP_USING_HW_I2C1
135+
range 50 400
136+
endif
80137

81138
source "$(BSP_DIR)/../libraries/gd32_drivers/Kconfig"
82139

bsp/gd32/risc-v/libraries/gd32_drivers/SConscript

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ if GetDepend(['RT_USING_SERIAL']):
2020
if GetDepend(['RT_USING_I2C', 'RT_USING_I2C_BITOPS']):
2121
if GetDepend('BSP_USING_I2C0') or GetDepend('BSP_USING_I2C1') or GetDepend('BSP_USING_I2C2') or GetDepend('BSP_USING_I2C3'):
2222
src += ['drv_soft_i2c.c']
23+
if GetDepend(['RT_USING_I2C', 'BSP_USING_HW_I2C']):
24+
if GetDepend('BSP_USING_HW_I2C0') or GetDepend('BSP_USING_HW_I2C1'):
25+
src += ['drv_i2c.c']
2326

2427
# add spi drivers.
2528
if GetDepend('RT_USING_SPI'):
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright (c) 2006-2026, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2026-01-25 yefeng first version
9+
*/
10+
11+
#ifndef __DRV_CONFIG_H__
12+
#define __DRV_CONFIG_H__
13+
14+
#include <board.h>
15+
#include <rtthread.h>
16+
17+
#ifdef __cplusplus
18+
extern "C" {
19+
#endif
20+
21+
22+
#ifdef __cplusplus
23+
}
24+
#endif
25+
26+
#endif

0 commit comments

Comments
 (0)