USB Device Driver

download USB Device Driver

of 25

Transcript of USB Device Driver

  • 8/17/2019 USB Device Driver

    1/25

    USB Device Driver

    www.vjece.blogspot.in

    - Vijay Selva. G

    Embedded Daemonswww.vjece.blogspot.in

    http://www.vjece.blogspot.in/http://www.vjece.blogspot.in/

  • 8/17/2019 USB Device Driver

    2/25

    Sequence

    • ost  !arget USB Device "eset# $ddress % &

    • ost  Send "equest 'or (a) *ac+etSi,e # Endpoint % & Get Descriptor(Device)

    • Device "eset $gain Set $ddressrequest.

    • Get Device Descriptor Get/on0guration Descriptor Get String

    Descriptor /ommandsEmbedded Daemonswww.vjece.blogspot.in

  • 8/17/2019 USB Device Driver

    3/25

    Sequence

    • 1nce all 2n'o about Device isobtained loads suitable DEV2/ED"2VE"

    • Set /on0guration request to t3edevice 45 DD

      DEVICE IS IN ADDRESSED & CONFIGUREDSTATE

    •  "esponds to device speci0c requests

    • Device Starts wor+ing as it is

    designed 'or. Embedded Daemonswww.vjece.blogspot.in

  • 8/17/2019 USB Device Driver

    4/25

    1ne /on0gurationDescriptor Set

    Embedded Daemonswww.vjece.blogspot.in

  • 8/17/2019 USB Device Driver

    5/25

    Descriptors /on0gurations2nter'aces

    Descriptors 7 De0nes Device /apability• (any possible con0gurations 'or a device

    • 8or e)ample to speci'y di9erent current requirements as t3ecurrent required is de0ned in t3e con0guration descriptor.

    • Similarly many 2nter'aces Eac3 Interface can 3ave

    a number o' endpoints and represents a 'unctional unitbelonging to a particular class.

    • Eac3 Enpoint is a source or sin+ o' data.• 8or e)ample a V12* p3one mig3t 3ave one audio class inter'ace

    wit3 : endpoints 'or trans'erring audio in eac3 direction plus a 2D

    inter'ace wit3 a single 2; interrupt endpoint 'or a built in +eypad.• 2t is also possible to 3ave alternative versions o' an inter'ace and

    t3is is more common t3an multiple con0gurations. 2n t3e V12*p3one e)ample t3e audio class inter'ace mig3t o9er an alternativewit3 a di9erent audio rate. 2t is possible to switc3 an inter'ace to analternate w3ile t3e device remains con0gured.

    Embedded Daemonswww.vjece.blogspot.in

  • 8/17/2019 USB Device Driver

    6/25

    SE!U* *ac+et

    Embedded Daemonswww.vjece.blogspot.in

  • 8/17/2019 USB Device Driver

    7/25

    /ontrol !rans'ers

    • /ontrol Endpoint #E* %& trans'ers all standard "equests  /ontrol !rans'ers

    • /ontrol !rans'er starts wit3 Setup !ransaction 5 < Bytes

    •  Structure o' bm"equest!ype ma+es to use it to switc3 on

    w3en your 0rmware is trying to interpret t3e setup request.•  Essentially w3en t3e SE!U* arrives you need to branc3 to

    t3e 3andler 'or t3e particular request so 'or e)ample bits=7> allow you to distinguis3 t3e mandatory standardcommands 'rom any class or vendor commands you may

    3ave implemented 'or you particular device.• Switc3ing on bit ? allows you to deal wit3 2; and 1U!

    direction requests in separate areas o' t3e code.

    Embedded Daemonswww.vjece.blogspot.in

  • 8/17/2019 USB Device Driver

    8/25

    Stanar Re!"ests

    Embedded Daemonswww.vjece.blogspot.in

  • 8/17/2019 USB Device Driver

    9/25

    Get Descriptor

    Embedded Daemonswww.vjece.blogspot.in

  • 8/17/2019 USB Device Driver

    10/25

    Embedded Daemonswww.vjece.blogspot.in

  • 8/17/2019 USB Device Driver

    11/25

    Set $ddress•

    $'ter Get Descriptor Device is "eset again.• SE!@$DD"ESS is a simple outward direction

    request in a control trans'er wit3 no data stage butit carries required address.

    • A3en implementing t3is request in 0rmware yous3ould note t3e 'ollowing. $ll ot3er requests mustbe actioned be'ore t3e status stage in completed.But in t3e case o' SE!@$DD"ESS you s3ould notc3ange t3e device address until after t3e status

    stage. !3e status stage will not succeed unless t3edevice is still responding to address % w3ile it ista+ing place. !3e device t3en 3as :ms to get readyto respond to t3e new address.

    Embedded Daemonswww.vjece.blogspot.in

  • 8/17/2019 USB Device Driver

    12/25

    Di9erent Stages o' Aor+ing !3e device can be in one o' t3ree states w3ic3 determine w3et3er a particular

    request is valid at t3e time.

    Defa"#t –$'ter reset but be'ore receiving Set $ddress.

     –2n t3e De'ault state t3e only valid requests are Get Descriptor and Set $ddress.

    Aresse

    •$'ter t3e device 3as been assigned an address via Set $ddress.

    ;ow t3e device must recogni,e t3e 'ollowing additional requests7

     –Set /on0guration

     –Get /on0guration –Set 8eature

     –/lear 8eature

     –Get Status

     –Set Descriptor optionalC

    Con$%"re

    •$'ter t3e 3ost 3as sent Set /on0guration wit3 a non-,ero value to select a con0guration. !3e

    device is now operational.•2n t3e /on0gured state only Set $ddress is not a valid request. !3ree 'urt3er requests arerestricted to /on0gured state only7

     –Get 2nter'ace

     –Set 2nter'ace

     –Sync3 8rame

    Embedded Daemonswww.vjece.blogspot.in

  • 8/17/2019 USB Device Driver

    13/25

    A3at a'ter Get Descriptorrequest

    • ;ot only /on0guration Descriptorot3er descriptors li+e – 2nter'ace Descriptor

     – Endpoint Descriptor

     – 1!G Descriptor

     – /lass-speci0c Descriptors

     – Vendor-speci0c Descriptors are alsoobtained.

    Embedded Daemonswww.vjece.blogspot.in

  • 8/17/2019 USB Device Driver

    14/25

    /on0guration Descriptor

    Embedded Daemonswww.vjece.blogspot.in

  • 8/17/2019 USB Device Driver

    15/25

    2nter'ace Descriptor

    By de0ning t3e class subclass and protocol in t3e inter'aceit is possible to 3ave inter'aces wit3 di9erent classes in t3e same device.

     !3is is re'erred to as a coposite device

    Embedded Daemonswww.vjece.blogspot.in

  • 8/17/2019 USB Device Driver

    16/25

    Endpoint Descriptor

    Embedded Daemonswww.vjece.blogspot.in

  • 8/17/2019 USB Device Driver

    17/25

    Device Descriptor String

    •  !3e strings de0ned in t3e device descriptor7 – (anu'acturer String

     – *roduct String

     – Serial ;umber String

    • Get Descriptor StringC wit3 a descriptor inde) o' % in t3e lowbyte o' wValue is used to 'etc3 a special string languagedescriptor. !3is contains a series o' :-byte si,ed languagespeci0ers. 2n t3eory i' t3e language o' your c3oice issupported in t3is list you can use t3e inde) to t3is language 2D

    to access t3e string descriptors in t3is language by speci'yingt3is in w2nde) o' t3e Get Descriptor StringC request. 2npractice wit3 Aindows you will 3ave diculties i' you do notensure t3at t3e 0rst language speci0ed is Englis3 USC.

    Embedded Daemonswww.vjece.blogspot.in

  • 8/17/2019 USB Device Driver

    18/25

    Embedded Daemonswww.vjece.blogspot.in

  • 8/17/2019 USB Device Driver

    19/25

    SE! /1;82GU"$!21;• A3en t3e 3ost 3as got all t3e in'ormation it requires it loads a

    driver 'or t3e device based on t3e V2D*2D combination in t3edevice descriptor or on t3e standard class de0ned t3ere or inan inter'ace descriptor.

    • Eventually it will decide to confgure t3e device using t3e

    SE!@/1;82GU"$!21; request. Usually w3en t3ere is onecon0gurationC t3e Set /on0guration request will 3ave wValueset to F w3ic3 will select t3e 0rst con0guration.

    • Set /on0guration can also be used wit3 wValue set to % todecon0gure t3e device.

    GET'CONFIGURATION

    •  !3is request compliments Set /on0guration and simply allowst3e 3ost to determine w3ic3 con0guration it previously set.

    Embedded Daemonswww.vjece.blogspot.in

  • 8/17/2019 USB Device Driver

    20/25

    $ /on0gured Device

    • 1nce a device 3as been con0gured it is allowed to respond toot3er trans'er types t3an /ontrol trans'ers.

    • $s we 3ave seen t3e ot3er trans'er types are

    • 2nterrupt !rans'ers

    Bul+ !rans'ers• 2soc3ronous !rans'ers

    • $s a result o' t3e in'ormation in t3e descriptors t3e 3ost willnow +now w3at particular trans'ers on w3ic3 particularendpoints t3e device is prepared to support. !3ere may nowalso be new class or vendor-speci0c requests w3ic3 may nowbe supported on t3e control endpoint in addition to t3estandard requests.

    • 2t is all t3ese additional trans'ers w3ic3 per'orm t3e'unctionality t3at t3e device was designed 'or.

    Embedded Daemonswww.vjece.blogspot.in

  • 8/17/2019 USB Device Driver

    21/25

    SE! /E$" 8E$!U"E

    •  !3is pair o' requests is used tocontrol a small number o' on-o9'eatures on a device an inter'ace oran endpoint.

    • $ device 3as > possible 'eatures anendpoint 3as one and an inter'ace

    actually 3as none at all.•  !3e grayed out 'eatures s3own in

    t3e table only apply to 1!G devices.

    ENDOINT'A*T – Setting t3is 'eature will cause an

    endpoint to S!$ any 2; or 1U!transactions.

    DEVICE'RE+OTE',A-EU – Setting t3is 'eature allows a device

    w3ic3 is t3en suspended to use res"esignalling to gain t3e 3ostHs attention.

    Embedded Daemonswww.vjece.blogspot.in

  • 8/17/2019 USB Device Driver

    22/25

    GE! S!$!US

    •  !3is request is used to 'etc3status bits 'rom a device aninter'ace or an endpoint. 2neac3 case t3e request'etc3es F= bits : bytesC. !3e

    tables to t3e rig3t s3ow t3estatus bits w3ic3 arecurrently implemented.

    • ;ote t3at "emote Aa+eupand alt status bits can bot3

    be controlled by t3e 3ostusing Set./lear 8eaturerequests but t3e Sel'-powered bit is only controlledby t3e device.

    Embedded Daemonswww.vjece.blogspot.in

  • 8/17/2019 USB Device Driver

    23/25

    ;e)t Sequence /ommands

    SET'INTERFACE . GET'INTERFACE – 1nce a device 3as been con0gured t3e 3ost may use Set

    2nter'ace to select an alternative inter'ace to a particularde'ault inter'ace. 2t can use t3e Get 2nter'ace to determinew3ic3 inter'ace alternative it previous set 'or a particular

    inter'ace.

      S/NC'FRA+E – !3is is used wit3 some isoc3ronous trans'er w3ere t3e

    trans'er si,e varies wit3 t3e 'rame. See USB :.% speci0cation'or more details.

      SET'DESCRITOR – !3is Standard request is optional and not o'ten used. 2t allows

    t3e 3ost to speci'y a new set o' values 'or a given descriptor.2t is 3ard to imagine w3en t3is mig3t be o' value.

    Embedded Daemonswww.vjece.blogspot.in

  • 8/17/2019 USB Device Driver

    24/25

    USB Device Driver 1S! /1DE ininu)

     !arget */:FI< - $"( ?$rc3itecture/1DE wal+t3roug3 in inu)

    USB DEV2/E D"2VE" DE(1

    Embedded Daemonswww.vjece.blogspot.in

  • 8/17/2019 USB Device Driver

    25/25

     !3an+ Jou Daemons

    Embedded Daemonswww vjece blogspot in