`IPR2019-00879 (US 9,059,969)
`Exhibit 2130
`Page 1 of 166
`
`
`
`Includes USB 2.0 and USB On-The-Go
`
`Now•iii..1110
`COMPLETE
`
`THIRD EDITION
`
`Everything You
`Need to Develop
`Custom USB
`Peripherals
`With firmware examples and
`host application code
`JAN AX LSON
`
`author of Embedded Ethernet and Internet Complete
`
`
`
`USB Complete
`
`Everything You Need
`to Develop Custom USB Peripherals
`Third Edition
`
`Jan Axelson
`
`Lakeview Research LLC
`Madison, WI 53704
`
`
`
`USB Complete: Everything You Need to Develop USB Peripherals, Third Edition
`USB Complete: Everything You Need to Develop USB Peripherals, Third Edition
`by Jan Axelson
`by Jan Axelson
`
`Copyright 1999-2005 by Janet L. Axelson
`Copyright 1999-2005 by Janet L. Axelson
`
`All rights reserved. No part of the contents of this book, except the program code, may
`All rights reserved. No part of the contents of this book, except the program code, may
`be reproduced or transmitted in any form or by any means without the written permis-
`be reproduced or transmitted in any form or by any means without the written permis(cid:173)
`sion of the publisher. The program code may be stored and executed in a computer sys(cid:173)
`sion of the publisher. The program code may be stored and executed in a computer sys-
`tem and may be incorporated into computer programs developed by the reader.
`tem and may be incorporated into computer programs developed by the reader.
`
`The information, computer programs, schematic diagrams, documentation, and other
`The information, computer programs, schematic diagrams, documentation, and other
`material in this book are provided "as is," without warranty of any kind, expressed or
`material in this book are provided "as is," without warranty of any kind, expressed or
`implied, including without limitation any warranty concerning the accuracy, adequacy,
`implied, including without limitation any warranty concerning the accuracy, adequacy,
`or completeness of the material or the results obtained from using the material. Neither
`or completeness of the material or the results obtained from using the material. Neither
`the publisher nor the author shall be responsible for any claims attributable to errors,
`the publisher nor the author shall be responsible for any claims attributable to errors,
`omissions, or other inaccuracies in the material in this book. In no event shall the pub(cid:173)
`omissions, or other inaccuracies in the material in this book. In no event shall the pub-
`lisher or author be liable for direct, indirect, special, incidental, or consequential dam-
`lisher or author be liable for direct, indirect, special, incidental, or consequential dam(cid:173)
`ages in connection with, or arising out of, the construction, performance, or other use of
`ages in connection with, or arising out of, the construction, performance, or other use of
`the materials contained herein.
`the materials contained herein.
`
`Many of the products and company names mentioned herein are the trademarks of their
`Many of the products and company names mentioned herein are the trademarks of their
`respective holders. PICMicro is a registered trademark of Microchip Technology Inc. in
`respective holders. PICMicro is a registered trademark of Microchip Technology Inc. in
`the U.S.A. and other countries.
`the U.S.A. and other countries.
`
`Published by Lakeview Research LLC, 5310 Chinook Ln., Madison WI 53704
`Published by Lakeview Research LLC, 5310 Chinook Ln., Madison WI 53704
`On the web at www.Lvr.com
`On the web at www.Lvr.com
`
`Distributed by Independent Publishers Group (www.ipgbook.com).
`Distributed by Independent Publishers Group (www.ipgbook.com).
`Cover by Rattray Design. Cover Photo by Bill Bilsley Photography.
`Cover by Rattray Design. Cover Photo by Bill Bilsley Photography.
`Index by Julie Kawabata.
`Index by Julie Kawabata.
`
`14 13 12 11 10 9 8 7 6 5 4 3 2
`14 13 12 11 10 9 8 7 6 5 4 3 2
`Printed and bound in the United States of America
`Printed and bound in the United States of America
`ISBN13 978-1-931448-02-4
`ISBN13 978-1-931448-02-4
`ISBN10 1-931448-02-7
`ISBN 10 1-931448-02-7
`
`
`
`Contents
`Contents
`
`iii
`111
`
`Contents
`Contents
`
`Introduction xv
`Introduction xv
`1. USB Basics 1
`1. USB Basics 1
`What USB Can Do 2
`What USB Can Do 2
`Benefits for Users 2
`Benefits for Users 2
`Benefits for Developers 6
`Benefits for Developers 6
`Beyond the Hype 10
`Beyond the Hype 10
`Evolution of an Interface 13
`Evolution of an Interface 13
`Original USB 14
`Original USB 14
`USB 2.0 15
`USB 2.0 15
`USB On-The-Go 16
`USB On-The-Go 16
`Wireless USB 16
`Wireless USB 16
`USB versus IEEE-1394 16
`USB versus IEEE-1394 16
`USB versus Ethernet 17
`USB versus Ethernet 17
`Bus Components 17
`Bus Components 17
`Topology 18
`Topology 18
`Defining Terms 19
`Defining Terms 19
`
`
`
`Contents
`Contents
`
`Division of Labor 22
`Division of Labor 22
`The Host's Duties 22
`The Host's Duties 22
`The Peripheral's Duties 25
`The Peripheral's Duties 25
`What about Speed? 28
`What about Speed? 28
`Developing a Device 29
`Developing a Device 29
`Elements in the Link 29
`Elements in the Link 29
`Tools for Developing 30
`Tools for Developing 30
`Steps in Developing a Project 30
`Steps in Developing a Project 30
`2. Inside USB Transfers 33
`2. Inside USB Transfers 33
`Transfer Basics 34
`Transfer Basics 34
`Enumeration Communications 34
`Enumeration Communications 34
`Application Communications 34
`Application Communications 34
`Managing Data on the Bus 35
`Managing Data on the Bus 35
`Host Speed and Bus Speed 36
`Host Speed and Bus Speed 36
`Elements of a Transfer 37
`Elements of a Transfer 37
`Device Endpoints: the Source and Sink of Data 38
`Device Endpoints: the Source and Sink of Data 38
`Pipes: Connecting Endpoints to the Host 40
`Pipes: Connecting Endpoints to the Host 40
`Types of Transfers 40
`Types of Transfers 40
`Stream and Message Pipes 42
`Stream and Message Pipes 42
`Initiating a Transfer 43
`Initiating a Transfer 43
`Transactions: the Building Blocks of a Transfer 44
`Transactions: the Building Blocks of a Transfer 44
`Transaction Phases 45
`Transaction Phases 45
`Ensuring that Transfers Are Successful 51
`Ensuring that Transfers Are Successful 51
`Handshaking 51
`Handshaking 51
`Reporting the Status of Control Transfers 55
`Reporting the Status of Control Transfers 55
`Error Checking 56
`Error Checking 56
`3. A Transfer Type for Every Purpose 61
`3. A Transfer Type for Every Purpose 61
`Control Transfers 61
`Control Transfers 61
`Availability 62
`Availability 62
`Structure 62
`Structure 62
`Data Size 66
`Data Size 66
`Speed 66
`Speed 66
`Detecting and Handling Errors 68
`Detecting and Handling Errors 68
`Bulk Transfers 68
`Bulk Transfers 68
`Availability 69
`Availability 69
`Structure 69
`Structure 69
`Data Size 69
`Data Size 69
`Speed 71
`Speed 71
`Detecting and Handling Errors 71
`Detecting and Handling Errors 71
`
`iv
`iv
`
`
`
`Contents
`Contents
`
`Interrupt Transfers 72
`Interrupt Transfers 72
`Availability 72
`Availability 72
`Structure 72
`Structure 72
`Data Size 73
`Data Size 73
`Speed 73
`Speed 73
`Detecting and Handling Errors 75
`Detecting and Handling Errors 75
`Isochronous Transfers 7 6
`Isochronous Transfers 76
`Availability 76
`Availability 76
`Structure 76
`Structure 76
`Data Size 79
`Data Size 79
`Speed 79
`Speed 79
`Detecting and Handling Errors 80
`Detecting and Handling Errors 80
`More about Time-critical Transfers 80
`More about Time-critical Transfers 80
`Bus Bandwidth 81
`Bus Bandwidth 81
`Device Capabilities 81
`Device Capabilities 81
`Host Capabilities 82
`Host Capabilities 82
`Host Latencies 83
`Host Latencies 83
`4. Enumeration: How the Host Learns about Devices 85
`4. Enumeration: How the Host Learns about Devices 85
`The Process 86
`The Process 86
`Enumeration Steps 87
`Enumeration Steps 87
`Enumerating a Hub 91
`Enumerating a Hub 91
`Device Removal 92
`Device Removal 92
`Tips for Successful Enumeration 92
`Tips for Successful Enumeration 92
`Descriptors 93
`Descriptors 93
`Types of Descriptors 94
`Types of Descriptors 94
`Device Descriptor 96
`Device Descriptor 96
`Device_qualifier Descriptor 99
`Device_qualifier Descriptor 99
`Configuration Descriptor 101
`Configuration Descriptor 101
`Other_speed_configuration Descriptor 103
`Other_speed_configuration Descriptor 103
`Interface Association Descriptor 103
`Interface Association Descriptor 103
`Interface Descriptor 106
`Interface Descriptor 106
`Endpoint Descriptor 108
`Endpoint Descriptor 108
`String Descriptor 112
`String Descriptor 112
`Other Standard Descriptors 113
`Other Standard Descriptors 113
`The Microsoft OS Descriptor 114
`The Microsoft OS Descriptor 114
`Descriptors in 2.0-compliant Devices 114
`Descriptors in 2.0-compliant Devices 114
`Making l.x Descriptors 2.0-compliant 114
`Making 1.x Descriptors 2.0-compliant 114
`Detecting the Speed of a Dual-Speed Device 116
`Detecting the Speed of a Dual-Speed Device 116
`
`V
`V
`
`
`
`Contents
`Contents
`
`5. Control Transfers:
`5. Control Transfers:
`Structured Requests for Critical Data 117
`Structured Requests for Critical Data 117
`Elements of a Control Transfer 117
`Elements of a Control Transfer 117
`Setup Stage 118
`Setup Stage 118
`Data Stage 120
`Data Stage 120
`Status Stage 122
`Status Stage 122
`Handling Errors 124
`Handling Errors 124
`Device Firmware 125
`Device Firmware 125
`The Requests 127
`The Requests 127
`Get_Status 129
`Get_Status 129
`Clear_Feature 130
`Clear_Feature 130
`Set_Feature 131
`Set_Feature 131
`Set_Address 132
`Set_Address 132
`Get_Descriptor 133
`Get_Descriptor 133
`Set_Descriptor 134
`Set_Descriptor 134
`Get_Configuration 135
`Get_Configuration 135
`Set_ Configuration 136
`Set_Configuration 136
`Get_Interface 137
`Get_Interface 137
`Set_Interface 138
`Set_Interface 138
`Synch_Frame 139
`Synch_Frame 139
`Other Control Requests 140
`Other Control Requests 140
`Class-specific Requests 140
`Class-specific Requests 140
`Vendor-specific Requests 140
`Vendor-specific Requests 140
`6. Chip Choices 141
`6. Chip Choices 141
`Components of a USB Device 142
`Components of a USB Device 142
`The USB Controller 143
`The USB Controller 143
`Other Device Components 145
`Other Device Components 145
`Simplifying Device Development 148
`Simplifying Device Development 148
`Device Requirements 149
`Device Requirements 149
`Chip Documentation 150
`Chip Documentation 150
`Driver Choices 151
`Driver Choices 151
`Debugging Tools 151
`Debugging Tools 151
`Controllers with Embedded CPUs 154
`Controllers with Embedded CPUs 154
`Microchip PIC18F4550 156
`Microchip PIC18F4550 156
`Cypress EZ-USB 157
`Cypress EZ-USB 157
`Cypress enCoRe II 163
`Cypress enCoRe II 163
`Freescale MC68HC908JB16 164
`Freescale MC68HC908JB16 164
`Freescale MCF5482 ColdFire 164
`Freescale MCF5482 ColdFire 164
`
`vi
`Vi
`
`
`
`-
`
`Contents
`Contents
`
`Controllers that Interface to External CPUs 165
`Controllers that Interface to External CPUs 165
`National Semiconductor USBN9603 165
`National Semiconductor USBN9603 165
`Philips Semiconductors ISP1181B 167
`Philips Semiconductors ISPl 181B 167
`Philips Semiconductors ISP1581 168
`Philips Semiconductors ISP1581 168
`PLX Technology NET2272 169
`PLX Technology NET2272 169
`FTDI Chip FT232BM and FT245BM 170
`FTDI Chip FT232BM and FT245BM 170
`7. Device Classes 177
`7. Device Classes 177
`About Classes 177
`About Classes 177
`Device Working Groups 178
`Device Working Groups 178
`Elements of a Class Specification 178
`Elements of a Class Specification 178
`Defined Classes 181
`Defined Classes 181
`Audio 181
`Audio 181
`Chip/Smart Card Interface 189
`Chip/Smart Card Interface 189
`Communication Devices: Modems and Networks 191
`Communication Devices: Modems and Networks 191
`Content Security 198
`Content Security 198
`Device Firmware Upgrade 200
`Device Firmware Upgrade 200
`Human Interface 203
`Human Interface 203
`lrDA Bridge 206
`IrDA Bridge 206
`Mass Storage 208
`Mass Storage 208
`Printers 213
`Printers 213
`Still Image Capture: Cameras and Scanners 217
`Still Image Capture: Cameras and Scanners 217
`Test and Measurement 220
`Test and Measurement 220
`Video 221
`Video 221
`Implementing Non-standard Functions 226
`Implementing Non-standard Functions 226
`Standard or Custom Driver? 226
`Standard or Custom Driver? 226
`Converting from RS-232 227
`Converting from RS-232 227
`Converting from the Parallel Port 229
`Converting from the Parallel Port 229
`PC-to-PC Communications 229
`PC-to-PC Communications 229
`Using a Generic Driver 231
`Using a Generic Driver 231
`8. How the Host Communicates 233
`8. How the Host Communicates 233
`Device Driver Basics 233
`Device Driver Basics 233
`Insulating Applications from the Details 234
`Insulating Applications from the Details 234
`Options for USB Devices 235
`Options for USB Devices 235
`User and Kernel Modes 235
`User and Kernel Modes 235
`WDM Drivers 237
`WDM Drivers 237
`Layered Drivers 238
`Layered Drivers 238
`Communication Flow 243
`Communication Flow 243
`More Examples 246
`More Examples 246
`
`vii
`vii
`
`
`
`Contents
`
`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
`
`VIII
`
`
`
`Contents
`Contents
`
`Obtaining a Handle 303
`Obtaining a Handle 303
`Requesting a Communications Handle 303
`Requesting a Communications Handle 303
`Closing the Handle 306
`Closing the Handle 306
`Detecting Attachment and Removal 306
`Detecting Attachment and Removal 306
`About Device Notifications 307
`About Device Notifications 307
`Registering for Device Notifications 307
`Registering for Device Notifications 307
`Capturing Device Change Messages 311
`Capturing Device Change Messages 311
`Reading Device Change Messages 312
`Reading Device Change Messages 312
`Retrieving the Device Path Name in the Message 314
`Retrieving the Device Path Name in the Message 314
`Stopping Device Notifications 317
`Stopping Device Notifications 317
`11. Human Interface Devices:
`11. Human Interface Devices:
`Using Control and Interrupt Transfers 319
`Using Control and Interrupt Transfers 319
`What is a HID? 320
`What is a HID? 320
`Hardware Requirements 321
`Hardware Requirements 321
`Firmware Requirements 323
`Firmware Requirements 323
`Identifying a Device as a HID 323
`Identifying a Device as a HID 323
`The HID Interface 326
`The HID Interface 326
`HID Class Descriptor 326
`HID Class Descriptor 326
`Report Descriptors 328
`Report Descriptors 328
`HID-specific Requests 330
`HID-specific Requests 330
`Get_Report 332
`Get_Report 332
`Get_Idle 333
`Get_Idle 333
`Get_Protocol 334
`Get_Protocol 334
`Set_Report 335
`Set_Report 335
`Set_Idle 336
`Set_Idle 336
`Set_Protocol 337
`Set_Protocol 337
`Transferring Data 338
`Transferring Data 338
`About the Example Code 338
`About the Example Code 338
`Sending Reports via Interrupt Transfers 340
`Sending Reports via Interrupt Transfers 340
`Receiving Reports via Interrupt Transfers 343
`Receiving Reports via Interrupt Transfers 343
`Sending Reports via Control Transfers 345
`Sending Reports via Control Transfers 345
`Receiving Reports via Control Transfers 347
`Receiving Reports via Control Transfers 347
`12. Human Interface Devices: Reports 351
`12. Human Interface Devices: Reports 351
`Report Structure 351
`Report Structure 351
`Using the HID Descriptor Tool 352
`Using the HID Descriptor Tool 352
`Control and Data Item Values 354
`Control and Data Item Values 354
`Item Types 354
`Item Types 354
`
`ix
`ix
`
`
`
`Contents
`Contents
`
`The Main Item Type 355
`The Main Item Type 355
`Input, Output, and Feature Items 356
`Input, Output, and Feature Items 356
`Collection and End Collection Items 360
`Collection and End Collection Items 360
`The Global Item Type 361
`The Global Item Type 361
`Identifying the Report 361
`Identifying the Report 361
`Describing the Data's Use 363
`Describing the Data's Use 363
`Converting Units 365
`Converting Units 365
`Converting Raw Data 366
`Converting Raw Data 366
`Describing the Data's Size and Format 369
`Describing the Data's Size and Format 369
`Saving and Restoring Global Items 369
`Saving and Restoring Global Items 369
`The Local Item Type 370
`The Local Item Type 370
`Physical Descriptors 373
`Physical Descriptors 373
`Padding 373
`Padding 373
`13. Human Interface Devices: Host Application 375
`13. Human Interface Devices: Host Application 375
`HID API Functions 375
`HID API Functions 375
`Requesting Information about the HID 376
`Requesting Information about the HID 376
`Sending and Receiving Reports 376
`Sending and Receiving Reports 376
`Providing and Using Report Data 378
`Providing and Using Report Data 378
`Managing HID Communications 379
`Managing HID Communications 379
`Identifying a Device 379
`Identifying a Device 379
`Reading the Vendor and Product IDs 380
`Reading the Vendor and Product IDs 380
`Getting a Pointer to a Buffer with Device Capabilities 384
`Getting a Pointer to a Buffer with Device Capabilities 384
`Getting the Device's Capabilities 385
`Getting the Device's Capabilities 385
`Getting the Capabilities of the Buttons and Values 388
`Getting the Capabilities of the Buttons and Values 388
`Sending and Receiving Reports 388
`Sending and Receiving Reports 388
`Sending an Output Report to the Device 389
`Sending an Output Report to the Device 389
`Reading an Input Report from the Device 392
`Reading an Input Report from the Device 392
`Writing a Feature Report to the Device 402
`Writing a Feature Report to the Device 402
`Reading a Feature Report from a Device 404
`Reading a Feature Report from a Device 404
`Closing Communications 406
`Closing Communications 406
`14. Bulk Transfers for Any CPU 407
`14. Bulk Transfers for Any CPU 407
`Two Projects 407
`Two Projects 407
`Asynchronous Serial Interface 408
`Asynchronous ·serial Interface 408
`Parallel Interface 414
`Parallel Interface 414
`Host Programming 421
`Host Programming 421
`Using the D2XX Direct Driver 422
`Using the D2XX Direct Driver 422
`Selecting a Driver 422
`Selecting a Driver 422
`
`X
`X
`
`
`
`Contents
`Contents
`
`Performance Tips 426
`Performance Tips 426
`Speed Considerations 426
`Speed Considerations 426
`Minimizing Latency 427
`Minimizing Latency 427
`Preventing Lost Data 428
`Preventing Lost Data 428
`EEPROM Programming 429
`EEPROM Programming 429
`EEPROM Data 429
`EEPROM Data 429
`Editing the Data 429
`Editing the Data 429
`15. Hubs: the Link between Devices and the Host 433
`15. Hubs: the Link between Devices and the Host 433
`Hub Basics 434
`Hub Basics 434
`The Hub Repeater 435
`The Hub Repeater 435
`The Transaction Translator 438
`The Transaction Translator 438
`The Hub Controller 444
`The Hub Controller 444
`Speed 445
`Speed 445
`Maintaing an Idle Bus 447
`Maintaing an Idle Bus 447
`How Many Hubs in Series? 447
`How Many Hubs in Series? 447
`The Hub Class 448
`The Hub Class 448
`Hub Descriptors 448
`Hub Descriptors 448
`Hub-class Requests 452
`Hub-class Requests 452
`Port Indicators 453
`Port Indicators 453
`16. Managing Power 455
`16. Managing Power 455
`Powering Options 455
`Powering Options 455
`Voltages 456
`Voltages 456
`Which Peripherals Can Use Bus Power? 457
`Which Peripherals Can Use Bus Power? 457
`Power Needs 458
`Power Needs 458
`Informing the Host 459
`Informing the Host 459
`Hub Power 461
`Hub Power 461
`Power Sources 461
`Power Sources 461
`Over-current Protection 462
`Over-current Protection 462
`Power Switching 463
`Power Switching 463
`Saving Power 464
`Saving Power 464
`Global and Selective Suspends 464
`Global and Selective Suspends 464
`Current Limits for Suspended Devices 464
`Current Limits for Suspended Devices 464
`Resuming Communications 466
`Resuming Communications 466
`Power Management under Windows 467
`Power Management under Windows 467
`17. Testing and Debugging 471
`17. Testing and Debugging 471
`Tools 471
`Tools 471
`Hardware Protocol Analyzers 472
`Hardware Protocol Analyzers 472
`Software Protocol Analyzers 475
`Software Protocol Analyzers 475
`Traffic Generators 477
`Traffic Generators 477
`
`xi
`Xi
`
`
`
`Contents
`Contents
`
`Testing 477
`Testing 477
`Compliance Testing 478
`Compliance Testing 478
`WHQL Testing 484
`WHQL Testing 484
`18. Signals and Encoding 489
`18. Signals and Encoding 489
`Bus States 489
`Bus States 489
`Low-speed and Full-speed Bus States 490
`Low-speed and Full-speed Bus States 490
`High-speed Bus States 492
`High-speed Bus States 492
`Data Encoding 494
`Data Encoding 494
`Staying Synchronized 496
`Staying Synchronized 496
`Timing Accuracy 498
`Timing Accuracy 498
`Packet Format 499
`Packet Format 499
`Fields 499
`Fields 499
`Inter-packet Delay 501
`Inter-packet Delay 501
`Test Modes 502
`Test Modes 502
`Entering and Exiting Test Modes 502
`Entering and Exiting Test Modes 502
`The Modes 502
`The Modes 502
`19. The Electrical Interface 505
`19. The Electrical Interface 505
`Transceivers and Signals 506
`Transceivers and Signals 506
`Cable Segments 506
`Cable Segments 506
`Low- and Full-speed Transceivers 508
`Low- and Full-speed Transceivers 508
`High-speed Transceivers 512
`High-speed Transceivers 512
`Signal Voltages 517
`Signal Voltages 517
`Low and Full Speeds 517
`Low and Full Speeds 517
`High Speed 518
`High Speed 518
`Cables 518
`Cables 518
`Conductors 518
`Conductors 518
`Connectors 520
`Connectors 520
`Detachable and Captive Cables 524
`Detachable and Captive Cables 524
`Cable Length 524
`Cable Length 524
`Ensuring Signal Quality 525
`Ensuring Signal Quality 525
`Sources of Noise 526
`Sources of Noise 526
`Balanced Lines 527
`Balanced Lines 527
`Twisted Pairs 527
`Twisted Pairs 527
`Shielding 528
`Shielding 528
`Edge Rates 529
`Edge Rates 529
`Isolated Interfaces 529
`Isolated Interfaces 529
`
`XII
`xii
`
`
`
`Contents
`Contents
`
`Wireless Links 530
`Wireless Links 530
`Cypress WirelessUSB 530
`Cypress WirelessUSB 530
`The Wireless USB Initiative 533
`The Wireless USB Initiative 533
`Other Options 534
`Other Options 534
`20. Dual-role Devices with USB On-The-Go 535
`20. Dual-role Devices with USB On-The-Go 535
`Device and Host in One 536
`Device and Host in One 536
`Capabilities and Limits 536
`Capabilities and Limits 536
`Requirements for an OTG Device 538
`Requirements for an OTG Device 538
`The OTG Descriptor 545
`The OTG Descriptor 545
`Feature Codes for HNP 545
`Feature Codes for HNP 545
`OTG Controller Chips 545
`OTG Controller Chips 545
`Philips ISP1362 546
`Philips ISP1362 546
`TransDimension TD242LP 547
`TransDimension TD242LP 547
`Cypress CY7C67200 EZ-OTG 548
`Cypress CY7C67200 EZ-OTG 548
`Philips ISP1261 Bridge Controller 549
`Philips ISP1261 Bridge Controller 549
`
`Index 551
`Index 551
`
`xiii
`
`
`
`Contents
`
`xiv
`
`
`
`Introduction
`Introduction
`
`Introduction
`Introduction
`
`This book is for developers who design and program devices that use the
`This book is for developers who design and program devices that use the
`Universal Serial Bus (USB) interface. My goal is to introduce you to USB
`Universal Serial Bus (USB) interface. My goal is to introduce you to USB
`and to help you get your devices up and communicating as quickly and eas-
`and to help you get your devices up and communicating as quickly and eas(cid:173)
`ily as possible.
`ily as possible.
`The USB interface is versatile enough for a wide range of peripheral devices.
`The USB interface is versatile enough for a wide range of peripheral devices.
`Standard peripherals that use USB include mice, keyboards, drives, printers,
`Standard peripherals that use USB include mice, keyboards, drives, printers,
`and audio/video devices. USB is also suitable for data-acquisition units, con-
`and audio/video devices. USB is also suitable for data-acquisition units, con(cid:173)
`trol systems, and other devices with specialized functions, including
`trol systems, and other devices with specialized functions, including
`one-of-a-kind designs.
`one-of-a-kind designs.
`To develop a device with a USB interface, you need to know something
`To develop a device with a USB interface, you need to know something
`about how the interface works, what tasks your device firmware must per-
`about how the interface works, what tasks your device firmware must per(cid:173)
`form to communicate on the bus, and what class drivers and other support
`form to communicate on the bus, and what class drivers and other support
`are available on the host computers that your device will attach to. The right
`are available on the host computers that your device will attach to. The right
`choices of device hardware, device class, and development tools and tech-
`choices of device hardware, device class, and development tools and tech-
`
`USB Complete
`USB Complete
`
`xv
`xv
`
`
`
`Introduction
`
`piques can go a long way in avoiding snags and simplifying what needs to be
`done.
`If you're involved with designing USB devices, writing the firmware that
`resides inside USB devices, or writing applications that communicate with
`USB devices, this book will help you along the way.
`
`What's Inside
`
`These are some of questions the book answers:
`• How do USB devices communicate? The USB interface can seem daunting
`at first. The USB 2.0 specification is over 600 pages, not counting the
`class specifications and other supplementary documents. This book
`doesn't attempt to restate everything in the specifications. Instead, the
`focus is on what you'll need to know to enable your devices to communi-
`cate efficiently and reliably.
`• How can I decide if my device should use a USB interface? USB isn't the
`best choice for every application. Find out whether your design should
`use USB or another interface. The chances are good that you will choose
`USB, however, and if so, you'll learn how to decide which of USB's three
`speeds and four transfer types are appropriate for your application.
`• What controller chip should my device use? Every USB device must contain
`an intelligent controller to implement the USB interface. Dozens of
`manufacturers offer controller chips with differing architectures and abil-
`ities. This book includes descriptions of popular chips and tips to help
`you select a controller based on your project's needs and your back-
`ground and preferences.
`• How do applications communicate with USB devices? PC applications
`access a USB device by communicating with the device driver the operat-
`ing system has assigned to the device. Some devices can use class drivers
`that are included with Windows. Others devices require custom drivers.
`This book will introduce you to the classes and will help you determine if
`a defined class is appropriate for your device. If your device requires a
`custom driver, you'll learn what's involved in writing a driver, what tools
`
`xvi
`
`USB Complete
`
`
`
`Introduction
`Introduction
`
`can help speed up the process, and options for obtaining drivers from
`can help speed up the process, and options for obtaining drivers from
`other sources. Example code shows how to detect and communicate with
`other sources. Example code shows how to detect and communicate with
`devices in Visual Basic .NET and Visual C++ .NET applications.
`devices in Visual Basic .NET and Visual C++ .NET applications.
`• What firmware does my device need to support USB communications? Learn
`• What firmware does my device need to support USE communications? Learn
`how to write device firmware that enables your device to respond to
`how to write device firmware that enables your device to respond to
`received requests and exchange other data on the bus.
`received requests and exchange other data on the bus.
`• How do I decide whether my device can use bus power or needs its own sup-
`• How do I decide whether my device can use bus power or needs its own sup(cid:173)
`ply? Many USB devices can be powered entirely from the bus. Find out
`ply? Many USB devices can be powered entirely from the bus. Find out
`whether your device can use bus power. Learn how to ensure that your
`whether your device can use bus power. Learn how to ensure that your
`device meets USB's requirement to limit the use of bus current when the
`device meets USB's requirement to limit the use of bus current when the
`host computer suspends the bus.
`host computer suspends the bus.
`• Can I connect other USB peripherals to my device? Find out how to use
`• Can I connect other USB peripherals to my device? Find out how to use
`USB On-The-Go to enable your device to act as a limited-capability host
`USB On-The-Go to enable your device to act as a limited-capability host
`that can access other USB peripherals.
`that can access other USB peripherals.
`• How can I ensure that my device will communicate without problems?At the
`• How can I ensure that my device will communicate without problems? At the
`device, writing bugfree firmware requires understanding what your
`device, writing bugfree firmware requires understanding what your
`device must do to meet the requirements of the USB specifications. At
`device must do to meet the requirements of the USB specifications. At
`the host computer, Windows must have the information needed to iden-
`the host computer, Windows must have the information needed to iden(cid:173)
`tify the device and locate a driver to communicate with the device. This
`tify the device and locate a driver to communicate with the device. This
`book has tips, example code, and information about debugging software
`book has tips, example code, and information about debugging software
`and hardware to help with these tasks.
`and hardware to help with these tasks.
`To understand the material in the book, it's helpful to have basic knowledge
`To understand the material in the book, it's helpful to have basic knowledge
`in a few areas. I assume you have some experience with digital logic, applica-
`in a few areas. I assume you have some experience with digital logic, applica(cid:173)
`tion programming for PCs and writing embedded code for peripherals. You
`tion programming for PCs and writing embedded code for peripherals. You
`don't have to know anything at all about USB.
`don't have to know anything at all about USB.
`
`What's New in the Third Edition?
`What's New in the Third Edition?
`
`Since the publication of USB Complete Second Edition, much has happened
`Since the publication of USE Complete Second Edition, much has happened
`in the world of USB. Additions to the USB specifications include many
`in the world of USB. Additions to the USB specifications include many
`updated and expanded device-class specifications and the USB On-The-Go
`updated and expanded device-class specifications and the USB On-The-Go
`supplement. Many new device-controller chips have been released. New
`supplement. Many new device-controller chips have been released. New
`tools for debugging and compliance testing are available. Support for USB
`tools for debugging and compliance testing are available. Support for USB
`
`USS Complete
`USB Complete
`
`xvii
`xvii
`
`
`
`Introduction
`
`device classes under Windows has improved. And Microsoft's .NET Frame-
`work has become a popular platform for developing host applications.
`
`These developments prompted me to write USB Complete Third Edition.
`The material is revised and updated from start to finish to reflect these and
`other developments related to USB hardware and programming.
`
`More Information, Updates, and Corrections
`
`To find out more about developing USB devices and the software that com-
`municates with them, I invite you to visit my USB Central page at Lakeview
`Research's Web site (www.Lvr.com). You'll find code examples and links to
`articles, products, tools, and other information related to developing USB
`devices. If you have a suggestion, code, or other information that you'd like
`me to post or link to, let me know at jan@Lvrcom.
`
`Corrections and updates will also be available at www.Lvrcom. If you find
`an error, please let me know a