USB论坛-百合电子工作室USB专题站

 找回密码
 我要注册
搜索
热搜: USB学习板
查看: 15089|回复: 5
打印 上一主题 下一主题

in,out,setup数据类型以及四种传输类型的区别

[复制链接]

6

主题

0

好友

1160

积分

管理员

Rank: 9Rank: 9Rank: 9

楼主
发表于 2015-8-28 11:07:56 |显示全部楼层
in是设备发到主机的
out中主机发到设备的
setup是双向的,在控制传输(control transfers)里才有
回复

使用道具 举报

6

主题

0

好友

1160

积分

管理员

Rank: 9Rank: 9Rank: 9

沙发
发表于 2015-8-28 11:10:22 |显示全部楼层
in,out是指传输的数据方向,Bulk Transaction、Control Transaction、Interrupt Transaction和Isochronous Transaction是协议定义的类型,每次通信过程可能包含几个in或out方向的数据包传输
回复

使用道具 举报

6

主题

0

好友

1160

积分

管理员

Rank: 9Rank: 9Rank: 9

板凳
发表于 2015-8-28 11:11:58 |显示全部楼层
是的,不过setup在这里又有点不一样,他应该只在控制传输里才有的
回复

使用道具 举报

6

主题

0

好友

1160

积分

管理员

Rank: 9Rank: 9Rank: 9

地板
发表于 2015-8-28 11:19:45 |显示全部楼层
是啊,不冲突,四种传输模式都包含多个in或out类型的数据包,特别地,setup只在控制传输里才有
回复

使用道具 举报

6

主题

0

好友

1160

积分

管理员

Rank: 9Rank: 9Rank: 9

5#
发表于 2015-8-28 11:27:52 |显示全部楼层
Each transfer consists of one or more transactions, and each transaction
inturn consists of one, two, or three packets.这句似乎和我理解的不一样。

我所理解的in和out,只是数据传输方向,所以只针对一个包。上句里说的应该是一个传输过程,一个传输过程可能包含几个包。在学习设备端点描述符时,也会遇到关于输入还是输出端点的说法,我说的就是这种情况
回复

使用道具 举报

6

主题

0

好友

1160

积分

管理员

Rank: 9Rank: 9Rank: 9

6#
发表于 2015-8-28 11:44:30 |显示全部楼层
最近在写一些关于驱动的文章,下面是一段国外关于winusb的原文以及我翻译的文字,参考一下:

Every USB data transfer is between a PC or other USB host computer and a device endpoint. A device endpoint is a buffer that stores received data or data to transmit. Every device must support endpoint zero, which is bidirectional. Additional, optional endpoint addresses each have a number (1-15) and a direction (IN or OUT).

Even though endpoints reside on devices, the USB specification defines endpoint direction from the view of the host PC. An IN endpoint sends data to the PC, and an OUT endpoint receives data from the PC. This naming convention can be confusing when writing code for the device side!

One reason why USB is so versatile is its support for four transfer types, each with different strengths. WinUSB supports control, bulk, and interrupt transfers. Control transfers use endpoint zero. The other transfer types can use endpoints one and higher.
Control transfers provide a structured way to send requests and data and receive responses. Control transfers are the only type that can pass information in both directions in a single transfer. After device attachment, in a process called enumeration, the host computer uses control transfers to learn about the device.

A control transfer has two or three stages. To learn about a newly attached device, the host computer uses control transfers to request data structures called descriptors from the device. In the Setup stage, the host sends the request. In the Data stage, the device sends the requested descriptor. In the Status stage, the host acknowledges receiving the descriptor. A host can also use control transfers to send information to a device in the Data stage, with the device acknowledging in the Status stage. Some requests have no Data stage.

A USB host reserves a portion of the bus bandwidth for control transfers: 10% for low- and full-speed endpoints and 20% for high-speed endpoints. If the bus isn’t busy, control transfers can use more than the reserved bandwidth. But all devices must share the bus, so on a busy bus, a control transfer may have to wait.

The other transfer types don’t have multiple stages and can transfer data for any purpose. On an otherwise idle bus, bulk transfers are the fastest. But bulk transfers have no guaranteed bandwidth, so on a busy bus, bulk transfers must wait. Common uses for bulk transfers are printers and scanners, where quick transfers are nice but not essential.

  每个USB传输发生在PC或其它USB主机与设备端点(endjpoint)之间,设备端点是一个收发数据的缓冲区,每个设备必须支持端点零(endpoint 0),端点零是双向的,设备还可以拥有端点1-15,它们是单向的(IN或OUT)。

  即使从设备里的端点来看,USB协议还定义了端点的方向(针对PC和其它USB主机来说),输入端点(IN endpoint)是设备向PC(或主机)发数据的端点,输出端点(OUT endpoint)是PC向设备发数据的端点,在写设备端代码的时候很容易引起混淆,一定要注意。

  USB是如此有用,一个理由是因为它支持四种传输模式,不同模式支持不同数据长度。WinUSB支持控制传输、批量传输和中断传输。控制传输用端点零,其它类型的传输使用1及1以上的端点。

  控制传输提供了一个结构化的方法来发送请求和数据,接收应答和数据,只有控制传输是双向的。当USB设备插入主机后,主机通过控制端点来取得设备相关信息,这一过程叫做枚举。

  控制传输有二到三个阶段。为了用于取得最新插入的USB设备设备,主机用控制传输请求设备标准描述符。在Setup阶段,主机发送请求,在Data阶段,设备向主机发送被请求的描述符,在Status阶段,主机分析收到的描述符。在Data阶段,主机也可以用控制传输向设备发送一些信息,接着设备在Status阶段分析这些信息。

  USB主机为控制传输保留了一部分总线带宽,全速设备最低10%,高速设备最低20%。如果总线不是很忙,控制传输和以取得更多保留带宽,但是所有设备必须共享总线带宽 ,所以在一个繁忙的总线上,控制传输可能需要等待。 

  其它类型传输可传输任何目的的数据,传输过程也没有被划分成这么多的阶段。....
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 我要注册

USB开发网 (渝ICP备09006681号-4)

GMT+8, 2024-5-8 05:43 , Processed in 0.040473 second(s), 19 queries .

百合电子工作室版权所有
回顶部