Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wwsmg1
rt-thread
提交
7d68083b
R
rt-thread
项目概览
wwsmg1
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7d68083b
编写于
7月 11, 2022
作者:
R
Rbb666
提交者:
guo
7月 28, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add Hardware I2C Bus
上级
a0be4ee3
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
215 addition
and
17 deletion
+215
-17
bsp/cypress/libraries/HAL_Drivers/SConscript
bsp/cypress/libraries/HAL_Drivers/SConscript
+1
-1
bsp/cypress/libraries/HAL_Drivers/drv_i2c.c
bsp/cypress/libraries/HAL_Drivers/drv_i2c.c
+175
-0
bsp/cypress/libraries/IFX_PSOC6_HAL/SConscript
bsp/cypress/libraries/IFX_PSOC6_HAL/SConscript
+1
-4
bsp/cypress/psoc6-cy8cproto-4343w/board/Kconfig
bsp/cypress/psoc6-cy8cproto-4343w/board/Kconfig
+38
-12
未找到文件。
bsp/cypress/libraries/HAL_Drivers/SConscript
浏览文件 @
7d68083b
...
...
@@ -23,7 +23,7 @@ if GetDepend(['RT_USING_I2C', 'RT_USING_I2C_BITOPS']):
src
+=
[
'drv_soft_i2c.c'
]
if
GetDepend
([
'RT_USING_I2C'
]):
if
GetDepend
(
'BSP_USING_HW_I2C
1
'
):
if
GetDepend
(
'BSP_USING_HW_I2C
3'
)
or
GetDepend
(
'BSP_USING_HW_I2C6
'
):
src
+=
[
'drv_i2c.c'
]
if
GetDepend
([
'RT_USING_ADC'
]):
...
...
bsp/cypress/libraries/HAL_Drivers/drv_i2c.c
0 → 100644
浏览文件 @
7d68083b
/*
* Copyright (c) 2006-2022, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-09-03 AisinoChip first implementation.
*/
#include "board.h"
#if defined(RT_USING_I2C)
#if defined(BSP_USING_HW_I2C3) || defined(BSP_USING_HW_I2C6)
#include <rtdevice.h>
#ifndef I2C3_CONFIG
#define I2C3_CONFIG \
{ \
.name = "i2c3", \
.scl_pin = P6_0, \
.sda_pin = P6_1, \
}
#endif
/* I2C3_CONFIG */
#endif
#ifndef I2C6_CONFIG
#define I2C6_CONFIG \
{ \
.name = "i2c6", \
.scl_pin = P13_0, \
.sda_pin = P13_1, \
}
#endif
/* I2C6_CONFIG */
enum
{
#ifdef BSP_USING_HW_I2C3
I2C3_INDEX
,
#endif
#ifdef BSP_USING_HW_I2C6
I2C6_INDEX
,
#endif
};
struct
ifx_i2c_config
{
char
*
name
;
rt_uint32_t
scl_pin
;
rt_uint32_t
sda_pin
;
};
struct
ifx_i2c
{
cyhal_i2c_t
mI2C
;
cyhal_i2c_cfg_t
mI2C_cfg
;
struct
ifx_i2c_config
*
config
;
struct
rt_i2c_bus_device
i2c_bus
;
};
static
struct
ifx_i2c_config
i2c_config
[]
=
{
#ifdef BSP_USING_HW_I2C3
I2C3_CONFIG
,
#endif
#ifdef BSP_USING_HW_I2C6
I2C6_CONFIG
,
#endif
};
static
struct
ifx_i2c
i2c_objs
[
sizeof
(
i2c_config
)
/
sizeof
(
i2c_config
[
0
])]
=
{
0
};
static
int
ifx_i2c_read
(
struct
ifx_i2c
*
hi2c
,
rt_uint16_t
slave_address
,
rt_uint8_t
*
p_buffer
,
rt_uint16_t
data_byte
)
{
if
(
cyhal_i2c_master_read
(
&
hi2c
->
mI2C
,
slave_address
,
p_buffer
,
data_byte
,
10
,
true
)
!=
RT_EOK
)
{
return
-
RT_ERROR
;
}
return
0
;
}
static
int
ifx_i2c_write
(
struct
ifx_i2c
*
hi2c
,
uint16_t
slave_address
,
uint8_t
*
p_buffer
,
uint16_t
data_byte
)
{
if
(
cyhal_i2c_master_write
(
&
hi2c
->
mI2C
,
slave_address
,
p_buffer
,
data_byte
,
10
,
true
)
!=
RT_EOK
)
{
return
-
RT_ERROR
;
}
return
0
;
}
static
rt_size_t
_i2c_xfer
(
struct
rt_i2c_bus_device
*
bus
,
struct
rt_i2c_msg
msgs
[],
rt_uint32_t
num
)
{
struct
rt_i2c_msg
*
msg
;
rt_uint32_t
i
;
struct
ifx_i2c
*
i2c_obj
;
RT_ASSERT
(
bus
!=
RT_NULL
);
RT_ASSERT
(
msgs
!=
RT_NULL
);
i2c_obj
=
rt_container_of
(
bus
,
struct
ifx_i2c
,
i2c_bus
);
for
(
i
=
0
;
i
<
num
;
i
++
)
{
msg
=
&
msgs
[
i
];
if
(
msg
->
flags
&
RT_I2C_RD
)
{
if
(
ifx_i2c_read
(
i2c_obj
,
msg
->
addr
,
msg
->
buf
,
msg
->
len
)
!=
0
)
{
goto
out
;
}
}
else
{
if
(
ifx_i2c_write
(
i2c_obj
,
msg
->
addr
,
msg
->
buf
,
msg
->
len
)
!=
0
)
{
goto
out
;
}
}
}
out:
return
i
;
}
static
const
struct
rt_i2c_bus_device_ops
i2c_ops
=
{
_i2c_xfer
,
RT_NULL
,
RT_NULL
};
void
HAL_I2C_Init
(
struct
ifx_i2c
*
obj
)
{
rt_uint8_t
result
=
RT_EOK
;
result
=
cyhal_i2c_init
(
&
obj
->
mI2C
,
obj
->
config
->
sda_pin
,
obj
->
config
->
scl_pin
,
NULL
);
RT_ASSERT
(
result
==
RT_EOK
);
result
=
cyhal_i2c_configure
(
&
obj
->
mI2C
,
&
obj
->
mI2C_cfg
);
RT_ASSERT
(
result
==
RT_EOK
);
}
int
rt_hw_i2c_init
(
void
)
{
rt_err_t
result
;
cyhal_i2c_t
mI2C
;
for
(
int
i
=
0
;
i
<
sizeof
(
i2c_config
)
/
sizeof
(
i2c_config
[
0
]);
i
++
)
{
i2c_objs
[
i
].
config
=
&
i2c_config
[
i
];
i2c_objs
[
i
].
i2c_bus
.
parent
.
user_data
=
&
i2c_config
[
i
];
i2c_objs
[
i
].
mI2C_cfg
.
is_slave
=
false
;
i2c_objs
[
i
].
mI2C_cfg
.
address
=
0
;
i2c_objs
[
i
].
mI2C_cfg
.
frequencyhal_hz
=
(
400000UL
);
i2c_objs
[
i
].
mI2C
=
mI2C
;
i2c_objs
[
i
].
i2c_bus
.
ops
=
&
i2c_ops
;
HAL_I2C_Init
(
&
i2c_objs
[
i
]);
result
=
rt_i2c_bus_device_register
(
&
i2c_objs
[
i
].
i2c_bus
,
i2c_config
[
i
].
name
);
RT_ASSERT
(
result
==
RT_EOK
);
}
return
0
;
}
INIT_DEVICE_EXPORT
(
rt_hw_i2c_init
);
#endif
/* defined(BSP_USING_I2C1) || defined(BSP_USING_I2C2) */
bsp/cypress/libraries/IFX_PSOC6_HAL/SConscript
浏览文件 @
7d68083b
...
...
@@ -94,9 +94,6 @@ path = [cwd + '/capsense',
cwd
+
'/TARGET_CY8CKIT-062S2-43012'
,
cwd
+
'/TARGET_CY8CKIT-062S2-43012/COMPONENT_BSP_DESIGN_MODUS/GeneratedSource'
]
if
rtconfig
.
PLATFORM
==
'gcc'
:
group
=
DefineGroup
(
'Libraries'
,
src
,
depend
=
[
''
],
CPPPATH
=
path
)
else
:
group
=
DefineGroup
(
'Libraries'
,
src
,
depend
=
[
''
],
CPPPATH
=
path
)
group
=
DefineGroup
(
'Libraries'
,
src
,
depend
=
[
''
],
CPPPATH
=
path
)
Return
(
'group'
)
bsp/cypress/psoc6-cy8cproto-4343w/board/Kconfig
浏览文件 @
7d68083b
...
...
@@ -29,12 +29,24 @@ menu "On-chip Peripheral Drivers"
default y
select RT_USING_SERIAL
if BSP_USING_UART
config BSP_USING_UART5
bool "Enable UART5"
default y
config BSP_USING_UART0
bool "Enable UART0"
default n
config BSP_USING_UART1
bool "Enable UART1"
default n
config BSP_USING_UART2
bool "Enable UART2"
default n
config BSP_USING_UART3
bool "Enable UART3"
default n
config BSP_USING_UART4
bool "Enable UART4"
default n
config BSP_USING_UART5
bool "Enable UART5"
default y
endif
menuconfig BSP_USING_ADC
...
...
@@ -60,24 +72,38 @@ menu "On-chip Peripheral Drivers"
select RT_USING_I2C
select RT_USING_PIN
if BSP_USING_HW_I2C
config BSP_USING_HW_I2C
1
bool "Enable I2C
1
Bus (User I2C)"
config BSP_USING_HW_I2C
3
bool "Enable I2C
3
Bus (User I2C)"
default n
if BSP_USING_HW_I2C
1
if BSP_USING_HW_I2C
3
comment "Notice: P6_0 --> 48; P6_1 --> 49"
config BSP_I2C
1
_SCL_PIN
int "i2c
1
SCL pin number"
config BSP_I2C
3
_SCL_PIN
int "i2c
3
SCL pin number"
range 1 113
default 48
config BSP_I2C
1
_SDA_PIN
int "i2c
1
SDA pin number"
config BSP_I2C
3
_SDA_PIN
int "i2c
3
SDA pin number"
range 1 113
default 49
endif
config BSP_USING_HW_I2C6
bool "Enable I2C6 Bus (User I2C)"
default n
if BSP_USING_HW_I2C6
comment "Notice: P13_0 --> 48; P13_1 --> 49"
config BSP_I2C6_SCL_PIN
int "i2c6 SCL pin number"
range 1 113
default 104
config BSP_I2C6_SDA_PIN
int "i2c6 SDA pin number"
range 1 113
default 105
endif
endif
menuconfig BSP_USING_I2C
bool "Enable I2C Bus"
bool "Enable
Software
I2C Bus"
default n
select RT_USING_I2C
select RT_USING_I2C_BITOPS
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录