[gd32][i2c] Add GD32VW553xx hardware I2C driver

This commit is contained in:
yefeng
2026-02-08 02:01:11 +08:00
committed by Rbb666
parent ec5f5e678f
commit 9aff6f8646
5 changed files with 847 additions and 1 deletions

View File

@@ -6,4 +6,15 @@ scons.args: &scons
component.pwm:
kconfig:
- CONFIG_BSP_USING_PWM=y
- CONFIG_BSP_USING_PWM0=y
- CONFIG_BSP_USING_PWM0=y
# ------ devices ------
devices.i2c:
kconfig:
- CONFIG_BSP_USING_HW_I2C=y
- CONFIG_BSP_USING_HW_I2C0=y
- CONFIG_BSP_HW_I2C0_PIN_PA2_PA3=y
- CONFIG_BSP_HW_I2C0_CLK=100
- CONFIG_BSP_USING_HW_I2C1=y
- CONFIG_BSP_HW_I2C1_PIN_PB12_PB13=y
- CONFIG_BSP_HW_I2C1_CLK=100

View File

@@ -79,8 +79,63 @@ menu "On-chip Peripheral Drivers"
bool "Enable PWM16"
default n
endif
menuconfig BSP_USING_HW_I2C
bool "Enable Hardware I2C"
default n
select RT_USING_I2C
if BSP_USING_HW_I2C
config BSP_USING_HW_I2C0
bool "Enable Hardware I2C0"
default n
# config i2c0 pins
choice
prompt "Select I2C0 pins"
depends on BSP_USING_HW_I2C0
config BSP_HW_I2C0_PIN_PA2_PA3
bool "SCL=PA2, SDA=PA3"
config BSP_HW_I2C0_PIN_PA15_PC8
bool "SCL=PA15, SDA=PC8"
config BSP_HW_I2C0_PIN_PB0_PB1
bool "SCL=PB0, SDA=PB1"
config BSP_HW_I2C0_PIN_PB15_PA8
bool "SCL=PB15, SDA=PA8"
endchoice
# config i2c0 clock
config BSP_HW_I2C0_CLK
int "I2C0 clock frequency(KHz)"
default 100
depends on BSP_USING_HW_I2C0
range 10 1000
config BSP_USING_HW_I2C1
bool "Enable Hardware I2C1"
default n
# config i2c1 pins
choice
prompt "Select I2C1 pins"
depends on BSP_USING_HW_I2C1
config BSP_HW_I2C1_PIN_PA6_PA7
bool "SCL=PA6, SDA=PA7"
config BSP_HW_I2C1_PIN_PA13_PA14
bool "SCL=PA13, SDA=PA14"
config BSP_HW_I2C1_PIN_PA15_PC8
bool "SCL=PA15, SDA=PC8"
config BSP_HW_I2C1_PIN_PB12_PB13
bool "SCL=PB12, SDA=PB13"
config BSP_HW_I2C1_PIN_PB15_PA8
bool "SCL=PB15, SDA=PA8"
endchoice
# config i2c1 clock
config BSP_HW_I2C1_CLK
int "I2C1 clock frequency(KHz)"
default 100
depends on BSP_USING_HW_I2C1
range 10 1000
endif
source "$(BSP_DIR)/../libraries/gd32_drivers/Kconfig"

View File

@@ -20,6 +20,9 @@ if GetDepend(['RT_USING_SERIAL']):
if GetDepend(['RT_USING_I2C', 'RT_USING_I2C_BITOPS']):
if GetDepend('BSP_USING_I2C0') or GetDepend('BSP_USING_I2C1') or GetDepend('BSP_USING_I2C2') or GetDepend('BSP_USING_I2C3'):
src += ['drv_soft_i2c.c']
if GetDepend(['RT_USING_I2C', 'BSP_USING_HW_I2C']):
if GetDepend('BSP_USING_HW_I2C0') or GetDepend('BSP_USING_HW_I2C1'):
src += ['drv_i2c.c']
# add spi drivers.
if GetDepend('RT_USING_SPI'):

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,33 @@
/*
* Copyright (c) 2006-2026, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2026-01-13 yefeng first implementation.
*/
#ifndef __DRV_I2C_H__
#define __DRV_I2C_H__
#include <rtthread.h>
#include <rtdevice.h>
#include <rthw.h>
#include <board.h>
struct gd32_i2c_config
{
const char *name;
rt_uint32_t i2c_periph;
rcu_periph_enum rcu_clk;
rt_uint32_t speed;
};
struct gd32_i2c_device
{
struct rt_i2c_bus_device parent;
struct gd32_i2c_config *config;
};
#endif