examples/device/uac2_headset/README.md
A USB audio headset that combines a stereo speaker output and a mono microphone input, adapting its descriptors to the negotiated bus speed — UAC1 at Full-Speed and UAC2 at High-Speed.
| Interface | Class driver |
|---|---|
| 0 | Audio control |
| 1 | Audio streaming — speaker output (OUT) |
| 2 | Audio streaming — microphone input (IN) |
(UAC1 at Full-Speed, UAC2 at High-Speed.)
Notable tusb_config.h settings:
#define CFG_TUD_AUDIO 1
#define CFG_TUD_AUDIO_ENABLE_INTERRUPT_EP 1
#define CFG_TUD_AUDIO_ENABLE_EP_IN 1 // microphone
#define CFG_TUD_AUDIO_ENABLE_EP_OUT 1 // speaker
#define CFG_TUD_AUDIO_FUNC_1_N_FORMATS 2
#define CFG_TUD_AUDIO_FUNC_1_MAX_SAMPLE_RATE 48000
#define CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX 1 // mic (mono)
#define CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_RX 2 // speaker (stereo)
#define CFG_TUD_AUDIO_FUNC_1_FORMAT_1_RESOLUTION_TX 16 // 16-bit
#define CFG_TUD_AUDIO_FUNC_1_FORMAT_2_RESOLUTION_TX 24 // 24-bit in 32-bit slots (UAC2)
CMake:
mkdir build && cd build
cmake -DBOARD=raspberry_pi_pico ..
cmake --build .
Make:
make BOARD=raspberry_pi_pico all
The device appears as both a USB playback (speaker) and capture (microphone) device. Play audio to the speaker (e.g. aplay -D ... or select it as the system output) and record from the microphone with arecord — you should hear the played audio looped back. Press the on-board button to toggle the volume between full scale and -30 dB and watch the host volume control follow.