我的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.mzph.cn/news/692359.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Java基于SpringBoot+Vue的图书管理系统

博主介绍:✌程序员徐师兄、7年大厂程序员经历。全网粉丝12w、csdn博客专家、掘金/华为云/阿里云/InfoQ等平台优质作者、专注于Java技术领域和毕业项目实战✌ 🍅文末获取源码联系🍅 👇🏻 精彩专栏推荐订阅👇…

leetcode第124场双周赛

第一题:相同分数的最大操作数目I 给你一个整数数组 nums ,如果 nums 至少 包含 2 个元素,你可以执行以下操作: 选择 nums 中的前两个元素并将它们删除。 一次操作的 分数 是被删除元素的和。 在确保 所有操作分数相同 的前提下…

Spring相关注解

文章目录 Spring注解Bean1、Bean 概述2、Bean 的声明1)搭配 Configuration2)搭配 Component3)搭配 ApplicationContext 3、Bean 的注入1)NO(主要关注这个)【1】同一配置类【2】不同配置类 2)BY_…

软件测试进阶自动化测试流程

如果想让测试在公司的项目中发挥出它最大的价值,并不是招两个测试技术高手,或引入几个测试技术,而是测试技术对项目流程的渗透,以及测试流程的改进与完善。虽然,当然测试行业前景乐观,许多中小企业也都在引…

C++11---(3)

目录 一、可变参数模板 1.1、可变参数模板的概念 1.2、可变参数模板的定义方式 1.3、如何获取可变参数 二、lambda表达式 2.1、Lamabda表达式定义 2.2、为什么有Lambda 2.3、Lambda表达式的用法 2.4、函数对象与lambda表达式 三、包装器 3.1、function 3.2、bind …

Spring源码:手写SpringIOC

文章目录 一、分析二、实现1、版本1:实现Bean注入IOC容器,并从容器中获取1)定义BeanDefinition2)定义BeanDefinition实现类3)定义BeanDefinitionRegistry4)定义Beanfactory5)定义默认Beanfactor…

GC调优学习

一.常见工具P62P63 1.jstat 2.visualvm插件 3.Prometheus Grafana 4.GC日志 5.GC Viewer 6.GCeasy(强推) 二.常见的GC模式P64 三.GC调优 1.优化基础JVM参数P65 2.减少对象产生 看以前视频,内存泄露相关 3.垃圾回收器的选择P66 4.优化垃圾回…

代码随想录算法训练营第二十三天 | LeeCode 669. 修剪二叉搜索树,108. 将有序数组转换为二叉搜索树, 538. 把二叉搜索树转换为累加树

题目链接&#xff1a;669. 修剪二叉搜索树 - 力扣&#xff08;LeetCode&#xff09; class Solution { public:TreeNode* trimBST(TreeNode* root, int low, int high) {if (root nullptr ) return nullptr;if (root->val < low) {TreeNode* right trimBST(root->r…

防御保护---内容保护

文章目录 目录 文章目录 一.防火墙内容安全概述 二.深度识别技术&#xff08;DFI/DPI&#xff09; 深度包检测技术&#xff08;DPI&#xff09; 深度流检测技术&#xff08;DFI&#xff09; 两者区别 三.入侵防御IPS 一.防火墙内容安全概述 防火墙内容安全是防火墙的一个重…

软件测试方法_边界值分析法

目录&#xff1a; ①边界值分析法的介绍和概念 ②边界值分析法的原理和思想 ③单缺陷假设和多缺陷假设 ④边界值测试数据类型 ⑤内部边界值分析 ⑥各类边界值测试介绍 ⑦基于边界值分析方法选择测试用例的原则 ⑧边界值分析法的实例分析 1、边界值分析法的介绍和概念 …

Kubernetes集群的扩容、优化 -1

1. 什么是Kubernetes集群的扩容&#xff1f; Kubernetes集群的扩容指的是增加集群中的计算资源&#xff0c;以满足应用程序不断增长的需求。 Kubernetes是一个开源的容器编排平台&#xff0c;它允许用户部署、管理和扩展容器化的应用程序。在Kubernetes中&#xff0c;当应用程…

全面解读视频生成模型Sora

2024年2月15日&#xff0c;OpenAI在其官网发布了《Video generation models as world simulators》的报告&#xff0c;该报告提出了作为世界模拟器的视频生成模型Sora。 OpenAI对Sora介绍如下&#xff1a; We explore large-scale training of generative models on video dat…

Java进阶之旅第十四天(doge

Java进阶之旅第十四天&#xff08;doge 打印流 特点&#xff1a; 分类: PrintStream&#xff08;字节打印流&#xff09;PrintWriter&#xff08;字符打印流&#xff09;1.打印流只操作文件的目的地&#xff0c;不操作数据源2.特有的写出方法可以实现->数据原样写出3.特有…

力扣96不同的二叉搜索树详解

最近在写动态规划的题目&#xff0c;这些题目的标签都标有数学&#xff0c;说来也是找规律题&#xff0c;但是这个规律真不是正常情况下可以找到的&#xff0c;即使看了解析有时候也写不出来&#xff0c;今天难得看了点解析就自己写出来的&#xff0c;因此分享一下这道题的想法…

C# Winfrom实现的肺炎全国疫情实时信息图

运行结果&#xff1a; using System; using System.Drawing; using System.Text; using NSoup; using NSoup.Nodes; using System.IO; using System.Net; using System.Text.RegularExpressions; using System.Windows.Forms;namespace Pneumonia {public partial class MainFo…

docker (七)-部署容器

实战开始&#xff1a; 1 docker 部署 kafka 集群&#xff0c;并验证 参考 Docker搭建Kafka集群 优秀文档 2 docker 部署 mysql 参考上一篇docker(六) 3.docker 部署 zabbix 参考 docker部署zabbix 优秀文档 BUG&#xff1a;根据这篇文章部署后&#xff0c;发现zabbix-s…

vue封装el-table表格组件

先上效果图&#xff1a; 本文包含了具名插槽、作用域插槽、jsx语法三种&#xff1a; Render.vue&#xff08;很重要&#xff0c;必须有&#xff09;: <script> export default {name: "FreeRender",functional: true,props: {scope:Object,render: Functio…

docker 使用运行指令讲解

1、新建运行并挂载容器 docker run -d -p 80:80 -v /path/on/host:/path/in/container nginx docker run 指令讲解 docker run [OPTIONS] IMAGE [COMMAND] [ARG...] option 作用 -i 以交互模式运行容器&#xff0c;通常与 -t 同时使用 -t 启动容器后&#xff0c;为容器…

面试题 17.23. 最大黑方阵

文章目录 题意思路代码 题意 题目链接 找到最长的边都是0的正方形&#xff0c;如果长度想等&#xff0c;尽可能起点小 思路 暴力剪枝dp &#xff0c;预处理每个点的上下左右最长长度&#xff0c;再去枚举长度去转移 代码 // 力大飞砖 class Solution { public:vector<…

6.2 数据库

本节介绍Android的数据库存储方式--SQLite的使用方法&#xff0c;包括&#xff1a;SQLite用到了哪些SQL语法&#xff0c;如何使用数据库管理操纵SQLitem&#xff0c;如何使用数据库帮助器简化数据库操作&#xff0c;以及如何利用SQLite改进登录页面的记住密码功能。 6.2.1 SQ…