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

..--

boards/04-Jan-2025-3225

src/04-Jan-2025-764435

CMakeLists.txtD04-Jan-2025422 1511

KconfigD04-Jan-2025699 2015

README.rstD04-Jan-20252.8 KiB6549

app.overlayD04-Jan-20251 KiB4639

prj.confD04-Jan-2025289 138

sample.yamlD04-Jan-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
18Explicit Feedback
19*****************
20
21Asynchronous USB Audio is used when the actual sample clock is not controlled by
22USB host. Because the sample clock is independent from USB SOF it is inevitable
23that 1 ms according to audio sink (I2S) will be either slightly longer or
24shorter than 1 ms according to audio source (USB host). In the long run, this
25discrepancy leads to overruns or underruns. By providing explicit feedback to
26host, the device can tell host how many samples on average it needs every frame.
27The host achieves the average by sending either nominal or nominal ±1 sample
28packets every frame.
29
30The dummy feedback implementation, used when there is no target-specific
31feedback code available, returns a feedback value that results in host sending
32nominal number of samples every frame. Theoretically it should be possible to
33obtain the timing information based on I2S and USB interrupts, but currently
34neither subsystem provides the necessary timestamp information.
35
36Explcit Feedback on nRF5340
37***************************
38
39The nRF5340 is capable of counting both edges of I2S LRCLK relative to USB SOF
40with the use of DPPI, TIMER and GPIOTE input. Alternatively, if the GPIOTE input
41is not available, the DPPI and TIMER peripherals on nRF5340 can be configured to
42provide relative timing information between I2S FRAMESTART and USB SOF.
43
44This sample in both modes (direct sample counting and indirect I2S buffer output
45to USB SOF offset) has been tested on :ref:`nrf5340dk_nrf5340`.
46
47The sample defaults to indirect feedback calculation because direct sample
48counting requires external connection between I2S LRCLK output pin to GPIOTE
49input pin (hardcoded to P1.09) on :ref:`nrf5340dk_nrf5340`. In the indirect mode
50no extra connections are necessary and the sample can even be used without any
51I2S device connected where I2S signals can be checked e.g. on logic analyzer.
52
53Building and Running
54********************
55
56The code can be found in :zephyr_file:`samples/subsys/usb/uac2_explicit_feedback`.
57
58To build and flash the application:
59
60.. zephyr-app-commands::
61   :zephyr-app: samples/subsys/usb/uac2_explicit_feedback
62   :board: nrf5340dk/nrf5340/cpuapp
63   :goals: build flash
64   :compact:
65