Resources for Developers of USB Devices in the

闲暇就玩USB之: HID I/O 其实我对USB还是很有感情的,第一个USB是2005年给航天智通的彩票机做一个客户显示系统,就是彩票机上那个给买彩票的人看的小显示器。之前他们用的是串口,后来很多机器串口少了,而且串口一般还要给POS机之类的其他终端使用,因此需要做这么一个模块。不过当时由于初次做USB, 而且还要写Linux和Windows下的驱动,当时觉得还是用自定义的设备,使用Bulk传输比较简单,最后在AN2131(Cypress)上做了这个项目,大概卖了一千多套,后来被人山寨了,前前后后也赚了点钱,也算是为清苦的研究生生活添加了一 阅读详情

http://www.lvr.com/hidpage.htm#MyExampleCode

brought to you by Jan Axelson

Basics | My Example Code | Other HID code | Host Programming

This page contains links to information and code samples for USB HID-class devices.

Basics

The HID FAQ answers some frequently asked questions about developing HID-class devices.

The USB Implementers Forum sponsors a HID Webpage with the specification for the HID class, Usage tables, and a Descriptor Tool for creating HID reports.

"HIDs Up" by Jan Axelson, Embedded Systems Programming (ESP), October 2000.

"Using the HID class eases the job of writing USB device drivers" by Stuart Allman. Includes a link to files for a thermometer project. The application code shows how to use RegisterDeviceNotification to detect device attachment or removal. From EDN magazine.

The HidTest utility tests HID-class devices with a variety of API calls. HidTest.zip contains the application and HidTestSource.zip contains the source files in Delphi. From Robert Marquardt.

USB Complete includes three chapters on HID firmware and application programming.

A Usenet discussion about using HIDs under Windows CE. For other posts on this topic, search the newsgroups microsoft.public.windowsce* from http://groups.google.com/advanced_group_search.

My Example Code

These are grouped in Host and Device sections. Comments, suggestions, and bug reports welcome via e-mail.

Host Applications

My HID applications below communicate with generic (custom) HIDs. Editions for several programming languages are available. All support exchanging Input, Output, and Feature reports and show how to search for devices that use a particular interface GUID. All except the Visual Basic 6 code show how to use RegisterDeviceNotification and WM_DEVICE_CHANGE messages to detect when a device is attached or removed.

Visual Basic .NET

HIDClass. Uses a delegate to perform reads in a separate thread. Updated 7/13/2005.

HIDClass using a single thread. This version will also load into and run under Visual Studio 2005 Beta 2. 8/27/2005.

HIDClass for Visual Studio 2005. Uses a delegate to perform reads in a separate thread. Adds marshaling of data from the ReadFile callback to the application's form (required by the .NET Framework 2.0). Created with Visual Basic 2005 Express Edition, Beta 2. This project will not load into earlier editions of Visual Studio. 8/29/2005.

A C# version
Visual Basic 6

Usbhidio2

Visual C++ 6

Usbhidio_vc6. This project will also load into and run in Visual Studio. The project requires the header files hid.lib, hid.h, and hidsdi.h from the Windows DDK.

1. If you get an errror like this on attempting to compile:

DBT_DEVTYP_DEVICEINTERFACE, PDEV_BROADCAST_DEVICEINTERFACE, HDEVNOTIFY, DEVICE_NOTIFY_WINDOW_HANDLE undeclared

Set WINVER = 0x0500 or higher in stdafx.h

For more info, go to www.groups.google.com and search on:

"DEV_BROADCAST_DEVICEINTERFACE" "undeclared identifier"

2. HidD_GetInputReport and HidD_SetInputReport require Windows XP or later.

Generic HID Device Firmware

Various HID firmware examples for communicating with the Windows host code above.

Microchip PIC18F4550

This C firmware for Microchip's full-speed USB chips is based on Microchip's Framework Firmware (mchpfsusb_ghid.zip). (Minor edits and fixes added 3/30/05.)

EZ-USB FX2

fx2hid.zip runs on Cypress' FX2 EZ-USB chips at full and high speeds. It's adapted from Cypress' frameworks examples and requires the full version of the Keil C compiler.

Cypress Encore series

Enchid.zip runs on Cypress' Encore chips (CY637xx). Now supports Feature reports as well as Input and Output reports. Assembly code.

EZ-USB

fwhid.zip runs on Cypress' EZ-USB. C code. Read more about it.

EZ-USB Buttons and Lights

A version of John Hyde's buttons and lights code for the USBSimm. My code supports interrupt Out transfers for Output reports.

Cypress CY63000 series

Usbhidio.zip (61k) contains assembly-code firmware and host software for communicating with a HID-class device. The firmware is written for Cypress Semiconductor's CY7C63000 USB microcontroller and runs on Cypress' 3650 Developer's Kit and CY3640 Starter Kit. The host software is Visual Basic 6 code. Bug list and fixes for usbhidio.

Update notes: 3/8/00: Usbhidio has been tested and runs under Windows 2000. Under Windows 2000, use the default input.inf file instead of usbhidio.inf. 2/24/00: Cypress has discontinued the Starter Kit. The Hi-Lo EPROM programmer that had been included in the Starter Kit is available as Cypress part #CY3649.

Cypress CY63000 firmware plus Visual Basic code using an ActiveX Exe server

HIDDemo2.zip (70k) is an enhanced version of usbhidio. Like usbhidio, HIDDemo2 contains CY7C63000 firmware and a Visual-Basic application for communicating with a HID-class device. But the Visual-Basic project includes an ActiveX Exe server that handles reading from the device. The ReadFile API function that reads from the device is a blocking call, so the calling thread has to wait for the device to send the requested amount of data. Because the server runs in its own thread, it can wait for data and notify the application when it has a report, without blocking the main application's thread.

The tradeoff is that the application as a whole is more complicated, but this method does offer an option for devices that send data infrequently or applications that can't afford to wait. The included readme file has more details.

The firmware has minor changes from usbhidio. The device prepares an Input report just once every 5 seconds. And the first byte in the Input and Output reports is used to inform the server when to stop reading from the device (so the server's thread can close).

Other HID Code

Various code from other sources.

Device Firmware for Use with My VB and VC++ HID Applications

These firmware examples are designed to work with my PC HID applications above.

Cypress 66113

Hidhub1.zip contains a version of my generic HID-class firmware for Cypress' CY7C66113 hub & peripheral chip. The firmware enumerates as a compound device made up of a 4-port hub and my usbhidio device. It runs on the 3652 development kit and will communicate with my hidvb and usbhidioc software. This code is provided by Mat Laibowitz.

Microchip PIC16C745

Firmware for the PIC16C745/765 to enable using my hidvb and usbhidioc software. From Microchip. For more PIC advice, see USB Device Development Notes from Alan Macek.

Assembly code and C firmware for the PIC16C745 and PIC18F2455. From Bradley A. Minch at Olin College

A tip from a user of PICBasic: the usb demo programs that come with PICBasic depend on several support files, which are preconfigured so that the usbmouse.bas runs out of the box. However, when you try to do anything else, you need to modify these files. For example, to get the jademo program to work, you modify the USBDESC.ASM to use the demo JADESC.ASM file instead of the demo MOUSEDESC.ASM file.

The PICBasic Pro Basic compiler includes instructions to perform HID communications, for use with PICMicros with USB support. From microEngineering Labs Inc.

My Very First USB Peripheral. A description of a PIC16C745 HID project. From Technology Stir Fry.

PC Applications

usbhidio.cs.zip is a version of my usbhidio application for C#. From Erick Woods. Some reported bugs.

USBSharp.zip contains my usbhidioc application ported to C#. From Camilo Toro.

The PICdotNET DLL is a replacement for Microchip's HIDCOMM control.Written in Visual Basic .NET. From Mio.

Additional Firmware HID Examples

Atmel

Automator is a HID project for the Atmel AVR-USB. Includes host code. From Objective Development Software.

DIY USB Joystick Controller Project. Uses an ATMEGA8-16PI. From Mindaugas Milasauskas.

Cypress

Example HID Firmware in C for Cypress enCoRe devices with an excellent writeup. From Stephen Santarelli.

John Hyde's USB Design By Example site has HID examples in VB and VC++. John's Design Guide for the USBSimm has a version of his buttons and lights example code that runs on the USBSimm. And I have a version of the USBSimm's buttons and lights firmware that supports interrupt Out transfers (zip file, 39k). (If a HID has an interrupt Out endpoint, the HID drivers under Windows 98 SE and later will use interrupt transfers (instead of control transfers with Set_Report) for Output reports.)

The MO1002 USB to UART is a HID device that translates between asynchronous serial data and USB, using Windows' HID drivers. Includes schematics, firmware, and a Visual C++ application. The chip used is Cypress' CY7C63001. From Moto Development Group.

Microchip

Microchip's Framework firmware for the PIC18F4550 includes a mouse example.

FMSUSB is a RC(PPM) to FMS (Flying Model Simulator) USB interface. Uses a PIC16C745. From Walter Zanette.

A firmware-only HID (no hardware device controller) using a Microchip 16F84A to control a parallel LCD module (HD44780 compatible) via USB. (Spanish)

National Semiconductor

National Semiconductor has an example C++ application using HID functions in the sample firmware for its USBN9603 Developer's Board.

Philips

USB Engine is firmware for the Atmel Flash AVR and PDIUSBD12. From Jens Peter Holme.

HID Development Hardware

MouseWarrior, KeyWarrior, JoyWarrior, IO-Warrier, and IO-Warrior 24PowerVampire (for using USB as a power supply). Available as programmed chips or kits. From Code Mercenaries.

Host Programming

Windows Information

You can use Windows' built-in HID (human interface device) drivers to communicate with devices that conform to the USB's HID class specification. There's no need for a custom driver; the device uses the drivers included in Windows. Use Visual Basic, Visual C++, Delphi, or any programming language that supports calling API functions. The device doesn't have to have a "human interface." Any device that can function within the limits of the HID specification (control and interrupt transfers only) may be able to be designed as a HID.

Microsoft's Windows DDK has documentation for the HID functions and an overview of how to use them. The examples include a C application (hclient) that uses HID functions. The DDK also includes the header files to use with Visual C++ programs that access HID-class devices (hidsdi.h, hidusage.h, hidpi.h).

Microsoft's DirectX technology includes DirectInput, which supports communications with HID-class game controllers (in both directions, in spite of the name), without requiring custom drivers. Microsoft's DirectX Developer Center has the latest info.

USB Driver Uses the Largest Supported Report Size (Microsoft Knowledge Base Article 249635). Describes a problem with the HID driver in Windows 98 SE.

Input/HID Technologies. HID information from Windows Hardware and Driver Central (WHDC).

Chapter 13: Human Interface Devices. From Programming the Microsoft® Windows® Driver Model, Second Edition by Walter Oney.

Windows Code

 

Robert Marquardt has a very complete HID Controller component suite for Delphi.

Controlling the Logitech iFeel Mouse. Experiments with force feedback. Daniel C. Moore

HIDMaker creates device firmware and a Windows application from information you provide. Also available are the AnyHID test program and the USBWatch software-only protocol analyzer. From Trace Systems Inc.

USB HID API Function Library. From Kadtronix.

Other Operating Systems

 

USB HID for Linux USB tutorial by Brad Hards

VC6.0环境下的USB HID通信实践 USB HID(Human Interface Device)是一种专门为计算机与人类交互设备之间的通信而设计的标准。在USB协议中,HID类设备定义了一系列标准化的方式来控制键盘、鼠标、游戏控制器等输入设备和一些有限的输出设备,如LED指示灯或振动反馈。HID类设备是指那些专门用于与用户直接进行交互的设备,如键盘、鼠标、游戏控制器以及特定的医疗和科学仪器等。HID类设备具有简单、高效和易于使用的特性,使其成为个人计算中不可或缺的组件。USB HID类设备通过预定义的标准报告描述符来通信。 阅读详情

相关推荐

VC6.0 USB HID通信源代码详解与应用

本文还有配套的精品资源,点击获取 简介:本源代码旨在VC6.0环境下,实现与USB HID设备的通信功能。开发者可以利用此代码与键盘、鼠标等HID类设备直接交互,无需额外驱动程序。源代码中包含关键组件如HID类库、设备枚举、设备描述符解析、IO控制、事件处理和错误处理等,旨在帮助开发者深入理解USB HID通信机制,并实现应用层的逻辑。同时,考虑到与不同Windows系统的...

weixin_30598047的博客 1178

HID ReadFile()使用

http://bbs.youkuaiyun.com/topics/390691197 看过一个文章“Windows主机端与自定义USB HID设备通信详解",有这样一段文字。 1 、 ReadFile 的调用不会引起设备的任何反应,即 HID 设备与主机之间的中断 IN 传输不与 ReadFile 打交道。实际上主机会在最大间隔时间(由设备的端点描述符来指定)内轮询设备,发出中断 IN 传输的请求。“

phenixyf的专栏 2万+

VC6编写的HID读写测试工具

在Jan Axelson上修改而来,下载文件中包含可以直接使用的可执行文件。修改了usbhidio_vc6的接收数据显示,不显示Report ID,只显示接收到的真实数据。将hid.lib, hidsdi.h等文件放在了工程中,下载以后即可编译使用,如果遇到以下错误: “DBT_DEVTYP_DEVICEINTERFACE, PDEV_BROADCAST_DEVICEINTERFACE, HDEVNOTIFY, DEVICE_NOTIFY_WINDOW_HANDLE undeclared” 则需要在stdafx.h里面增加#define WINVER 0x0500就OK了。

USB相关的芯片

<br />转一:<br /><br /><br />做USB两个星期了,找了一些芯片,发现到处都没有人总结,找得挺辛苦的,这里发一下我的劳动成果,为后来人省点事吧。 <br />USB1.1:  <br />CH375     有HOST和SLAVE两种方式,即可以当主机去控制别的USB设备,如U盘等,又可以被PC控制。 <br />CH372      只有设备模式,不能控制别的USB设备 <br />   <br />USB2.0: <br />内部不含单片机核的USB芯片:CY7C68001    

hnxtls的专栏 1060

带全速USB接口的PIC18F4550应用设计

带全速USB接口的PIC18F4550应用设计

pic18f4550 usb 驱动库文件

在microchip下载的驱动文件,用VC++重新编释,生成的lib文件和dll文件可以直接用。

USB HID通信上位机程序VC6.0源代码

USB HID通信上位机程序VC6.0源代码 去发现同类优质开源项目:https://gitcode.com/ 资源描述 本仓库提供了一个名为“USB_HID通信上位机程序VC6.0(真正类似呀呀USB工具的源代码).rar”的资源文件。该资源文件包含了一个基于VC6.0开发的USB HID通信上位机程序的源代码。 资源背景 在STM32F10X开发板中,有一个非常有用的USB上位机工具,可以直接...

gitblog_09799的博客 813

PIC18F4550单片机中文版

PIC18F4550单片机硬件中文版文档,最新版,硬件开发必备

MICROCHIP系列解密

MICROCHIP(微芯)PIC系列单片机解密一直是单片机解密技术研究领域的重点,由于PIC以保密熔丝来保护代码,用户在烧入代码后熔断熔丝,别人很难读出,所以单片机解密难度很高,单片机解密周期相应变长,单片机解密费用相对增加。美国微芯科技公司(Microchip Technology Inc.)推出的PIC18F高性能8位单片机系列,充分利用microchip最新工艺技术的8款器件。这一新系列单片机确立了低功耗、低成本及高性能运行的新基准。PIC18F单片机是PIC的8位单片机目前主流产品。深圳芯片解密研究

芯片解密|IC解密|单片机解密|软件破解——深圳芯片解密研究所 2157

PIC18F4550_USB_firmware

PIC18F4550,usb开发,含源代码。使用编译器PICC-18

基于PIC18F4550的USB接口读卡器的设计

基于PIC18F4550的USB接口读卡器的设计

Android开发实战:从环境搭建到性能优化全攻略

Android开发作为移动应用开发的核心领域,其技术栈涵盖从基础环境搭建到高级架构设计的完整体系。理解Android Studio配置、Gradle构建系统以及ADB调试工具的原理,是提升开发效率的关键。在工程实践中,内存泄漏检测、启动速度优化等性能调优技术直接影响用户体验,而MVVM架构、跨进程通信等方案则关系到应用的可维护性。随着Kotlin和Jetpack Compose的普及,现代Android开发更强调声明式UI和响应式编程。本指南基于十余年实战经验,系统梳理了环境配置、框架设计、性能优化等核心知

457

快速搭建SpringBoot3+Vue3+ElementPlus管理系统

快速搭建SpringBoot3+Vue3管理系统前端项目搭建(默认开发环境:node20,Jdk17)创建项目并下载依赖--执行以下命令 前端项目搭建(默认开发环境:node20,Jdk17) 创建项目并下载依赖–执行以下命令 创建项目 yarn create vite admin-vue --template 2.下载依赖(也可按需下载) yarn add echarts --save yarn add vue-router --save yarn add element-plus --save y

adingyb的博客 2817

Cocos Creator VR开发环境配置全攻略:从原理到实践

虚拟现实(VR)开发的核心在于构建沉浸式的三维交互体验,其技术原理基于双目立体视觉渲染和六自由度(6DoF)空间追踪。在游戏引擎中实现VR功能,通常需要桥接设备原生SDK,处理特殊的渲染管线与输入系统,这对应用的性能与交互设计提出了更高要求。Cocos Creator作为一款跨平台游戏引擎,通过其原生扩展机制,为开发者提供了集成Meta Quest、PICO等主流VR设备的技术路径。本文聚焦于Cocos Creator中VR开发环境的具体配置,详细解析了从环境准备、插件集成、场景配置到真机构建与调试的完整流

weixin_30617737的博客 329

SAP系统中PP模块全配置文档

配置路径IMG>SAP NetWeaver>常规设置>维护日历>工厂日历事务代码SCAL要求传输工厂代码描述日历代码日历描述起始日期星期一星期二星期三星期四星期五星期六星期日有效开始日期有效结束日期1000南微医学工厂MT南微医学工厂日历√√√√√√√201820502.4定义工厂配置路径IMG>生产>物料清单>常规数据>定义BOM状态事务代码OS23要求传输配置路径IMG>生产>主数据>资源>常规数据>标准值>定义参数。

yanzibing99的博客 1894

【鼠标在不点击的情况下,直接移动到QT控件上不显示提示信息】

有时明明已经调用了setToolTips方法,鼠标移动到QT控件上仍然不会有提示信息,这时候就需要具体分析下。重点就是标红的这段话,大概意思就是。.h文件中加入鼠标移动事件的定义。.cpp文件中实现该事件。

ZTH_G的博客 2426

用VC对USB口的打开读写操作

USB口的打开读写操作程序的通用性是很好的,不同的USB只需修改不同的GUID至于调试,你怎么调试串口程序就怎么调试USB程序,大小方面一次性发送和接受数据不大于64个字节.这个可能和USB设备有关使用一个GUIDguidHID_1查找并打开一个USB设备extern "C" int PASCAL SearchUSBDevice(){ HANDLE hUsb; int nCount

xust999的专栏 9208

B-Tree数据存储

SQLITE数据存储1. B-Tree的优势  在SQLite中数据库、表、索引都是通过B-Tree和B+Tree的形式进行存储的。如果采用传统的二叉树查找树、红黑树的查找深度一般为log2(N) \log{_2}(N)(其中N表示的是整个树的关键字的数目),在数据库中如果存储的资源过多,就会导致查找一个数据过程中出现较多的磁盘I/O操作,而过多的磁盘操作就会导致整个查找的效率较低,而基于二叉树的一

Promiscuous_youth的博客 1142

VC++ libusb 实现usbhid数据读取

文章目录简单说明USB传输方式常用方法说明初始化和退出打开设备设备信息声明接口读取数据项目下载 简单说明 本文使用的libusb版本是1.0.22 github地址:https://github.com/libusb/libusb 老版本的需要安装winusb/libusbk/libwin32(三选一)驱动程序,才能和usb设备进行通讯。驱动生成程序可以从这里下载: https://downloa...

lhangtk的专栏 1万+

别再为倍福EL6021/EL6022的RS485接线头疼了!手把手教你硬件跳线与软件配置(附Modbus RTU主站例程)

本文详细解析了倍福EL6021/EL6022模块的RS485硬件跳线与软件配置方法,包括Modbus RTU主站编程实战。从端子定义、跳线操作到TwinCAT 3环境设置,提供完整的通信例程和故障排查技巧,帮助工程师快速解决工业现场通信问题。

weixin_30634661的博客 592

告别反复格式化!用Ventoy制作2025年终极启动盘,Windows/Linux/macOS一网打尽

本文详细介绍了如何使用Ventoy制作2025年终极多系统启动盘,彻底告别反复格式化U盘的烦恼。Ventoy通过创新的引导加载器架构,允许用户在一个U盘内同时存放并直接启动Windows、Linux、macOS等多种系统镜像和WePE等维护工具,实现真正的非破坏性管理和极高的U盘利用率。文章涵盖从安装配置、镜像库构建到安全启动设置等全流程实战指南。

weixin_29280219的博客 243

PIC18F2455/2550/4455/4550之通用串行总线USB

PIC18FX455/X550 系列器件包含全速和低速兼容的USB串行接口引擎(Serial Interface Engine,SIE),它允许在任何USB主机和PIC单片机之间进行高速通信。 可以利用内部收发器或通过外部收发器将SIE 直接连接到USB。内部的3.3V稳压器也可以在5V的应用中被用作内部收发器的电源。 USB模块还包含了某些特殊硬件以提高其工作性能。在...

a53203556的博客 712

AI上推荐 之 NeuralCF与PNN模型(改变特征交叉方式)

1. 前言 随着信息技术和互联网的发展, 我们已经步入了一个信息过载的时代,这个时代,无论是信息消费者还是信息生产者都遇到了很大的挑战: 信息消费者:如何从大量的信息中找到自己感兴趣的信息? 信息生产者:如何让自己生产的信息脱颖而出, 受到广大用户的关注? 为了解决这个矛盾, 推荐系统应时而生, 并飞速前进,在用户和信息之间架起了一道桥梁,一方面帮助用户发现对自己有价值的信息, 一方面让信息能够展现在对它感兴趣的用户前面。 推荐系统近几年有了深度学习的助推发展之势迅猛, 从前深度学习的传统推荐模型(协

Miracle8070 1万+

USB设计中的VUSB

设计一个USB HID类设备,所用硬件资源: 1. PIC18F4553(PIC18F4550):下位机设计,包括USB及其他需要实现的功能; 2. Windows XP:上位机应用程序编写,VC++6.0。 写好固件程序和应用程序后,插上USB后提示:无法识别。 经查,

seaman_003的专栏 3500

springboot整合sharding-jdbc实现分库分表详解

springboot整合sharding-jdbc实现分库分表详解

congge 9090

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

MICROCHIP-PIC18F4550 USB设备模式

本文深入解析Microchip PIC18F4550在USB设备模式下的工作原理,涵盖时钟配置、枚举流程、数据传输机制及硬件设计要点,帮助开发者理解从‘未知设备’到成功通信的关键步骤,适用于HID、CDC等低成本嵌入式应用。

weixin_33816734的博客 719

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

上一篇: Cisco基于策略路由的配置实例
下一篇: ping的源代码
iiprogram
博客等级 码龄25年 1068粉丝 1515原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值