Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
逝缘~
rt-thread
提交
d9057a32
R
rt-thread
项目概览
逝缘~
/
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,发现更多精彩内容 >>
提交
d9057a32
编写于
9月 25, 2021
作者:
B
BernardXiong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[BSP] fix the formating issue for drv_spi in ls2k
上级
5e643ff6
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
18 addition
and
11 deletion
+18
-11
bsp/ls2kdev/drivers/drv_spi.c
bsp/ls2kdev/drivers/drv_spi.c
+18
-11
未找到文件。
bsp/ls2kdev/drivers/drv_spi.c
浏览文件 @
d9057a32
...
...
@@ -15,36 +15,38 @@
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <rtthread.h>
#include <drivers/spi.h>
#include "drv_spi.h"
#ifdef RT_USING_SPI
#ifdef RT_USING_SPI_GPIOCS
#include <drivers/pin.h>
#endif
static
void
spi_init
(
uint8_t
spre_spr
,
uint8_t
copl
,
uint8_t
cpha
)
{
SET_SPI
(
SPSR
,
0xc0
);
SET_SPI
(
SPSR
,
0xc0
);
SET_SPI
(
PARAM
,
0x40
);
SET_SPI
(
PARAM2
,
0x01
);
SET_SPI
(
SPER
,
(
spre_spr
&
0
b00001100
)
>>
2
);
SET_SPI
(
SPCR
,
0x50
|
copl
<<
3
|
cpha
<<
2
|
(
spre_spr
&
0
b00000011
));
SET_SPI
(
SPCR
,
0x50
|
copl
<<
3
|
cpha
<<
2
|
(
spre_spr
&
0
b00000011
));
SET_SPI
(
SOFTCS
,
0xff
);
}
static
void
spi_set_csn
(
uint8_t
val
)
rt_inline
void
spi_set_csn
(
uint8_t
val
)
{
SET_SPI
(
SOFTCS
,
val
);
}
#ifdef RT_USING_SPI_GPIOCS
#include <drivers/pin.h>
#endif
static
void
spi_set_cs
(
unsigned
char
cs
,
int
new_status
)
static
void
spi_set_cs
(
unsigned
char
cs
,
int
new_status
)
{
if
(
cs
<
4
)
{
unsigned
char
val
=
0
;
val
=
GET_SPI
(
SOFTCS
);
val
|=
0x01
<<
cs
;
// csen=1
val
|=
0x01
<<
cs
;
// csen=1
if
(
new_status
)
// cs = 1
{
val
|=
(
0x10
<<
cs
);
// csn=1
...
...
@@ -64,6 +66,7 @@ static void spi_set_cs(unsigned char cs, int new_status)
}
#endif
}
static
uint8_t
spi_write_for_response
(
uint8_t
data
)
{
uint8_t
val
;
...
...
@@ -94,6 +97,7 @@ static int cmd_spi_init(int argc, char *argv[])
}
}
MSH_CMD_EXPORT
(
cmd_spi_init
,
cmd_spi_init
);
static
int
cmd_spi_set_csn
(
int
argc
,
char
*
argv
[])
{
uint8_t
val
,
csn
;
...
...
@@ -110,6 +114,7 @@ static int cmd_spi_set_csn(int argc, char *argv[])
}
}
MSH_CMD_EXPORT
(
cmd_spi_set_csn
,
cmd_spi_set_csn
);
static
int
cmd_spi_write
(
int
argc
,
char
*
argv
[])
{
uint8_t
data
,
resp
;
...
...
@@ -129,6 +134,7 @@ MSH_CMD_EXPORT(cmd_spi_write, cmd_spi_write);
static
rt_err_t
configure
(
struct
rt_spi_device
*
device
,
struct
rt_spi_configuration
*
configuration
);
static
rt_uint32_t
xfer
(
struct
rt_spi_device
*
device
,
struct
rt_spi_message
*
message
);
const
static
unsigned
char
SPI_DIV_TABLE
[]
=
{
0
b0000
,
0
b0001
,
0
b0100
,
0
b0010
,
0
b0011
,
0
b0101
,
0
b0110
,
0
b0111
,
0
b1000
,
0
b1001
,
0
b1010
,
0
b1011
};
// 2 4 8 16 32 64 128 256 512 1024 2048 4096
static
rt_err_t
configure
(
struct
rt_spi_device
*
device
,
...
...
@@ -171,8 +177,8 @@ static rt_err_t configure(struct rt_spi_device *device,
return
RT_EOK
;
}
static
rt_uint32_t
xfer
(
struct
rt_spi_device
*
device
,
struct
rt_spi_message
*
message
)
static
rt_uint32_t
xfer
(
struct
rt_spi_device
*
device
,
struct
rt_spi_message
*
message
)
{
unsigned
char
cs
=
0
;
...
...
@@ -214,18 +220,19 @@ static rt_uint32_t xfer(struct rt_spi_device *device,
}
return
message
->
length
;
}
static
struct
rt_spi_ops
loongson_spi_ops
=
{
.
configure
=
configure
,
.
xfer
=
xfer
};
static
struct
rt_spi_bus
loongson_spi
;
static
int
loongson_spi_init
()
{
//rt_kprintf("spi_init\n");
return
rt_spi_bus_register
(
&
loongson_spi
,
"spi"
,
&
loongson_spi_ops
);
}
INIT_BOARD_EXPORT
(
loongson_spi_init
);
#endif
/*@}*/
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录