Date post: | 07-Jul-2015 |
Category: |
Technology |
Upload: | lloydmoore |
View: | 822 times |
Download: | 3 times |
Using the PSoC USBUsing the PSoC USB
March 17, 2012March 17, 2012Lloyd Moore, President/OwnerLloyd Moore, President/Owner
OverviewOverview
USB BackgroundUSB Background USB Standard ClassesUSB Standard Classes Endpoints and Transfer TypesEndpoints and Transfer Types Enumeration Enumeration USB DescriptorsUSB Descriptors Example ProjectExample Project
USB BackgroundUSB Background
Star topology, master / slave architectureStar topology, master / slave architecture• Host is the master, initiates all communicationsHost is the master, initiates all communications
Multiple speeds: Low=1.5Mbps, Full=12 Multiple speeds: Low=1.5Mbps, Full=12 Mbps, High=480Mbps, Super=5GbpsMbps, High=480Mbps, Super=5Gbps
Self powered vs. Bus poweredSelf powered vs. Bus powered• Low power: 100mA or 150mA Max (USB 2,3)Low power: 100mA or 150mA Max (USB 2,3)• High power: 500mA or 900mA Max (USB 2,3)High power: 500mA or 900mA Max (USB 2,3)
Vendor Id, Product Id, serial number Vendor Id, Product Id, serial number uniquely identify each deviceuniquely identify each device
Standard USB ClassesStandard USB Classes Used to define the Used to define the
USB device.USB device. Standardizes Standardizes
protocols and protocols and drivers for drivers for common devices.common devices.
Allows operating Allows operating systems to systems to provide default provide default drivers.drivers.
Can also create Can also create vendor specific vendor specific classes for custom classes for custom applications. applications.
AudioAudio Speakers, microphone, Speakers, microphone, MIDIMIDI
Communication (CDC)Communication (CDC) Virtual Serial Port, modem, Virtual Serial Port, modem, EthernetEthernet
Content SecurityContent Security File and resource accessFile and resource access
Firmware Upgrade (DFU)Firmware Upgrade (DFU) Device software upgradesDevice software upgrades
Human Interface (HID)Human Interface (HID) Keyboards, mice, joysticks, Keyboards, mice, joysticks, barcode scanners, UPSbarcode scanners, UPS
IrDA BridgeIrDA Bridge IR communicationsIR communications
Mass StorageMass Storage Hard drives, DVD, flash Hard drives, DVD, flash memorymemory
Personal HealthcarePersonal Healthcare Heart rate, blood pressure, Heart rate, blood pressure, glucose meters, ect.glucose meters, ect.
PrinterPrinter Printers – ya that simple!Printers – ya that simple!
Smart CardSmart Card Phone cards, keyless entryPhone cards, keyless entry
Still Image CaptureStill Image Capture Cameras, scannersCameras, scanners
Test & MeasurementTest & Measurement ADC, DAC, sensors, etc.ADC, DAC, sensors, etc.
VideoVideo Video cameras, web camsVideo cameras, web cams
EndpointsEndpoints
Uniquely addressable portion of a USB device. Uniquely addressable portion of a USB device. 4 end points max for a low speed device, 16 for 4 end points max for a low speed device, 16 for
other speedsother speeds End point 0 is special, must be present and is End point 0 is special, must be present and is
used for enumeration and controlused for enumeration and control Data transfer happens at end points. Data transfer happens at end points. Simplest way to think about an end point is that Simplest way to think about an end point is that
it provides an addressable buffer to send and it provides an addressable buffer to send and receive data.receive data.
IN refers to dataflow TO the HostIN refers to dataflow TO the Host OUT refers to dataflow FROM the HostOUT refers to dataflow FROM the Host
Transfer TypesTransfer Types
Type Guarantees Typical Use
ControlControl Presence,Presence,
Error FreeError FreeDevice id and Device id and configurationconfiguration
BulkBulk Error FreeError Free Printer, hard Printer, hard drivedrive
InterruptInterrupt LatencyLatency
Error FreeError FreeKeyboard, Keyboard, mousemouse
IsochronousIsochronous Delivery rateDelivery rate Streaming Streaming audio & videoaudio & video
EnumerationEnumeration
Process by which the host discovers what devices Process by which the host discovers what devices are connected and the properties of those are connected and the properties of those devices. devices.
Utilizes a series of resets and Control transfers to Utilizes a series of resets and Control transfers to end point 0. end point 0.
Each device given a unique address between 1 Each device given a unique address between 1 and 127. and 127.
Power and bandwidth requirements are collected Power and bandwidth requirements are collected and allocated.and allocated.• Device will not be “connected” if resources are not Device will not be “connected” if resources are not
available.available. Communication details collected by way of Communication details collected by way of
“descriptors”“descriptors”
DescriptorsDescriptors
Data structures which allow the host to Data structures which allow the host to learn about a device and how to learn about a device and how to communicate with it. communicate with it.
Essentially a language which defines the Essentially a language which defines the protocol between the host and each protocol between the host and each device.device.
Can be quite complex but standard Can be quite complex but standard descriptors are well defined. descriptors are well defined.
Standard device drivers can interpret Standard device drivers can interpret these for a wide range of devices. these for a wide range of devices.
Example ProjectExample Project Configure a PSoC 5 to send data from the Configure a PSoC 5 to send data from the
CapSense buttons and slider to a PC in the CapSense buttons and slider to a PC in the form of a joystick.form of a joystick.
Will be using the CY8CKIT-001, and PSoC Will be using the CY8CKIT-001, and PSoC Creator 1.0 for this demo.Creator 1.0 for this demo.• Upgraded LCD display Lumex LCM-S02004DSRUpgraded LCD display Lumex LCM-S02004DSR• If using PSoC Creator 2.0 will also need to add If using PSoC Creator 2.0 will also need to add
24Mhz crystal to bottom of processor module 24Mhz crystal to bottom of processor module due to a tighter clock requirement.due to a tighter clock requirement.
Data will be shown on LCD as well as sent Data will be shown on LCD as well as sent to PC. to PC.
Will be using a “canned” set of code as the Will be using a “canned” set of code as the configuration is pretty time consuming.configuration is pretty time consuming.
Hardware ConfigurationHardware Configuration
DebugLcd used to control the LCD displayDebugLcd used to control the LCD display CapSense will run the CapSense buttons CapSense will run the CapSense buttons
and slider control for inputand slider control for input• Heavy filtering here as the demo board USB Heavy filtering here as the demo board USB
spews lots of noise to CapSense when running.spews lots of noise to CapSense when running. USBFS – USB 2.0 Full Speed driver, will USBFS – USB 2.0 Full Speed driver, will
configure this to be a Joystick HID device configure this to be a Joystick HID device to send information to the PC.to send information to the PC.
Device DescriptorDevice Descriptor
Walkthrough live configuration of Walkthrough live configuration of descriptor.descriptor.
Clock ConfigurationClock Configuration
IMO = 24.000 MHz
USB = IMOx2
ILO = 100KHz
USB Initialization CodeUSB Initialization Code
USBFS_Start() configures the USBFS_Start() configures the hardwarehardware
Next we wait while the USB device Next we wait while the USB device goes through enumerationgoes through enumeration
Finally prepare the first set of data to Finally prepare the first set of data to be dropped to the host when be dropped to the host when requestedrequested
Main LoopMain Loop
General operational pattern is to wait for General operational pattern is to wait for Host to grab data currently at the end Host to grab data currently at the end point, then replace it.point, then replace it.
USBFS_bGetEPAckState() waits for grabUSBFS_bGetEPAckState() waits for grab USBFS_LoadInEP() loads next batch of USBFS_LoadInEP() loads next batch of
data to be grabbed by the hostdata to be grabbed by the host
ResourcesResources Book: USB Complete, Fourth EditionBook: USB Complete, Fourth Edition
• Jan AxelsonJan Axelson• ISBN: 978-1-931448-08-6ISBN: 978-1-931448-08-6
PSoC Application notes: AN57294, AN57473, AN58726PSoC Application notes: AN57294, AN57473, AN58726 PSoC Product Web Site:PSoC Product Web Site:
• http://www.cypress.com/?id=1353http://www.cypress.com/?id=1353 PSoC Developer Community:PSoC Developer Community:
• http://www.psocdeveloper.com/forums/http://www.psocdeveloper.com/forums/ PSoC Training On Demand:PSoC Training On Demand:
• http://www.cypress.com/traininghttp://www.cypress.com/training PSoC Full Development Kit (1, 3, 5): $249PSoC Full Development Kit (1, 3, 5): $249
• http://www.cypress.com/?rID=37464http://www.cypress.com/?rID=37464 My Contact Info: My Contact Info:
• [email protected]@CyberData-Robotics.com• http://www.CyberData-Robotics.comhttp://www.CyberData-Robotics.com
Questions????Questions????
Will be around a bit after the Will be around a bit after the meeting for individual questionsmeeting for individual questions
Feel free to e-mail meFeel free to e-mail me