Universal Serial Bus (USB)

is a high-speed wired communication standard used to connect peripheral devices (keyboard, mouse, printer, flash drive) to a computer or other electronic devices.

  • Developed in: 1995
  • By: Intel, Microsoft, IBM, and other tech companies

1. Key Features

FeatureDescription
Host ControllerHardware + software in PC to control USB
Master-Slave ProtocolHost controls all communication
ExpandableMultiple devices can be connected via hubs
Plug & PlayNo manual configuration needed

2. USB Power Delivery (USB PD)

USB PD is a technology that allows higher power to be delivered through a USB cable. It also supports bi-directional power flow – power can go both ways between devices.

How USB Detects a Device

  • A device must pull D+ or D– HIGH to 3.3V using a pull-up resistor
  • This tells the host/hub that a device is connected
  • No pull-up resistor → USB assumes nothing is connected

Pull up registor

┌─────────────────────────────┐
│       USB Controller Chip    │
│  ┌─────────────────────┐    │
│  │  Pull-up Resistor   │    │
│  │  (1.5 kΩ)           │    │
│  └─────────────────────┘    │
│         │                    │
│    ┌────┴────┐              │
│    │         │              │
│   D+        D-              │
└─────────────────────────────┘
         │         │
         ▼         ▼
    Connected to Host via USB Cable

User plugs in device
        ↓
Device gets +5V power
        ↓
Pull-up resistor that build in USB pulls D+ or D– HIGH (3.3V)
        ↓
Host checks D+ / D– lines
        ↓
   ┌────┴────┐
   │         │
 D+ HIGH   D– HIGH   → Low Speed Device
 (Full/Hi-Speed)
   │         │
   └────┬────┘
        ↓
Host sends Reset (D+ & D– LOW for 10ms)
        ↓
Device is ready to communicate

3 Examples of USB

3.1 Example 1: Charging Low-Power Peripherals

ItemDetails
ConnectionLaptop connected to AC adapter + Speaker connected to laptop via USB
What HappensLaptop provides power to the speaker through the USB port
Use CaseCharging or powering small devices like speakers, headphones, smartphones

Simple: Laptop acts as a power source for small devices.


3.2 Example 2: Docking Station Power Delivery

ItemDetails
ConnectionAC adapter connected to Docking Station → Docking Station to Laptop via single USB-C cable
What HappensDocking Station provides power AND data to the laptop through one cable
Use CaseNo separate charger needed for laptop – all through one USB-C cable

Simple: One cable from docking station charges the laptop and connects all peripherals.

3.3 Example 3: Powering High-Draw External Storage

ItemDetails
ConnectionLaptop on AC power + External HDD/SSD connected via USB-C
What HappensLaptop provides enough power to run the external drive
Use CaseHigh-power devices like NVMe enclosures or external hard drives run without separate power adapters

Simple: USB-C provides enough power to run external hard drives – no extra plug needed.


3.4 Example 4: Bi-Directional Monitor Charging & Display

ItemDetails
ConnectionMonitor connected to wall outlet + Laptop connected to Monitor via single USB-C cable
What HappensOne cable does TWO things:
1. Video data from laptop → Monitor (display)
2. Power from Monitor → Laptop (charges laptop)
Use CaseMonitor charges laptop while showing the display – no separate charger needed

3.5 USB On-the-Go (OTG)

Normal: Computer is the host – you connect mouse, keyboard, pen drive to it.

With OTG: Your smartphone or tablet becomes the host!

How it works:

  • Use an OTG adapter to connect pen drives, keyboard, mouse, or even a 3D scanner directly to your phone
  • Your phone can read files from the pen drive
  • Your phone can also act like a pen drive when connected to a computer

Examples:

  • Phone + USB mouse = Desktop-like experience
  • Phone + Pen drive = Copy files directly
Observed Damage in Macul and Ñuñoa
Types of USB

3.5 Advantages

AdvantageDescription
Single InterfaceOne port connects many devices
Auto ConfigurationNo DIP switches or IRQ settings needed
Hot-PluggingConnect/disconnect while computer is ON
Low CostCheap to produce and use
Power SupplyProvides power to devices (no extra adapter needed)
High SpeedUSB 3.0: 5 Gbps, USB4: 40 Gbps

Limitations

LimitationDescription
SpeedSlower than Gigabit Ethernet
No Peer-to-PeerTwo hosts or two peripherals cannot talk directly
DistanceMax cable length: 5 meters (USB 2.0)
No BroadcastingOnly host-to-peripheral messages, no broadcast

USB Versions & Speeds

VersionMax SpeedName
USB 1.01.5 / 12 MbpsLow/Full-Speed
USB 2.0480 MbpsHi-Speed
USB 3.05 GbpsSuperSpeed
USB 3.110 GbpsSuperSpeed+
USB 3.220 GbpsSuperSpeed+
USB440 GbpsUSB4

Cable Length Limits

VersionMax Length
USB 1.0/1.13 meters
USB 2.05 meters
USB 3.03 meters

For longer distances, USB hubs are needed.


USB Connector Types

ConnectorShapeUsed In
Type-ARectangularComputers, chargers
Type-BSquarePrinters, scanners
Type-COval, reversibleModern phones, laptops
Micro-USBSmall, flatOld phones, tablets
Mini-USBSmall, oldOld cameras, MP3 players

USB Connector Pinouts

1. USB Type A and Type B (4 Pins) USB 2.0

Type A: Flat port (computers, pen drives)
Type B: Square port (printers, scanners)

PinSignalWire ColorFunction
1VccRed+5V Power
2D–WhiteData Negative
3D+GreenData Positive
4GNDBlackGround

1.2. Key Points

  • USB uses 4 shielded wires:

    • 2 for power (+5V and GND)
    • 2 for differential data (D+ and D–)
  • D+ and D– work together (not separate connections)

  • Twisted pair used to reduce noise

  • Half-duplex – data flows in one direction at a time

Observed Damage in Macul and Ñuñoa
pinout
Observed Damage in Macul and Ñuñoa
pinout

2. Mini B Pinout (5 Pins) USB 2.0

Used in: Old phones, MP3 players, portable hard drives, digital cameras

PinSignalWire ColorFunction
1VccRed+5V Power
2D–WhiteData Negative
3D+GreenData Positive
4IDN/AOTG ID – tells device if it is Host or Peripheral
5GNDBlackGround
Observed Damage in Macul and Ñuñoa
pinout
Observed Damage in Macul and Ñuñoa
pinout

3. Micro A & Micro B Pinout (5 Pins) USB 2.0

Micro B: Used in most Android phones before USB-C
Micro A: Completely rectangular shape

PinSignalWire ColorFunction
1VccRed+5V Power
2D–WhiteData Negative
3D+GreenData Positive
4IDN/AOTG ID – enables Host mode
5GNDBlackGround
Observed Damage in Macul and Ñuñoa
pinout
Observed Damage in Macul and Ñuñoa
pinout

4. Type A and B USB 3.0

USB 3.0 (SuperSpeed) is the third generation of USB. It is 10 times faster than USB 2.0.

4.1 USB 2.0 vs USB 3.0 – Key Difference

FeatureUSB 2.0USB 3.0 (SuperSpeed)
Data FlowHalf-Duplex (one way at a time)Full-Duplex (both ways at once)
Speed480 Mbps5 Gbps (10x faster)
Pins49
Separate TX/RXNoYes (Transmit + Receive lines)

4.2 Why 9 Pins?

USB 3.0 is backward compatible – it works with USB 2.0 devices too.

PartPinsPurpose
Front / Top4 pinsUSB 2.0 (Power, Data+, Data–, Ground)
Back / Bottom5 pinsSuperSpeed (Transmit, Receive, Ground)

4.3 Type A SuperSpeed (Blue Flat Port)

Top 4 Pins (USB 2.0):

PinSignalFunction
1VCC+5V Power
2D–Data Negative
3D+Data Positive
4GNDGround

Bottom 5 Pins (SuperSpeed):

PinSignalFunction
5SSRX–Receive Negative
6SSRX+Receive Positive
7GND_DRAINSignal Ground
8SSTX–Transmit Negative
9SSTX+Transmit Positive

4.4 Type B SuperSpeed

Used in: External hard drives, high-speed printers, drive enclosures

Top Part (USB 2.0):

  • 4 pins: Power, Data+, Data–, Ground

Bottom Extra Part (SuperSpeed):

  • 5 pins: Transmit (+/–), Receive (+/–), Ground

Shape: Looks like USB 2.0 Type-B but taller (has extra bump on top)

Observed Damage in Macul and Ñuñoa
pinout
Observed Damage in Macul and Ñuñoa
pinout

4.4 USB 3.0 Micro-B

Observed Damage in Macul and Ñuñoa
pinout
Observed Damage in Macul and Ñuñoa
pinout

Why is it Wider?

USB 2.0 Micro-B had only 5 pins. For SuperSpeed, 5 extra pins were needed. So the connector was made wider to fit them.

USB 2.0 Micro-B:     ████████ (Narrow)
USB 3.0 Micro-B:     ████████████ (Wider, two-part)

Pinout (10 Pins)

PinSignalFunction
1VCC+5V Power
2D–USB 2.0 Data Negative
3D+USB 2.0 Data Positive
4IDOTG Detection
5GNDGround (USB 2.0)
6SSTX–SuperSpeed Transmit Negative
7SSTX+SuperSpeed Transmit Positive
8GND_DRAINSignal Ground
9SSRX–SuperSpeed Receive Negative
10SSRX+SuperSpeed Receive Positive
Observed Damage in Macul and Ñuñoa
pinout

4.5 USB Type-C 3.0

Flippable (Reversible) Design

Biggest advantage: You can plug it in any way – upside down or right side up – it works!

Old USB Type-AUSB Type-C
One direction onlyAny direction
Can damage port if forcedCompletely safe
Annoying to useEasy and convenient
Observed Damage in Macul and Ñuñoa
pinout

5. USB4 Architecture


Three Layers of USB4

┌─────────────────────────────────┐
│     Application Layer           │
│  (Protocol Tunneling & Routing) │
└───────────────┬─────────────────┘
                │
┌───────────────▼─────────────────┐
│     Protocol Layer              │
│  (Packet Creation & Exchange)   │
└───────────────┬─────────────────┘
                │
┌───────────────▼─────────────────┐
│     Physical Layer              │
│  (Data Transmission)            │
└───────────────┬─────────────────┘
                │
    ┌───────────┼───────────┐
    │           │           │
┌───▼───┐ ┌───▼───┐ ┌───▼───┐
│USB 3.x│ │Display│ │ PCIe  │
│ Data  │ │ Port  │ │ Data  │
└───────┘ └───────┘ └───────┘
Observed Damage in Macul and Ñuñoa
pinout

Layer 1: Application Layer

FunctionDescription
Protocol TunnelingCarries USB 3.x, DisplayPort, and PCIe data together
RoutingSends data to the correct destination

Layer 2: Protocol Layer

FunctionDescription
Packet CreationCreates data packets to send
Packet ExchangeManages sending and receiving of packets

Layer 3: Physical Layer

FunctionDescription
Data TransmissionActually sends data through the cable

5.1 What Flows Through USB4?

USB4 can carry three types of data at the same time:

ProtocolCarries
USB 3.xRegular data (files, etc.)
DisplayPortVideo signals (to monitors)
PCIeHigh-speed data (to external GPU, SSD)

5.2 USB4 – Questions and Answers

Q1: What is Protocol Tunneling?

Answer: When devices communicate, they use a protocol. Protocol Tunneling creates a “pipe” using one protocol and sends data of another protocol through it.

USB4 Protocol Tunneling: Creates a USB-C tunnel to send DisplayPort or PCIe data. It is similar to Alt Mode but does not require a separate DP or PCIe controller.


Q2: What is USB4 Fabric?

Answer: The word “fabric” describes a network of interconnected nodes (like switches). When drawn, the crisscross pattern looks like woven cloth.

USB4 Fabric: Dynamically manages connections between USB4 routers so multiple protocols can share resources at the same time.


Q3: Will Apple Support USB4?

Answer: Yes. Apple’s new MacBooks and Mac Mini with Apple Silicon (M1, M2, M3) support both USB4 and Thunderbolt 3.

6. USB Architecture


6.1. Does USB-C Support USB 2.0?

QuestionAnswer
What is USB-C?A physical connector shape (not a speed standard)
Can USB-C support USB 2.0?YES – Many cheap USB-C cables only give 480 Mbps (USB 2.0 speed)
Can USB-C do video?Only if the cable supports Alt Mode or higher speed

Key Point: USB-C is just the plug shape. The speed depends on the technology inside!


6.2. USB Architecture – Tiered-Star Topology

ComponentRole
HostOnly one host (computer) – controls everything
Root HubBuilt into the host – gives USB ports
FunctionDevices like mouse, printer, scanner
Observed Damage in Macul and Ñuñoa
pinout

6.3. Upstream & Downstream Connections

ConnectionPurpose
UpstreamConnects up to the host or higher hub (only 1 per hub)
DownstreamConnects down to devices or lower hubs (up to 7 per hub)
Observed Damage in Macul and Ñuñoa
pinout

7. USB Host Controllers and Endpoints


7.1. Host Controllers

Host controllers are the hardware inside your computer that manage USB communication. A software layer called HCD (Host Controller Device) helps the OS talk to this hardware.

Types of Host Controllers:


1. OHCI (Open Host Controller Interface)

FeatureDetails
Made byCompaq, Microsoft, National Semiconductor
ForUSB 1.0 and USB 1.1
SpeedLow Speed and Full Speed
TypeHardware-oriented (does more work in hardware, less CPU load)

2. UHCI (Universal Host Controller Interface)

FeatureDetails
Made byIntel
ForUSB 1.0 and USB 1.1
SpeedLow Speed and Full Speed
TypeSoftware-oriented (needs license from Intel, uses more CPU)

3. EHCI (Extended Host Controller Interface)

FeatureDetails
Made byUSB-IF (all companies together)
ForUSB 2.0 (High Speed)
SpeedHandles High Speed itself
SpecialPasses Low/Full Speed to OHCI or UHCI (companion controllers)

4. VHCI (Virtual Host Controller Interface)

FeatureDetails
What is it?Not real hardware – a virtual controller
UseShows virtual USB devices not physically connected
ExampleOn Linux, used to access USB devices from other computers via USB/IP protocol

5. USB4 Host Interface

FeatureDetails
What is it?Latest and most advanced host interface
ManagesUSB, DisplayPort, PCI Express, Thunderbolt, and Host-to-Host communication
BenefitOne system handles everything together

7.2. Endpoints

Endpoints are small memory buffers (storage areas) inside a USB device where data is temporarily stored.

Observed Damage in Macul and Ñuñoa
pinout

7.2.3 Key Points:

FeatureExplanation
DirectionSame endpoint number can have IN (host receives) and OUT (host sends) directions
IN / OUTAlways from host’s perspective
Endpoint 0The default endpoint – always active when a device is first plugged in

7.2.4 Endpoint 0 – The First Contact

StepWhat Happens
1. Plug inDevice connected to computer
2. Endpoint 0 activeOnly this endpoint works at first
3. EnumerationHost asks: “Who are you? What is your name, brand, type?”
4. Identity confirmedHost learns about the device
5. Other endpoints openNow endpoints like 1, 2, etc. become active for data transfer

7.2.5 Example: USB Printer

EndpointDirectionPurpose
Endpoint 0IN / OUTEnumeration (initial setup)
Endpoint 1OUTHost sends print data to printer
Endpoint 2INPrinter sends status (ink level, paper jam) back to host

8. USB Pipes

is a logical (software) connection between the host (computer) and an endpoint (memory buffer inside a USB device).

Simple Analogy:

  • Endpoint = water tank (memory in device)
  • Host = main water source (computer)
  • Pipe = the pipe that carries water from source to tank

Pipes are created automatically when you plug in a device and destroyed when you unplug it.

Observed Damage in Macul and Ñuñoa
pinout

8.1 Types of Pipes

1. Message Pipes

FeatureDescription
DirectionBi-directional (data can go both ways)
FormatMust follow defined packet format (strict rules)
UseControl Transfer – used for settings, commands, identification
ControlFully controlled by the host (computer)

Example: When you plug in a new device, the host uses a message pipe to ask: “Who are you? What is your name?”

2. Stream Pipes

FeatureDescription
DirectionUnidirectional (one way only)
FormatNo fixed format – can carry raw data
UseLarge data transfer

Four Types of Transfers Supported by the USB

Transfer TypeUsed ForExample
BulkLarge data, reliableCopying files to pen drive
InterruptSmall data, frequentMouse movement, keyboard press
IsochronousReal-time dataWebcam video, USB speaker audio

8.2 The Default Control Pipe

FeatureDescription
What is it?A special message pipe connected to Endpoint 0
DirectionBi-directional (uses Endpoint 0-IN and Endpoint 0-OUT)
PurposeEnumeration – identifies the device when first plugged in
Always ActiveEvery USB device has this pipe
Observed Damage in Macul and Ñuñoa
pinout

9. USB Transactions, Packets, and Handshaking

1. What is a USB Transaction?

A USB transaction is one complete communication between the host and a device. Each transaction has up to 3 packets:

StepPacket TypeSent ByPurpose
1Token PacketHost (always)Starts the transaction – tells which device and endpoint
2Data PacketHost or DeviceCarries the actual data
3Handshake PacketHost or DeviceConfirms if data was received successfully

2. USB Packet Fields (Structure)

Every USB packet contains these parts:

FieldSizePurpose
Sync8-bit (Low/Full) / 32-bit (High)Synchronizes clocks between sender and receiver
PID8-bit (4-bit type + 4-bit complement)Identifies packet type (Token, Data, Handshake)
ADDR7-bitAddress of the device (0 to 127)
ENDP4-bitEndpoint number inside the device (0 to 15)
CRC Field (Cyclic Redundancy Check)5-bit (Token) / 16-bit (Data)Error detection code
EOP Field (End of Packet)Special signalMarks the end of the packet

3. Handshaking – Confirming Data Transfer

Handshaking ensures data is received correctly.

Observed Damage in Macul and Ñuñoa
pinout

IN Transaction (Host reads data from device)

StepPacketSent ByMeaning
1IN TokenHost“Device, send me data”
2DATADeviceDevice sends data
3ACKHost“Data received correctly!”

Other Responses:

ResponseMeaning
NAKDevice has no new data to send
STALLDevice has an error or doesn’t support the request

OUT Transaction (Host writes data to device)

StepPacketSent ByMeaning
1OUT TokenHost“Device, I’m sending you data”
2DATAHostHost sends data
3ACKDevice“Data received and stored correctly!”

Other Responses:

ResponseMeaning
NAKDevice is busy (buffer full) – try again later
STALLDevice doesn’t support the command
NYET“Not Yet” – device is busy, not ready for next packet

9. USB Device States and Classes

1. USB Device States (6 Stages)

When you plug in a USB device, it goes through 6 states:

StateWhat Happens
1. AttachedDevice is physically connected to the computer
2. PoweredDevice gets power from the host – but can only draw up to 100 mA initially
3. DefaultDevice resets – uses address 0 and Endpoint 0 to start communication
4. AddressedHost assigns a unique address (1 to 127) to the device
5. ConfiguredHost loads the correct driver – device is now ready to work
6. SuspendedPower-saving mode – if bus is idle for 3 ms, device draws less than 500 µA
Plug in → Attached → Powered → Default → Addressed → Configured → Working!
                                                              ↓
                                                         Suspended (idle)

2. USB Device Classes

USB uses Class Codes so the computer can use a generic driver for similar devices – no need for manufacturer-specific drivers.

Class codes are stored in the device’s Descriptor memory.

Common USB Device Classes

Class CodeDevice ClassTransfer TypeExamples
01HAudioIsochronousSpeaker, Microphone, Sound Card
03HHID (Human Interface)InterruptKeyboard, Mouse, Joystick
07HPrinterBulkLaser Printer, Inkjet Printer
08HMass StorageBulkPen Drive, External HDD, Card Reader
09HUSB HubControl / InterruptUSB Hub (to add more ports)
0DhContent SecurityBulk / InterruptFingerprint Reader
0EhVideoIsochronous / BulkWebcam, Scanner
Device Plugged In
        ↓
Host reads Class Code from Descriptor(store in computer os)
        ↓
Host loads the matching generic driver
        ↓
Device is ready to use

10. USB Enumeration

Enumeration is the process where the computer (Host) identifies a newly connected USB device and prepares it for use. It happens automatically every time you plug in a device.

The 4 Steps of Enumeration

Step 1: Reset & Speed Detection

ActionDetails
Device plugged inHub detects the new device and informs the Host
Host sends Reset signalHost resets the device
Speed detectedHost determines if device is Low Speed, Full Speed, or High Speed

Step 2: Default Address & Descriptor Read

ActionDetails
Device enters Default StateAddress is set to 0
Host reads Device DescriptorHost reads the device’s basic information (like an ID card)
Firmware requiredDevice must have built-in firmware to respond

Step 3: Set Unique Address

ActionDetails
Host assigns an addressDevice gets a unique 7-bit address (1 to 127)
Example“You are now Device Number 4”

Step 4: Driver Loading & Configuration

ActionDetails
Host checks all endpointsReads other endpoints (besides Endpoint 0)
Host checks Class CodeIdentifies what type of device it is
Driver loadedOS loads the correct driver (e.g., INF file on Windows)
Device enters Configured StateDevice is now ready to work!

Complete Flowchart

Device Plugged In
        ↓
Host detects device (via Hub)
        ↓
Step 1: Host sends Reset → Speed detected
        ↓
Step 2: Device uses Address 0 → Host reads Descriptor
        ↓
Step 3: Host assigns Unique Address (1-127)
        ↓
Step 4: Host loads Driver → Device Configured → Ready!
Next Topic 8255 PPI

Table of Contents