Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
55 changes: 55 additions & 0 deletions bsp/gd32/risc-v/gd32vw553h-eval/board/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,63 @@ menu "On-chip Peripheral Drivers"
bool "Enable PWM16"
default n
endif
menuconfig BSP_USING_HW_I2C
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 [PR Checklist/PR 检查清单]: PR checklist items are not checked / PR 检查清单项目未勾选

English: According to RT-Thread PR guidelines, the PR checklist in the description should be reviewed and checked before submission. Several important items remain unchecked including: "Already check the difference between PR and old code", "Style guide is adhered to", "Code in this PR is of high quality", and "This PR complies with RT-Thread code specification". Please review each checklist item carefully and check them if they have been completed, or address any outstanding issues.

中文:根据 RT-Thread PR 指南,提交前应审查并勾选描述中的 PR 检查清单。几个重要项目仍未勾选,包括:"已经仔细查看过代码改动的对比"、"代码风格正确"、"代码是高质量的"和"已经使用 formatting 等源码格式化工具确保格式符合 RT-Thread 代码规范"。请仔细审查每个检查清单项目,如果已完成则勾选,或解决任何未完成的问题。

Copilot generated this review using guidance from repository custom instructions.
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"

Expand Down
3 changes: 3 additions & 0 deletions bsp/gd32/risc-v/libraries/gd32_drivers/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Comment on lines 20 to +25
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential conflict with soft I2C configuration check.

English: The condition checking on lines 23-25 verifies BSP_USING_HW_I2C0 or BSP_USING_HW_I2C1, but this is nested inside a check for RT_USING_I2C and BSP_USING_HW_I2C. The check is redundant since if neither HW_I2C0 nor HW_I2C1 is defined, the drv_i2c.c file itself has an #error directive (lines 15-23 of drv_i2c.c) that would catch this. However, it's good defensive programming. Consider if both soft I2C and hardware I2C can be enabled simultaneously, as they check for the same RT_USING_I2C flag. This might need clarification in documentation.

中文:第 23-25 行的条件检查验证 BSP_USING_HW_I2C0 或 BSP_USING_HW_I2C1,但这嵌套在 RT_USING_I2C 和 BSP_USING_HW_I2C 的检查中。该检查是冗余的,因为如果既未定义 HW_I2C0 也未定义 HW_I2C1,drv_i2c.c 文件本身就有一个 #error 指令(drv_i2c.c 的第 15-23 行)会捕获这一点。但是,这是良好的防御性编程。考虑软件 I2C 和硬件 I2C 是否可以同时启用,因为它们检查相同的 RT_USING_I2C 标志。这可能需要在文档中澄清。

Suggested change
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']
if GetDepend('RT_USING_I2C'):
if GetDepend('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('BSP_USING_HW_I2C'):
if GetDepend('BSP_USING_HW_I2C0') or GetDepend('BSP_USING_HW_I2C1'):
src += ['drv_i2c.c']

Copilot uses AI. Check for mistakes.

# add spi drivers.
if GetDepend('RT_USING_SPI'):
Expand Down
26 changes: 26 additions & 0 deletions bsp/gd32/risc-v/libraries/gd32_drivers/drv_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2006-2026, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2026-01-25 yefeng first version
*/

#ifndef __DRV_CONFIG_H__
#define __DRV_CONFIG_H__

#include <board.h>
#include <rtthread.h>

#ifdef __cplusplus
extern "C" {
#endif


#ifdef __cplusplus
}
#endif

#endif
Loading