-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[gd32][i2c] Add hardware I2C driver for GD32VW553xx #11151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -77,6 +77,63 @@ menu "On-chip Peripheral Drivers" | |
| select RT_SERIAL_USING_DMA | ||
| 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 50 400 | ||
|
||
|
|
||
| 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 50 400 | ||
| endif | ||
|
|
||
| source "$(BSP_DIR)/../libraries/gd32_drivers/Kconfig" | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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
|
||||||||||||||||||||||||||||
| 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'] |
| 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 |
There was a problem hiding this comment.
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 代码规范"。请仔细审查每个检查清单项目,如果已完成则勾选,或解决任何未完成的问题。