Skip to main content
欢迎来到PAWPAW技术文档网站了解更多信息

API - USB Audio

7.1 配置定义

使用USB音频框架的应用程序需要为配置设置了定义。这些定义的默认值可以在devicedefines.h中的module_usb_audio中找到。

这些定义应该在 customdefines.h文件或相关构建配置的Makefile中被覆盖。

本节完整记录了所有分段定义及其默认值(在合适的地方)。

7.1.1 代码位置(tile)

MacroAUDIO_IO_TILE
DescriptionLocation (tile) of audio I/O. Default: 0
MacroXUD_TILE
DescriptionLocation (tile) of audio I/O. Default: 0
MacroAUDIO_IO_TILE
DescriptionLocation (tile) of IAP. Default: AUDIO_IO_TILE
MacroAUDIO_IO_TILE
DescriptionLocation (tile) of MIDI I/O. Default: AUDIO_IO_TILE

7.1.2 通道计数

MacroNUM_USB_CHAN_OUT
DescriptionNumber of output channels (host to device). Default: NONE (Must be defined by app)
MacroNUM_USB_CHAN_IN
DescriptionNumber of input channels (device to host). Default: NONE (Must be defined by app)
MacroDSD_CHANS_DAC
DescriptionNumber of DSD output channels. Default: 0 (disabled)
MacroI2S_CHANS_DAC
DescriptionNumber of IS2 channels to DAC/CODEC. Must be a multiple of 2. Default: NONE (Must be defined by app)
MacroI2S_CHANS_ADC
DescriptionNumber of I2S channels from ADC/CODEC. Must be a multiple of 2. Default: NONE (Must be defined by app)

7.1.3 频率和时钟

MacroMAX_FREQ
DescriptionMax supported sample frequency for device (Hz). Default: 192000
MacroMIN_FREQ
DescriptionMin supported sample frequency for device (Hz). Default 44100
MacroDEFAULT_FREQ
DescriptionDefault device sample frequency. A safe default should be used. Default: MIN_FREQ
MacroMCLK_441
DescriptionMaster clock defines for 44100 rates (in Hz). Default: NONE (Must be defined by app)
MacroMCLK_48
DescriptionMaster clock defines for 48000 rates (in Hz). Default: NONE (Must be defined by app)

7.1.4 Audio Class

MacroAUDIO_CLASS
DescriptionUSB Audio Class Version. Default: 2 (Audio Class version 2.0)
MacroAUDIO_CLASS_FALLBACK
DescriptionWhether or not to fall back to Audio Class 1.0 in USB Full-speed. Default: 0 (Disabled)
MacroFULL_SPEED_AUDIO_2
DescriptionWhether or not to run UAC2 in full-speed. When disabled device can either operate in UAC1 mode in full-speed (if AUDIO_CLASS_FALLBACK enabled) or return “null” descriptors. Default: 1 (Enabled) when AUDIO_CLASS_FALLBACK disabled.

7.1.5 系统功能配置

7.1.5.1 MIDI

MacroMIDI
DescriptionEnable MIDI functionality including buffffering, descriptors etc. Default: DISABLED
MacroMIDI_RX_PORT_WIDTH
DescriptionMIDI Rx port width (1 or 4bit). Default: 1

7.1.5.2 S/PDIF

MacroSPDIF_TX
DescriptionEnables SPDIF Tx. Default: 0 (Disabled)
MacroSPDIF_TX_INDEX
DescriptionDefines which output channels (stereo) should be output on S/PDIF. Note, Output channels indexed from 0. Default: 0 (i.e. channels 0 & 1)
MacroSPDIF_RX
DescriptionEnables SPDIF Rx. Default: 0 (Disabled)
MacroSPDIF_RX_INDEX
DescriptionS/PDIF Rx first channel index, defines which channels S/PDIF will be input on. Note, indexed from 0. Default: NONE (Must be defined by app when SPDIF_RX enabled)

7.1.5.3 ADAT

MacroADAT_RX
DescriptionEnables ADAT Rx. Default: 0 (Disabled)
MacroADAT_RX_INDEX
DescriptionADAT Rx first channel index. defines which channels ADAT will be input on. Note, indexed from 0. Default: NONE (Must be defined by app when ADAT_RX enabled)

7.1.5.4 PDM Microphones

MacroNUM_PDM_MICS
DescriptionNumber of PDM microphones in the design. Default: None

7.1.5.5 DFU

MacroDFU
DescriptionEnable DFU functionality. A driver required for Windows operation. Default: 1 (Enabled)

7.1.5.6 HID

MacroHID_CONTROLS
DescriptionEnable HID playback controls functionality. 1 for enabled, 0 for disabled. Default 0 (Disabled)

7.1.5.7 CODEC Interface

MacroCODEC_MASTER
Description

7.1.6 USB Device Configuration

MacroVENDOR_STR
DescriptionVendor String used by the device. This is also pre-pended to various strings used by the design. Default: “XMOS”
MacroVENDOR_ID
DescriptionUSB Vendor ID (or VID) as assigned by the USB-IF. Default: 0x20B1 (XMOS)
MacroPRODUCT_STR
DescriptionUSB Product String for the device. If defined will be used for both PRODUCT_STR_A2 and PRODUCT_STR_A1. Default: Undefined
MacroPRODUCT_STR_A2
DescriptionProduct string for Audio Class 2.0 mode. Default: “xCore USB Audio 2.0”
MacroPRODUCT_STR_A1
DescriptionProduct string for Audio Class 1.0 mode. Default: “xCore USB Audio 1.0”
MacroPID_AUDIO_1
DescriptionUSB Product ID (PID) for Audio Class 1.0 mode. Only required if AUDIO_CLASS == 1 or AUDIO_CLASS_FALLBACK is enabled. Default: 0x0003
MacroPID_AUDIO_2
DescriptionUSB Product ID (PID) for Audio Class 2.0 mode. Default: 0x0002
MacroBCD_DEVICE
DescriptionDevice firmware version number in Binary Coded Decimal format: 0xJJMN where JJ: major, M: minor, N: sub-minor version number. NOTE: User code should not modify this but should modify BCD_DEVICE_J, BCD_DEVICE_M, BCD_DEVICE_N instead Default: XMOS USB Audio Release version (e.g. 0x0651 for 6.5.1).

7.1.7 流格式

7.1.7.1 Output/Playback

MacroOUTPUT_FORMAT_COUNT
DescriptionNumber of supported output stream formats. Values 1,2,3 supported. Default: 2
MacroSTREAM_FORMAT_OUTPUT_1_RESOLUTION_BITS
DescriptionSample resolution (bits) of output stream Alternate 1. Default: 24 if Alternate 1 is PCM, else 32 if DSD/RAW. Note, 24 on the lowests alt in case of OUTPUT_FORMAT_COUNT = 1 leaving 24bit as the designs default resolution.
MacroSTREAM_FORMAT_OUTPUT_2_RESOLUTION_BITS
DescriptionSample resolution (bits) of output stream Alternate 2. Default: 16 if Alternate 2 is PCM, else 32 if DSD/RAW.
MacroSTREAM_FORMAT_OUTPUT_3_RESOLUTION_BITS
DescriptionSample resolution (bits) of output stream Alternate 3. Default: 32 if Alternate 2 is PCM, else 32 if DSD/RAW
MacroHS_STREAM_FORMAT_OUTPUT_1_SUBSLOT_BYTES
DescriptionSample sub-slot size (bytes) of output stream Alternate 1 when running in high-speed. Default: 4 if resolution for Alternate 1 is 24bits, else resolution / 8. Note, the default catchs the 24bit special case where 4-byte subslot is nicer for our 32-bit machine. Typically do not care about this extra bus overhead at High-speed.
MacroHS_STREAM_FORMAT_OUTPUT_2_SUBSLOT_BYTES
DescriptionSample sub-slot size (bytes) of output stream Alternate 2 when running in high-speed. Default: 4 if resolution for Alternate 2 is 24bits, else resolution / 8. Note, the default catchs the 24bit special case where 4-byte subslot is nicer for our 32-bit machine. Typically do not care about this extra bus overhead at High-speed.
MacroHS_STREAM_FORMAT_OUTPUT_3_SUBSLOT_BYTES
DescriptionSample sub-slot size (bytes) of output stream Alternate 3 when running in high-speed. Default: 4 if resolution for Alternate 3 is 24bits, else resolution / 8. Note, the default catchs the 24bit special case where 4-byte subslot is nicer for our 32-bit machine. Typically do not care about this extra bus overhead at High-speed.
MacroFS_STREAM_FORMAT_OUTPUT_1_SUBSLOT_BYTES
DescriptionSample sub-slot size (bytes) of output stream Alternate 1 when running in full-speed. Note, in full-speed mode bus bandwidth is at a premium, therefore pack samples into smallest possible sub-slot. Default: STREAM_FORMAT_OUTPUT_1_RESOLUTION_BITS / 8.
MacroFS_STREAM_FORMAT_OUTPUT_2_SUBSLOT_BYTES
DescriptionSample sub-slot size (bytes) of output stream Alternate 2 when running in full-speed. Note, in full-speed mode bus bandwidth is at a premium, therefore pack samples into smallest possible sub-slot. Default: STREAM_FORMAT_OUTPUT_2_RESOLUTION_BITS / 8
MacroFS_STREAM_FORMAT_OUTPUT_3_SUBSLOT_BYTES
DescriptionSample sub-slot size (bytes) of output stream Alternate 3 when running in full-speed. Note, in full-speed mode bus bandwidth is at a premium, therefore pack samples into smallest possible sub-slot. Default: STREAM_FORMAT_OUTPUT_3_RESOLUTION_BITS / 8
MacroSTREAM_FORMAT_OUTPUT_1_DATAFORMAT
DescriptionSample audio data-format if output stream Alternate 1. Default: UAC_FORMAT_TYPEI_RAW_DATA when Alternate 1 is RAW/DSD else UAC_FORMAT_TYPEI_PCM
MacroSTREAM_FORMAT_OUTPUT_2_DATAFORMAT
DescriptionSample audio data-format if output stream Alternate 2. Default: UAC_FORMAT_TYPEI_RAW_DATA when Alternate 2 is RAW/DSD else UAC_FORMAT_TYPEI_PCM
MacroSTREAM_FORMAT_OUTPUT_3_DATAFORMAT
DescriptionSample audio data-format if output stream Alternate 3. Default: UAC_FORMAT_TYPEI_RAW_DATA when Alternate 3 is RAW/DSD else UAC_FORMAT_TYPEI_PCM

7.1.7.2 Input/Recording

MacroINPUT_FORMAT_COUNT
DescriptionNumber of supported input stream formats. Default: 1.
MacroSTREAM_FORMAT_INPUT_1_RESOLUTION_BITS
DescriptionSample resolution (bits) of input stream Alternate 1. Default: 24.
MacroHS_STREAM_FORMAT_INPUT_1_SUBSLOT_BYTES
DescriptionSample sub-slot size (bytes) of input stream Alternate 1 when running in high-speed. Default: 4 if resolution for Alternate 1 is 24bits, else resolution / 8. Note, the default catchs the 24bit special case where 4-byte subslot is nicer for our 32-bit machine. Typically do not care about this extra bus overhead at High-speed.
MacroFS_STREAM_FORMAT_INPUT_1_SUBSLOT_BYTES
DescriptionSample sub-slot size (bytes) of input stream Alternate 1 when running in full-speed. Note, in full-speed mode bus bandwidth is at a premium, therefore pack samples into smallest possible sub-slot. Default: STREAM_FORMAT_INPUT_1_RESOLUTION_BITS / 8.
MacroSTREAM_FORMAT_INPUT_1_DATAFORMAT
DescriptionSample audio data-format for input stream Alternate 1. Default: UAC_FORMAT_TYPEI_PCM.

7.1.8 Volume Control

MacroOUTPUT_VOLUME_CONTROL
DescriptionEnable/disable output volume control including all processing and descriptor support. Default: 1 (Enabled).
MacroINPUT_VOLUME_CONTROL
DescriptionEnable/disable input volume control including all processing and descriptor support. Default: 1 (Enabled).
MacroMIN_VOLUME
DescriptionThe minimum volume setting above -inf. This is a signed 8.8 fixed point number that must be strictly greater than -128 (0x8000). Default: 0x8100 (-127db).
MacroMAX_VOLUME
DescriptionThe maximum volume setting. This is a signed 8.8 fixed point number. Default: 0x0000 (0db).
MacroVOLUME_RES
DescriptionThe resolution of the volume control in db as a 8.8 fixed point number. Default: 0x100 (1db).

7.1.9 Mixing Parameters

MacroMIXER
DescriptionEnable “mixer” core. Default: 0 (Disabled)
MacroMAX_MIX_COUNT
DescriptionNumber of seperate mixes to perform. Default: 8 if MIXER enabled, else 0.
MacroMIX_INPUTS
DescriptionNumber of channels input into the mixer. Note, total number of mixer nodes is MIX_INPUTS * MAX_MIX_COUNT. Default: 18.
MacroMIN_MIXER_VOLUME
DescriptionThe minimum volume setting for the mixer unit above -inf. This is a signed 8.8 fixed point number that must be strictly greater than -128 (0x8000). Default: 0x8100 (-127db).
MacroMAX_MIXER_VOLUME
DescriptionThe maximum volume setting for the mixer. This is a signed 8.8 fixed point number. Default: 0x0000 (0db).
MacroVOLUME_RES_MIXER
DescriptionThe resolution of the volume control in db as a 8.8 fixed point number. Default: 0x100 (1db).

7.1.10 Power

MacroSELF_POWERED
DescriptionReport as self to the host when enabled, else reports as bus-powered. This affffects descriptors and XUD usage. Default: 0 (Disabled).
MacroBMAX_POWER
DescriptionPower drawn from the host (in mA x 2). Default: 0 when SELF_POWERED enabled else 250 (500mA).

7.2 所需的用户函数定义

以下功能需要由一个使用XMOS USB音频框架的应用程序来定义。

7.2.1 外部音频硬件配置功能

FunctionAudioHwInit
DescriptionThis function is called when the audio core starts after the device boots up and should initialize the external audio harware e.g. clocking, DAC, ADC etc.
Typevoid AudioHwInit(chanend ?c_codec)
Parametersc_codec An optional chanend that was original passed into audio() that can be used to communicate with other cores.
FunctionAudioHwConfig
DescriptionThis function is called when the audio core starts or changes sample rate. It should configure the extenal audio hardware to run at the specified sample rate given the supplied master clock frequency.
Typevoid AudioHwConfig(unsigned samFreq, unsigned mclk, chanend ?c_codec, unsigned dsdMode, unsigned sampRes_DAC, unsigned sampRes_ADC)
ParameterssamFreq The sample frequency in Hz that the hardware should be configured to (in Hz).
mclkThe master clock frequency that is required in Hz.
c_codecAn optional chanend that was original passed into audio() that can be used to communicate with other cores.
dsdModeSignifies if the audio hardware should be configured for DSD operation.
sampRes_DACThe sample resolution of the DAC stream.
sampRes_ADC The sample resolution of the ADC stream.

7.2.2 音频流功能

设计人员可选择使用以下功能。它们可以用于静音线等。

FunctionAudioStreamStart
DescriptionThis function is called when the audio stream from device to host starts.
Typevoid AudioStreamStart(void)
Parameters
FunctionAudioStreamStop
DescriptionThis function is called when the audio stream from device to host stops.
Typevoid AudioStreamStop(void)

7.2.3 主机激活

以下功能可用于指示设备已连接到有效主机的信号。这是对状态的改变的。

FunctionAudioStreamStart
Description
Typevoid AudioStreamStart(int active)
Parametersactive Indicates if the host is active or not. 1 for active else 0.

7.2.4 HID Controls

当设备希望读取物理用户输入(按钮等)时,将调用以下函数。

FunctionUserReadHIDButtons
Description
Typevoid UserReadHIDButtons(unsigned char hidData[])
ParametershidData The function should write relevant HID bits into this array. The bit ordering and functionality is defined by the HID report descriptor used.

7.3 组件API

可以从应用程序的顶级主节点调用以下函数,并实现3.1中描述的各种组件。

FunctionXUD_Manager
DescriptionThis performs the low-level USB I/O operations. Note that this needs to run in a thread with at least 80 MIPS worst case execution speed.
Typeint XUD_Manager(chanend c_epOut[],int noEpOut,chanend c_epIn[],int noEpIn,chanend ?c_sof,XUD_EpType epTypeTableOut[],XUD_EpType epTypeTableIn[],out port ?p_usb_rst,clock ?clk,unsigned rstMask,XUD_BusSpeed_t desiredSpeed,XUD_PwrConfig pwrConfig)
Parametersc_epOutAn array of channel ends, one channel end per output endpoint (USB OUT transaction); this includes a channel to obtain requests on Endpoint 0.
noEpOutThe number of output endpoints, should be at least 1 (for Endpoint 0).
c_epInAn array of channel ends, one channel end per input endpoint (USB IN transaction); this includes a channel to respond to requests on Endpoint 0.
noEpInThe number of input endpoints, should be at least 1 (for Endpoint 0).
c_sofA channel to receive SOF tokens on. This channel must be connected to a process that can receive a token once every 125 ms. If tokens are not read, the USB layer will lock up. If no SOF tokens are required null should be used for this parameter.
epTypeTableOutSeeepTypeTableIn.
epTypeTableIn.This andepTypeTableOut are two arrays indicating the type of the endpoint. Legal types include: XUD_EPTYPE_CTL (Endpoint 0), XUD_EPTYPE_BUL (Bulk endpoint), XUD_EPTYPE_ISO (Isochronous endpoint), XUD_EPTYPE_INT (Interrupt endpoint), XUD_EPTYPE_DIS (Endpoint not used). The first array contains the endpoint types for each of the OUT endpoints, the second array contains the endpoint types for each of the IN endpoints.
p_usb_rstThe port to used to connect to an external phy reset line. Should be null for U-Series.
clkThe clock block to use for the p_usb_rst port - this should not be clock block 0. Should be null for U-Series.
rstMaskThe mask to use when taking an external phy into/out of reset. The mask is ORed into the port to disable reset, and unset when deasserting reset. Use ‘-1’ as a default mask if this port is not shared.
desiredSpeedThis parameter specifies what speed the device will attempt to run at i.e. full-speed (ie 12Mbps) or high-speed (480Mbps) if supported by the host. Pass XUD_SPEED_HS if high-speed is desired or XUD_SPEED_FS if not. Low speed USB is not supported by XUD.
pwrConfigSpecifies whether the device is bus or self-powered. When self-powered the XUD will monitor the VBUS line for host disconnections. This is required for compliance reasons. Valid values are XUD_PWR_SELF and XUD_PWR_BUS.

当使用USB音频框架时,c_ep_in数组总是按以下顺序组成:

Endpoint 0 (in)

  • Audio Feedback endpoint (if output enabled)

  • Audio IN endpoint (if input enabled)

  • MIDI IN endpoint (if MIDI enabled)

  • Clock Interrupt endpoint

数组c_ep_out总是按以下顺序组成:

  • Endpoint 0 (out)

  • Audio OUT endpoint (if output enabled)

  • MIDI OUT endpoint (if MIDI enabled)

FunctionEndpoint0
DescriptionFunction implementing Endpoint 0 for enumeration, control and configuration of USB audio devices. It uses the descriptors defined in descriptors_2.h.
Typevoid Endpoint0(chanend c_ep0_out,chanend c_ep0_in,chanend c_audioCtrl,chanend ?c_mix_ctl,chanend ?c_clk_ctl,chanend ?c_EANativeTransport_ctr,client interface i_dfu dfuInterface)
Parametersc_ep0_outChanend connected to the XUD_Manager() out endpoint array
c_ep0_inChanend connected to the XUD_Manager() in endpoint array
c_audioCtrlChanend connected to the decouple thread for control audio (sample rate changes etc.)
c_mix_ctlOptional chanend to be connected to the mixer thread if present
c_clk_ctlOptional chanend to be connected to the clockgen thread if present.
c_usb_testOptional chanend to be connected to XUD if test modes required.
c_EANativeTransport_ctrlOptional chanend to be connected to EA Native endpoint manager if present
Functionbuffffer
DescriptionUSB Audio Buffffering Thread. This function buffffers USB audio data between the XUD layer and the decouple thread. Most of the chanend parameters to the function should be connected to XUD_Manager()
Typevoid buffer(chanend c_aud_out,chanend c_aud_in,chanend c_aud_fb,chanend c_sof,chanend c_aud_ctl,in port p_off_mclk)
Parametersc_aud_outAudio OUT endpoint channel connected to the XUD
c_aud_inAudio IN endpoint channel connected to the XUD
c_aud_fbAudio feedback endpoint channel connected to the XUD
c_midi_from_hostMIDI OUT endpoint channel connected to the XUD
c_midi_to_hostMIDI IN endpoint channel connected to the XUD
c_intAudio clocking interrupt endpoint channel connected to the XUD
c_clk_intOptional chanend connected to the clockGen() thread if present
c_sofStart of frame channel connected to the XUD
c_aud_ctlAudio control channel connected to Endpoint0()
p_off_mclkA port that is clocked of the MCLK input (not the MCLK input itself)
Functiondecouple
DescriptionManage the data transfer between the USB audio buffffer and the Audio I/O audio driver.
Typevoid decouple(chanend c_audio_out)
Parametersc_audio_outChannel connected to the audio() or mixer() threads
Functionmixer
DescriptionDigital sample mixer. This thread mixes audio streams between the decouple() and the audio() thread.
Typevoid mixer(chanend c_to_host, chanend c_to_audio, chanend c_mix_ctl)
Parametersc_to_hosta chanend connected to the decouple() thread for receiving/transmitting samples
c_to_audioa chanend connected to the audio() thread for receiving/transmitting samples
c_mix_ctla chanend connected to the Endpoint0() thread for receiving control commands
Functionaudio
DescriptionThe audio driver thread. This function drives I2S ports and handles samples to/from other digital I/O threads.
Typevoid audio(chanend c_in, chanend ?c_config, chanend ?c_adc)
Parametersc_inAudio sample channel connected to the mixer() thread or the decouple() thread
c_digchannel connected to the clockGen() thread for receiving/transmitting samples
c_configAn optional channel that will be passed on to the CODEC configuration functions.
FunctionclockGen
DescriptionClock generation and digital audio I/O handling.
Typevoid clockGen(streaming chanend ?c_spdif_rx,chanend ?c_adat_rx,out port p,chanend c_audio,chanend c_clk_ctl,chanend c_clk_int)
Parametersc_spdif_rxchannel connected to S/PDIF receive thread.
c_adat_rxchannel connect to ADAT receive thread.
pport to output clock signal to drive external frequency synthesizer.
c_audiochannel connected to the audio() thread.
c_clk_ctlchannel connected to Endpoint0() for configuration of the clock.
c_clk_intchannel connected to the decouple() thread for clock interrupts
FunctionSpdifReceive
DescriptionS/PDIF receive function. This function needs 1 thread and no memory other than ~2800 bytes of program code. It can do 11025, 12000, 22050, 24000, 44100, 48000, 88200, 96000, and 192000 Hz. When the decoder encounters a long series of zeros it will lower the divider; when it encounters a short series of 0-1 transitions it will increase the divider.
Output: the received 24-bit sample values are output as a word on the streaming channel end. Each value is shifted up by 4-bits with the bottom four bits being one of FRAME_X, FRAME_Y, or FRAME_Z. The bottom four bits should be removed whereupon the sample value should be sign extended.
The function does not return unless compiled with TEST defined in which case it returns any time that it loses synchronisation.
Typevoid SpdifReceive(in buffered port:4 p,streaming chanend c,int initial_divider,clock clk)
ParameterspS/PDIF input port. This port must be 4-bit buffffered, declared as in buffered port:4
cchannel to output samples to
initial_dividerinitial divide for initial estimate of sample rate For a 100Mhz reference clock, use an initial divider of 1 for 192000, 2 for 96000/88200, and 4 for 48000/44100.
clkclock block sourced from the 100 MHz reference clock.
FunctionadatReceiver48000
DescriptionADAT Receive Thread (48kHz sample rate).
When a data rame is received, samples will be output onto the streaming channel At first a word 0x000000Z1 will be output, where Z are the user data; after that eight words 0x0ZZZZZZ0 will be output where ZZZZZZ is a 24-bit sample value. The eight words may refer to sample values on eight channels, or on fewer channels if muxing is used.
The function will return if it cannot lock onto a 48,000 Hz signal. Normally the 48000 function is called in a while(1) loop. If both 44,100 and 48,000 need to be supported, they should be called in sequence in a while(1) loop. Note that the functions are large, and that 44,100 should not be called if 44.1 KHz does not need to be supported.
Typevoid adatReceiver48000(buffered in port:32 p, chanend oChan)
ParameterspADAT port - should be 1-bit and clocked at 100MHz
oChanchannel on which decoded samples are output
FunctionadatReceiver44100
DescriptionADAT Receive Thread (44.1kHz sample rate).
When a data rame is received, samples will be output onto the streaming channel At first a word 0x000000Z1 will be output, where Z are the user data; after that eight words 0x0ZZZZZZ0 will be output where ZZZZZZ is a 24-bit sample value. The eight words may refer to sample values on eight channels, or on fewer channels if muxing is used.
The function will return if it cannot lock onto a 44,100 Hz signal. Normally the 44,100 function is called in a while(1) loop. If both 44,100 and 48,000 need to be supported, they should be called in sequence in a while(1) loop. Note that the functions are large, and that 48,000 should not be called if 48 Khz does not need to be supported.
Typevoid adatReceiver44100(buffered in port:32 p, chanend oChan)
ParameterspADAT port - should be 1-bit and clocked at 100MHz

oChanchannel on which decoded samples are output
Functionusb_midi
DescriptionUSB MIDI I/O thread. This function passes MIDI data from USB to UART I/O.
Typevoid usb_midi(buffered in port:1 ?p_midi_in, port ?p_midi_out, clock ?clk_midi, chanend ?c_midi, unsigned cable_number, chanend ?c_iap, chanend ?c_i2c, port ?p_scl, port ?p_sda)
Parametersp_midi_in1-bit input port for MIDI
p_midi_out1-bit output port for MIDI

clk_midiclock block used for clockin the UART; should have a rate of 100MHz
c_midichanend connected to the decouple() thread
cable_numberthe cable number of the MIDI implementation. This should be set to 0.