• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

boards/18-Mar-2025-3225

src/18-Mar-2025-764435

CMakeLists.txtD18-Mar-2025422 1511

KconfigD18-Mar-2025699 2015

README.rstD18-Mar-20253.1 KiB7154

app.overlayD18-Mar-20251 KiB4639

prj.confD18-Mar-2025289 138

sample.yamlD18-Mar-2025254 1312

README.rst

1.. zephyr:code-sample:: uac2-explicit-feedback
2   :name: USB Audio asynchronous explicit feedback sample
3   :relevant-api: usbd_api uac2_device i2s_interface
4
5   USB Audio 2 explicit feedback sample playing audio on I2S.
6
7Overview
8********
9
10This sample demonstrates how to implement USB asynchronous audio playback with
11explicit feedback. It can run on any board with USB and I2S support, but the
12feedback calculation is currently only implemented for the Nordic nRF5340 IC.
13
14The device running this sample presents itself to the host as a Full-Speed
15Asynchronous USB Audio 2 class device supporting 48 kHz 16-bit 2-channel
16(stereo) playback.
17
18.. warning::
19   Microsoft Windows USB Audio 2.0 driver available since Windows 10,
20   release 1703 expects Full-Speed explicit feedback endpoint wMaxPacketSize to
21   be equal 4, which violates the USB 2.0 Specification.
22   See https://aka.ms/AArvnax for Windows Feedback Hub report.
23
24Explicit Feedback
25*****************
26
27Asynchronous USB Audio is used when the actual sample clock is not controlled by
28USB host. Because the sample clock is independent from USB SOF it is inevitable
29that 1 ms according to audio sink (I2S) will be either slightly longer or
30shorter than 1 ms according to audio source (USB host). In the long run, this
31discrepancy leads to overruns or underruns. By providing explicit feedback to
32host, the device can tell host how many samples on average it needs every frame.
33The host achieves the average by sending either nominal or nominal ±1 sample
34packets every frame.
35
36The dummy feedback implementation, used when there is no target-specific
37feedback code available, returns a feedback value that results in host sending
38nominal number of samples every frame. Theoretically it should be possible to
39obtain the timing information based on I2S and USB interrupts, but currently
40neither subsystem provides the necessary timestamp information.
41
42Explcit Feedback on nRF5340
43***************************
44
45The nRF5340 is capable of counting both edges of I2S LRCLK relative to USB SOF
46with the use of DPPI, TIMER and GPIOTE input. Alternatively, if the GPIOTE input
47is not available, the DPPI and TIMER peripherals on nRF5340 can be configured to
48provide relative timing information between I2S FRAMESTART and USB SOF.
49
50This sample in both modes (direct sample counting and indirect I2S buffer output
51to USB SOF offset) has been tested on :ref:`nrf5340dk_nrf5340`.
52
53The sample defaults to indirect feedback calculation because direct sample
54counting requires external connection between I2S LRCLK output pin to GPIOTE
55input pin (hardcoded to P1.09) on :ref:`nrf5340dk_nrf5340`. In the indirect mode
56no extra connections are necessary and the sample can even be used without any
57I2S device connected where I2S signals can be checked e.g. on logic analyzer.
58
59Building and Running
60********************
61
62The code can be found in :zephyr_file:`samples/subsys/usb/uac2_explicit_feedback`.
63
64To build and flash the application:
65
66.. zephyr-app-commands::
67   :zephyr-app: samples/subsys/usb/uac2_explicit_feedback
68   :board: nrf5340dk/nrf5340/cpuapp
69   :goals: build flash
70   :compact:
71