Part 1
요약·해설
48 kHz stereo playback, overrun/underrun 원인과 nominal ±1 packet 제어를 설명합니다.
Full-Speed UAC2
48 kHz · 16-bit · stereo
Direct · Indirect
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
83FDACB2DFE0D7C6966FCCF39D1CA356C13ECAB14E6D562BFC4F8C4CF40657F1
.. zephyr:code-sample:: uac2-explicit-feedback
:name: USB Audio asynchronous explicit feedback sample
:relevant-api: usbd_api uac2_device i2s_interface
USB Audio 2 explicit feedback sample playing audio on I2S.
Overview
********
This sample demonstrates how to implement USB asynchronous audio playback with
explicit feedback. It can run on any board with USB and I2S support, but the
feedback calculation is currently only implemented for the Nordic nRF5340 IC.
The device running this sample presents itself to the host as a Full-Speed
Asynchronous USB Audio 2 class device supporting 48 kHz 16-bit 2-channel
(stereo) playback.
Explicit Feedback
*****************
Asynchronous USB Audio is used when the actual sample clock is not controlled by
USB host. Because the sample clock is independent from USB SOF it is inevitable
that 1 ms according to audio sink (I2S) will be either slightly longer or
shorter than 1 ms according to audio source (USB host). In the long run, this
discrepancy leads to overruns or underruns. By providing explicit feedback to
host, the device can tell host how many samples on average it needs every frame.
The host achieves the average by sending either nominal or nominal ±1 sample
packets every frame.
The dummy feedback implementation, used when there is no target-specific
feedback code available, returns a feedback value that results in host sending
nominal number of samples every frame. Theoretically it should be possible to
obtain the timing information based on I2S and USB interrupts, but currently
neither subsystem provides the necessary timestamp information.
Explcit Feedback on nRF5340
***************************
The nRF5340 is capable of counting both edges of I2S LRCLK relative to USB SOF
with the use of DPPI, TIMER and GPIOTE input. Alternatively, if the GPIOTE input
is not available, the DPPI and TIMER peripherals on nRF5340 can be configured to
provide relative timing information between I2S FRAMESTART and USB SOF.
This sample in both modes (direct sample counting and indirect I2S buffer output
to USB SOF offset) has been tested on :ref:`nrf5340dk_nrf5340`.
The sample defaults to indirect feedback calculation because direct sample
counting requires external connection between I2S LRCLK output pin to GPIOTE
input pin (hardcoded to P1.09) on :ref:`nrf5340dk_nrf5340`. In the indirect mode
no extra connections are necessary and the sample can even be used without any
I2S device connected where I2S signals can be checked e.g. on logic analyzer.
Building and Running
********************
The code can be found in :zephyr_file:`samples/subsys/usb/uac2_explicit_feedback`.
To build and flash the application:
.. zephyr-app-commands::
:zephyr-app: samples/subsys/usb/uac2_explicit_feedback
:board: nrf5340dk/nrf5340/cpuapp
:goals: build flash
:compact:
Part 3
한국어 전문 번역
개요
Explicit feedback을 사용해 USB asynchronous audio playback을 구현하는 sample입니다. USB와 I2S를 지원하는 board에서 실행할 수 있지만 feedback 계산은 현재 Nordic nRF5340 IC에만 구현되어 있습니다.
Sample device는 host에 Full-Speed asynchronous USB Audio 2 class device로 나타나며 48 kHz, 16-bit, 2-channel(stereo) playback을 지원합니다.
Explicit Feedback
Asynchronous USB Audio는 실제 sample clock을 USB host가 제어하지 않을 때 사용합니다. Sample clock이 USB SOF(Start of Frame)와 독립적이므로 audio sink인 I2S의 1 ms는 audio source인 USB host의 1 ms보다 조금 길거나 짧을 수밖에 없습니다.
이 차이가 누적되면 buffer overrun 또는 underrun이 발생합니다. Device가 host에 explicit feedback을 제공하면 frame마다 평균적으로 필요한 sample 수를 알려 줄 수 있습니다. Host는 각 frame에 nominal sample 수 또는 nominal ±1 sample 수를 보내 장기 평균을 맞춥니다.
Target별 feedback code가 없을 때 사용하는 dummy implementation은 host가 frame마다 nominal sample 수만 보내게 하는 feedback 값을 반환합니다. 이론상 I2S와 USB interrupt에서 timing 정보를 얻을 수 있지만 현재 두 subsystem 모두 필요한 timestamp 정보를 제공하지 않습니다.
nRF5340의 Explicit Feedback
nRF5340은 DPPI, TIMER와 GPIOTE input을 이용해 USB SOF를 기준으로 I2S LRCLK의 양쪽 edge를 셀 수 있습니다. GPIOTE input을 사용할 수 없다면 DPPI와 TIMER를 구성해 I2S FRAMESTART와 USB SOF 사이의 상대 timing 정보를 얻을 수도 있습니다.
Direct sample counting과 I2S buffer output-to-USB SOF offset을 사용하는 indirect mode 모두 nRF5340 DK에서 시험됐습니다.
기본값은 indirect feedback 계산입니다. Direct sample counting은 nRF5340 DK의 I2S LRCLK output pin을 P1.09로 고정된 GPIOTE input pin에 외부로 연결해야 하기 때문입니다. Indirect mode는 추가 연결이 필요 없으며 I2S device 없이도 실행해 logic analyzer로 I2S signal을 확인할 수 있습니다.
빌드 및 실행
Source는 samples/subsys/usb/uac2_explicit_feedback에 있습니다. 다음 command로 nRF5340 DK application core용 image를 build하고 flash합니다.
west build -b nrf5340dk/nrf5340/cpuapp samples/subsys/usb/uac2_explicit_feedback
west flash
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.