Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year...

65
Windows Embedded CE Windows Embedded CE 6.0 USB Function 接口驱 动程序 Sunny Cheng 程胜辅 Sunny Cheng 程胜辅 Director, Worldwide Technical Marketing Intrinsyc Software International Inc. scheng@intrinsyc.com

Transcript of Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year...

Page 1: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

Windows Embedded CE Windows Embedded CE 6.0 USB Function 接口驱动程序

Sunny Cheng 程胜辅Sunny Cheng 程胜辅

Director, Worldwide Technical MarketingIntrinsyc Software International [email protected]@ y

Page 2: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

Who Is Intrinsyc (英传信)Who Is Intrinsyc (英传信)Over 12 years experience in wireless, handheld and embedded device development (Founded in 1996)Located in Vancouver BC (HQ), Seattle, Beijing, Taipei and Israel System Integration for Tier 1 OEMs with 200+ engineering services projectsprojects Strong expertise in: Windows Mobile/CE, Android, and Symbian200 employees with 75% in development or engineering Offering both low level platform and application solutionsMultiple times winner of Microsoft Windows Embedded Partner of the Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008)

Microsoft MEDC 2007 - System Integrator Excellence Award

Gold level Windows Embedded CE Partner. Over 12 years experience on the Windows Embedded CE platform (started from Windows CE 1.0)

Page 3: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

Who Am IWho Am I1988年,西安电子科技大学计算机工程专业学士学位

1991年 航天部第三研究院工程硕士学位1991年,航天部第三研究院工程硕士学位

航天部第三研究院,导弹制导系统开发

TJNEC公司,NEC程控交换机软件开发,后期任职软件开发经理TJNEC公司,NEC程控交换机软件开发,后期任职软件开发经理

AirPatrol公司,任职资深软件工程师,专攻WiFi客户管理技术,独立开发了pocketWiNc,AirSafe Service, 和AirSafe Personal等产品品。

加入Intrinsyc总部工作后,先任职资深软件工程师。主要工作领域

电源管理电源管理

BootloaderNAND, OneNAND技术

USB技术USB技术

现任职Intrinsyc总部全球技术市场总监,负责公司全球范围的技术方案制定,技术推广,技术支持等

Page 4: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

下载Webcast好帮手下载Webcast好帮手

iRiReaper

文件大小<=2.5Mb

可按照多种分类方式进行批量下载

WMV、MP3、MP4、Zune四种格式Webcast

访问iReaper主页:h d l ihttp://www.codeplex.com/iReaper

Page 5: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

加速企业解决方案部署尽在

• 用于解决方案开发的集中资源 资源包括指向测试工具 开发

资源和利益资源和利益• 用于解决方案开发的集中资源:资源包括指向测试工具、开发

人员 SDK、技术论坛、联机培训等的链接,微软全球技术支持中心(GTSC)的邮件技术支持。( )

• 对市场调查的访问权限:您可以使用这些宝贵信息来识别您当前的客户或未来客户的特定需求。

• 认证徽标计划:该徽标可以向客户证明您所具有的优秀技术。

• 市场营销和销售支持

h Ohttp://InnovateOn.com

Page 6: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

Metro – ISV领航计划最先应用微软最新技术最先应用微软最新技术

提升提升ISVISV竞争优势和商业价值竞争优势和商业价值• Metro 提供了结构化的支持来帮助ISV进行新技术的评估和

部署

提升提升ISVISV竞争优势和商业价值竞争优势和商业价值

部署:

– 参与前沿技术培训

评估最新的微软技术及产品

Discover Discover

– 评估最新的微软技术及产品

– 获取微软Beta版产品的技术支持

联络全球开发人员和架构师社区

LearnLearnReleaseRelease

– 联络全球开发人员和架构师社区

– 与世界级的商务和技术社区分享最先部署的经验

DevelopDevelop部署的经验

Page 7: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

收听本次课程需具备的条件收听本次课程需具备的条件

• Understand Windows CE device driver development conceptp p

• Have knowledge of one or more embedded application processors ARM orembedded application processors, ARM or Xscale

• Have knowledge of BSP development

Level 300

Page 8: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

本次课程内容包括本次课程内容包括

接 已经是所有 的标USB接口已经是所有Windows Mobile的标准接口。但是USB接口有各种不同的标准和的相应的驱动程序。本课程在介绍USB Function接口概念的基础上以S3C2410为Function接口概念的基础上以S3C2410为例介绍了如何开发Windows Embedded CE6 0 USB Function Controller驱动程序CE6.0 USB Function Controller驱动程序,以及Function Controller驱动程序和F i Cli 驱动程序的关系Function Client驱动程序的关系

Page 9: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

内容内容

• USB Overview 1• Windows CE USB Function Driver Architecture• Windows CE USB Function Client Drivers• Windows CE USB Function Controller Driver• Windows CE USB Function Controller Driver

S3C2410 as exampleUSB T ti• USB Testing

Page 10: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

USB Overview 1USB Overview 1

• Introduction• ArchitectureArchitecture• Data Transfer Model

Page 11: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

USB IntroductionUSB Introduction

U i l S i l B (USB) l bUniversal Serial Bus (USB): an external bus architecture standard for connecting USB-

bl i h l d i t h t d icapable peripheral devices to a host deviceStandard interface for peripherals and hostHot-pluggable and plug-and-playVirtually suitable for any peripheral devicesOne host to many peripherals simultaneouslySupport power management USB Logo

Page 12: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

USB ArchitectureUSB Architecture

Star-Tier bus topology (Tree)Star Tier bus topology (Tree)Nodes on the USB bus

Page 13: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

Star-Tier Bus TopologyStar Tier Bus Topology

Page 14: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

USB Bus Topology LimitationUSB Bus Topology Limitation

Supports the attachment of 127 devicesSupports the attachment of 127 devices per USBO l 5 t l d ti hOnly 5 external cascade tiers can have hub, add the root hub Tier 1 and the lowest leaf function node Tier 7, the maximum tiers allowed is 7

Page 15: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

USB Hardware USB Hardware

Host (Root Hub)Host (Root Hub)HubFunctionTransfer SpeedTransfer SpeedUSB 2.0PortUSB Cable & ConnectorsUSB Cable & Connectors

Page 16: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

USB HostUSB HostOnly one host in any USB systemOriginates the communicationContains a host controller and a root hubContains a host controller and a root hub

Page 17: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

USB Host ControllerUSB Host ControllerInterfaces to the host computer systemManages the data transferring between USB devices and the host systemUSB devices and the host system componentsManages the communication on the busManages attach and detach of the devicesManages attach and detach of the devices

Page 18: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

USB Host – Root HubUSB Host Root HubProvides the connection points (ports) for USB devicesProvides power management to its portsProvides power management to its portsEnables and disables portsRecognizes devices attached to each portSets and reports status events associatedSets and reports status events associated with each port

Page 19: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

USB HubUSB HubA device that provides attachment points (ports) to USB devicesBus poweredpOr self-poweredRepeat the bus data trafficRepeat the bus data trafficDetect the attachment and detachment of USB d idevicesConvert the data format between different speed

Page 20: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

USB FunctionUSB Function

Function (Device, Peripheral, Client)( , p , )A device that provides a capability to the hostFunction is the official term from USB specificationpClient has different meanings for both Function and Host

Device = PeripheralAttached to a USB portAttached to a USB portCan be a function, or a hub, or a composite device (a hub and one or more functions))

Page 21: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

USB OTGUSB OTG

Support SRP and HNPSupport SRP and HNPSRP: Session Request ProtocolHNP H t N ti ti P t lHNP: Host Negotiation Protocol

Simple versionno SRP, HNP support

Page 22: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

USB 2.0USB 2.0

Added support for high-speedpp g pExternal USB 2.0 hub must support all speedsBackward compatible to 1 xBackward compatible to 1.x

USB 2.0 peripherals can work with USB2.0 or 1.x host or hubor hubUSB 2.0 hosts and hubs can also communicate with 1 x peripherals1.x peripherals

Some other features, not very important for now

Page 23: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

USB Transfer SpeedUSB Transfer SpeedHigh-Speed Device – up to 480 MbpsFull-Speed Device – up to 12 MbpsLow Speed Device up to 1 5 MbpsLow-Speed Device – up to 1.5 MbpsDevice means hub or function

Page 24: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

USB Transfer SpeedUSB Transfer SpeedGood or bad?

To talk about a USB host/device support high speedsupport high-speed

a USB 2.0 host/deviceTo talk about a USB host/device not support high-speedsupport high-speed

a USB 1.1 host/device

Page 25: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

USB Transfer SpeedUSB Transfer Speed

The USB-IF wayThe USB IF wayTo talk about a USB host/device support high-speedspeed

a “High-Speed USB” host/deviceTo talk about a USB host/device not support high-speed

a “USB” host/device (for general public. I prefer “Full-Speed USB” as a platform developer)

Page 26: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

USB PortUSB PortAn addressable location available for attaching

dditi l i itadditional circuitsHost controller manages a single bus, each connector on the bus represents a USB portEach port can attach a USB devicepExternal Hub has one upstream port and up to 7 downstream portsdownstream portsAll of the ports on the bus share a single path to the host and aren’t directly addressablethe host and aren t directly addressable

Only one device, or the host, transmit at a time

Page 27: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

USB Cable & ConnectorsUSB Cable & Connectors

Type A/BPin Name Color Description

1 VBUS Red +5V

2 D- White Data-

3 D+ Green Data+

4 GND Black Ground

Pin Name Color Description

1 VBUS Red +5V

mini/micro A/B

2 D- White Data-

3 D+ Green Data+

4 ID None Type A: connected to GroundType B: not connected

5 GND Black Ground

OTG: Mini AB/micro ABOTG: Mini-AB/micro-AB

Page 28: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

USB Data Transfer ModelUSB Data Transfer Model

Enumeration ProcessEnumeration ProcessDescriptorsEndpointPipePipeData FlowTransfer TypesTransactionTransactionPacket

Page 29: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

Enumeration ProcessEnumeration ProcessTo recognize the presence of the device and assigns it a unique 7-bit addressTypical USB 2.0 steps1. A new device is attached to root hub/hub – Powered State2 Th h b d t t th d i d t t h t2. The hub detects the device and report to host3. The host/hub detects the speed of the device (low/full?>reset>high?) -

Reset State4. The hub establishes a signal path between the device and the bus –

Default StateThe device is ready to respond to control transfers at endpoint zero

5. The host sends a Get Descriptor request to learn the maximum packet size of the default pipe

6. The host assigns an address (Set Address command) - Address State7. The host learns about the device’s abilities

The host asks for Device Descriptor, then asks for Configuration Descriptor It then followed with Interface Descriptor(s) and/or class- or vendor-specific Descriptors

8. Host assigns and loads device driver(s)

Page 30: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

DescriptorsDescriptorsA device has a single Device descriptor. The Device descriptor can have multiple Configuration descriptorsConfiguration descriptors

Only a single one can be active at a time.

The Configuration descriptor can define oneThe Configuration descriptor can define one or more Interface descriptors.

Each of the Interface descriptors can have one or more alternate settings, but only one setting can be active at a timea time. The Interface descriptor defines one or more Endpoints

Page 31: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

DescriptorsDescriptors

Page 32: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

Endpoint (Device Endpoint)Endpoint (Device Endpoint)A uniquely addressable portion of a USB device that is the source or sink of information in communication flowsource or sink of information in communication flow between host and deviceA buffer that stores data to be transferredA buffer that stores data to be transferredHost doesn’t have endpointsUnique endpoint addressUnique endpoint address

number (0-F)direction (In or Out from host perspective)

Endpoint 0 Control endpoint - configure and setup the deviceBidirectionalNo descriptor

Page 33: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

PipePipeA logical abstraction represents the association between an device endpoint and the hostbetween an device endpoint and the host controller software

fMessage pipes support the control transfer typeStream pipes handle all other transfer types

Page 34: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

Data FlowData Flow

Page 35: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

Transfer TypesTransfer Types

ControlControlInterruptI hIsochronousBulk

Page 36: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

Control Transfer TypeControl Transfer TypeBursthost software-initiatedTypically for command/status operationsMust use Endpoint 0Bidirectional with message pipeBidirectional with message pipeLow speed packet size: 8 bytesF ll d k i 8 16 32 64 bFull speed packet size: 8, 16, 32 or 64 bytesHigh speed packet size: 64 bytes

Page 37: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

Interrupt Transfer TypeInterrupt Transfer TypeLow-frequencyUnidirectional with stream pipeUnidirectional with stream pipeHost polls device to determine if they have any data to transfertransferGuaranteed time interval defined in interrupt endpoint descriptordescriptorTypically used by slow devices Example: mouse keyboardExample: mouse, keyboardLow speed packet size: 1-8 bytesFull speed packet size: 1-64 bytesFull speed packet size: 1-64 bytesHigh speed packet size: 1-1024 bytes

Page 38: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

Isochronous Transfer TypeIsochronous Transfer TypePeriodic, continuous communication Unidirectional with stream pipeCan only support in full speed/high speed devicesno error checkingTypically used for time sensitive dataTypically used for time sensitive dataExample: Audio, VideoF ll d k i 0 1023 bFull speed packet size: 0 – 1023 bytesHigh speed packet size: Up to 1024 bytes

Page 39: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

Bulk Transfer TypeBulk Transfer TypeNon-periodic, large packet burst communicationUnidirectional with stream pipeUnidirectional with stream pipeGuaranteed to arrive without errorCan onl s pport in f ll speed/high speed de icesCan only support in full speed/high speed devicesTypically used for data that can use any available bandwidth and can also be delayed until bandwidth is availableand can also be delayed until bandwidth is availableExample: files from a mass storage device or the output from a scannerfrom a scannerFull speed packet size: 8, 16,32 or 64 bytesHigh speed packet size: 512 bytesHigh speed packet size: 512 bytesConsists of one or more IN or OUT transactions

Page 40: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

Transfer and TransactionTransfer and Transaction

USB data transfers are performed across theUSB data transfers are performed across the USB wire using one or more transactionsData Transfer contains Setup Data (optional)Data Transfer contains Setup, Data (optional) and Status stagesT ti t i ll i t f th k tTransactions typically consist of three packets

TokenDataHandshake

One transaction:Token Packet

DataPacket

HandshakePacketPacket Packet Packet

Page 41: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

PacketPacketThe basic data blocks transferred on USB wireAll USB packets are sent LSB firstAll USB packets are sent from the hostPacket type

Token - IN, OUT, SETUP, SOF, PING(2.0), SPLIT(2.0)Data – DATA0, DATA1, DATA2(2.0), MDATA(2.0)Handshake – ACK, NAK, STALL, NYET(2.0), ERR(2.0)

Packet format:Packet format:

Packet informationSYNC PID EOPPacket information (Data) CRC

Page 42: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

CE 6.0 USB Function DriverCE 6.0 USB Function Driver

Windows CE 6.0 USB Driver ArchitectureWindows CE 6.0 USB Driver ArchitectureFunction Driver Architecture Function Client DriversFunction Controller Driver MDDFunction Controller Driver MDDFunction Controller Driver PDD

Page 43: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

CE6.0 USB Driver ArchitectureCE6.0 USB Driver Architecture

USB Host Client (USB USB Function

USBD

USB Host Client (USB Class) Driver

USB Function Client Driver

USB Function Composite D i D i

USB HCD(Host Controller Driver) USB Function Controller

Driver

Device Driver

USB Host

USB Host Controller Driver

MDD

USB Function Controller Driver

MDD

USB FunctionUSB HostController Driver

PDD

USB Function Controller Driver

PDD

USB Host Hardware USB Device HardwareUSB Cable

Page 44: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

Function Driver ArchitectureFunction Driver ArchitectureApplications

USB Function Mass Storage Client Driver

USB FunctionSerial

USB FunctionRNDIS

Client Driver

USB FunctionPrinter Client Driver

(SCSI-2) Client Driver Client Driver(Activesync) Client Driver

USB Function Composite Device Driver

USB Function Controller Driver

USB Function Composite Device Driver

USB Function Controller Driver MDD

USB Function Controller Driver PDD

Page 45: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

Function Client DriversFunction Client Drivers

Mass Storage Client DriverMass Storage Client DriverSerial Client DriverRNDIS Client DriverPrinter Client DriverPrinter Client DriverComposite Device DriverNormally no need to change

Page 46: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

Mass Storage Client DriverMass Storage Client DriverExpose a storage device to a USB hostSet SYSGEN_USBFN_STORAGE=1Consists of

a SCSI-2 direct-access device emulatora transport-to-emulator proxy

Need a block driver implements the SCSI-2 direct-access device emulatorS l dSample source code:

C:\WINCE600\PUBLIC\COMMON\OAK\DRIVERS\USBFN\CLASS\STORAGE

Registry settings:Registry settings:HKEY_LOCAL_MACHINE\Drivers\USB\FunctionDrivers\Mass_Storage_Class

MSDN reference:http://msdn.microsoft.com/en-ca/library/aa932254.aspx

Page 47: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

Serial Client DriverSerial Client DriverExpose a stream interfaceSet SYSGEN_USBFN_SERIAL=1Sample source code:

C:\WINCE600\PUBLIC\COMMON\OAK\DRIVERS\USBFN\CLASS\SERIAL

Registry settings:HKEY LOCAL MACHINE\D i \USB\F ti D i \S i l ClHKEY_LOCAL_MACHINE\Drivers\USB\FunctionDrivers\Serial_Class

MSDN reference:http://msdn microsoft com/en-ca/library/aa912978 aspxhttp://msdn.microsoft.com/en-ca/library/aa912978.aspx

Page 48: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

RNDIS Client DriverRNDIS Client DriverImplements the RNDIS protocol over USBIs used to implement KITL or network supportWindows Mobile uses RNDIS to provide ActiveSync support and Internet sharingSample source code:

C:\WINCE600\PUBLIC\COMMON\OAK\DRIVERS\USBFN\CLASS\RNDIS\RNDISFN

Registry settings:eg st y sett gsHKEY_LOCAL_MACHINE\Drivers\USB\FunctionDrivers\RNDIS

MSDN reference:http://msdn.microsoft.com/en-ca/library/aa932050.aspx

Page 49: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

Printer Client DriverPrinter Client DriverDesigned to help build a CE based USB printerA bridge between an attached printer and a USB function portConsists of

a USB function printer classa USB function printer class a USB function data pipe class

Set SYSGEN_USBFN_PRINTER=1Sample source code:

C:\WINCE600\PUBLIC\COMMON\OAK\DRIVERS\USBFN\CLASS\USBPRN

Registry settings:Registry settings:HKEY_LOCAL_MACHINE\Drivers\USB\FunctionDrivers\UFN_PRINTER_Class\USBFNPrinter:"LPTx"

MSDN reference:MSDN reference:http://msdn.microsoft.com/en-ca/library/bb202143.aspx

Page 50: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

Composite Client DriverComposite Client DriverEnable simultaneous multiple functions supportNew to CE6.0Older client driver use new version of the UfnClientLiblibrary to workDynamic loading and unloading of individual client drivers i till t dis still supported Set SYSGEN_USBFN_COMPOSITE=1S l dSample source code:

C:\WINCE600\PUBLIC\COMMON\OAK\DRIVERS\USBFN\CLASS\COMPOSITEFN

Registry settings:Registry settings:HKEY_LOCAL_MACHINE\Drivers\USB\FunctionDrivers\CompositeFN

MSDN reference:http://msdn.microsoft.com/en-ca/library/aa909606.aspx

Page 51: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

Function Controller Driver MDDFunction Controller Driver MDD

Normally no modification neededyLoads the client driver specified in registryS t th i t ti f USBSupports the registration of a USB descriptor setHandles the enumeration processProvides pipe access and maintain pipe toProvides pipe access and maintain pipe-to-endpoint mapping

Page 52: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

Function Controller Driver MDDFunction Controller Driver MDDMDD – PDD interface is defined in UFN_PDD_INTERFACE_INFO

PDD has to implement the functions defined in itC:\WINCE600\public\common\oak\inc\usbfn.hC:\WINCE600\public\common\oak\inc\usbfnioctl.hC:\WINCE600\public\common\oak\inc\usbfntypes hC:\WINCE600\public\common\oak\inc\usbfntypes.h

Sample source code:C:\WINCE600\PUBLIC\COMMON\OAK\DRIVERS\USBFN\CONTROLLER\C:\WINCE600\PUBLIC\COMMON\OAK\DRIVERS\USBFN\CONTROLLER\MDD

MSDN reference:http://msdn.microsoft.com/en-ca/library/aa932645.aspx

Page 53: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

Function Controller Driver PDDFunction Controller Driver PDDPlatform dependent portion of the function controller driverFacilitates the presentation of an abstract USB function controllerSupports configuration of the USB function controllerPresents the USB protocol as an event systemProvides pipe access and maintain pipe-to-endpoint mapping3 S l d3 Sample source code:

C:\WINCE600\Platform\Common\Src\SOC\PXA27X_MS_v1\USBFNC:\WINCE600\Platform\Deviceemulator\Src\Drivers\USB\FunctionC:\WINCE600\Public\Common\OAK\Drivers\USBFN\Controller\Net2280

MSDN reference:htt // d i ft / /lib / 930557http://msdn.microsoft.com/en-ca/library/aa930557.aspx

Page 54: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

PDD Sample – S3C2410PDD Sample S3C2410

Simple and easy to understandp yRegistry under:

HKEY LOCAL MACHINE\Drivers\BuiltIn\SC2410USBFNHKEY_LOCAL_MACHINE\Drivers\BuiltIn\SC2410USBFN

Source under:C:\WINCE600\Platform\Deviceemulator\Src\Drivers\USB\FunctionC:\WINCE600\Platform\Deviceemulator\Src\Drivers\USB\Function

Sc2410pdd.h: register const definition Sc2410pdd cpp: the PDD source codeSc2410pdd.cpp: the PDD source code

Page 55: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

UfnPdd InitUfnPdd_Initstatic const UFN_PDD_INTERFACE_INFO sc_PddInterfaceInfo = {

UFN_PDD_INTERFACE_VERSION,UFN PDD CAPS SUPPORTS FULL SPEED

typedef struct CTRL_PDD_CONTEXT {PVOID pvMddContext;DWORD dwSig;HANDLE hIST;UFN_PDD_CAPS_SUPPORTS_FULL_SPEED,

ENDPOINT_COUNT,NULL, // This gets filled in later

&UfnPdd_Deinit,

HANDLE hIST;HANDLE hevInterrupt;BOOL fRunning;CRITICAL_SECTION csIndexedRegisterAccess;BOOL fSpeedReported;BOOL fRestartIST;_

&UfnPdd_IsConfigurationSupportable,&UfnPdd_IsEndpointSupportable,&UfnPdd_InitEndpoint,&UfnPdd_RegisterDevice,&UfnPdd DeregisterDevice

BOOL fRestartIST;BOOL fExitIST;BOOL attachedState;BOOL sendDataEnd;EP0_STATE Ep0State;

&UfnPdd_DeregisterDevice,&UfnPdd_Start,&UfnPdd_Stop,&UfnPdd_IssueTransfer,&UfnPdd_AbortTransfer,&Uf Pdd D i itE d i t

// registry DWORD dwIOBase;DWORD dwSysIntr;DWORD dwIrq;DWORD dwIOLen;

&UfnPdd_DeinitEndpoint,&UfnPdd_StallEndpoint,&UfnPdd_ClearEndpointStall,&UfnPdd_SendControlStatusHandshake,&UfnPdd_SetAddress,

;DWORD dwISTPriority;

USB_DEVICE_REQUEST udr;EP_STATUS rgEpStatus[ENDPOINT_COUNT];

&UfnPdd_IsEndpointHalted,&UfnPdd_InitiateRemoteWakeup,&UfnPdd_PowerDown,&UfnPdd_PowerUp,&UfnPdd IOControl

PFN_UFN_MDD_NOTIFY pfnNotify;HANDLE hBusAccess;CEDEVICE_POWER_STATE cpsCurrent;

} *PCTRLR_PDD_CONTEXT;……&UfnPdd_IOControl,

}; pContext = (PCTRLR_PDD_CONTEXT) LocalAlloc(LPTR, sizeof(*pContext));

Page 56: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

UfnPdd InitUfnPdd_InitMap the functions to the pointers in the UFN_PDD_INTERFACE_INFO structureAllocate and initialize the pContext

The context pointer holds all the status information for this instanceMap the registers into the context pointerMap the registers into the context pointer

Configure the USB controller register (and the attached USB transceiver register) to the appropriate modeg ) pp p

SpeedTransfer modeEndpoint numberEtc.

Page 57: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

Other FunctionsOther Functions

UfnPdd-DeinitDeinitialize the PDD – free the pContext pointer

UfnPdd-StartUfnPdd StartStart USB function device after the configuration has been completed – register and start the interruptbeen completed register and start the interrupt handler

UfnPdd-StopUfnPdd StopStop USB function device – stop the interrupt handler

Page 58: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

Other FunctionsOther FunctionsUfnPdd_IsConfigurationSupportable,UfnPdd IsEndpointS pportableUfnPdd_IsEndpointSupportable,UfnPdd_InitEndpoint,UfnPdd_RegisterDevice,Uf Pdd D i t D iUfnPdd_DeregisterDevice,UfnPdd_IssueTransfer,UfnPdd_AbortTransfer,UfnPdd_DeinitEndpoint,UfnPdd_StallEndpoint,UfnPdd_ClearEndpointStall,UfnPdd_SendControlStatusHandshake,UfnPdd_SetAddress,UfnPdd_IsEndpointHalted,UfnPdd_InitiateRemoteWakeup,UfnPdd_PowerDown,UfnPdd_PowerUp,UfnPdd_IOControl,

Page 59: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

USB MDD MessagesUSB MDD MessagesWhen device attaches/detaches, data arrives or after data has

f ll t t PDD tifi MDD th h tif tisuccessfully sent out, PDD notifies MDD through notify routine specified in UfnPdd-Init

pContext->pfnNotify = pMddInterfaceInfo->pfnNotify;y yThe following MDD message must be implemented in PDD to notify MDD

UFN MSG BUS EVENT : Attach or detach from host controller itUFN_MSG_BUS_EVENT : Attach or detach from host controller, it supports parameter UFN_ATTACH or UFN_DETACHUFN_MSG_BUS_SPEED: Notify to MDD the USB speed of operation. Can be BS HIGH SPEED or BS FULL SPEEDCan be BS_HIGH_SPEED or BS_FULL_SPEEDUFN_MSG_SETUP_PACKET: For Control Transfer when setup packet has been arrived. It passes the pointer to 8-byte data as a parameterUFN_MSG_TRANSFER_COMPLETE :Notify MDD the result of transfer after an IssueTransfer. It passes the parameter of Stransfer which contains the data received if any (OUT transaction) and the USB error it

treturns

Page 60: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

USB Function Driver TestingUSB Function Driver TestingCETK (WMTK)

Mainly to test USB Host controllerHas test cases for performance and stress N d t h CEPC (Wi d CE i PC) t t t itNeed to have a CEPC (Window CE running on PC) to test it

Windows Mobile LTKLTK3019: USB Soft DisconnectLTK3019: USB Soft DisconnectLTK3020: USB specification compliance

Passed the USB-IF USB Gold Tree integration test (Sec. D/E)g ( )Passed the USB-IF electrical level test (Sec. B)Etc.

LTK3030/3032: ActiveSync test casesLTK3030/3032: ActiveSync test casesLTK5060: Internet Sharing test cases

Page 61: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

USB Function Driver TestingUSB Function Driver Testing

Chapter 9 Test from USB.orgp ghttp://www.usb.org/developers/tools/USB-IF Test SuiteFor verifying USB Device Controller functionalityIt would switch the USB stack on your PC, connectingIt would switch the USB stack on your PC, connecting to your device and perform some test suites.There are many test suites available but most ycompanies would interest in chapter 9 test only

Page 62: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

USB Debug ToolsUSB Debug ToolsKITL Debugging

Debug build vs Retail buildUsing PB debugger to set breakpoint to debug!!

CE Kernel TrackerA way to view what happen to the slow down of your system

USB A lUSB AnalyzerLook at your data on USB BusLeCroy USB analyzer and Ellisys USB ExplorerLeCroy USB analyzer and Ellisys USB Explorer

Page 63: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

获取更多MSDN资源获取更多 资源• MSDN中文网站

http://msdn2.microsoft.com/zh‐cn• MSDN中文网络广播

http:// www.microsoft.com/china/msdn/webcast• MSDN中文网络广播课程预告邮件• MSDN中文网络广播课程预告邮件

http://www.microsoft.com/china/msdn/WebcastNewsletter/• MSDN免费中文速递邮件 (MSDN Flash) 

htt // d 2 i ft / h /fl hhttp://msdn2.microsoft.com/zh‐cn/flash• MSDN开发中心

http://msdn2 microsoft com/zh‐cn/developercentershttp://msdn2.microsoft.com/zh cn/developercenters• MSDN图书中心

http://www.microsoft.com/china/msdn/book主页• iReaper主页

http://www.codeplex.com/iReaper

Page 64: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System

Question & Answer

如需提出问题,请在此区域输入文字,并单击“问题和解答”右上方的“提问”按钮即可。

您也可以选择在微软中文技术论坛上寻求帮助,MSDN中文网络广播的讲师们会定期在论坛上为大家解答与课程相关的技术问题。http://forums microsoft com/chinahttp://forums microsoft com/chinahttp://forums.microsoft.com/chinahttp://forums.microsoft.com/china

Page 65: Webcast CE 6 USB Function - pudn.comread.pudn.com/downloads182/doc/854396/winCE6-USB.pdfthe Year (2002 x 2 2007 2008)the Year (2002 x 2, 2007, 2008) ¾Microsoft MEDC 2007 - System