Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dgr6878
rt-thread
提交
90778f6f
R
rt-thread
项目概览
dgr6878
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
90778f6f
编写于
6月 15, 2013
作者:
qiuyiuestc
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #103 from heyuanjie87/ForPullRequest
udisk can be ejected
上级
4cdb0154
02869d7e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
31 addition
and
17 deletion
+31
-17
components/drivers/include/drivers/usb_common.h
components/drivers/include/drivers/usb_common.h
+1
-0
components/drivers/usb/usbdevice/class/mstorage.c
components/drivers/usb/usbdevice/class/mstorage.c
+28
-15
components/drivers/usb/usbdevice/core/core.c
components/drivers/usb/usbdevice/core/core.c
+2
-2
未找到文件。
components/drivers/include/drivers/usb_common.h
浏览文件 @
90778f6f
...
...
@@ -368,6 +368,7 @@ typedef struct ureqest* ureq_t;
#define SCSI_INQUIRY_CMD 0x12
#define SCSI_ALLOW_MEDIUM_REMOVAL 0x1e
#define SCSI_MODE_SENSE_6 0x1a
#define SCSI_START_STOP 0x1b
#define SCSI_READ_CAPACITIES 0x23
#define SCSI_READ_CAPACITY 0x25
#define SCSI_READ_10 0x28
...
...
components/drivers/usb/usbdevice/class/mstorage.c
浏览文件 @
90778f6f
...
...
@@ -33,6 +33,7 @@ static rt_device_t disk;
static
rt_uint32_t
_block
;
static
rt_uint32_t
_count
,
_size
;
static
struct
rt_device_blk_geometry
geometry
;
static
rt_uint32_t
_removed
=
0
;
static
struct
udevice_descriptor
dev_desc
=
{
...
...
@@ -126,13 +127,13 @@ static rt_err_t _request_sense(udevice_t device, uep_t ep_in)
data
.
ErrorCode
=
0x70
;
data
.
Valid
=
0
;
data
.
SenseKey
=
5
;
data
.
SenseKey
=
2
;
//TODO
data
.
Information
[
0
]
=
0
;
data
.
Information
[
1
]
=
0
;
data
.
Information
[
2
]
=
0
;
data
.
Information
[
3
]
=
0
;
data
.
AdditionalSenseLength
=
0x0
b
;
data
.
AdditionalSenseCode
=
0x
20
;
data
.
AdditionalSenseLength
=
0x0
a
;
data
.
AdditionalSenseCode
=
0x
3a
;
//TODO
data
.
AdditionalSenseCodeQualifier
=
0
;
dcd_ep_write
(
device
->
dcd
,
ep_in
,
(
rt_uint8_t
*
)
&
data
,
sizeof
(
struct
request_sense_data
));
...
...
@@ -299,6 +300,19 @@ static rt_err_t _verify_10(udevice_t device)
return
RT_EOK
;
}
static
void
_send_status
(
udevice_t
device
,
mass_eps_t
eps
,
ustorage_csw_t
csw
)
{
dcd_ep_write
(
device
->
dcd
,
eps
->
ep_in
,
(
rt_uint8_t
*
)
csw
,
SIZEOF_CSW
);
dcd_ep_read
(
device
->
dcd
,
eps
->
ep_out
,
eps
->
ep_out
->
buffer
,
SIZEOF_CBW
);
status
=
STATUS_CBW
;
}
static
void
_start_stop
(
ustorage_cbw_t
cbw
)
{
//TODO
_removed
=
1
;
}
/**
* This function will handle mass storage bulk in endpoint request.
*
...
...
@@ -313,13 +327,11 @@ static rt_err_t _ep_in_handler(udevice_t device, uclass_t cls, rt_size_t size)
RT_ASSERT
(
device
!=
RT_NULL
);
eps
=
cls
->
eps
;
if
(
status
==
STATUS_CSW
)
if
(
status
==
STATUS_CSW
)
{
dcd_ep_write
(
device
->
dcd
,
eps
->
ep_in
,
(
rt_uint8_t
*
)
&
csw
,
SIZEOF_CSW
);
status
=
STATUS_CBW
;
dcd_ep_read
(
device
->
dcd
,
eps
->
ep_out
,
eps
->
ep_out
->
buffer
,
SIZEOF_CBW
);
_send_status
(
device
,
eps
,
&
csw
);
}
if
(
status
==
STATUS_SEND
)
else
if
(
status
==
STATUS_SEND
)
{
rt_device_read
(
disk
,
_block
,
eps
->
ep_in
->
buffer
,
1
);
dcd_ep_write
(
device
->
dcd
,
eps
->
ep_in
,
eps
->
ep_in
->
buffer
,
...
...
@@ -388,8 +400,8 @@ static rt_err_t _ep_out_handler(udevice_t device, uclass_t cls, rt_size_t size)
switch
(
cbw
->
cb
[
0
])
{
case
SCSI_TEST_UNIT_READY
:
dcd_ep_write
(
device
->
dcd
,
eps
->
ep_in
,
(
rt_uint8_t
*
)
&
csw
,
SIZEOF_CSW
)
;
dcd_ep_read
(
device
->
dcd
,
eps
->
ep_out
,
eps
->
ep_out
->
buffer
,
SIZEOF_CBW
);
csw
.
status
=
_removed
;
_send_status
(
device
,
eps
,
&
csw
);
break
;
case
SCSI_REQUEST_SENSE
:
_request_sense
(
device
,
eps
->
ep_in
);
...
...
@@ -404,8 +416,7 @@ static rt_err_t _ep_out_handler(udevice_t device, uclass_t cls, rt_size_t size)
status
=
STATUS_CSW
;
break
;
case
SCSI_ALLOW_MEDIUM_REMOVAL
:
dcd_ep_write
(
device
->
dcd
,
eps
->
ep_in
,
(
rt_uint8_t
*
)
&
csw
,
SIZEOF_CSW
);
dcd_ep_read
(
device
->
dcd
,
eps
->
ep_out
,
eps
->
ep_out
->
buffer
,
SIZEOF_CBW
);
_send_status
(
device
,
eps
,
&
csw
);
break
;
case
SCSI_READ_CAPACITIES
:
_read_capacities
(
device
,
eps
->
ep_in
);
...
...
@@ -425,6 +436,10 @@ static rt_err_t _ep_out_handler(udevice_t device, uclass_t cls, rt_size_t size)
case
SCSI_VERIFY_10
:
_verify_10
(
device
);
break
;
case
SCSI_START_STOP
:
_start_stop
(
cbw
);
_send_status
(
device
,
eps
,
&
csw
);
break
;
}
}
else
if
(
status
==
STATUS_RECEIVE
)
...
...
@@ -439,9 +454,7 @@ static rt_err_t _ep_out_handler(udevice_t device, uclass_t cls, rt_size_t size)
_block
++
;
if
(
_size
==
0
)
{
dcd_ep_write
(
device
->
dcd
,
eps
->
ep_in
,
(
rt_uint8_t
*
)
&
csw
,
SIZEOF_CSW
);
dcd_ep_read
(
device
->
dcd
,
eps
->
ep_out
,
eps
->
ep_out
->
buffer
,
SIZEOF_CBW
);
status
=
STATUS_CBW
;
_send_status
(
device
,
eps
,
&
csw
);
}
else
{
...
...
components/drivers/usb/usbdevice/core/core.c
浏览文件 @
90778f6f
...
...
@@ -734,8 +734,8 @@ rt_err_t _reset_notify(udevice_t device)
RT_ASSERT
(
device
!=
RT_NULL
);
_stop_notify
();
_run_notify
();
_stop_notify
(
device
);
_run_notify
(
device
);
return
RT_EOK
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录