资源说明:1. USB Basics 1
What USB Can Do 2
Benefits for Users 2
Benefits for Developers 6
Beyond the Hype 10
Evolution of an Interface 13
Original USB 14
USB 2.0 15
USB On-The-Go 16
Wireless USB 16
USB versus IEEE-1394 16
USB versus Ethernet 17
Bus Components 17
Topology 18
Defining Terms 19
Contents
iv
Division of Labor 22
The Host’s Duties 22
The Peripheral’s Duties 25
What about Speed? 28
Developing a Device 29
Elements in the Link 29
Tools for Developing 30
Steps in Developing a Project 30
2. Inside USB Transfers 33
Transfer Basics 34
Enumeration Communications 34
Application Communications 34
Managing Data on the Bus 35
Host Speed and Bus Speed 36
Elements of a Transfer 37
Device Endpoints: the Source and Sink of Data 38
Pipes: Connecting Endpoints to the Host 40
Types of Transfers 40
Stream and Message Pipes 42
Initiating a Transfer 43
Transactions: the Building Blocks of a Transfer 44
Transaction Phases 45
Ensuring that Transfers Are Successful 51
Handshaking 51
Reporting the Status of Control Transfers 55
Error Checking 56
3. A Transfer Type for Every Purpose 61
Control Transfers 61
Availability 62
Structure 62
Data Size 66
Speed 66
Detecting and Handling Errors 68
Bulk Transfers 68
Availability 69
Structure 69
Data Size 69
Speed 71
Detecting and Handling Errors 71
Contents
v
Interrupt Transfers 72
Availability 72
Structure 72
Data Size 73
Speed 73
Detecting and Handling Errors 75
Isochronous Transfers 76
Availability 76
Structure 76
Data Size 79
Speed 79
Detecting and Handling Errors 80
More about Time-critical Transfers 80
Bus Bandwidth 81
Device Capabilities 81
Host Capabilities 82
Host Latencies 83
4. Enumeration: How the Host Learns about Devices 85
The Process 86
Enumeration Steps 87
Enumerating a Hub 91
Device Removal 92
Tips for Successful Enumeration 92
Descriptors 93
Types of Descriptors 94
Device Descriptor 96
Device_qualifier Descriptor 99
Configuration Descriptor 101
Other_speed_configuration Descriptor 103
Interface Association Descriptor 103
Interface Descriptor 106
Endpoint Descriptor 108
String Descriptor 112
Other Standard Descriptors 113
The Microsoft OS Descriptor 114
Descriptors in 2.0-compliant Devices 114
Making 1.x Descriptors 2.0-compliant 114
Detecting the Speed of a Dual-Speed Device 116
Contents
vi
5. Control Transfers:
Structured Requests for Critical Data 117
Elements of a Control Transfer 117
Setup Stage 118
Data Stage 120
Status Stage 122
Handling Errors 124
Device Firmware 125
The Requests 127
Get_Status 129
Clear_Feature 130
Set_Feature 131
Set_Address 132
Get_Descriptor 133
Set_Descriptor 134
Get_Configuration 135
Set_Configuration 136
Get_Interface 137
Set_Interface 138
Synch_Frame 139
Other Control Requests 140
Class-specific Requests 140
Vendor-specific Requests 140
6. Chip Choices 141
Components of a USB Device 142
The USB Controller 143
Other Device Components 145
Simplifying Device Development 148
Device Requirements 149
Chip Documentation 150
Driver Choices 151
Debugging Tools 151
Controllers with Embedded CPUs 154
Microchip PIC18F4550 156
Cypress EZ-USB 157
Cypress enCoRe II 163
Freescale MC68HC908JB16 164
Freescale MCF5482 ColdFire 164
Contents
vii
Controllers that Interface to External CPUs 165
National Semiconductor USBN9603 165
Philips Semiconductors ISP1181B 167
Philips Semiconductors ISP1581 168
PLX Technology NET2272 169
FTDI Chip FT232BM and FT245BM 170
7. Device Classes 177
About Classes 177
Device Working Groups 178
Elements of a Class Specification 178
Defined Classes 181
Audio 181
Chip/Smart Card Interface 189
Communication Devices: Modems and Networks 191
Content Security 198
Device Firmware Upgrade 200
Human Interface 203
IrDA Bridge 206
Mass Storage 208
Printers 213
Still Image Capture: Cameras and Scanners 217
Test and Measurement 220
Video 221
Implementing Non-standard Functions 226
Standard or Custom Driver? 226
Converting from RS-232 227
Converting from the Parallel Port 229
PC-to-PC Communications 229
Using a Generic Driver 231
8. How the Host Communicates 233
Device Driver Basics 233
Insulating Applications from the Details 234
Options for USB Devices 235
User and Kernel Modes 235
WDM Drivers 237
Layered Drivers 238
Communication Flow 243
More Examples 246
Contents
viii
Creating a Custom Driver 247
Writing a Driver from Scratch 247
Using a Driver Toolkit 248
Using GUIDs 249
Device Setup GUIDs 250
Device Interface GUIDs 251
9. Matching a Driver to a Device 253
Using the Device Manager 253
Viewing Devices 254
Property Pages 257
Device Information in the Registry 257
The Hardware Key 258
The Class Key 259
The Driver Key 260
The Service Key 262
Inside INF Files 262
Syntax 265
Sections 266
Using Device Identification Strings 272
Finding a Match 274
Do You Need to Provide an INF File? 276
Tools and Diagnostic Aids 277
Tips for Using INF Files 277
What the User Sees 279
10. Detecting Devices 281
A Brief Guide to Calling API Functions 281
Managed and Unmanaged Code 282
Documentation 284
Using Visual C++ .NET 284
Using Visual Basic .NET 286
Finding Your Device 291
Obtaining the Device Interface GUID 292
Requesting a Pointer to a Device Information Set 293
Identifying a Device Interface 295
Requesting a Structure Containing the Device Path Name 298
Extracting the Device Path Name 301
Closing Communications 302
Contents
ix
Obtaining a Handle 303
Requesting a Communications Handle 303
Closing the Handle 306
Detecting Attachment and Removal 306
About Device Notifications 307
Registering for Device Notifications 307
Capturing Device Change Messages 311
Reading Device Change Messages 312
Retrieving the Device Path Name in the Message 314
Stopping Device Notifications 317
11. Human Interface Devices:
Using Control and Interrupt Transfers 319
What is a HID? 320
Hardware Requirements 321
Firmware Requirements 323
Identifying a Device as a HID 323
The HID Interface 326
HID Class Descriptor 326
Report Descriptors 328
HID-specific Requests 330
Get_Report 332
Get_Idle 333
Get_Protocol 334
Set_Report 335
Set_Idle 336
Set_Protocol 337
Transferring Data 338
About the Example Code 338
Sending Reports via Interrupt Transfers 340
Receiving Reports via Interrupt Transfers 343
Sending Reports via Control Transfers 345
Receiving Reports via Control Transfers 347
12. Human Interface Devices: Reports 351
Report Structure 351
Using the HID Descriptor Tool 352
Control and Data Item Values 354
Item Types 354
Contents
x
The Main Item Type 355
Input, Output, and Feature Items 356
Collection and End Collection Items 360
The Global Item Type 361
Identifying the Report 361
Describing the Data’s Use 363
Converting Units 365
Converting Raw Data 366
Describing the Data’s Size and Format 369
Saving and Restoring Global Items 369
The Local Item Type 370
Physical Descriptors 373
Padding 373
13. Human Interface Devices: Host Application 375
HID API Functions 375
Requesting Information about the HID 376
Sending and Receiving Reports 376
Providing and Using Report Data 378
Managing HID Communications 379
Identifying a Device 379
Reading the Vendor and Product IDs 380
Getting a Pointer to a Buffer with Device Capabilities 384
Getting the Device’s Capabilities 385
Getting the Capabilities of the Buttons and Values 388
Sending and Receiving Reports 388
Sending an Output Report to the Device 389
Reading an Input Report from the Device 392
Writing a Feature Report to the Device 402
Reading a Feature Report from a Device 404
Closing Communications 406
14. Bulk Transfers for Any CPU 407
Two Projects 407
Asynchronous Serial Interface 408
Parallel Interface 414
Host Programming 421
Using the D2XX Direct Driver 422
Selecting a Driver 422
Contents
xi
Performance Tips 426
Speed Considerations 426
Minimizing Latency 427
Preventing Lost Data 428
EEPROM Programming 429
EEPROM Data 429
Editing the Data 429
15. Hubs: the Link between Devices and the Host 433
Hub Basics 434
The Hub Repeater 435
The Transaction Translator 438
The Hub Controller 444
Speed 445
Maintaing an Idle Bus 447
How Many Hubs in Series? 447
The Hub Class 448
Hub Descriptors 448
Hub-class Requests 452
Port Indicators 453
16. Managing Power 455
Powering Options 455
Voltages 456
Which Peripherals Can Use Bus Power? 457
Power Needs 458
Informing the Host 459
Hub Power 461
Power Sources 461
Over-current Protection 462
Power Switching 463
Saving Power 464
Global and Selective Suspends 464
Current Limits for Suspended Devices 464
Resuming Communications 466
Power Management under Windows 467
17. Testing and Debugging 471
Tools 471
Hardware Protocol Analyzers 472
Software Protocol Analyzers 475
Traffic Generators 477
Contents
xii
Testing 477
Compliance Testing 478
WHQL Testing 484
18. Signals and Encoding 489
Bus States 489
Low-speed and Full-speed Bus States 490
High-speed Bus States 492
Data Encoding 494
Staying Synchronized 496
Timing Accuracy 498
Packet Format 499
Fields 499
Inter-packet Delay 501
Test Modes 502
Entering and Exiting Test Modes 502
The Modes 502
19. The Electrical Interface 505
Transceivers and Signals 506
Cable Segments 506
Low- and Full-speed Transceivers 508
High-speed Transceivers 512
Signal Voltages 517
Low and Full Speeds 517
High Speed 518
Cables 518
Conductors 518
Connectors 520
Detachable and Captive Cables 524
Cable Length 524
Ensuring Signal Quality 525
Sources of Noise 526
Balanced Lines 527
Twisted Pairs 527
Shielding 528
Edge Rates 529
Isolated Interfaces 529
Contents
xiii
Wireless Links 530
Cypress WirelessUSB 530
The Wireless USB Initiative 533
Other Options 534
20. Dual-role Devices with USB On-The-Go 535
Device and Host in One 536
Capabilities and Limits 536
Requirements for an OTG Device 538
The OTG Descriptor 545
Feature Codes for HNP 545
OTG Controller Chips 545
Philips ISP1362 546
TransDimension TD242LP 547
Cypress CY7C67200 EZ-OTG 548
Philips ISP1261 Bridge Controller 549
本源码包内暂不包含可直接显示的源代码文件,请下载源码包。