我的NPI项目之Android USB 系列(一) - USB第一面

和USB应该是老朋友了,从2011年接触Android开发开始,就天天和USB打交道了。那时候还有不

对称扁头的usb/方口的usb,直到如今使用广泛的防反插USB3.0 type-C。

但是,一直有一个不是很清楚的问题萦绕在心头,那就是。先有USB协议还是先有USB connector定义?

什么USB1.0,USB2.0,USB3.0 , USB PD, 等等。这些协议和接口又是一个什么样的关系?今天就来简单整理一下。但是重心会放在移动设备上广泛使用的USB2.0/USB OTG/ USB3.0,Type-B和Type-C。

认识USB设备,带USB插槽的Laptop,U盘,USB鼠标/键盘,USB移动硬盘,USB充电宝,USB Type-C。


USB 设备分类
通常USB设备分为主设备和从设备。通常,笔记本会充当主设备,而其它接在笔记本上的设备为从设备,也可以统一称为外设。


通信过程
以U盘为例

Powering on the Laptop: When you power on the laptop, the system boots up, and the operating system (such as Windows, macOS, or Linux) is loaded into the laptop's memory (RAM). The operating system takes control of the laptop's hardware and manages the execution of software applications.

Connecting the USB Interface Disk: You connect the USB interface disk (such as a USB flash drive or an external hard drive) to one of the available USB ports on the laptop. The USB port provides both power and data connectivity for the attached device.

Device Recognition(枚举的过程): The operating system detects the presence of the connected USB interface disk. It identifies the device and loads the appropriate device drivers if necessary. Device drivers are software components that enable the operating system to communicate with and control the connected device.

Mounting the Disk: Once the USB interface disk is recognized, the operating system "mounts" it(挂在文件系统), which means it makes the storage space on the disk accessible to the laptop's file system. The operating system assigns a drive letter or mount point to the disk, allowing you to access its contents.

File System Access: With the USB interface disk mounted, you can interact with its contents through the file manager or file explorer of the operating system. You can browse files, copy, move, delete, or perform other file operations on the disk, similar to how you would interact with files on the laptop's internal storage.

Data Transfer: You can transfer data between the laptop and the USB interface disk by simply dragging and dropping files or using copy-paste operations. The operating system manages the data transfer process, ensuring that the data is written to or read from the appropriate locations on the disk.

Safe Removal: To safely remove the USB interface disk, you should use the operating system's "eject" or "safely remove" feature. This ensures that all pending write operations are completed and the file system is properly unmounted from the disk. Following this procedure helps prevent data corruption or loss.

Disconnecting the Disk: After safely removing the USB interface disk, you can physically disconnect it from the laptop's USB port.
协议上 通信过程

In USB communication, the transfer process is typically initiated by the USB master device.(所有的通信都应该由主设备法起)。 The USB master device, also known as the host, is responsible for controlling the USB bus and managing communication with connected USB devices.

The USB master device takes the initiative to initiate various USB transactions such as data(数据) transfers, control commands(命令), and enumeration(枚举). It sends requests to the connected USB devices, instructing them to perform specific actions or transfer data.

On the other hand, USB slave devices, also called peripherals(通称为外设), respond to the commands and requests from the USB master device. They do not initiate communication actively but instead wait for commands or requests from the master device.

When you connect a USB interface disk (a slave device) to a laptop (the master device), the laptop's operating system, acting as the USB host, recognizes the presence of the USB device and initiates the communication. It sends commands and requests to the USB interface disk to perform actions such as reading or writing data.

The USB master device controls the entire transfer process, including the direction of data flow (from the host to the device or vice versa), the type of transfer (bulk, control, isochronous, or interrupt), and the timing and coordination of the transfer.
总而言之,USB主设备控制一切通信过程!


电气差异,作为主设备时候

  1. 4-Pin USB2.0
  2. 5-Pin USB2.0 OTG

  1. 9-Pin USB 3.0 USB3.0向后兼容USB2.0,另外支持一个SuperSeepd bus。

电气差异,作为从设备时候

               1. 4-Pin USB2.0
               2. 4-Pin USB2.0 OTG
               3. 9-Pin USB3.0

对应的引脚说明(USB3.0 Type A):

Type-B的长下面的样子:

USB3.0 Type-C,24Pin


发展时间


速度对比

总结

USB的协议发展很快,从USB协议1.0/2.0/3.0/4.0 ...对应的connector也是4pin/5pin/9pin/24pin的演化。

如果9pin的USB3.0 需要支持OTG,那么要将上图中的一路GND_DRAIN设备ID pin. 而我的使用case是设备作为USB3.0 prepherial 和USB2.0 host(支持OTG,并对外供电,5pin)

当我们使用USB3.0时候,不建议带OTG,因为USB2.0已经支持,3.0追求的是更快/更大电流!

万能的WWW,什么知识都有,就看你是否愿意花时间了。Serial port, RS232 and RS485 software. Data logging and monitoring software for COM, RS232, USB and TCP ports, OPC and DDE interfaces

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/397601.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

天洑AIFEM软件将助力竞技机器人国际冠军战队再攀高峰

2023年底,烈鹏战队作为中国顶尖机器人队伍代表出征国际赛事Battle of Robots,经过与全球战队激烈竞争,取得国际赛场上5连胜的优秀战绩斩获国际冠军。 天洑智能结构仿真软件AIFEM与玄智科技的技术方案联合,基于烈鹏战队的冠军机器人…

基于shp数据制作3DTiles建筑白膜

经纬管网建模系统MagicPipe3D,本地离线参数化构建地下管网、建筑三维模型,输出标准3DTiles服务、Obj模型等格式,支持Cesium、Unreal、Unity、Osg等引擎加载进行三维可视化、语义查询、专题分析。欢迎下载试用:http://www.magic3d.…

P1824 进击的奶牛题解

题目 Farmer John 建造了一个有N(2≤N≤105) 个隔间的牛棚,这些隔间分布在一条直线上,坐标是(0≤​≤)。 他的C(2≤C≤N)头牛不满于隔间的位置分布,它们为牛棚里其他的牛的存在而愤…

“比特币突破5.2万美元”,一枚币可换一斤半黄金?黄金比特币之争再次甚嚣尘上!

自今年1月美国SEC批准比特币现货ETF登陆美股市场之后,只用了短短的30个交易日,比特币ETF就从零膨胀到了近400亿美元的规模,超过白银ETF约100多亿美元的规模,和规模约为900多亿美元的黄金ETF暂时形成了“三七开”的格局。比特币现货…

毕业设计:基于知识图谱的《红楼梦》人物关系可视化

文章目录 项目介绍部署步骤项目运行 项目介绍 github地址:https://github.com/chizhu/KGQA_HLM?tabreadme-ov-file 基于知识图谱的《红楼梦》人物关系可视化:应该是重庆邮电大学林智敏同学的毕业设计,在学习知识图谱的过程中参考使用。 文…

ESP8266 烧录 MQTT固件

~~ 文章约定 ~~ 约定1:本篇所述固件,已测试可用于阿里云连接,其它云,未测试。 约定2:本烧录方法,以魔女开发板的板载ESP8266作示范。 约定3:如果使用独立的CH340、独立的ESP8266,请…

Puresuit 轨迹跟踪

在网上看过了很多Puresuit的轨迹跟踪算法,看起来都写的差不多,用起来不会用。 套用一份demo,在C转C语言的时候又深入理解了一些,在此整理成文档,供大家参考。输入 1.输入量是什么; 要知道车的长度,车的后轮位置以及下…

Redis(03)——发布订阅

基础命令 基于频道 publish channel message:将信号发送到指定的频道pubsub subcommand [argument [argyment]]:查看订阅或发布系统状态subscribe channel [channel]:订阅一个或多个频道的信息unsubscribe [channel [channel]]:退…

Leetcode 1089.复写零

目录 题目 思路 代码 题目 给你一个长度固定的整数数组 arr ,请你将该数组中出现的每个零都复写一遍,并将其余的元素向右平移。 注意:请不要在超过该数组长度的位置写入元素。请对输入的数组 就地 进行上述修改,不要从函数返回…

javascript选择器大全

目录 1.getElementsByTagName 2.getElementsByName 3.getElementById 4.getElementsByClassName 5.querySelector 6.querySelectorAll 1.getElementsByTagName 俗称标签选择器&#xff0c;可以根据标签名查找匹配到页面的元素对象&#xff0c;返回为一个数组。 <div&…

google邮箱开启两步验证

我开发的chatgpt网站&#xff1a; https://chat.xutongbao.top/

美国Mercari煤炉注册教程,还不快来Get!

想要掘金全球电商市场&#xff0c;美国的Mercari平台绝对值得关注。Mercari&#xff0c;也被称作煤炉&#xff0c;类似于我们国内的闲鱼二手交易平台&#xff0c;它同时拥有美国和日本两个市场。其中&#xff0c;美国市场的消费需求稳定且持续增长&#xff0c;成为了许多跨境电…

Gradle8之下载安装与环境变量配置及国内下资源设置

Gradle8之下载安装与环境变量配置及国内下资源设置 文章目录 Gradle8之下载安装与环境变量配置及国内下资源设置1. Gradle1. 官网2. 关于Gradle1. 构建任何内容2. 自动化一切3. 更快地交付 2. 下载与安装1. 下载2. 环境变量3.本地存储路径4. 查看Gradle版本 3. 配置国内下资源1…

GZ036 区块链技术应用赛项赛题第8套

2023年全国职业院校技能大赛 高职组 “区块链技术应用” 赛项赛卷&#xff08;8卷&#xff09; 任 务 书 参赛队编号&#xff1a; 背景描述 现实中患者私密信息泄露情况时有发生&#xff0c;医疗部门的柜式存储和纸质记录已不再是最优选择。在2015-2016年间&…

爬虫知识--01

爬虫介绍 # 爬虫的概念&#xff1a; 通过编程技术(python:request,selenium)&#xff0c;获取互联网中的数据(app&#xff0c;小程序&#xff0c;网站)&#xff0c;数据清洗(xpaht&#xff0c;lxml)后存到库中(mysql&#xff0c;redis&#xff0c;文件&#xff0c;excel&#x…

探索未来-Sora

AI如何将静态图像转化为动态、逼真的视频&#xff1f; OpenAI 的 Sora 通过时空片段&#xff08;以下统称片段&#xff09;的创新使用给出了答案。 Sora 展示与探讨 在快速发展的生成模型领域&#xff0c;OpenAI 的 Sora成为一个重要的里程碑&#xff0c;有望重塑我们对视频生…

uniapp离线打包(使用Android studio打包)

一、准备工作 安装HbuilderX&#xff0c;记住版本号下载对应HbuilderX版本的Android离线SDK&#xff0c;如我使用3.6.18版本打包&#xff0c;则对应应下载3.6.18版本的SDK&#xff08;官网不提供旧版本的SDK&#xff0c;有些需要自己找&#xff09;官网下载地址&#xff1a;ht…

亚马逊鲲鹏系统一键注册亚马逊买家号的软件

在如今的电商世界中&#xff0c;自动注册亚马逊买家号已经成为了一种必要的操作需求。为了规避关联性问题&#xff0c;许多用户选择借助专门设计的软件工具&#xff0c;其中最为流行的就是亚马逊鲲鹏系统。这款软件以其自带防指纹浏览器和全自动化操作功能而闻名。 亚马逊鲲鹏系…

《摔跤吧爸爸》19岁女星突患皮肌炎离世

从确诊到离世仅10天……罕见病“皮肌炎”&#xff01; 曾凭借在知名电影《摔跤吧&#xff01;爸爸》中饰演童年时期“小芭比塔”一角而广受喜爱的年轻演员苏哈尼巴特纳格尔不幸离世&#xff0c;年仅19岁。她的突然逝世引发了全球关注&#xff0c;据苏哈妮的家人表示&#xff0…

基于docker安装HDFS

1.docker一键安装见 docker一键安装 2.拉取镜像 sudo docker pull kiwenlau/hadoop:1.03.下载启动脚本 git clone https://github.com/kiwenlau/hadoop-cluster-docker4.创建网桥 由于 Hadoop 的 master 节点需要与 slave 节点通信&#xff0c;需要在各个主机节点配置节点…