Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
f268ffa5
R
rt-thread
项目概览
BaiXuePrincess
/
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看板
提交
f268ffa5
编写于
3月 13, 2018
作者:
L
liang yongxiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[bsp] delete SDIO test code
上级
5760c356
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
0 addition
and
147 deletion
+0
-147
bsp/imxrt1052-evk/applications/sdio_test.c
bsp/imxrt1052-evk/applications/sdio_test.c
+0
-147
未找到文件。
bsp/imxrt1052-evk/applications/sdio_test.c
已删除
100644 → 0
浏览文件 @
5760c356
#include "rtthread.h"
#include <stdint.h>
#include "string.h"
#define __is_print(ch) ((unsigned int)((ch) - ' ') < 127u - ' ')
static
void
dump_hex
(
const
rt_uint8_t
*
ptr
,
rt_size_t
buflen
)
{
unsigned
char
*
buf
=
(
unsigned
char
*
)
ptr
;
int
i
,
j
;
for
(
i
=
0
;
i
<
buflen
;
i
+=
16
)
{
rt_kprintf
(
"%08X: "
,
i
);
for
(
j
=
0
;
j
<
16
;
j
++
)
if
(
i
+
j
<
buflen
)
rt_kprintf
(
"%02X "
,
buf
[
i
+
j
]);
else
rt_kprintf
(
" "
);
rt_kprintf
(
" "
);
for
(
j
=
0
;
j
<
16
;
j
++
)
if
(
i
+
j
<
buflen
)
rt_kprintf
(
"%c"
,
__is_print
(
buf
[
i
+
j
])
?
buf
[
i
+
j
]
:
'.'
);
rt_kprintf
(
"
\n
"
);
}
}
static
void
read_sd__
(
uint32_t
addr
,
int
length
,
int
count
)
{
rt_device_t
device
=
RT_NULL
;
rt_err_t
result
;
struct
rt_device_blk_geometry
geometry
;
rt_uint8_t
*
read_buffer
=
RT_NULL
;
device
=
rt_device_find
(
"sd0"
);
rt_device_init
(
device
);
rt_device_open
(
device
,
RT_DEVICE_FLAG_RDWR
);
rt_memset
(
&
geometry
,
0
,
sizeof
(
geometry
));
result
=
rt_device_control
(
device
,
RT_DEVICE_CTRL_BLK_GETGEOME
,
&
geometry
);
rt_kprintf
(
"device info:
\r\n
"
);
rt_kprintf
(
"sector size : %d byte
\r\n
"
,
geometry
.
bytes_per_sector
);
rt_kprintf
(
"sector count : %d
\r\n
"
,
geometry
.
sector_count
);
rt_kprintf
(
"block size : %d byte
\r\n
"
,
geometry
.
block_size
);
rt_kprintf
(
"
\r\n
"
);
read_buffer
=
rt_malloc
(
geometry
.
bytes_per_sector
*
length
);
if
(
read_buffer
==
RT_NULL
)
{
rt_kprintf
(
"no memory for read_buffer!
\r\n
"
);
goto
__return
;
}
memset
(
read_buffer
,
0x00
,
geometry
.
bytes_per_sector
*
length
);
// for(i = 0;i < count; i++)
{
result
=
rt_device_read
(
device
,
addr
,
read_buffer
,
length
);
dump_hex
(
read_buffer
,
geometry
.
bytes_per_sector
*
length
);
if
(
result
!=
length
)
{
rt_kprintf
(
"read device :%s "
,
device
->
parent
.
name
);
rt_kprintf
(
"the first sector failed.
\r\n
"
);
goto
__return
;
}
rt_kprintf
(
"
\n
"
);
}
__return:
if
(
read_buffer
!=
RT_NULL
)
{
rt_free
(
read_buffer
);
}
}
static
void
write_sd__
(
uint32_t
addr
,
int
length
,
unsigned
char
data
)
{
int
i
;
rt_device_t
device
=
RT_NULL
;
rt_err_t
result
;
struct
rt_device_blk_geometry
geometry
;
rt_uint8_t
*
write_buffer
=
RT_NULL
;
rt_uint8_t
*
data_point
=
RT_NULL
;;
device
=
rt_device_find
(
"sd0"
);
rt_device_init
(
device
);
rt_device_open
(
device
,
RT_DEVICE_FLAG_RDWR
);
rt_memset
(
&
geometry
,
0
,
sizeof
(
geometry
));
result
=
rt_device_control
(
device
,
RT_DEVICE_CTRL_BLK_GETGEOME
,
&
geometry
);
rt_kprintf
(
"device info:
\r\n
"
);
rt_kprintf
(
"sector size : %d byte
\r\n
"
,
geometry
.
bytes_per_sector
);
rt_kprintf
(
"sector count : %d
\r\n
"
,
geometry
.
sector_count
);
rt_kprintf
(
"block size : %d byte
\r\n
"
,
geometry
.
block_size
);
rt_kprintf
(
"
\r\n
"
);
write_buffer
=
rt_malloc
(
geometry
.
bytes_per_sector
);
if
(
write_buffer
==
RT_NULL
)
{
rt_kprintf
(
"no memory for write_buffer!
\r\n
"
);
goto
__return
;
}
data_point
=
write_buffer
;
for
(
i
=
data
;
i
<
geometry
.
bytes_per_sector
;
i
++
)
{
*
data_point
++
=
(
rt_uint8_t
)
i
;
}
for
(
i
=
addr
;
i
<
(
length
+
addr
);
i
++
)
{
rt_device_write
(
device
,
addr
,
write_buffer
,
1
);
}
__return:
if
(
write_buffer
!=
RT_NULL
)
{
rt_free
(
write_buffer
);
}
}
int
sdio_read
(
uint32_t
addr
,
int
length
,
int
count
)
{
read_sd__
(
addr
,
length
,
count
);
return
0
;
}
int
sdio_write
(
uint32_t
addr
,
int
length
,
unsigned
char
data
)
{
write_sd__
(
addr
,
length
,
data
);
return
0
;
}
#ifdef RT_USING_FINSH
#include <finsh.h>
FINSH_FUNCTION_EXPORT_ALIAS
(
sdio_read
,
sdior
,
sdio
read
test
);
FINSH_FUNCTION_EXPORT_ALIAS
(
sdio_write
,
sdiow
,
sdio
write
test
);
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录