我的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
  3. 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 对应的引脚说明

USB3.0 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/399141.html

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

相关文章

韶音、南卡、Cleer怎么样?2024年主流产品硬核测评对比

​作为一位资深的开放式耳机使用者,我要强调,在选购耳机时应避免仅仅因为某款产品的流行度或是品牌名气而做出选择。适合自己需求的耳机才是最佳之选。我和我的团队经过多次测试,对比了几种市场上热门的开放式耳机,从中总结了我们…

【Algorithms 4】算法(第4版)学习笔记 09 - 3.2 二叉查找树

文章目录 前言参考目录学习笔记1:二叉树与二叉搜索树定义1.1:二叉树定义1.2:二叉搜索树定义1.3:Java定义1.4:BST基本实现1.5:BST demo 演示1.5.1:节点搜索成功命中演示1.5.2:节点搜索…

ElementUI table表格组件实现双击编辑单元格失去焦点还原,支持多单元格

在使用ElementUI table表格组件时有时需要双击单元格显示编辑状态,失去焦点时还原表格显示。 实现思路: 在数据中增加isFocus:false.控制是否显示在table中用cell-dblclick双击方法 先看效果: 上源码:在表格模板中用scope.row…

Nginx缓存相关配置解析

文章目录 前言配置示例proxy_cacheproxy_cache_pathproxy_cache_keyproxy_cache_validproxy_cache_lockproxy_cache_methodsproxy_cache_bypassproxy_no_cacheproxy_cache_min_usesadd_header 可选项 使用示例通过响应头判断是否走缓存 缓存手动删除原博客 前言 客户端需要访问…

10、内网安全-横向移动域控提权NetLogonADCSPACKDC永恒之蓝

用途:个人学习笔记,有所借鉴,欢迎指正! 背景: 主要针对内网主机中的 域控提权漏洞,包含漏洞探针和漏洞复现利用。 1、横向移动-系统漏洞-CVE-2017-0146(ms17-010,永恒之蓝&#xff0…

如何添加或编辑自定义WordPress侧边栏

WordPress侧边栏是许多WordPress网站上的固定装置。它为您的内容提供了一个垂直空间,您可以在其中帮助读者导航、增加电子邮件列表或社交关注、展示广告等。 因为它是许多WordPress网站不可或缺的一部分,所以我们认为侧边栏值得拥有自己的大型指南。在这…

SpringBootWeb学习笔记——12万字详细总结!

0. 写在前面 注:这套笔记是根据黑马程序员B站2023-3-21的视频学习的成果,其中省略了前端基础部分、Maven部分和数据库基础部分,详情可见目录。 注注:目前文章内结尾处多幅图片加载不出来,因为图片还存在本地没被传上来,过段时间再改~ 所有的Spring项目都基于Spring Fra…

3、windows环境下vscode开发c/c++环境配置(二)

前言:上一篇文章写了windows环境下,配置vscode的c/c开发环境,这一篇讲vscode开发c/c的配置文件,包括c_cpp_propertues.json,task.json及launch.json。 一、总体流程 通过c/c插件我们就可以来编写c/c程序了&#xff0c…

网贷大数据查询多了对征信有影响吗?

网贷大数据在日常的金融借贷中起到很重要的风控作用,不少银行已经将大数据检测作为重要的风控环节。很多人在申贷之前都会提前了解自己的大数据信用情况,那网贷大数据查询多了对征信有影响吗?本文带你一起去看看。 首先要说结论:那就是查询网…

面试经典150题——同构字符串

"Dream big and dare to fail." - Norman Vaughan 1. 题目描述 2. 题目分析与解析 2.1 思路一 看见这个题目的第一反应就是使用一个hash表,用来存储映射关系,具体思路如下: 首先二者要是同构的长度肯定是得相同的,但…

Android 多线程并发优化实现

和你一起终身学习,这里是程序员Android 经典好文推荐,通过阅读本文,您将收获以下知识点: 一、Thread 使用二、Android Thread三.线程优先级 一、Thread 使用 在讲解多线程之前,我们先来讲解Thread使用几个需要注意的点&#xff1a…

Unity UGUI的DrawCall优化

Unity UGUI是一种强大的用户界面设计工具,它可以帮助开发者快速创建各种界面元素,从按钮和文本到滑块和面板等。然而,在使用UGUI时,一个常见的性能瓶颈就是DrawCall过多导致的性能下降。在本文中,我们将深入探讨UGUI的…

集成使用 GitHub Copilot 提升 IDEA 开发效率

集成使用 GitHub Copilot 提升 IDEA 开发效率 在现代软件开发中,集成开发环境(IDE)如IntelliJ IDEA已经成为开发人员不可或缺的工具。它们提供了代码编辑、调试、版本控制等一系列功能,极大地提高了开发效率。而GitHub Copilot作…

C# Winfrom实例:武汉智能安检闸机数据接收和解析

项目介绍:本实例主要是接收安检闸机的数据解析并显示到界面上,只做功能实现,不做界面美化 硬件:闸机一个、网线一根、电脑主机开发环境:vs2017 系统:win10涵盖知识点:tcp通讯、文件写入、多线程…

《软件方法(下)》8.2.5.2 属性是否直接描述类(202402更新)(2)

导致出现违反本要点的错误的原因有: (1)缺少抽象能力 缺少抽象能力的建模人员经常会把手上素材的信息,一一对应地映射为类和属性,导致本来属于多个类的信息被合并在一个类中。 如图8-63,建模人员对照着一…

ETL、ELT区别以及如何正确运用

一、 浅谈ETL、ELT ETL与ELT的概念 ETL (Extract, Transform, Load) 是一种数据集成过程,通常用于将数据从一个或多个源系统抽取出来,经过清洗、转换等处理后,加载到目标数据存储中。这种方法适用于需要对数据进行加工和整合后再加载到目标…

Django学习笔记-HTML实现MySQL的图片上传

1.django项目编写index.html代码 创建form表单,路由指向upload,请求方式post,enctype设置"multipart/form-data", post请求添加{% csrf_token %},编写两个input,上传和提交 2.添加upload路由 3.views中创建upload 1).获取上传的文件,没有上传则返回"没有指定…

打码半年,开源一款自定义大屏设计软件!

hi,大家好,我是Tduck马马。 最近我们开源了一款大屏软件-TReport,与大家分享。 TReport是一款基于Vue3技术栈的数据可视化系统,支持静态、动态api等数据源;可用于数据可视化分析、报表分析、海报设计使用。 提供自定…

Stable Diffusion 绘画入门教程(webui)-图生图

通过之前的文章相信大家对文生图已经不陌生了,那么图生图是干啥的呢? 简单理解就是根据我们给出的图片做为参考进行生成图片。 一、能干啥 这里举两个例子 1、二次元头像 真人转二次元,或者二次元转真人都行, 下图为真人转二次…

.net6 webapi log4net完整配置使用流程

前置&#xff1a;为项目安装如下两个依赖 1.创建文件夹cfgFile 2.创建log4net.Config <?xml version"1.0" encoding"utf-8" ?> <log4net><appender name"ConsoleAppender" type"log4net.Appender.ConsoleAppender"…