当前位置:网站首页>Principle of USB Communication
Principle of USB Communication
2022-08-06 17:38:00 【A mouthful of Linux】
USB是轮询总线,USBThe data exchange between the host and the device is initiated by the host,The device side can only respond passively.USBData is passed in or out USB 设备中的端点.
USB 主机中的客户端将数据存储在缓冲区中,USBHosts have no concept of endpoints.
USB Host 和外围 USB Device 有不同的层,如下图所示.The connections between the tiers are logical hosts between each horizontal tier-设备接口.Used between logical connectionsUSB Pipes传输数据.

USB通讯过程
A complete communication is divided into three processes:请求过程(令牌包)、数据过程(数据包)and state process(握手包),When there is no data to transfer,Skip the data process.
The communication process includes the following three cases:

The host sends the token packet(Token)Begin the request process,There is a data process if the request states that there is data to transfer,Finally by the data receiver(There are data processes)or slave(No data process)Initiate a state process,结束本次通信.
与USB全速设备通信时,The host will divide every second equally1000个帧(Frame).host at the beginning of each frame,Broadcast a start of frame token packet to all slaves(Start Of Frame,SOF包).它的作用有两个:One is to notify all slaves,主机的USBThe bus works normally;The second is that the slave uses this to synchronize the timing of the master.
与USB高速设备通信时,The host further divides the frame into equal parts8个微帧(Microframe),Each microframe accounts for 125μ \muμs.within the same frame,8The frame number of each microframe is equal to the current oneSOFThe frame number of the packet.
管道PIPE
管道分为两种类型:
- Message pipes have defined USB format and controlled by the host.Message pipes allow data to flow in both directions and are only supported控制传输.
- 流管道没有定义的 USB 格式,可以由主机或设备控制.数据流具有预定义的方向,即IN或OUT.Stream pipeline support中断传输、同步传输和批量传输.
当 USB 设备连接到 USB 总线并由 USB During host configuration,Most pipes will exist.Pipes originate from data buffers within the host client,并在 USB Terminates at the endpoint within the device.
传输
传输(数据流类型)可以由一个或多个事务组成.Pipes support only one of the following transport types:
- 控制传输通常用于设置 USB 设备.他们总是使用 IN/OUT 端点 0.
- 中断传输可用于定期发送数据的地方,例如状态更新.
- 同步传输传输实时数据,例如音频和视频.They have a guaranteed fixed bandwidth,但没有错误检测.
- 批量传输Can be used to send data when time is not important,For example to a printer.
事务
Data in so called事务中传输.通常,They consist of three packets:
- The token package is to define the transaction type and direction、Device address and endpoint headers.
- 数据以数据包的形式传输.
- The final state of the transaction is the confirmation in the handshake packet.

在事务中,数据从 USB 主机传输到 USB 设备,反之亦然.The transmission direction is from USB 主机发送的令牌包中指定.然后,The source sends a packet or indicates that it has no data to transmit.一般情况下,The destination responds with a handshake packet,指示传输是否成功.
数据包
A packet can be thought of as the smallest element of data transfer.每个数据包以当前传输速率传输整数个字节.数据包以同步模式开始,This is followed by the data bytes of the packet,and ends with a packet (EOP) 信号结束.所有 USB Packet modes all transmit the least significant bit first.Before and after the packet,总线处于空闲状态.

A special packet is will USB The bus is divided into time-segmented start-of-frame packets (SOF).Each pipeline is allocated a slot in each frame.Start-of-Frame 数据包在全速链路上每 1ms 发送一次.在高速下,1ms Frames are divided into 8 个微帧,每个微帧 125μs.Start-of-Frame Packets are sent with the same frame number at the beginning of each microframe.帧号每 1ms 递增一次.
端点
端点可以描述为数据源或接收器,并且仅存在于 USB 设备中.Data stored on endpoints can be retrieved from USB The host receives or waits to send to USB 主机.Endpoints can be configured to supportUSB 规范中定义的四种传输类型(控制传输、中断传输、同步传输和批量传输).within hardware limitations,端点可以使用 USB 中间件进行配置(例如,将端点限制为某种传输类型).
端点充当一种缓冲区.例如,USB Clients of the host can communicate to the endpoint 1 发送数据.来自 USB The host's data will be sent toOUT 端点 1. The program on the microcontroller will read the data as soon as it is ready.Return data must be writtenIN Endpoint 1,Because the program is not freely accessible USB 总线(USB 总线由 USB 主机控制).IN Endpoint 1 The data in is always kept there,until the host Endpoint 1 发送 IN Packets request data.
这些规则适用于所有微控制器设备:
- 一个设备最多可以有16 个 OUT和16 个 IN端点.
- There can only be one per endpoint 传输 方向.
- 端点 0仅用于控制传输,Cannot be assigned to any other function.
The total number of endpoints and the data size of each endpoint are defined by the underlying hardware.
- OUTAlways refers to the direction from the host to the device.
- INAlways point in the direction of the host.
¥打赏
边栏推荐
猜你喜欢

win7 suffix name is hidden how to open win7 file how to display suffix name

浅谈Jmeter性能测试流程

appcrash事件怎么解决win7 win7系统修复appcrash

基于 OPLG 从 0 到 1 构建统一可观测平台实践

Flyway error source code analysis - Validate failed: Migrations have failed validation

使用接口地址池为直连网段分配地址

Win7 and win10 which takes up less resources Win7 and win10 take up resources in detail

windows7激活产品密钥最新免费2022大全(含旗舰版、专业版、家庭版、通用版)

mysql存储过程实现 定时删除指定表中指定时间点的数据

win7强制恢复出厂设置 win7怎么格式化电脑恢复出厂设置
随机推荐
php ini设置session过期时间
See three years of CRUD programmers how to solve the database deadlock
sql语句之字符串截取函数(substring_index)
Redis 基础
电脑系统怎么重装win7u盘启动 台式笔记本电脑重装win7步骤
QWT下载、安装、配置教程
软件测试周刊(第83期):当你感觉忙得没时间休息,就是你最需要找时间休息的时候。
快捷方式指向的驱动器或网络连接不可用怎么解决
面试20场,我总结了面试问题及解答!激光+IMU融合定位方向
`英语` 2022/8/6
华泰证券开户怎么样?安不安全
2022 华数杯 B 题 水下机器人的组装计划
FR9608SP SOP-8 28V、3A、340 KHz同步降压DC/DC转换器
win7旗舰版强行删除开机密码 win7开机密码忘了怎么解除
win7启动项设置在哪 win7关闭开机启动项怎么设置
win7台式机如何调整屏幕亮度 win7设置屏幕亮度
win7输入法不见了怎么调出来 win7输入法图标不见了
#yyds干货盘点# WWW服务
`English` 2022/8/3
IDEA03:数据库CDC、Kafka和连接器Debezium配置

