Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
luozhenger
rt-thread
提交
aaf5462c
R
rt-thread
项目概览
luozhenger
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
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,发现更多精彩内容 >>
提交
aaf5462c
编写于
12月 02, 2022
作者:
L
linshire
提交者:
mysterywolf
12月 02, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
更改了函数名
上级
622062aa
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
14 addition
and
14 deletion
+14
-14
bsp/wch/risc-v/Libraries/ch32_drivers/drv_spi.c
bsp/wch/risc-v/Libraries/ch32_drivers/drv_spi.c
+14
-14
未找到文件。
bsp/wch/risc-v/Libraries/ch32_drivers/drv_spi.c
浏览文件 @
aaf5462c
...
...
@@ -65,10 +65,10 @@ static struct ch32_spi spi_bus_obj[sizeof(spi_config) / sizeof(spi_config[0])] =
static
rt_uint32_t
ch32_spi_clock_get
(
SPI_TypeDef
*
spix
);
static
void
ch32_spi_clock_and_io_init
(
SPI_TypeDef
*
spix
);
static
rt_uint8_t
spix_
ReadWriteB
yte
(
SPI_TypeDef
*
Instance
,
rt_uint8_t
TxData
);
static
rt_err_t
spi_
TransmitR
eceive
(
SPI_TypeDef
*
Instance
,
uint8_t
*
send_buf
,
uint8_t
*
recv_buf
,
uint16_t
send_length
);
static
rt_err_t
spi_
T
ransmit
(
SPI_TypeDef
*
Instance
,
uint8_t
*
send_buf
,
uint16_t
send_length
);
static
rt_err_t
spi_
R
eceive
(
SPI_TypeDef
*
Instance
,
uint8_t
*
recv_buf
,
uint16_t
send_length
);
static
rt_uint8_t
spix_
readwriteb
yte
(
SPI_TypeDef
*
Instance
,
rt_uint8_t
TxData
);
static
rt_err_t
spi_
transmitr
eceive
(
SPI_TypeDef
*
Instance
,
uint8_t
*
send_buf
,
uint8_t
*
recv_buf
,
uint16_t
send_length
);
static
rt_err_t
spi_
t
ransmit
(
SPI_TypeDef
*
Instance
,
uint8_t
*
send_buf
,
uint16_t
send_length
);
static
rt_err_t
spi_
r
eceive
(
SPI_TypeDef
*
Instance
,
uint8_t
*
recv_buf
,
uint16_t
send_length
);
static
void
ch32_spi_clock_and_io_init
(
SPI_TypeDef
*
spix
)
{
...
...
@@ -166,7 +166,7 @@ static rt_uint32_t ch32_spi_clock_get(SPI_TypeDef *spix)
/*
*spix read write byte
* */
static
rt_uint8_t
spix_
ReadWriteB
yte
(
SPI_TypeDef
*
Instance
,
rt_uint8_t
TxData
)
static
rt_uint8_t
spix_
readwriteb
yte
(
SPI_TypeDef
*
Instance
,
rt_uint8_t
TxData
)
{
uint8_t
i
=
0
;
while
(
SPI_I2S_GetFlagStatus
(
Instance
,
SPI_I2S_FLAG_TXE
)
==
RESET
)
...
...
@@ -188,12 +188,12 @@ static rt_uint8_t spix_ReadWriteByte(SPI_TypeDef *Instance, rt_uint8_t TxData)
/*
*spi transmit and receive
* */
static
rt_err_t
spi_
TransmitR
eceive
(
SPI_TypeDef
*
Instance
,
uint8_t
*
send_buf
,
uint8_t
*
recv_buf
,
uint16_t
send_length
)
static
rt_err_t
spi_
transmitr
eceive
(
SPI_TypeDef
*
Instance
,
uint8_t
*
send_buf
,
uint8_t
*
recv_buf
,
uint16_t
send_length
)
{
uint16_t
i
=
0
;
for
(
i
=
0
;
i
<
send_length
;
i
++
)
{
recv_buf
[
i
]
=
spix_
ReadWriteB
yte
(
Instance
,
send_buf
[
i
]);
recv_buf
[
i
]
=
spix_
readwriteb
yte
(
Instance
,
send_buf
[
i
]);
}
return
RT_EOK
;
}
...
...
@@ -201,12 +201,12 @@ static rt_err_t spi_TransmitReceive(SPI_TypeDef *Instance, uint8_t *send_buf, ui
/*
*spi transmit
* */
static
rt_err_t
spi_
T
ransmit
(
SPI_TypeDef
*
Instance
,
uint8_t
*
send_buf
,
uint16_t
send_length
)
static
rt_err_t
spi_
t
ransmit
(
SPI_TypeDef
*
Instance
,
uint8_t
*
send_buf
,
uint16_t
send_length
)
{
uint16_t
i
=
0
;
for
(
i
=
0
;
i
<
send_length
;
i
++
)
{
spix_
ReadWriteB
yte
(
Instance
,
send_buf
[
i
]);
spix_
readwriteb
yte
(
Instance
,
send_buf
[
i
]);
}
return
RT_EOK
;
}
...
...
@@ -214,12 +214,12 @@ static rt_err_t spi_Transmit(SPI_TypeDef *Instance, uint8_t *send_buf, uint16_t
/*
*spi receive
* */
static
rt_err_t
spi_
R
eceive
(
SPI_TypeDef
*
Instance
,
uint8_t
*
recv_buf
,
uint16_t
send_length
)
static
rt_err_t
spi_
r
eceive
(
SPI_TypeDef
*
Instance
,
uint8_t
*
recv_buf
,
uint16_t
send_length
)
{
uint16_t
i
=
0
;
for
(
i
=
0
;
i
<
send_length
;
i
++
)
{
recv_buf
[
i
]
=
spix_
ReadWriteB
yte
(
Instance
,
0xFF
);
/*发送数据为0xff 此时显示为不发送*/
recv_buf
[
i
]
=
spix_
readwriteb
yte
(
Instance
,
0xFF
);
/*发送数据为0xff 此时显示为不发送*/
}
return
RT_EOK
;
}
...
...
@@ -416,12 +416,12 @@ static rt_uint32_t spi_xfer(struct rt_spi_device *device, struct rt_spi_message
/* start once data exchange */
if
(
message
->
send_buf
&&
message
->
recv_buf
)
{
state
=
spi_
TransmitR
eceive
(
spi_handle
->
Instance
,
(
uint8_t
*
)
send_buf
,
(
uint8_t
*
)
recv_buf
,
send_length
);
state
=
spi_
transmitr
eceive
(
spi_handle
->
Instance
,
(
uint8_t
*
)
send_buf
,
(
uint8_t
*
)
recv_buf
,
send_length
);
}
else
if
(
message
->
send_buf
)
{
state
=
spi_
T
ransmit
(
spi_handle
->
Instance
,
(
uint8_t
*
)
send_buf
,
send_length
);
state
=
spi_
t
ransmit
(
spi_handle
->
Instance
,
(
uint8_t
*
)
send_buf
,
send_length
);
if
(
message
->
cs_release
&&
(
device
->
config
.
mode
&
RT_SPI_3WIRE
))
{
/* release the CS by disable SPI when using 3 wires SPI */
...
...
@@ -433,7 +433,7 @@ static rt_uint32_t spi_xfer(struct rt_spi_device *device, struct rt_spi_message
memset
((
uint8_t
*
)
recv_buf
,
0xff
,
send_length
);
/* clear the old error flag */
SPI_I2S_ClearFlag
(
spi_handle
->
Instance
,
SPI_I2S_FLAG_OVR
);
state
=
spi_
R
eceive
(
spi_handle
->
Instance
,
(
uint8_t
*
)
recv_buf
,
send_length
);
state
=
spi_
r
eceive
(
spi_handle
->
Instance
,
(
uint8_t
*
)
recv_buf
,
send_length
);
}
if
(
state
!=
RT_EOK
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录