Introducing a new way to review your PRs.

Read the announcement

hathach / tinyusb

An open source cross-platform USB stack for embedded system

View on GitHub

18 documents · Updated Nov 23, 2026

docs / class-media-and-connectivity

Media, storage, and connectivity classes

The media and connectivity classes connect USB devices to useful application data. Audio carries time-sensitive samples, mass storage exposes block devices, and network support carries Ethernet packets. Each class has a host-facing and/or device-facing role with an API that hides USB transfers behind the data model that the application needs.

Class boundaries

The classes use different USB roles and data contracts. This table gives the first choice for an engineer who needs to select a class.

ClassUSB rolesApplication viewTransfer model
AudioHost and deviceCapture or playback streams plus controlsPeriodic isochronous transfers with FIFO buffering
Mass StorageHost and deviceLogical units made of fixed-size blocksSCSI commands over bulk transport
NetworkDeviceEthernet frames for a network stackBulk transfers carrying packets or packed packet blocks

The class driver manages USB enumeration, interfaces, endpoints, and transfer completion. The application chooses stream settings, block operations, or packet ownership at the class API boundary. See USB class drivers for the place of these classes in the wider class-driver model. For neighboring device categories, see serial and human interface classes and specialized peripheral classes.

Audio class

The Audio class transports real-time audio between a USB host and a device. It describes control entities such as terminals and feature units, then uses separate streaming interfaces for capture and playback. The shared header defines USB Audio Class 1.0 and 2.0 descriptor and control vocabulary, but its module note says that only the MIDI subclass is currently supported. Treat these definitions as the USB contract and check the enabled class drivers before assuming that every listed audio capability is available (src/…/audio.h• L9-12, src/…/audio.h• L23-45, src/…/audio.h• L153-181, src/…/audio.h• L575-622).

Audio host role

The host role discovers logical capture and playback streams instead of exposing USB interface details to the application. It accepts supported Type-I PCM formats and presents each valid format, sample rate, and channel count as a complete configuration tuple. UAC1 rates come from stream descriptors, while UAC2 rates come from the connected clock source through asynchronous mount-time queries. The host reports the audio function as mounted only after its supported clock rates and common feature controls have been probed (src/…/audio_host.c• L1350-1623, src/…/audio_host.c• L1753-1947). UAC1 and UAC2 support can be enabled together so devices of both versions can be mounted (src/…/audio_host.h• L22-53).

The host API separates setup from data flow. tuh_audio_configure() selects one supported stream configuration. tuh_audio_start() and tuh_audio_stop() change the active stream asynchronously. tuh_audio_read() and tuh_audio_write() then move whole frames through the stream FIFO (src/…/audio_host.h• L158-210, src/…/audio_host.c• L2004-2353). A successful start or stop call means that the first request was submitted; the event callback reports completion of the full operation. Stopping also discards queued frames before it reports completion (src/…/audio_host.h• L182-196, src/…/audio_host.c• L2102-2245).

The control API exposes common device controls without forcing an application to build raw class requests. Applications can query mute and volume support, use the cached volume range, or send a raw control request for an entity that the typed API does not cover (src/…/audio_host.h• L243-284). Synchronous control requests are for stopped streams because a control transfer can disturb active isochronous traffic (src/…/audio_host.h• L286-314).

The host keeps playback packet timing aligned with the device clock when an explicit feedback endpoint is present. It validates the feedback range and packet capacity, then carries fractional frames into later packets so it does not split an audio frame. A failed isochronous packet is treated as a dropped packet and the stream continues with an empty packet until failures persist or the endpoint stalls (src/…/audio_host.c• L578-609, src/…/audio_host.c• L824-865, src/…/audio_host.c• L881-953).

This diagram shows the host audio path from device discovery to application frames.

flowchart LR
    A[Audio device] --> B[Stream and control discovery]
    B --> C[Select format, rate, and channels]
    C --> D[Configure and start stream]
    D --> E[Isochronous USB transfers]
    E --> F[Per-stream FIFO]
    F --> G[Application reads capture frames]
    F --> H[Application writes playback frames]
    G --> I[Audio controls]
    H --> I

References: src/…/audio_host.h• L22-53 src/…/audio_host.h• L143-210 src/…/audio_host.h• L243-314 src/…/audio_host.c• L1350-1623 src/…/audio_host.c• L1753-1947 src/…/audio_host.c• L578-609 src/…/audio_host.c• L824-953 src/…/audio_host.c• L2004-2353

Audio device role

The device role presents audio functions to a host within a constrained endpoint model. Each function can expose one audio IN path, one audio OUT path, one control path, and one feedback path, while the data paths can carry multiple channels. The application supplies or consumes data through endpoint FIFOs and answers class requests for stream settings and controls (src/…/audio_device.c• L11-30, src/…/audio_device.h• L19-35, src/…/audio_device.h• L154-178).

The device accepts an audio function only when its advertised isochronous endpoints can be allocated on the USB port. A configuration that exceeds the port's endpoint or FIFO and packet memory cannot mount, so its stream settings or number of audio functions must be reduced (src/…/audio_device.c• L813-978).

Streaming starts when the host selects a non-zero alternate setting for a streaming interface. The class opens the matching data and feedback endpoints, clears the old FIFO when a stream closes, and invokes application callbacks around the interface change. Queued samples therefore belong to the active stream setting and are not preserved across a setting change (src/…/audio_device.c• L1073-1298).

Audio data is time-sensitive, so the application must keep the endpoint path supplied at the required rate. A device may use flow control or a feedback endpoint when its audio clock is not locked to the USB clock. FIFO-count feedback trades more buffering and delay for lower interrupt cost, while frequency-based feedback can reduce jitter but needs clock timing work (src/…/audio_device.h• L126-139, src/…/audio_device.h• L236-300, src/…/audio_device.c• L1576-1672).

The device application normally connects tud_audio_read() and tud_audio_write() to its hardware audio path. The class keeps USB packet timing separate from that application path through software FIFOs. It can use a direct FIFO transfer when the controller supports it or a linear staging buffer when it does not. With several channels, separate channel FIFOs can be combined into one USB stream (src/…/audio_device.c• L11-30, src/…/audio_device.c• L441-558). The callbacks for completed packets are available when the application needs transfer events, but the examples show the main audio task or a hardware audio callback driving the data exchange (src/…/audio_device.h• L186-197, src/…/audio_device.h• L220-233, examples/…/main.c• L578-617). These callbacks run in interrupt context when the USB port handles completion in an ISR. On ports that defer completion, they run in tud_task() context instead (src/…/audio_device.h• L220-235, src/…/audio_device.c• L1479-1572).

References: src/…/audio_device.h• L19-35 src/…/audio_device.h• L126-139 src/…/audio_device.h• L186-233 src/…/audio_device.c• L11-30 src/…/audio_device.c• L441-558 src/…/audio_device.c• L813-978 src/…/audio_device.c• L1073-1298 src/…/audio_device.c• L1576-1672 src/…/audio_device.c• L1479-1572 examples/…/main.c• L578-617

Audio buffering

The host stream FIFO decouples application calls from the endpoint polling cadence. Playback reports free frame capacity and sends queued frames on later transfers. If a complete packet is not ready, the driver sends silence. Capture reports ready frames and overwrites the oldest complete frames when the FIFO is full (src/…/audio_host.h• L64-70, src/…/audio_host.h• L198-210, src/…/audio_host.c• L935-951, examples/…/README.md• L118-122).

Playback packet size follows the selected sample rate and endpoint interval. When a playback device supplies explicit feedback, the host validates the rate, scales it to the endpoint interval, and carries the fractional remainder into later packets. This keeps the packet schedule close to the device clock without splitting an audio frame (src/…/audio_host.c• L578-609, src/…/audio_host.c• L824-865).

The device stream FIFO also decouples the hardware audio path from USB packet completion. The application writes playback data into the IN FIFO and reads captured data from the OUT FIFO. When an IN packet has no data ready, the class arms an empty packet so that the isochronous endpoint remains ready for the host (src/…/audio_device.c• L441-558, src/…/audio_device.c• L1525-1549).

An empty OUT packet still completes the USB receive cycle even though it adds no sample data. The class therefore re-arms the OUT endpoint and runs the receive callback for that packet, which keeps later audio packets flowing (src/…/audio_device.c• L466-492).

The device side requires software endpoint buffers that can hold the largest configured endpoint packet. A device configuration must therefore size the endpoint buffer for every alternate streaming setting that it advertises (src/…/audio_device.h• L36-67, src/…/audio_device.h• L69-124). The application should service its audio FIFO often enough to avoid underflow or overflow. The host example uses half-FIFO watermarks so one half can absorb short delays in the main loop (examples/…/audio_app.c• L146-150, examples/…/audio_app.c• L258-291).

References: src/…/audio_host.h• L64-70 src/…/audio_host.h• L198-210 src/…/audio_host.c• L578-609 src/…/audio_host.c• L824-865 src/…/audio_host.c• L935-951 src/…/audio_device.h• L19-35 src/…/audio_device.h• L69-139 src/…/audio_device.h• L186-235 src/…/audio_device.c• L11-30 src/…/audio_device.c• L441-558 src/…/audio_device.c• L466-492 src/…/audio_device.c• L888-978 src/…/audio_device.c• L1073-1298 src/…/audio_device.c• L1525-1549 examples/…/audio_app.c• L146-150 examples/…/audio_app.c• L258-291

Mass Storage class

The Mass Storage class presents media as one or more logical units. It uses SCSI commands over Bulk-Only Transport to describe media and move fixed-size logical blocks. A command has a command phase, an optional data phase, and a status phase (src/…/msc.h• L20-50, src/…/msc.h• L62-85, src/…/msc.h• L91-104).

Mass Storage host role

The host role mounts a storage interface, learns its reported logical-unit count, and caches block geometry for the first logical unit. It then exposes asynchronous SCSI operations. Enumeration checks readiness and capacity before it reports the device as mounted (src/…/msc_host.h• L38-62, src/…/msc_host.c• L652-803). The reported logical-unit count is limited to the storage reserved by the host driver, and the public count remains representable in its one-byte API (src/…/msc_host.c• L67-69, src/…/msc_host.c• L693-708).

Applications usually place a file system or another block layer above this API. The file explorer uses the cached block size and count, submits reads or writes, and waits for completion while the USB task continues to run (examples/…/msc_app.c• L111-163, examples/…/msc_app.c• L192-246).

A storage interface accepts one SCSI operation at a time. If a transfer stage cannot be submitted or the device reports a phase error, the host fences the interface and refuses new commands until the application completes asynchronous Bulk-Only Transport reset recovery. Successful recovery clears the fence while keeping the mount state and cached geometry (src/…/msc_host.h• L43-53, src/…/msc_host.h• L64-74, src/…/msc_host.h• L111-120, src/…/msc_host.c• L209-237, src/…/msc_host.c• L446-471).

References: src/…/msc_host.h• L38-120 src/…/msc_host.c• L67-69 src/…/msc_host.c• L209-237 src/…/msc_host.c• L362-471 src/…/msc_host.c• L652-803 examples/…/msc_app.c• L111-163 examples/…/msc_app.c• L192-246

Mass Storage device role

The device role maps host SCSI requests to application-owned media. Callbacks provide inquiry data, readiness, capacity, write protection, sense data, and block reads or writes. An application can also handle commands outside the built-in set (src/…/msc_device.h• L57-129).

Media access may be immediate or delayed. A read or write callback can return data, report busy or failure, or return an asynchronous result and later call tud_msc_async_io_done(). This lets slow flash or removable media finish without blocking the USB task (src/…/msc_device.h• L60-64, src/…/msc_device.c• L342-385, src/…/msc_device.c• L993-1125).

The device checks the requested logical-block range and data length before it calls the media callbacks. It then moves read and write data through a bounded endpoint buffer, so the application handles each callback as a portion of the full command and preserves any media state needed until command completion. A reset can abandon the USB command, but an outstanding asynchronous operation still owns the buffer until its completion is reported (src/…/msc_device.c• L169-225, src/…/msc_device.h• L70-93, src/…/msc_device.c• L448-484, src/…/msc_device.c• L993-1125).

References: src/…/msc_device.h• L44-129 src/…/msc_device.c• L169-225 src/…/msc_device.c• L342-385 src/…/msc_device.c• L448-484 src/…/msc_device.c• L810-972 src/…/msc_device.c• L993-1125

Mass Storage data transfer

Mass Storage is a queued command path rather than a continuous stream. The host submits one non-blocking SCSI operation with a USB/DMA-accessible buffer. The completion callback returns the command status and data context. A caller can use the typed helpers for inquiry, readiness, sense data, capacity, reads, and writes or submit a complete SCSI command (src/…/msc_host.h• L64-109).

Large data phases continue as several bulk transfers under one SCSI command. The host splits the phase into safe USB request sizes that fit the host transfer length and align with bulk packet behavior, then advances the caller's buffer until the requested byte count is complete (src/…/msc_host.c• L102-129, src/…/msc_host.c• L506-574). The application must keep the buffer valid until completion and match its size to the logical block geometry.

The host can also run reset recovery for a mounted interface with no command in flight. Recovery sends the class reset, clears the Bulk-In and Bulk-Out halts, and restores the host-side data toggles. The completion callback reports whether the interface can accept commands again; unplugged devices do not receive this callback (src/…/msc_host.h• L111-120, src/…/msc_host.c• L362-444).

This diagram shows the normal host storage path.

sequenceDiagram
    participant A as Host application
    participant M as Mass Storage host
    participant D as USB storage device
    participant F as File system
    A->>M: Mount and inspect logical unit
    M->>D: Test readiness and read capacity
    D-->>M: Block geometry
    A->>F: Mount volume
    F->>M: Read or write blocks
    M->>D: SCSI command and bulk data
    D-->>M: Command status
    M-->>F: Completion callback

References: src/…/msc.h• L31-85 src/…/msc_host.h• L38-120 src/…/msc_host.c• L102-129 src/…/msc_host.c• L362-444 src/…/msc_host.c• L506-574 src/…/msc_host.c• L652-803 src/…/msc_device.c• L342-385 src/…/msc_device.c• L810-972 examples/…/msc_app.c• L111-163 examples/…/msc_app.c• L192-246

Network class

The Network class makes the USB device appear to the host as an Ethernet adapter. It provides CDC-NCM or ECM/RNDIS device support and connects a network stack to USB packet transfers. Only one of the NCM and ECM/RNDIS drivers can be enabled at a time (src/…/net_device.h• L15-19, src/…/net_device.h• L54-122).

Network device role

The network role is device-facing. The application supplies a MAC address and implements packet receive and transmit callbacks. The host sees an Ethernet interface, while the application sees packet ownership and link state (src/…/net_device.h• L62-114).

ECM sends one Ethernet frame per bulk transfer. RNDIS wraps one frame in a validated data message. NCM groups one or more frames into a Network Transfer Block (NTB), which uses one bulk transfer to improve packet throughput (src/…/ecm_rndis_device.c• L332-359, src/…/ncm.h• L14-60, src/…/ncm_device.c• L12-20, src/…/ncm_device.c• L612-704, src/…/ncm_device.c• L760-808). ECM activates its data endpoints through an alternate interface setting. NCM also waits for its data interface to become active before starting packet traffic (src/…/ecm_rndis_device.c• L161-197, src/…/ecm_rndis_device.c• L230-281, src/…/ncm_device.c• L578-603, src/…/ncm_device.c• L1142-1155).

The application checks transmit capacity before calling tud_network_xmit(). Its transmit callback copies a frame into the driver's packet or NTB buffer. On receive, the application accepts the frame and calls tud_network_recv_renew() when it has finished with the receive path. NCM also supports holding a received NTB for zero-copy use through tud_network_recv_hold() and tud_network_recv_release() when buffer capacity permits. With only one receive NTB, the application must copy the frame instead of holding it (src/…/net_device.h• L62-82, src/…/ncm_device.c• L709-752, src/…/ncm_device.c• L764-880).

References: src/…/net_device.h• L15-19 src/…/net_device.h• L54-122 src/…/ecm_rndis_device.c• L161-197 src/…/ecm_rndis_device.c• L230-281 src/…/ecm_rndis_device.c• L332-414 src/…/ncm.h• L14-60 src/…/ncm_device.c• L12-20 src/…/ncm_device.c• L578-704 src/…/ncm_device.c• L709-880 src/…/ncm_device.c• L1142-1155

Network buffering

NCM maintains free, ready, and active buffers for both directions. It aggregates frames until an NTB reaches its configured size or datagram limit, then sends the NTB as one USB transfer. During setup, the host can request a smaller device transmit size or datagram limit within the device's supported range. The negotiated NTB input size must stay within the protocol's valid range and never exceeds the device's configured maximum (src/…/ncm.h• L14-60, src/…/ncm_device.c• L62-115, src/…/ncm_device.c• L384-480, src/…/ncm_device.c• L760-808, src/…/ncm_device.c• L1188-1230).

The number and size of NCM buffers set the burst that the device can absorb. Larger NTBs and more buffers improve burst handling but consume RAM. If all transmit buffers are in use, tud_network_can_xmit() returns false and the network stack must retry later (src/…/ncm_device.c• L278-350, src/…/ncm_device.c• L448-480, src/…/ncm_device.c• L764-776). A held receive NTB also remains unavailable until the application releases it, so zero-copy retention trades packet copies for receive-buffer depth (src/…/ncm_device.c• L839-880).

ECM and RNDIS use a single packet buffer path. The driver accepts another transmit only after the prior bulk transfer and any required zero-length packet finish. RNDIS validates message and payload bounds before exposing a received frame (src/…/ecm_rndis_device.c• L332-379, src/…/ecm_rndis_device.c• L389-414).

This diagram shows how a network stack crosses the USB class boundary.

flowchart LR
    A[Network stack] -->|Outgoing Ethernet frame| B[Transmit capacity]
    B --> C[Copy into packet or NTB]
    C --> D[USB bulk transfer]
    D --> E[Host network adapter]
    E --> F[USB bulk receive]
    F --> G[Validate and unpack]
    G --> H[Receive callback]
    H --> A

References: src/…/net_device.h• L15-28 src/…/net_device.h• L62-90 src/…/ncm.h• L14-60 src/…/ncm_device.c• L62-115 src/…/ncm_device.c• L384-480 src/…/ncm_device.c• L448-480 src/…/ncm_device.c• L764-880 src/…/ncm_device.c• L1026-1230 src/…/ecm_rndis_device.c• L161-197 src/…/ecm_rndis_device.c• L230-281 src/…/ecm_rndis_device.c• L332-414

USB attachment and network carrier state are separate. The application reports link changes through tud_network_link_state(), and the class sends the state to the host when the selected protocol supports it (src/…/net_device.h• L104-122).

NCM defers link changes to the USB device task. This keeps notification changes in sequence with notification completion and preserves the latest change if it occurs while the data interface or notification endpoint is busy. NCM sends the speed and connection notification sequence when the interface is active (src/…/ncm_device.c• L206-268, src/…/ncm_device.c• L893-968). ECM sends a network-connection notification and retains the current state for later reports. RNDIS does not yet send dynamic link-state indications after enumeration (src/…/ecm_rndis_device.c• L204-228, src/…/ecm_rndis_device.c• L416-441).

References: src/…/net_device.h• L104-122 src/…/ncm_device.c• L206-268 src/…/ncm_device.c• L893-968 src/…/ecm_rndis_device.c• L204-228 src/…/ecm_rndis_device.c• L416-441

Application API selection

The application-facing API follows the data shape of each class. Use the matching boundary so timing, ownership, and completion rules remain clear.

NeedAPI boundaryMain expectation
Select and run USB audiotuh_audio_*Configure a complete stream tuple and keep the frame FIFO supplied or drained
Implement a USB audio devicetud_audio_*Keep endpoint FIFOs aligned with the audio clock and answer class controls
Read or write a USB disktuh_msc_*Submit non-blocking SCSI work, keep its buffer valid until completion, and recover a fenced interface
Present storage to a hosttud_msc_*Return block data or a clear busy, error, or asynchronous result
Connect a network stacktud_network_*Check transmit capacity, renew receive processing, and release held NCM buffers

Audio callers work in frames and timing. Storage callers work in blocks and command completion. Network callers work in packet ownership and link state. These boundaries keep a periodic stream separate from a queued disk request and a packet path separate from a byte stream.

Change checklist

When these files or sections are changed, remember to consider these:

  • When audio stream descriptors or alternate settings change, check endpoint allocation, maximum packet sizes, FIFO sizes, endpoint activation, and the data format selected by the application.
  • When audio FIFO or transfer scheduling changes, check empty IN packets, OUT re-arming, FIFO clearing on interface changes, staging-buffer use, and callback timing.
  • When audio feedback changes, check feedback range limits, full-speed and high-speed formats, feedback interval timing, FIFO thresholds, and clock drift.
  • When mass-storage LUN reporting changes, check the configured LUN storage, the clamped public count, one-byte count range, capacity lookup, and which LUN enumeration initializes before mount.
  • When mass-storage command buffers or data-stage splitting changes, check USB/DMA buffer lifetime, block-size multiplication, bulk request limits, command fencing, and completion status.
  • When mass-storage reset recovery changes, check command admission, Bulk-Only Transport reset ordering, endpoint halt clearing, data-toggle recovery, fence release, and unplug handling.
  • When asynchronous device media I/O changes, check busy versus error results, partial write consumption, deferred completion, reset-abandoned I/O ownership, sense data, and the final SCSI status phase.
  • When ECM or RNDIS framing changes, check packet lengths, RNDIS offset validation, zero-length packet handling, and single-transmit ownership.
  • When NCM NTB limits or negotiation changes, check the 2048-byte minimum, alignment, maximum size, datagram count, free-buffer depth, host-selected limits, and MTU handling.
  • When network receive renewal changes, check accepted packets, held and released NTBs, re-entrant renewal, and continued USB reception.
  • When network link notification changes, check interface activation, notification completion ordering, deferred cross-task calls, and protocol differences between NCM, ECM, and RNDIS.

Important failure modes

TriggerConsequenceGuard
Audio isochronous endpoints or packet memory exceed the controller resourcesThe audio function does not mountReduce stream packet size, channel count, sample rate, or the number of audio functions
Audio endpoint FIFOs are smaller than an advertised maximum packetAudio data cannot be staged safely for an alternate settingSize each software FIFO and endpoint buffer for the largest advertised packet
Audio application stops servicing a stream FIFOPlayback underflows or capture data overflowsDrive the API from the audio clock and use enough FIFO headroom for scheduling delay
Audio stream setting changes while queued samples are expected to remainThe class clears the old FIFO and those samples are lostTreat a setting change as a new stream and refill or drain the new path
Audio feedback parameters do not match the device clock or intervalThe host changes packet size at the wrong rate and the FIFO driftsUse a valid feedback method and keep its range and interval within the selected USB speed limits
Repeated audio transfer failures or a stalled endpoint occurThe host stops the stream and reports TUH_AUDIO_EVENT_XFER_FAILEDTreat zero-byte data callbacks as dropped packets and restart only after the failure event
Host submits a storage buffer that is not USB/DMA-accessible or does not remain validThe SCSI operation can fail or corrupt dataUse an aligned controller-accessible buffer and keep it until the completion callback
A storage command has a failed transfer stage or phase errorThe interface is fenced and later commands are refusedWait for the command completion, then run tuh_msc_reset() and continue only after successful recovery
Device storage reports a delayed operation as successThe host receives incomplete media dataReturn the defined asynchronous or busy result and complete it only after media I/O finishes
A reset abandons device-side asynchronous media I/O and the application reuses its bufferThe late completion can consume invalid data or corrupt the next commandKeep the buffer owned until tud_msc_async_io_done() reports the result
Host reports more LUNs than the host driver can storePublic LUN access can use missing capacity data or the count can wrap to zeroClamp the widened count to configured storage and keep it within the one-byte public range
Network transmit starts without available capacityThe frame is not queued and traffic can stallCall tud_network_can_xmit() and retry when it returns false
Application does not renew a received network bufferUSB reception stops when the buffer remains ownedCall tud_network_recv_renew() after the stack finishes with the frame
Application holds an NCM receive buffer and does not release itThe held NTB cannot return to the free receive poolCall tud_network_recv_release() in task context after the stack stops using the packet
NCM NTB is below the valid negotiation range, exceeds the configured size, or contains invalid pointersThe NTB is rejected or the transmit request is refusedKeep negotiated input size at least 2048 bytes, honor device limits, and validate the NTB before exposing datagrams
RNDIS payload offsets or lengths point outside the transferThe frame is discarded instead of reaching the network stackValidate message type, message length, data offset, and data length
ECM data interface remains on alternate setting zeroBulk endpoints are inactive and no network traffic movesWait for alternate setting one before using the data path
RNDIS link changes after enumerationThe host does not receive a dynamic carrier updateDo not depend on tud_network_link_state() for RNDIS dynamic status
Both NCM and ECM/RNDIS drivers are enabledThe network configuration fails at build timeSelect one network driver

Key files

FileWhy to read it
src/…/audio_host.hShows the host stream, frame FIFO, control, and event contract.
src/…/audio_host.cShows audio discovery, UAC1/UAC2 rate handling, stream activation, feedback scheduling, and frame transfer.
src/…/audio_device.hShows the device stream, endpoint FIFO, feedback, and control contract.
src/…/audio_device.cShows device audio resource checks, stream activation, FIFO paths, and feedback timing.
src/…/msc.hDefines the shared Bulk-Only Transport, SCSI command, and status contract.
src/…/msc_host.hDefines the asynchronous host storage API, block geometry, command fencing, and reset recovery.
src/…/msc_host.cShows storage enumeration, bounded LUN reporting, SCSI phases, large data transfers, and reset recovery.
src/…/msc_device.hDefines block callbacks, asynchronous I/O results, buffer ownership, and SCSI application hooks.
src/…/msc_device.cShows device SCSI handling, bounded block transfers, delayed media I/O, and reset behavior.
src/…/net_device.hDefines network packet ownership, transmit capacity, receive holds, callbacks, and link state.
src/…/ncm.hDefines NCM buffer limits, NTB capacity defaults, and the NTB wire structures.
src/…/ecm_rndis_device.cShows single-packet ECM/RNDIS framing, endpoint activation, ZLP handling, validation, and link reports.
src/…/ncm_device.cShows NTB negotiation, packet aggregation, buffer queues, zero-copy receive ownership, and deferred link notifications.
examples/…/msc_app.cShows how asynchronous storage operations feed a file-system layer.
examples/…/main.cShows how a network stack uses the device class for IP services over USB.