USB鼠标实现——设置地址(二)

news/2024/5/17 2:46:00/文章来源:https://blog.csdn.net/tyustli/article/details/129773551

设置地址

设备请求

在这里插入图片描述

标准设备请求

typedef struct __attribute__ ((packed)){union {struct __attribute__ ((packed)) {uint8_t recipient :  5; ///< Recipient type usb_request_recipient_t.uint8_t type      :  2; ///< Request type usb_request_type_t.uint8_t direction :  1; ///< Direction type. usb_dir_t} bmRequestType_bit;uint8_t bmRequestType;};uint8_t  bRequest;uint16_t wValue;uint16_t wIndex;uint16_t wLength;
} usb_control_request_t;

USB 控制端点收到的数据

0x0 0x5 0x4 0x0 0x0 0x0 0x0 0x0
  • bmRequestType:0x00
    • 数据传输方向为 0,host->device
    • 标准请求
    • 请求的接收者为设备
  • bRequest:0x05
    • SET_ADDRESS 设置地址请求
  • wValue:0x0004(LSB)
    • 低位:0x04 设备地址低位
    • 高位:0x00 设备地址高位
  • wIndex:0x0000(LSB)
    • 低位:0x00
    • 高位:0x00
  • wLength:0x0000
    • 低位:0x00
    • 高位:0x00

这里将收到的地址 0x04 写入 STM32 的 USB 地址寄存器 USB_OTG_DCFG_DAD 即可

设置地址完成之后主机会再次获取设备描述符,这一次是真心的获取

0x80 0x6 0x0 0x1 0x0 0x0 0x12 0x0
  • wLength:0x12
    • 低位:0x12 请求返回的字节数为 0x12。
    • 高位:0x00

其它位段和设备描述符一致。

附 STM32 枚举日志

HID 鼠标枚举过程分析

suspend int
bus reset int
enum done int
rxflvl int
setup packed recvd
setup packed done
output ep int
h->d: 0x80 0x6 0x0 0x1 0x0 0x0 0x40 0x0
dcd xfer
input ep int
d->h :0x12 0x1 0x0 0x2 0x0 0x0 0x0 0x40 0xfe 0xca 0x8 0x40 0x0 0x1 0x1 0x2 0x3 0x1
turn off txfe
input ep int
edpt int send xfer complete event
dcd xfer
rxflvl int
bus reset int
output ep int
send xfer complete event
enum done int
rxflvl int
setup packed recvd
setup packed done
output ep int
h->d: 0x0 0x5 0x4 0x0 0x0 0x0 0x0 0x0
dcd xfer
input ep int
edpt int send xfer complete event
rxflvl int
setup packed recvd
setup packed done
output ep int
h->d: 0x80 0x6 0x0 0x1 0x0 0x0 0x12 0x0
dcd xfer
input ep int
d->h :0x12 0x1 0x0 0x2 0x0 0x0 0x0 0x40 0xfe 0xca 0x8 0x40 0x0 0x1 0x1 0x2 0x3 0x1
turn off txfe
input ep int
edpt int send xfer complete event
dcd xfer
rxflvl int
output ep int
send xfer complete event
rxflvl int
setup packed recvd
setup packed done
output ep int
h->d: 0x80 0x6 0x0 0x2 0x0 0x0 0xff 0x0
dcd xfer
input ep int
d->h :0x9 0x2 0x22 0x0 0x1 0x1 0x0 0xa0 0x32 0x9 0x4 0x0 0x0 0x1 0x3 0x1 0x2 0x0 0x9 0x21 0x11 0x1 0x0 0x1 0x22 0x4d 0x0 0x7 0x5 0x81 0x3 0x8 0x0 0xa
turn off txfe
input ep int
edpt int send xfer complete event
dcd xfer
rxflvl int
setup packed recvd
setup packed done
output ep int
h->d: 0x80 0x6 0x3 0x3 0x9 0x4 0xff 0x0
send xfer complete event
dcd xfer
input ep int
d->h :0xe 0x3 0x31 0x0 0x32 0x0 0x33 0x0 0x34 0x0 0x35 0x0 0x36 0x0
turn off txfe
input ep int
edpt int send xfer complete event
dcd xfer
rxflvl int
setup packed recvd
setup packed done
output ep int
h->d: 0x80 0x6 0x0 0x3 0x0 0x0 0xff 0x0
send xfer complete event
dcd xfer
input ep int
d->h :0x4 0x3 0x9 0x4
turn off txfe
input ep int
edpt int send xfer complete event
dcd xfer
rxflvl int
setup packed recvd
setup packed done
output ep int
h->d: 0x80 0x6 0x2 0x3 0x9 0x4 0xff 0x0
send xfer complete event
dcd xfer
input ep int
d->h :0x1e 0x3 0x54 0x0 0x69 0x0 0x6e 0x0 0x79 0x0 0x55 0x0 0x53 0x0 0x42 0x0 0x20 0x0 0x44 0x0 0x65 0x0 0x76 0x0 0x69 0x0 0x63 0x0 0x65 0x0
turn off txfe
input ep int
edpt int send xfer complete event
dcd xfer
rxflvl int
setup packed recvd
setup packed done
output ep int
h->d: 0x80 0x6 0x0 0x6 0x0 0x0 0xa 0x0
send xfer complete event
rxflvl int
setup packed recvd
setup packed done
output ep int
h->d: 0x80 0x6 0x0 0x1 0x0 0x0 0x12 0x0
dcd xfer
input ep int
d->h :0x12 0x1 0x0 0x2 0x0 0x0 0x0 0x40 0xfe 0xca 0x8 0x40 0x0 0x1 0x1 0x2 0x3 0x1
turn off txfe
input ep int
edpt int send xfer complete event
dcd xfer
rxflvl int
setup packed recvd
setup packed done
output ep int
h->d: 0x80 0x6 0x0 0x2 0x0 0x0 0x9 0x0
send xfer complete event
dcd xfer
input ep int
d->h :0x9 0x2 0x22 0x0 0x1 0x1 0x0 0xa0 0x32
turn off txfe
input ep int
edpt int send xfer complete event
dcd xfer
rxflvl int
setup packed recvd
setup packed done
output ep int
h->d: 0x80 0x6 0x0 0x2 0x0 0x0 0x22 0x0
send xfer complete event
dcd xfer
input ep int
d->h :0x9 0x2 0x22 0x0 0x1 0x1 0x0 0xa0 0x32 0x9 0x4 0x0 0x0 0x1 0x3 0x1 0x2 0x0 0x9 0x21 0x11 0x1 0x0 0x1 0x22 0x4d 0x0 0x7 0x5 0x81 0x3 0x8 0x0 0xa
turn off txfe
input ep int
edpt int send xfer complete event
dcd xfer
rxflvl int
setup packed recvd
setup packed done
output ep int
h->d: 0x0 0x9 0x1 0x0 0x0 0x0 0x0 0x0
send xfer complete event
edpt open
dcd xfer
input ep int
edpt int send xfer complete event
rxflvl int
setup packed recvd
setup packed done
output ep int
h->d: 0x21 0xa 0x0 0x0 0x0 0x0 0x0 0x0
dcd xfer
input ep int
edpt int send xfer complete event
rxflvl int
setup packed recvd
setup packed done
output ep int
h->d: 0x81 0x6 0x0 0x22 0x0 0x0 0x8d 0x0
dcd xfer
input ep int
d->h :0x5 0x1 0x9 0x2 0xa1 0x1 0x9 0x1 0xa1 0x0 0x5 0x9 0x19 0x1 0x29 0x5 0x15 0x0 0x25 0x1 0x95 0x5 0x75 0x1 0x81 0x2 0x95 0x1 0x75 0x3 0x81 0x1 0x5 0x1 0x9 0x30 0x9 0x31 0x15 0x81 0x25 0x7f 0x95 0x2 0x75 0x8 0x81 0x6 0x9 0x38 0x15 0x81 0x25 0x7f 0x95 0x1 0x75 0x8 0x81 0x6 0x5 0xc 0xa 0x38
turn off txfe
input ep int
edpt int send xfer complete event
dcd xfer
input ep int
d->h :0x2 0x15 0x81 0x25 0x7f 0x95 0x1 0x75 0x8 0x81 0x6 0xc0 0xc0
turn off txfe
input ep int
edpt int send xfer complete event
dcd xfer
rxflvl int
output ep int
send xfer complete event
rxflvl int
setup packed recvd
setup packed done
output ep int
h->d: 0x80 0x6 0x0 0x3 0x0 0x0 0xff 0x0
dcd xfer
input ep int
d->h :0x4 0x3 0x9 0x4
turn off txfe
input ep int
edpt int send xfer complete event
dcd xfer
rxflvl int
setup packed recvd
setup packed done
output ep int
h->d: 0x80 0x6 0x1 0x3 0x9 0x4 0xff 0x0
send xfer complete event
dcd xfer
input ep int
d->h :0x10 0x3 0x54 0x0 0x69 0x0 0x6e 0x0 0x79 0x0 0x55 0x0 0x53 0x0 0x42 0x0
turn off txfe
input ep int
edpt int send xfer complete event
dcd xfer
rxflvl int
setup packed recvd
setup packed done
output ep int
h->d: 0x80 0x6 0x0 0x3 0x0 0x0 0xff 0x0
send xfer complete event
dcd xfer
input ep int
d->h :0x4 0x3 0x9 0x4
turn off txfe
input ep int
edpt int send xfer complete event
dcd xfer
rxflvl int
setup packed recvd
setup packed done
output ep int
h->d: 0x80 0x6 0x2 0x3 0x9 0x4 0xff 0x0
send xfer complete event
dcd xfer
input ep int
d->h :0x1e 0x3 0x54 0x0 0x69 0x0 0x6e 0x0 0x79 0x0 0x55 0x0 0x53 0x0 0x42 0x0 0x20 0x0 0x44 0x0 0x65 0x0 0x76 0x0 0x69 0x0 0x63 0x0 0x65 0x0
turn off txfe
input ep int
edpt int send xfer complete event
dcd xfer
rxflvl int
setup packed recvd
setup packed done
output ep int
h->d: 0x80 0x6 0x1 0x3 0x9 0x4 0xff 0x0
send xfer complete event
dcd xfer
input ep int
d->h :0x10 0x3 0x54 0x0 0x69 0x0 0x6e 0x0 0x79 0x0 0x55 0x0 0x53 0x0 0x42 0x0
turn off txfe
input ep int
edpt int send xfer complete event
dcd xfer
rxflvl int
setup packed recvd
setup packed done
output ep int
h->d: 0x80 0x6 0x2 0x3 0x9 0x4 0xff 0x0
send xfer complete event
dcd xfer
input ep int
d->h :0x1e 0x3 0x54 0x0 0x69 0x0 0x6e 0x0 0x79 0x0 0x55 0x0 0x53 0x0 0x42 0x0 0x20 0x0 0x44 0x0 0x65 0x0 0x76 0x0 0x69 0x0 0x63 0x0 0x65 0x0
turn off txfe
input ep int
edpt int send xfer complete event
dcd xfer
rxflvl int
output ep int
send xfer complete event
dcd xfer
0x0 0x5 0x5 0x0 0x0
input ep int
d->h :0x0 0x5 0x5 0x0 0x0
turn off txfe
input ep int
edpt int send xfer complete event
dcd xfer
0x0 0x5 0x5 0x0 0x0
input ep int
d->h :0x0 0x5 0x5 0x0 0x0
turn off txfe
input ep int
edpt int send xfer complete event
dcd xfer
0x0 0x5 0x5 0x0 0x0
input ep int
d->h :0x0 0x5 0x5 0x0 0x0
turn off txfe
input ep int
edpt int send xfer complete event
dcd xfer
0x0 0x5 0x5 0x0 0x0
input ep int
d->h :0x0 0x5 0x5 0x0 0x0
turn off txfe
input ep int
edpt int send xfer complete event
dcd xfer
0x0 0x5 0x5 0x0 0x0
input ep int
d->h :0x0 0x5 0x5 0x0 0x0
turn off txfe
input ep int
edpt int send xfer complete event
dcd xfer
0x0 0x5 0x5 0x0 0x0
input ep int
d->h :0x0 0x5 0x5 0x0 0x0
turn off txfe
input ep int
edpt int send xfer complete event
dcd xfer
0x0 0x5 0x5 0x0 0x0
input ep int
d->h :0x0 0x5 0x5 0x0 0x0
turn off txfe
input ep int
edpt int send xfer complete event

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

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

相关文章

Win10用cmd强制卸载软件

Win10系统想要卸载某些软件&#xff0c;通过“控制面板”---“程序和功能”&#xff0c;卸载可能会报错&#xff0c;大概率是因为权限不够。 于是给予cmd进行卸载&#xff0c;步骤如下&#xff1a; 1. 在“开始”处键入cmd; 2. 以管理员身份运行“cmd.exe” 3. 键入“Wmic”…

元宇宙虚拟数字人系统

许多的电商企业都想通过短视频渠道实现拓客&#xff0c;实现提升销量&#xff0c;进行产品的介绍&#xff0c;售卖&#xff0c;与粉丝互动。充分的实现直播技术的融合&#xff0c;帮助企业实现快速入局&#xff0c;加速企业的数字转型。借力直播系统平台&#xff0c;实现新增长…

python基于django汽车用品商城销售平台vue

本汽车销售商城采用的数据库是Mysql&#xff0c;使用框架开发。在设计过程中&#xff0c;充分保证了系统代码的良好可读性、实用性、易扩展性、通用性、便于后期维护、操作方便以及页面简洁等特点。 开发语言&#xff1a;Python 框架&#xff1a;django Python版本&#xff1a;…

win10系统常用办公技巧

操作系统篇1、系统自带截图快捷键&#xff1a;在Win10中任按下组合键【WinShiftS】进入截屏模式。点击【任意形状截图】。按住鼠标左键画出截图区域即可2、录屏快捷键先在系统菜单->设置->游戏栏中开启快捷键&#xff0c;录屏快捷键是【WinAltG】Excel篇单元格拼接&#…

进阶C语言:指针笔试题

在学习完进阶C指针之后&#xff0c;可以来做一些笔试题来进行提升、巩固&#xff0c;小编在这里给大家分享几道比较有意思的笔试题 目录 一、笔试题1&#xff1a; 二、笔试题2 三、笔试题3&#xff1a; 四、笔试题4&#xff1a; 五、笔试题5&#xff1a; ​编辑 六、笔试题…

TiDB K8S

1、 命名空间 k create ns ti k create namespace tidb-admin k create namespace tidb-clusteralias kkubectl alias tik -n tidb alias tiak -n tidb-admin alias tick -n tidb-cluster2、 Helm安装 tidb-operator helm repo add pingcap https://charts.pingcap.org/ helm…

华为OD机试题【对称美学】用 Java 解 | 含解题说明

华为Od必看系列 华为OD机试 全流程解析+经验分享,题型分享,防作弊指南华为od机试,独家整理 已参加机试人员的实战技巧华为od 2023 | 什么是华为od,od 薪资待遇,od机试题清单华为OD机试真题大全,用 Python 解华为机试题 | 机试宝典本篇题目:对称美学 题目 对称就是最大的…

Rust学习总结之String

有编程经验的相信没少和字符串打交道&#xff0c;无论是C/C&#xff0c;还是现在比较流行的Python&#xff0c;字符串都是用的非常多的类型。在Rust中字符串类型同样有举足轻重的作用&#xff0c;几乎编码都离不开字符串。下面将详细学习Rust中的String类型。 一&#xff1a;创…

微信小程序——API promise化,全局数据共享,MobX,将Stroe中的成员绑定到页面中,在页面上使用Strore中的成员

一.API promise化1&#xff0e;基于回调函数的异步 API 的缺点默认情况下&#xff0c;小程序官方提供的异步 API 都是基于回调函数实现的&#xff0c;例如&#xff0c;网络请求的 API 需要按照如下的方式调用&#xff1a;缺点&#xff1a;容易造成回调地狱的问题&#xff0c;代…

25种代码坏味道总结

前言 什么样的代码是好代码呢&#xff1f;好的代码应该命名规范、可读性强、扩展性强、健壮性......而不好的代码又有哪些典型特征呢&#xff1f;这25种代码坏味道大家要注意啦 1. Duplicated Code &#xff08;重复代码&#xff09; 重复代码就是不同地点&#xff0c;有着相同…

为什么保存按钮那么像自动售货机?

高中生 Every Highschool Senior: I can’t wait to move out and go to college and Be on my Own. 每一个高中毕业生&#xff1a; 我等不及离开去大学&#xff0c;独立自我。 Everyone in College: 大学里的每个人&#xff1a; 评论区 Stoovin: The real world sucks. But…

LD_PRELOAD劫持(超详细篇)

目录 前提知识 环境变量 链接 LD_PRELOAD LD_LIBRARY_PATH ELF文件 /bin、/sbin、/usr/sbin、/usr/bin 漏洞复现 案例一(随机数劫持) 案例二(ls的劫持) 案例三(__attribute__&LD_PRELOAD劫持) 案例四(利用 LD_PRELOAD 绕过 Disable_Functions) 案例五(利用 er…

小白学Pytorch系列--Torch.nn API Pooling layers(3)

小白学Pytorch系列–Torch.nn API (3) 方法注释nn.MaxPool1d对由多个输入平面组成的输入信号应用1D最大池化。nn.MaxPool2d对由多个输入平面组成的输入信号应用二维最大池化。nn.MaxPool3d在由多个输入平面组成的输入信号上应用3D最大池化。nn.MaxUnpool1d计算MaxPool1d的偏逆。…

Zookeeper3.5.7版本—— Curator框架实现分布式锁案例

目录一、Zookeeper原生的 Java API 存在的问题二、Zookeeper原生的 Java API 存在问题的解决方式三、Curator框架实现分布式锁示例代码3.1、pom文件添加依赖3.2、示例代码3.3、Curator框架实现分布式锁测试一、Zookeeper原生的 Java API 存在的问题 会话连接是异步的&#xff…

Kubernetes为容器和 Pods 分配 CPU 资源

Kubernetes为容器和 Pods 分配 CPU 资源 一、指定CPU请求和CPU限制 1、创建一个命名空间&#xff08;namespace&#xff09; [rootmaster ~]# kubectl create namespace cpu-example namespace/cpu-example created2、编写yaml文件 要为容器指定CPU请求&#xff0c;需要在容…

STC32G 比较器及其应用编程

一 STC32G系列单片机寄存器简介STC32G系列单片机内部集成了一个比较器&#xff0c;其正极可以在P3.7、P5.0、P5.1、或者ADC的模拟输入通道间切换&#xff1b;而负极可以是P3.7或者内部BandGap经过OP的REF电压。通过配置分时复用可以实现多个比较器的应用。STC32G系列单片机的比…

MySQL数据库基础到进阶笔记整理包含事务、SQL优化、锁等内容

写在前面 本文是在学习MySQL数据库时整理的笔记&#xff0c;可供初学者学习 是在https://dhc.pythonanywhere.com/entry/share/?key12e4a7324f68371db3984d93e26e458962a4f0bc188ec23ec70637a4f3b4d58f 笔记基础上增加了一些内容以及后续的锁、InnoDB引擎等内容 课程参考b站黑…

Java数据结构与算法----搜索篇(DFS与BFS)

一.概念DFS&#xff08;Depth First Search&#xff09;深度优先搜索 和BFS&#xff08;Breadth First Search&#xff09;广度优先搜索 是两种广泛应用于搜索和遍历算法中的基本技术。这两种算法都涉及到搜索数据结构中的节点 。这里我们以二叉树为例&#xff0c;简单地图解一…

实验九 TSP问题

《算法设计与分析》实验报告 所在院系 计算机与信息工程学院 学生学号 学生姓名 年级专业 2020级计算机科学与技术 授课教师 彭绪富 学 期 2022-2023学年第一学期 提交时间 2022年10月26日 目 录 实验九-1&#xff1a;TSP问题 一、实验目的与要求 二…

【图解http】

目录了解web及网络基础TCP/IP协议族与HTTP关系密切的协议&#xff1a;IP、TCP和DNS各种协议与HTTP协议的关系URI和URLhttp协议HTTP是不保存状态的协议请求URI定位资源告知服务器意图的HTTP方法持久连接节省通信量HTTP报文编码提升传输速率压缩传输的内容编码分割发送的分块传输…