XMOS xCORE-200 Multi-channel Audio board Design Manual

Usb audio
Hide thumbs Also See for xCORE-200 Multi-channel Audio board:
Table of Contents

Advertisement

USB Audio Design Guide
Document Number: XM0088546.1
Publication Date: 2016/5/12
XMOS © 2016, All Rights Reserved.

Advertisement

Table of Contents
loading

Summary of Contents for XMOS xCORE-200 Multi-channel Audio board

  • Page 1 USB Audio Design Guide Document Number: XM0088546.1 Publication Date: 2016/5/12 XMOS © 2016, All Rights Reserved.
  • Page 2 The XMOS USB Audio solution provides USB Audio Class compliant devices over USB 2.0 (high- speed or full-speed). Based on the XMOS XS1 architecture, it supports USB Audio Class 2.0 and USB Audio Class 1.0, asynchronous mode and sample rates up to 384kHz.
  • Page 3: Table Of Contents

    Table of Contents 1 Overview 2 Hardware Platforms xCORE-200 Multi-Channel Audio Board ......2.1.1 Analogue Input & Output .
  • Page 4 USB Audio Design Guide 4/110 3.13 Overview of PDM implemention ......37 3.13.1 PDM Microphone Hardware Characteristics .
  • Page 5 ....... 79 The xCORE-200 Multi-Channel Audio Board ..... . . 79 6.6.1 Clocking and Clock Selection...
  • Page 6: Overview

    1 Overview XM0088546.1...
  • Page 7: Usb Audio Design Guide

    External audio DAC/ADC/CODECs (and required supporting componentry) supporting I2S/TDM Boot/Storage Compatible SPI Flash device Licensing and Support Reference code provided without charge under license from XMOS. Please visit for support. http://www.xmos.com/support/contact Reference code is maintained by XMOS Limited. http://www.usb.org/developers/devclass_docs/audio10.pdf http://www.usb.org/developers/devclass_docs/Audio2.0_final.zip http://www.usb.org/developers/devclass_docs/DFU_1.1.pdf...
  • Page 8: Hardware Platforms

    USB Audio 2.0 Reference Design Board USB Audio 2.0 Multichannel Reference Design Board The following sections describe the hardware platforms that support development with the XMOS USB Audio software framework. 2.1 xCORE-200 Multi-Channel Audio Board The XMOS xCORE-200 Multi-channel Audio board...
  • Page 9: Analogue Input & Output

    An array of 4*4 green LEDs, 3 buttons and a switch are provided for general purpose user interfacing. The LED array is driven by eight signals each controlling one of 4 rows and 4 columns. A standard XMOS xSYS interface is provided to allow host debug of the board via JTAG. XM0088546.1...
  • Page 10: Xcore-200 Microphone Array Board

    2.2 xCORE-200 Microphone Array Board The XMOS xCORE-200 Microphone Array board (XK-USB-MIC-UF216) is design available from XMOS based on a dual-tile XMOS xCORE-200 device. The board integrates the following building blocks: multiple omni-directional microphones, on-board low-jitter clock sources, configurable user input buttons and a USB2.0 device for connectivity.
  • Page 11: Microphones

    USB Audio Design Guide 11/110 2.2.1 Microphones The xCORE Microphone Array board features 7 MEMS microphones with PDM (Pulse Density Modulation) output. Figure shows the microphone arrangement on the board. MIC6 MIC1 xCORE-200 XUF216 MIC0 MIC5 MIC2 Figure 2: MIC3 xCORE-200 MIC4 Microphone...
  • Page 12: Audio Clocking

    USB Audio Design Guide 12/110 2.2.3 Audio Clocking The board provides a low-jitter clock-source, an 24.576MHz oscillator, to serve as reference clock to the CS2100-CP (Cirrus Logic) Fractional-N PLL (U22). The CS2100 generates a low-jitter output signal that is distributed to the xCORE- 200 device and DAC.
  • Page 13 Four general purpose push-button switches are provided. When pressed, each button creates a connection from the I/O to GND. A standard XMOS xSYS interface (J2) is provided to allow host debug of the board via JTAG. The board also includes Ethernet conextivity, however, this is outside the scope of this documentation.
  • Page 14: Usb Multi-Function Audio (Mfa) Kit

    The separate USB slice board allows flexibility in the connection method to the USB audio source/sink as well as other functionality such as 3rd party authentication ICs and any required USB switching. This also means the XMOS device can be used as a USB device or host using the same main board.
  • Page 15: U16 Multi-Channel Usb Audio Kit

    The separate USB slice board allows flexibility in the connection method to the USB audio source/sink as well as other functionality such as 3rd party authentication ICs and any required USB switching. This also means the XMOS device can be used as a USB device or host using the same main board.
  • Page 16: Usb Audio 2.0 Dj Kit

    This hardware should not be used for the basis of a new design. The USB Audio 2.0 Reference Design is a stereo hardware reference design available from XMOS based on an XMOS L8 device (previously named L1). The diagram in Figure shows the block layout of the USB Audio 2.0 Reference Design board.
  • Page 17: Usb Audio 2.0 Multichannel Reference Design Board

    This hardware should not be used for the basis of a new design. The USB Audio 2.0 Multichannel Reference Design (XR-USB-AUDIO-2.0-MC) is a hardware reference design available from XMOS based on the XMOS L16 device (previously named L2) Figure shows the block layout of the USB Audio 2.0 Multichannel Reference Design board.
  • Page 18 USB Audio Design Guide 18/110 <= 012.. 012.. 012.. 012.. 012.. Figure 6: 012.. USB Audio 012.. Multichannel Reference 012.. Design Block Diagram XM0088546.1...
  • Page 19: Software Architecture

    PDM Microphones Overview of PDM implemention Resource Usage The following sections describe the software architecture of the XMOS USB Audio framework. XMOS USB Audio solutions are provided as a framework with reference design applications customising and extending this framework to provide the required functionality.
  • Page 20: The Usb Audio System Architecture

    This section will now examine these components in further detail. 3.2 XMOS USB Device (XUD) Library All low level communication with the USB host is handled by the XMOS USB Device (XUD) library. The XUD_Manager() function runs in its own core and communicates with endpoint cores though a mixture of shared memory and channel communications.
  • Page 21 21/110 Figure 9: USB Audio Core Diagram For more details and full XUD API documentation please refer to XMOS USB Device (XUD) Library Figure shows the XUD library communicating with two other cores: Endpoint 0: This core controls the enumeration/configuration tasks of the USB device.
  • Page 22: Endpoint 0: Management And Control

    USB SET_ADDRESS requests For more information and full documentation, including full worked examples of simple devices, please refer the XMOS USB Device Design Guide The USB_StandardRequests() function takes the devices various descriptors as parameters, these are passed from data structures found in the descriptors.h file.
  • Page 23: Over-Riding Standard Requests

    USB Audio Design Guide 23/110 The function may also return XUD_RES_RST if a bus-reset has been issued onto the bus by the host and communicated from XUD to Endpoint 0. Since the USB_StandardRequests() function STALLs an unknown request, the end- point 0 code must parse the USB_SetupPacket_t structure to handle device specific requests and then calling USB_StandardRequests() as required.
  • Page 24: Audio Endpoints (Endpoint Buffer And Decoupler)

    USB Audio Design Guide 24/110 3.3.3.2 Audio Request: Set Sample Rate The AudioClassRequests_2() function parses the passed USB_SetupPacket_t struc- ture for a CUR request of type SAM_FREQ_CNTROL to a Clock Unit in the devices topology (as described in the devices descriptors). The new sample frequency is extracted and passed via channel to the rest of the design - through the buffering code and eventually to the Audio IO/I2S core.
  • Page 25: Decoupler

    USB Audio Design Guide 25/110 3.4.2 Decoupler The decoupler supplies the USB buffering core with buffers to transmit/receive audio data to/from the host. It marshals these buffers into FIFOs. The data from the FIFOs are then sent over XC channels to other parts of the system as they need it.
  • Page 26 USB Audio Design Guide 26/110 The audio system sends a word over a channel to the decouple core to request sample transfer (using the build in outuint function). The receipt of this word in the channel causes the handle_audio_request interrupt to fire. The first operation the interrupt handler does is to send back a word acknowledging the request (if there was a change of sample frequency a control token would instead be sent—the audio system uses a testct() to inspect for this case).
  • Page 27: Audio Driver

    USB Audio Design Guide 27/110 This asynchronous clocking scheme means that the device is the clocking master than therefore means a high-quality local master clock source can be used. After each received USB SOF token, the buffering core takes a time-stamp from a port clocked off...
  • Page 28 The bit clock controls the rate at which data is transmitted to and from the CODEC. In the case where the XMOS device is the master, it divides the MCLK to generate the required signals for both BCLK and LRCLK, with BCLK then being used to clock data in (SDIN) and data out (SDOUT) of the CODEC.
  • Page 29: Port Configuration (Xcore Master)

    The code to configure the ports and clocks is in the ConfigAudioPorts() function. Developers should not need to modify this. The XMOS device inputs MCLK and divides it down to generate BCLK and LRCLK. To achieve this MCLK is input into the device using the 1-bit port p_mclk . This is attached to the clock block clk_audio_mclk , which is in turn used to clock the BCLK port, p_bclk .
  • Page 30: Changing Audio Sample Frequency

    USB Audio Design Guide 30/110 master-clock and bit-clock. The following table shows the required pattern for different values of this divide: Divide Output pattern Outputs per sample Figure 15: 0xAAAAAAAA Output 0xCCCCCCCC patterns 0xF0F0F0F0 In any case, the bit clock outputs 32 clock cycles per sample. In the special case where the divide is 1 (i.e.
  • Page 31: Control

    3.6.2 Host Control The mixer can be controlled from a host PC by sending requests to Endpoint 0. XMOS provides a simple command line based sample application demonstrating how the mixer can be controlled. For details, consult the README file in the host_usb_mixer_control directory.
  • Page 32 There is enough flexibility within this configuration that there will often be multiple ways of creating the required solution. Whilst using the XMOS Host control example application, consider setting the mixer to perform a loop-back from analogue inputs 1 and 2 to analogue outputs 1 and 2.
  • Page 33: S/Pdif Transmit

    1/2 this can be heard looped through to analogue outputs 1/2. 3.7 S/PDIF Transmit XMOS devices can support S/PDIF transmit up to 192kHz. The XMOS S/SPDIF transmitter component runs in a single core and can be found in sc_spdif/module_spdif_tx XM0088546.1...
  • Page 34: Clocking

    USB Audio Design Guide 34/110 The S/PDIF transmitter core takes PCM audio samples via a channel and outputs them in S/PDIF format to a port. A lookup table is used to encode the audio data into the required format. It receives samples from the Audio I/O core two at a time (for left and right). For each sample, it performs a lookup on each byte, generating 16 bits of encoded data which it outputs to a port.
  • Page 35: Usage

    Unused, set to 0 S/PDIF Stream Channel status See below Structure Parity Correct parity across bits 4:30 Frequency (kHz) 44.1 88.2 Figure 21: Channel 176.4 Status Bits 3.8 S/PDIF Receive XMOS devices can support S/PDIF receive up to 192kHz. XM0088546.1...
  • Page 36: Usage And Integration

    USB Audio Design Guide 36/110 The S/PDIF receiver module uses a clockblock and a buffered one-bit port. The clock-block is divided of a 100 MHz reference clock. The one bit port is buffered to 4-bits. The receiver code uses this clock to over sample the input data. The receiver outputs audio samples over a streaming channel end where data can be input using the built-in input operator.
  • Page 37: Adat Receive

    USB Audio Design Guide 37/110 The following code snippet illustrates how the output of the S/PDIF receive compo- nent could be used: while (1) c_spdif_rx : > data ; if ( badParity ( data ) continue ; tag = data & 0 xF ; /* Extract 24 bit audio sample */ sample = ( data <<...
  • Page 38: Integration

    An application can either provide fixed master clock sources via selectable oscil- lators, clock generation IC, etc, to provide the audio master or use an external PLL/Clock Multiplier to generate a master clock based on reference from the XMOS device.
  • Page 39: Midi

    The design is capable of integrating PDM microphones. The PDM stream from the microphones is converted to PCM and output to the host via USB. Interfacing to the PDM microphones is done using the XMOS microphone array library ( lib_mic_array ). lib_mic_array is designed to allow interfacing to PDM microphones coupled with efficient decimation to user selectable output sample...
  • Page 40: Pdm Microphone Hardware Characteristics

    USB Audio Design Guide 40/110 Up to sixteen PDM microphones can be attached to each high channel count PDM interface ( mic_array_pdm_rx() ). One to four processing tasks, mic_array_decimate_to_pcm_4ch() , each process up to four channels. For 1-4 channels the library requires two logical cores: Figure 24: Div N Select...
  • Page 41: Integration Of Pdm Microphones Into Usb Audio

    USB Audio Design Guide 41/110 Figure 26: microphone data and CLOCK Clock line, the PDM clock the used by the microphones to drive the data out. signal wires DQ_PDM The data from the PDM microphones on an 8 bit port. The only port that is passed into lib_mic_array is the 8-bit data port.
  • Page 42: Resource Usage

    The ULPI ports are a fixed set of ports on the L-Series device. When using these ports, other ports are unavailable when ULPI is active. See the XS1-L Hardware Design Checklist for further details. http://www.xmos.com/published/xs1lcheck XM0088546.1...
  • Page 43: Features & Options

    The DFU interface handles updates to the boot image of the device. The DFU code is called from the Endpoint 0 core. The interface links USB to the XMOS flash user library (see XM-000953-PC). In Application mode the DFU can accept commands to reset the device into DFU mode.
  • Page 44: Driver Support

    XMOS for further details. 4.2.2 Audio Class 1.0 Mode and Fall-back The normal default for XMOS USB Audio applications is to run as a high-speed Audio Class 2.0 device. However, some products may prefer to run in Audio Class 1.0 mode, this is normally to allow “driver-less”...
  • Page 45: Audio Controls Via Human Interface Device (Hid)

    USB Audio Design Guide 45/110 Due to bandwidth limitations of full-speed USB the following sample-frequency restrictions are also applied: Sample rate is limited to a maximum of 48kHz if both input and output are enabled. Sample rate is limited to a maximum of 96kHz if only input or output is enabled. 4.3 Audio Controls via Human Interface Device (HID) The design supports simple audio controls such as play/pause, volume up/down etc via the USB Human Interface Device Class Specification.
  • Page 46: Apple Mfi Compatibility

    For a full example please see the HID section in §6.1. 4.4 Apple MFi compatibility XMOS devices are capable of operating with Apple iPod, iPhone, and iPad devices that feature USB host support. Information regarding this functionality is protected by the Made For iPod (MFi) program and associated licensing.
  • Page 47: Audio Subslot

    USB Audio Design Guide 47/110 4.5.1 Audio Subslot An audio subslot holds a single audio sample. See USB Device Class Definition for Audio Data Formats for full details. This is represented by bSubslotSize in the devices descriptors An audio subslot always contains an integer number of bytes. The specification limits the possible audio sublot size (bSubslotSize) to 1, 2, 3 or 4 bytes per audio subslot.
  • Page 48: Audio Format

    Since the Apple OS only allows a PCM path a method of transporting DSD audio data over PCM frames has been developed. This data can then be sent via the native USB Audio support. The XMOS USB Audio design(s) implement the method described in DoP Open Standard 1.1 http://www.usb.org/developers/devclass_docs/Audio2.0_final.zip http://dsd-guide.com/sites/default/files/white-papers/DoP_openStandard_1v1.pdf...
  • Page 49 USB Audio Design Guide 49/110 Standard DSD has a sample size of 1 bit and a sample rate of 2.8224MHz - this is 64x the speed of CD. This equates to the same data-rate as a 16 bit PCM stream at 176.4kHz.
  • Page 50: Programming Guide

    5 Programming Guide IN TH I S C H A P T ER Getting Started Project Structure Build Configurations Validated Build Configurations Configuration Naming Scheme A USB Audio Application Adding Custom Code The following sections provide a guide on how to program the USB audio software platform including instructions for building and running programs and creating your own custom USB audio applications.
  • Page 51: Installing The Application Onto Flash

    8. Browse for the XE file in the Project and C/XC Application boxes. 9. Ensure the xTAG-2 device appears in the target list. 10. Click Flash. From the command line: 1. Open the XMOS command line tools (Desktop Tools Prompt) and execute the following command: xflash < binary >. xe XM0088546.1...
  • Page 52: Project Structure

    USB Audio Design Guide 52/110 5.2 Project Structure 5.2.1 Applications and Modules The code is split into several module directories. The code for these modules can be included by adding the module name to the USED_MODULES define in an application Makefile: module_xud Low level USB device library module_usb_shared...
  • Page 53: Validated Build Configurations

    5.4 Validated Build Configurations It is not possible for all build configuration permutations to be exhaustively tested. XMOS therefore test a subset of build configurations for proper behaviour, these are based on popular device configurations. The presence of a build configuration in an application signifies it as a Validated Build Configuration and should be considered supported.
  • Page 54: Custom Defines

    USB Audio Design Guide 54/110 5.6.1 Custom Defines The customdefines.h file contains all the #defines required to tailor the USB audio framework to the particular application at hand. Typically these over-ride default values in devicedefines.h in module_usb_audio. First there are defines to determine overall capability. For this appliction S/PDIF output and DFU are enabled.
  • Page 55: Configuration Functions

    # define MAX_FREQ (192000) # endif Finally, there are some general USB identification defines to be set. These are set for the XMOS reference design but vary per manufacturer: # define VENDOR_ID (0 x20B1 ) /* XMOS VID */ # define PID_AUDIO_2...
  • Page 56 USB Audio Design Guide 56/110 /* Configures the CODEC for the required sample frequency . * CODEC reset and frequency select are connected to port 32 A * Port 32 A is shared with other functionality ( LEDs etc ) so we * access via inline assembly .
  • Page 57: The Main Program

    USB Audio Design Guide 57/110 # include < xs1 .h > # include " port32A . h " /* Functions that handle functions that must occur on stream * start / stop e . g . DAC mute / un - mute . These need implementing * for a specific design .
  • Page 58 USB Audio Design Guide 58/110 The framework supports devices with multiple tiles so it uses the on tile[n]: syntax. The first core run is the XUD library: # if ( AUDIO_CLASS ==2) XUD_Manager ( c_xud_out , ENDPOINT_COUNT_OUT , c_xud_in , ENDPOINT_COUNT_IN , c_sof , epTypeTableOut , epTypeTableIn , p_usb_rst , clk , 1 , XUD_SPEED_HS , XUD_PWR_CFG ) ;...
  • Page 59 USB Audio Design Guide 59/110 buffer ( c_xud_out [ E N D P O I N T _ N U M B E R _ O U T _ A U D I O ] , /* Audio Out */ c_xud_in [ E N D P O I N T _ N U M B E R _ I N _ A U D I O ] , /* Audio In */ # if ( NU M _U S B_ CH A N_ IN == 0) || defined ( U A C _ F O R C E _ F E E D B A C K _ E P )
  • Page 60: Adding Custom Code

    Finally, if MIDI is enabled you need a core to drive the MIDI input and output. The MIDI core also optionally handles authentication with Apple devices. Due to licensing issues this code is only available to Apple MFI licensees. Please contact XMOS for details. on tile [ MIDI_TILE ]: thread_speed () ;...
  • Page 61: Example: Changing Output Format

    To do this you need to alter the main audio driver loop in audio.xc . After the alteration you need to re-test the functionality. The XMOS Timing Analyzer can help guarantee that your changes do not break the timing requirement of this core.
  • Page 62 USB Audio Design Guide 62/110 3. Implement the DSP on this core. This needs to be synchronous (i.e. for every sample received from the decoupler, a sample needs to be outputted to the audio driver). XM0088546.1...
  • Page 63: Usb Audio Applications

    The USB Audio 2.0 Multichannel Reference Design (L-Series) Software The Multi-function Audio Kit (U-Series) The U-Series Multi-Channel USB Audio Kit The xCORE-200 Multi-Channel Audio Board The xCORE-200 Array Microphone Board In addition to the overall framework, reference design applications are provided.
  • Page 64: Port 32A

    USB Audio Design Guide 64/110 Figure 32: Single Tile L-Series Software Core Diagram (with S/PDIF Figure 33: Single Tile L-Series Software Core Diagram (with MIDI I/O) 6.1.1 Port 32A Port 32A on the XS1-L device is a 32-bit wide port that has several separate signal bit signal connected to it, accessed by multiple cores.
  • Page 65: Clocking

    USB Audio Design Guide 65/110 This method of port usage (i.e. sharing a port between cores) is outside the standard XC usage model so is implemented using inline assembly as required. The peek instruction is used to get the current output value on the port: /* Peek at current port value using port 32 A resource ID */ asm ( "...
  • Page 66: Hid

    USB Audio Design Guide 66/110 BCLK Codec LR CLK L8A-64-TQ128 SDOUT CS427 SDIN MCLK MCLK_SEL 24.576 MHz 11.2896 MHz Figure 35: Crystal Crystal Audio Clock Connections CODEC mode CODEC sample rate range (kHz) Single-Speed 4-54 Figure 36: CODEC Double-Speed 50-108 Modes Quad-Speed 100-216...
  • Page 67: Validated Build Options

    USB Audio Design Guide 67/110 /* Write HID Report Data into hidData array * Bits are as follows : * 0: Play / Pause * 1: Scan Next Track * 2: Scan Prev Track * 3: Volume Up * 4: Volime Down * 5: Mute void U s e r R e a d H I D B u t t o n s ( unsigned char hidData []) # ifndef MIDI...
  • Page 68: The Usb Audio 2.0 Dj Kit (U-Series)

    §2.5 and is implemented on the U-Series single tile device (500MIPS). The software design supports four channels of audio at sample frequencies up to 192kHz and uses the following components: XMOS USB Device Driver (XUD) Endpoint 0 Endpoint buffer Decoupler...
  • Page 69: Clocking And Clock Selection

    USB Audio Design Guide 69/110 6.2.1 Clocking and Clock Selection The actual hardware involved in the clock generation is somewhat different to the single tile L-Series board. Instead of two separate oscillators and switching logic a single oscillator with a Phaselink PLL is used to generate fixed 24.576MHz and 22.5792MHz master-clocks.
  • Page 70: Validated Build Options

    USB Audio Design Guide 70/110 The Vendor_ReadHIDButtons() function simply looks at the value from the ADC, if is near the maximum value it reports a volume up, near the minimum value a volume down is reported. If the ADC value is mid-range no event is reported. The code is shown below: void V e n d o r _ R e a d H I D B u t t o n s ( unsigned char hidData []) unsigned adcVal ;...
  • Page 71: The Usb Audio 2.0 Multichannel Reference Design (L-Series) Software

    L-Series dual tile device (1000MIPS). The software design supports up to 16 channels of audio in and 10 channels of audio out and supports sample frequencies up to 192 kHz and uses the following components: XMOS USB Device Driver (XUD) Endpoint 0 Endpoint buffer Decoupler XM0088546.1...
  • Page 72 USB Audio Design Guide 72/110 Audio Driver Device Firmware Upgrade (DFU) Mixer S/PDIF Transmitter S/PDIF Receiver ADAT Receiver Clockgen MIDI Figure shows the software layout of the USB Audio 2.0 Multichannel Reference Design. tile[0] tile[1] Figure 37: Dual Tile L-Series Reference Design Core Layout...
  • Page 73: Clocking

    USB Audio Design Guide 73/110 6.3.1 Clocking For complete clocking flexibility the dual tile L-Series reference design drives a reference clock to an external fractional-n clock multiplier IC (Cirrus Logic CS2300). This in turn generates the master clock used over the design. This is described in §3.10.
  • Page 74: The Multi-Function Audio Kit (U-Series)

    The application assumes a standard USB B socket (i.e. USB device) is attached as the USB connectivity method. The software design supports 2 channels channels of audio at sample frequencies up to 192kHz and uses the following components: XMOS USB Device Driver (XUD) Endpoint 0 Endpoint buffer Decoupler...
  • Page 75: Dac And Adc Configuration

    USB Audio Design Guide 75/110 When changing sample frequency, the AudioHwConfig() function first puts the both the DAC and ADC into reset by setting P4C[0] and P4C[1] low. It selects the required master clock and keeps both the DAC and ADC in reset for 1ms to allow the clocks to stabilize.
  • Page 76 USB Audio Design Guide 76/110 hidData [0] = ( a << H I D _ C O N T R O L _ V O L U P _ S H I F T ) | ( b << H I D _ C O N T R O L _ V O L D N _ S H I F T If the switch input is high (i.e.
  • Page 77 USB Audio Design Guide 77/110 void U s e r R e a d H I D B u t t o n s ( unsigned char hidData []) /* Variables for buttons a & b and switch sw */ unsigned a , b , sw , tmp ;...
  • Page 78: Validated Build Options

    USB Audio Design Guide 78/110 6.4.5 Validated Build Options The reference design can be built in several ways by changing the build options. These are described in §7.1. The design has only been fully validated against the build options as set in the application as distributed.
  • Page 79: The U-Series Multi-Channel Usb Audio Kit

    USB connectivity method. The related code can be found in app_usb_aud_u16_audio8. The design supports 10 channels channels of audio input and output at sample frequencies up to 192kHz and uses the following components: XMOS USB Device Driver (XUD) Endpoint 0 Endpoint buffer Decoupler...
  • Page 80: Dac And Adc Configuration

    USB Audio Design Guide 80/110 The master clock source is controlled by a mux which, in turn, is controlled by bit 1 of PORT 4D: Figure 38: Value Source Master Clock Source Master clock is sourced from PhaseLink PLL Selection Master clock is source from Cirrus Clock Multiplier The current version of the supplied application only supports the use of the fixed master-clocks from the PhaseLink part.
  • Page 81: Validated Build Options

    (for volume processing only, supports 10 channels in, 10 channels out, supports sample rates up to 192kHz and S/PDIF transmit. 6.6 The xCORE-200 Multi-Channel Audio Board An application of the USB audio framework is provided specifically for the hardware described in §2.1...
  • Page 82: Clocking And Clock Selection

    USB Audio Design Guide 82/110 S/PDIF Transmitter MIDI The software layout is the identical to the dual tile L-Series Multi-channel Reference Design and therefore the diagram Figure shows the software arrangement of the code running on the xCORE-200 device. As with the L/U-Series, each unit runs in a single core concurrently with the others units.
  • Page 83: Audiohwinit()

    USB Audio Design Guide 83/110 6.6.3 AudioHwInit() AudioHwInit() function is implemented to perform the following: Initialise the I2C master software module Puts the audio hardware into reset Enables the power to the audio hardware Select the PhaseLink PLL as the audio master clock source. 6.6.4 AudioHwConfig() AudioHwConfig() function is called on every sample frequency change.
  • Page 84: Validated Build Options

    The design supports upto 2 channels of analogue audio output at sample-rates from the on-board DAC. The design also supports input from the 7 PDM microphones. The design uses the following components: XMOS USB Device Driver (XUD) Endpoint 0 XM0088546.1...
  • Page 85: Clocking And Clock Selection

    USB Audio Design Guide 85/110 Endpoint buffer Decoupler Audio Driver Device Firmware Upgrade (DFU) PDM Microphone integration The software layout is the identical to the dual tile L-Series Multi-channel Reference Design and therefore the diagram Figure shows the software arrangement of the code running on the xCORE-200 device.
  • Page 86: Dac Configuration

    USB Audio Design Guide 86/110 6.7.2 DAC Configuration The board is equipped with a single stereo audio DAC with integrated headphone amplifier (Cirrus Logic CS43L21) Configuration of both the DAC takes place using I2C. The design uses the I2C component sc_i2c The reset lines of the DAC is connected to bits 0 PORT 4F.
  • Page 87: Validated Build Options

    USB Audio Design Guide 87/110 The example also provides a simple summing example, where all 7 microphones are summed into output[0] with the original microphone signals output to output[1..7] . This functionality is enabled and disabled using Button A. 6.7.6 Validated Build Options The reference design can be built in several ways by changing the build options.
  • Page 88: Api

    7 API IN TH I S C H A P T ER Configuration Defines Required User Function Definitions Component API 7.1 Configuration Defines An application using the USB audio framework needs to have defines set for configuration. Defaults for these defines are found in module_usb_audio in devicedefines.h . These defines should be over-ridden in the mandatory customdefines.h file or in Makefile for a relevant build configuration.
  • Page 89: Channel Counts

    USB Audio Design Guide 89/110 Macro MIDI_TILE Description Location (tile) of MIDI I/O. Default: AUDIO_IO_TILE 7.1.2 Channel Counts Macro NUM_USB_CHAN_OUT Description Number of output channels (host to device). Default: NONE (Must be defined by app) Macro NUM_USB_CHAN_IN Description Number of input channels (device to host). Default: NONE (Must be defined by app) Macro DSD_CHANS_DAC...
  • Page 90: Audio Class

    USB Audio Design Guide 90/110 Macro MAX_FREQ Description Max supported sample frequency for device (Hz). Default: 192000 Macro MIN_FREQ Min supported sample frequency for device (Hz). Description Default 44100 Macro DEFAULT_FREQ Description Default device sample frequency. A safe default should be used. Default: MIN_FREQ Macro MCLK_441 Description...
  • Page 91: System Feature Configuration

    USB Audio Design Guide 91/110 Macro FULL_SPEED_AUDIO_2 Description Whether or not to run UAC2 in full-speed. When disabled device can either operate in UAC1 mode in full-speed (if AU- DIO_CLASS_FALLBACK enabled) or return “null” descriptors. Default: 1 (Enabled) when AUDIO_CLASS_FALLBACK disabled. 7.1.5 System Feature Configuration 7.1.5.1 MIDI Macro...
  • Page 92 USB Audio Design Guide 92/110 Macro SPDIF_RX_INDEX Description S/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 Macro ADAT_RX Enables ADAT Rx. Description Default: 0 (Disabled) Macro...
  • Page 93: Usb Device Configuration

    This is also pre-pended to various strings used by the design. Default: “XMOS” Macro VENDOR_ID Description USB Vendor ID (or VID) as assigned by the USB-IF. Default: 0x20B1 (XMOS) Macro PRODUCT_STR Description USB Product String for the device. If defined will be used for both PRODUCT_STR_A2 and PRODUCT_STR_A1 Default: Undefined...
  • Page 94: Stream Formats

    Device 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 Stream Formats 7.1.7.1 Output/Playback Macro...
  • Page 95 USB Audio Design Guide 95/110 Description Sample 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. Macro STREAM_FORMAT_OUTPUT_2_RESOLUTION_BITS Sample resolution (bits) of output stream Alternate 2.
  • Page 96 USB Audio Design Guide 96/110 Description Sample 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.
  • Page 97 USB Audio Design Guide 97/110 Macro STREAM_FORMAT_OUTPUT_2_DATAFORMAT Description Sample 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 Macro STREAM_FORMAT_OUTPUT_3_DATAFORMAT Description Sample 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 Macro...
  • Page 98: Volume Control

    USB Audio Design Guide 98/110 Description Sample 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 Macro STREAM_FORMAT_INPUT_1_DATAFORMAT Description...
  • Page 99: Mixing Parameters

    USB Audio Design Guide 99/110 Macro VOLUME_RES Description The resolution of the volume control in db as a 8.8 fixed point number. Default: 0x100 (1db) 7.1.9 Mixing Parameters Macro MIXER Description Enable “mixer” core. Default: 0 (Disabled) Macro MAX_MIX_COUNT Description Number of seperate mixes to perform.
  • Page 100: Power

    Power drawn from the host (in mA x 2). Default: 0 when SELF_POWERED enabled else 250 (500mA) 7.2 Required User Function Definitions The following functions need to be defined by an application using the XMOS USB Audio framework. 7.2.1 External Audio Hardware Configuration Functions Function...
  • Page 101: Audio Streaming Functions

    USB Audio Design Guide 101/110 Type void AudioHwConfig(unsigned samFreq, unsigned mclk, chanend ?c_codec, unsigned dsdMode, unsigned sampRes_DAC, unsigned sampRes_ADC) Parameters The sample frequency in Hz that the hardware should be config- samFreq ured to (in Hz). The master clock frequency that is required in Hz. mclk An optional chanend that was original passed into audio()
  • Page 102: Hid Controls

    USB Audio Design Guide 102/110 This is called on a change in state. Function AudioStreamStart Description Type void AudioStreamStart(int active) Parameters Indicates if the host is active or not. 1 for active else 0. active 7.2.4 HID Controls The following function is called when the device wishes to read physical user input (buttons etc). Function UserReadHIDButtons Description...
  • Page 103 USB Audio Design Guide 103/110 Type int 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) Continued on next page XM0088546.1...
  • Page 104 USB Audio Design Guide 104/110 Parameters An array of channel ends, one channel end per output endpoint c_epOut (USB OUT transaction); this includes a channel to obtain requests on Endpoint 0. The number of output endpoints, should be at least 1 (for End- noEpOut point 0).
  • Page 105 USB Audio Design Guide 105/110 When using the USB audio framework the c_ep_in array is always composed in the following order: Endpoint 0 (in) Audio Feedback endpoint (if output enabled) Audio IN endpoint (if input enabled) MIDI IN endpoint (if MIDI enabled) Clock Interrupt endpoint The array c_ep_out is always composed in the following order: Endpoint 0 (out)
  • Page 106 USB Audio Design Guide 106/110 Parameters Chanend connected to the XUD_Manager() out endpoint array c_ep0_out Chanend connected to the XUD_Manager() in endpoint array c_ep0_in Chanend connected to the decouple thread for control audio c_audioCtrl (sample rate changes etc.) Optional chanend to be connected to the mixer thread if present c_mix_ctl Optional chanend to be connected to the clockgen thread if c_clk_ctl...
  • Page 107 USB Audio Design Guide 107/110 Parameters Audio OUT endpoint channel connected to the XUD c_aud_out Audio IN endpoint channel connected to the XUD c_aud_in Audio feedback endpoint channel connected to the XUD c_aud_fb c_midi_from_host MIDI OUT endpoint channel connected to the XUD c_midi_to_host MIDI IN endpoint channel connected to the XUD Audio clocking interrupt endpoint channel connected to the XUD...
  • Page 108 USB Audio Design Guide 108/110 Parameters a chanend connected to the decouple() thread for receiving/- c_to_host transmitting samples a chanend connected to the audio() thread for receiving/trans- c_to_audio mitting samples a chanend connected to the Endpoint0() thread for receiving c_mix_ctl control commands Function audio...
  • Page 109 USB Audio Design Guide 109/110 Parameters channel connected to S/PDIF receive thread c_spdif_rx channel connect to ADAT receive thread c_adat_rx port to output clock signal to drive external frequency synthe- sizer channel connected to the audio() thread c_audio channel connected to Endpoint0() for configuration of the clock c_clk_ctl...
  • Page 110 USB Audio Design Guide 110/110 Function adatReceiver48000 Description ADAT 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.
  • Page 111 USB Audio Design Guide 111/110 Function usb_midi Description USB MIDI I/O thread. This function passes MIDI data from USB to UART I/O. Type void 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) Parameters...
  • Page 112: Frequently Asked Questions

    XMOS and the XMOS logo are registered trademarks of Xmos Ltd. in the United Kingdom and other countries, and may not be used without written permission. All other trademarks are property of their respective owners.

Table of Contents