Initial file tidy-up. Created app_xua_simple.

This commit is contained in:
xross
2017-10-10 15:00:00 +01:00
parent 4d4765dc77
commit eae3e4237b
49 changed files with 270 additions and 115 deletions

View File

@@ -1,5 +1,16 @@
sc_usb_audio Change Log
=======================
lib_xua Change Log
==================
1.0.0
-----
- CHANGE: Fork from sc_xud to lib_xud
Legacy release history
----------------------
(Note: Forked from sc_usb_audio at this point)
7.5.0
-----

View File

@@ -0,0 +1,19 @@
APP_NAME = app_xua_simple
TARGET = xk-audio-216-mc.xn
# The flags passed to xcc when building the application
XCC_FLAGS = -fcomment-asm -Xmapper --map -Xmapper MAPFILE -O3 -report -fsubword-select -save-temps -g -Wno-unused-function -Wno-timing -DXUD_SERIES_SUPPORT=XUD_X200_SERIES
# The USED_MODULES variable lists other module used by the application. These
# modules will extend the SOURCE_DIRS, INCLUDE_DIRS and LIB_DIRS variables.
# Modules are expected to be in the directory above the BASE_DIR directory.
USED_MODULES = lib_i2c lib_mic_array lib_logging lib_xua lib_device_control lib_src lib_dsp lib_spi lib_xud
#=============================================================================
# The following part of the Makefile includes the common build infrastructure
# for compiling XMOS applications. You should not need to edit below here.
XMOS_MAKE_PATH ?= ../..
include $(XMOS_MAKE_PATH)/xcommon/module_xcommon/build/Makefile.common

View File

@@ -0,0 +1,68 @@
/* A very simple example of a USB audio application (and as such is un-verified)
*
* It uses some tedious blocks from the lib_xua i.e. Endpoint 0, whilst re-implementing simple versions of others i.e. buffering
*
*/
#include <xs1.h>
#include <platform.h>
#include "xud_device.h"
#include "xua.h"
void OutBuffer(chanend c_aud_out)
{
while(1)
{
}
}
void I2S()
{
while(1)
{
}
}
/* Endpoint type tables - informs XUD what the transfer types for each Endpoint in use and also
* if the endpoint wishes to be informed of USB bus resets
*/
XUD_EpType epTypeTableOut[] = {XUD_EPTYPE_CTL | XUD_STATUS_ENABLE};
XUD_EpType epTypeTableIn[] = {XUD_EPTYPE_CTL | XUD_STATUS_ENABLE, XUD_EPTYPE_ISO};
int main()
{
/* Channels for lib_xud */
chan c_ep_out[2];
chan c_ep_in[1];
chan c_aud_ctl;
par
{
/* Low level USB device layer core */
on tile[1]: XUD_Main(c_ep_out, 2, c_ep_in, 1,
null, epTypeTableOut, epTypeTableIn,
null, null, -1 , XUD_SPEED_HS, XUD_PWR_BUS);
/* Endpoint 0 core from lib_xua */
/* Note, since we are not using many features we pass in null for quite a few params.. */
on tile[1]: XUA_Endpoint0(c_ep_out[0], c_ep_in[0], c_aud_ctl, null, null, null, null);
/* Our own simple buffering and I2S cores */
on tile[1]: OutBuffer(c_ep_out[1]);
/* Our own simple I2S driver core */
on tile[1]: I2S();
}
return 0;
}

View File

@@ -0,0 +1,34 @@
/* Required by lib_xua at the moment. To be replaced with lib_xua_conf.h"
*/
// Copyright (c) 2016, XMOS Ltd, All rights reserved
#ifndef __custom_defines_h__
#define __custom_defines_h__
#define NUM_USB_CHAN_OUT 2
#define NUM_USB_CHAN_IN 0
#define I2S_CHANS_DAC 2
#define I2S_CHANS_ADC 2
#define EXCLUDE_USB_AUDIO_MAIN
#define NUM_PDM_MICS 0
#define XUD_TILE 1
#define AUDIO_IO_TILE 0
#define MIXER 0
#define MCLK_441 (512 * 44100)
#define MCLK_48 (512 * 48000)
#define MIN_FREQ 48000
#define MAX_FREQ 48000
#define SPDIF_TX_INDEX 0
#define VENDOR_STR "XMOS"
#define VENDOR_ID 0x20B1
#define PRODUCT_STR_A2 "XUA Simple"
#define PRODUCT_STR_A1 "XUA Simple"
#define PID_AUDIO_1 1
#define PID_AUDIO_2 2
#define AUDIO_CLASS 2
#define AUDIO_CLASS_FALLBACK 0
#define BCD_DEVICE 0x1234
#define XUA_DFU 0
#endif // __custom_defines_h__

View File

@@ -0,0 +1,17 @@
// Copyright (c) 2016, XMOS Ltd, All rights reserved
#include <platform.h>
#include "audiohw.h"
#include "customdefines.h"
void AudioHwConfig(unsigned samFreq, unsigned mClk, chanend ?c_codec, unsigned dsdMode,
unsigned sampRes_DAC, unsigned sampRes_ADC)
{
// nothing
}
void AudioHwInit(chanend ?c_codec)
{
// nothing
}

View File

@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>
<Network xmlns="http://www.xmos.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.xmos.com http://www.xmos.com" ManuallySpecifiedRouting="true">
<Type>Board</Type>
<Name>XS2 MC Audio</Name>
<Declarations>
<Declaration>tileref tile[2]</Declaration>
<Declaration>tileref usb_tile</Declaration>
</Declarations>
<Packages>
<Package id="0" Type="XS2-UnA-512-FB236">
<Nodes>
<Node Id="0" InPackageId="0" Type="XS2-L16A-512" Oscillator="24MHz" SystemFrequency="500MHz" referencefrequency="100MHz">
<Boot>
<Source Location="SPI:bootFlash"/>
</Boot>
<Tile Number="0" Reference="tile[0]">
<Port Location="XS1_PORT_1B" Name="PORT_SQI_CS"/>
<Port Location="XS1_PORT_1C" Name="PORT_SQI_SCLK"/>
<Port Location="XS1_PORT_4B" Name="PORT_SQI_SIO"/>
<!-- Audio Ports -->
<Port Location="XS1_PORT_1A" Name="PORT_PLL_REF"/>
<Port Location="XS1_PORT_1F" Name="PORT_MCLK_IN"/>
<Port Location="XS1_PORT_1G" Name="PORT_I2S_LRCLK"/>
<Port Location="XS1_PORT_1H" Name="PORT_I2S_BCLK"/>
<Port Location="XS1_PORT_1M" Name="PORT_I2S_DAC0"/>
<port Location="XS1_PORT_1N" Name="PORT_I2S_DAC1"/>
<port Location="XS1_PORT_1O" Name="PORT_I2S_DAC2"/>
<port Location="XS1_PORT_1P" Name="PORT_I2S_DAC3"/>
<Port Location="XS1_PORT_1I" Name="PORT_I2S_ADC0"/>
<Port Location="XS1_PORT_1J" Name="PORT_I2S_ADC1"/>
<Port Location="XS1_PORT_1K" Name="PORT_I2S_ADC2"/>
<Port Location="XS1_PORT_1L" Name="PORT_I2S_ADC3"/>
<Port Location="XS1_PORT_4A" Name="PORT_I2C"/>
<Port Location="XS1_PORT_1M" Name="PORT_DSD_DAC0"/>
<port Location="XS1_PORT_1N" Name="PORT_DSD_DAC1"/>
<Port Location="XS1_PORT_1G" Name="PORT_DSD_CLK"/>
<Port Location="XS1_PORT_1E" Name="PORT_ADAT_OUT"/>--> <!-- D: COAX E: OPT -->
<Port Location="XS1_PORT_1D" Name="PORT_SPDIF_OUT"/>--> <!-- D: COAX E: OPT -->
</Tile>
<Tile Number="1" Reference="tile[1]">
<!-- USB intended to run on this tile -->
<!-- Audio Ports -->
<Port Location="XS1_PORT_16B" Name="PORT_MCLK_COUNT"/>
<Port Location="XS1_PORT_1L" Name="PORT_MCLK_IN2"/>
<Port Location="XS1_PORT_1M" Name="PORT_MIDI_IN"/>
<Port Location="XS1_PORT_1N" Name="PORT_MIDI_OUT"/>
<Port Location="XS1_PORT_1O" Name="PORT_ADAT_IN"/>--> <!-- P: COAX O: OPT -->
<Port Location="XS1_PORT_1P" Name="PORT_SPDIF_IN"/>--> <!-- P: COAX O: OPT -->
</Tile>
</Node>
<Node Id="1" InPackageId="1" Type="periph:XS1-SU" Reference="usb_tile" Oscillator="24MHz">
</Node>
</Nodes>
<Links>
<Link Encoding="5wire">
<LinkEndpoint NodeId="0" Link="8" Delays="52clk,52clk"/>
<LinkEndpoint NodeId="1" Link="XL0" Delays="1clk,1clk"/>
</Link>
</Links>
</Package>
</Packages>
<Nodes>
<Node Id="2" Type="device:" RoutingId="0x8000">
<Service Id="0" Proto="xscope_host_data(chanend c);">
<Chanend Identifier="c" end="3"/>
</Service>
</Node>
</Nodes>
<Links>
<Link Encoding="2wire" Delays="4,4" Flags="XSCOPE">
<LinkEndpoint NodeId="0" Link="XL0"/>
<LinkEndpoint NodeId="2" Chanend="1"/>
</Link>
</Links>
<ExternalDevices>
<Device NodeId="0" Tile="0" Class="SQIFlash" Name="bootFlash" Type="S25FL116K">
<Attribute Name="PORT_SQI_CS" Value="PORT_SQI_CS"/>
<Attribute Name="PORT_SQI_SCLK" Value="PORT_SQI_SCLK"/>
<Attribute Name="PORT_SQI_SIO" Value="PORT_SQI_SIO"/>
</Device>
</ExternalDevices>
<JTAGChain>
<JTAGDevice NodeId="0"/>
<JTAGDevice NodeId="1"/>
</JTAGChain>
</Network>

9
lib_xua/api/xua.h Normal file
View File

@@ -0,0 +1,9 @@
#ifndef __XUA_H__
#define __XUA_H__
#include "xua_audio.h"
#include "xua_endpoint0.h"
#endif

View File

@@ -22,7 +22,7 @@
* \param c_EANativeTransport_ctrl Optional chanend to be connected to EA Native
* endpoint manager if present
*/
void Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioCtrl,
void XUA_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
VENDOR_REQUESTS_PARAMS_DEC_);

View File

@@ -1,11 +0,0 @@
module_dfu
==========
:scope: General Use
:description: module_dfu
:keywords: DFU
:boards: XMOS USB Audio Reference Designes
Code providing firmware upgrade over USB.
./host provides an example of a host application for DFU. This is written and tested for OSX. LibUSB is used to aid cross-platform porting.

View File

@@ -1,22 +0,0 @@
# This file describes how this module will affect the application
# using it. The file is included in the Makefile of the main application.
#
# The module contributes to the build of the application by extending
# the following variables:
#
# SOURCE_DIRS - directories with source files to be included in the build
# INCLUDE_DIRS - directories to be added to the include path during the build
# LIB_DIRS - directories containing libraries to be linked into the build
#
# Note that all the source files in each directory in SOURCE_DIRS
# will be compiled (you do not need to name the files individually).
#
MODULE_DIRS = src
SOURCE_DIRS += $(MODULE_DIRS)
INCLUDE_DIRS += $(MODULE_DIRS)
MODULE_XCC_FLAGS = -Os -mno-dual-issue $(XCC_FLAGS)
MODULE_C_FLAGS = -Os -mno-dual-issue $(XCC_FLAGS)

View File

@@ -1 +0,0 @@
Code providing firmware upgrade over USB.

View File

@@ -1,4 +0,0 @@
def use_module(bld):
sources = bld.path.ant_glob(['src/*.xc', 'src/*.c'])
bld.env.XCC_FLAGS = ['-Os', '-mno-dual-issue'] + bld.env.XCC_FLAGS
bld.module(source=sources, includes=['src'])

View File

@@ -1,9 +0,0 @@
Queuing Module For USB Audio Framework
======================================
:scope: General Use
:description: queue
:keywords: UAC2
:boards:

View File

@@ -1,14 +0,0 @@
# You can set flags specifically for your module by using the MODULE_XCC_FLAGS
# variable. So the following
#
# MODULE_XCC_FLAGS = $(XCC_FLAGS) -O3
#
# specifies that everything in the modules should have the application
# build flags with -O3 appended (so the files will build at
# optimization level -O3).
#
# You can also set MODULE_XCC_C_FLAGS, MODULE_XCC_XC_FLAGS etc..
MODULE_XCC_XC_FLAGS = $(XCC_XC_FLAGS)
DEPENDENT_MODULES =

View File

@@ -1 +0,0 @@
One line module description.

View File

@@ -1,2 +0,0 @@
def use_module(bld):
bld.module(source='src/queue.xc')

View File

@@ -16,7 +16,7 @@
#include "audiostream.h"
#include "hostactive.h"
#include "vendorrequests.h"
#include "dfu_types.h"
//#include "dfu_types.h"
#include "xc_ptr.h"
#include "audiorequests.h"
#ifdef HID_CONTROLS
@@ -52,7 +52,7 @@
#warning DFU_PID not defined, Using PID_AUDIO_2. This is probably fine!
#endif
#ifdef DFU
#if (XUA_DFU == 1)
#include "dfu.h"
#define DFU_IF_NUM INPUT_INTERFACES + OUTPUT_INTERFACES + MIDI_INTERFACES + 1
extern void device_reboot(chanend);
@@ -199,7 +199,7 @@ const unsigned g_chanCount_In_HS[INPUT_FORMAT_COUNT] = {HS_STREAM_FORMAT_I
};
/* Endpoint 0 function. Handles all requests to the device */
void Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
void XUA_Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
chanend c_mix_ctl, chanend c_clk_ctl, chanend c_EANativeTransport_ctrl, CLIENT_INTERFACE(i_dfu, dfuInterface) VENDOR_REQUESTS_PARAMS_DEC_)
{
USB_SetupPacket_t sp;
@@ -281,7 +281,7 @@ void Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
VendorAudioRequestsInit(c_audioControl, c_mix_ctl, c_clk_ctl);
#endif
#ifdef DFU
#if (XUA_DFU == 1)
/* Check if device has started in DFU mode */
if (DFUReportResetState(null))
{
@@ -547,7 +547,7 @@ void Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
//unsigned request = (sp.bmRequestType.Recipient ) | (sp.bmRequestType.Type << 5);
/* TODO Check on return value retval = */
#ifdef DFU
#if (XUA_DFU == 1)
unsigned DFU_IF = INTERFACE_NUMBER_DFU;
/* DFU interface number changes based on which mode we are currently running in */
@@ -587,7 +587,7 @@ void Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
* - Audio endpoint request (Audio 1.0 Sampling freq requests are sent to the endpoint)
*/
if(((interfaceNum == 0) || (interfaceNum == 1) || (interfaceNum == 2))
#ifdef DFU
#if (XUA_DFU == 1)
&& !DFU_mode_active
#endif
)
@@ -750,8 +750,8 @@ void Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
cfgDesc_Null, sizeof(cfgDesc_Null),
(char**)&g_strTable, sizeof(g_strTable)/sizeof(char *), &sp, g_curUsbSpeed);
#endif
#ifdef DFU
}
#if (XUA_DFU == 1)
else
{
/* Running in DFU mode - always return same descs for DFU whether HS or FS */
@@ -776,7 +776,7 @@ void Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
g_curStreamAlt_Out = 0;
g_curStreamAlt_In = 0;
#ifdef DFU
#if (XUA_DFU == 1)
if (DFUReportResetState(null))
{
if (!DFU_mode_active)

View File

@@ -1,5 +1,5 @@
#include "devicedefines.h"
#ifdef DFU
#if (XUD_DFU == 1)
#include "uac_hwresources.h"
#include <xs1.h>
#include <xclib.h>

View File

@@ -1,3 +1,7 @@
#include "devicedefines.h" /* Device specific defines */
#ifndef EXCLUDE_USB_AUDIO_MAIN
/**
* @file main.xc
* @brief Top level for XMOS USB 2.0 Audio 2.0 Reference Designs.
@@ -14,10 +18,9 @@
#include "xud.h" /* XMOS USB Device Layer defines and functions */
#ifndef NO_USB
#include "endpoint0.h"
#include "xua_endpoint0.h"
#endif
#include "devicedefines.h" /* Device specific defines */
#include "uac_hwresources.h"
#include "usb_buffer.h"
#include "decouple.h"
@@ -392,7 +395,7 @@ VENDOR_REQUESTS_PARAMS_DEC_
/* Endpoint 0 Core */
{
thread_speed();
Endpoint0( c_xud_out[0], c_xud_in[0], c_aud_ctl, c_mix_ctl, c_clk_ctl, c_EANativeTransport_ctrl, dfuInterface VENDOR_REQUESTS_PARAMS_);
XUA_Endpoint0( c_xud_out[0], c_xud_in[0], c_aud_ctl, c_mix_ctl, c_clk_ctl, c_EANativeTransport_ctrl, dfuInterface VENDOR_REQUESTS_PARAMS_);
}
/* Decoupling core */
@@ -496,7 +499,6 @@ void usb_audio_io(chanend ?c_aud_in, chanend ?c_adc,
#define USER_MAIN_CORES
#endif
#ifndef EXCLUDE_USB_AUDIO_MAIN
/* Main for USB Audio Applications */
int main()

View File

@@ -1,9 +0,0 @@
def use_module(bld):
# Set file specific flags
for item in ('endpoint0.c', 'dbcalc.xc', 'audiorequests.xc',
'flashlib_user.c', 'audioports.c', 'audioports.xc'):
bld.env['XCC_FLAGS_{}'.format(item)] = ['-Os', '-mno-dual-issue'
] + bld.env.XCC_FLAGS
sources = bld.path.ant_glob(['**/*.xc', '**/*.c', '**/*.S'])
tgen = bld.module(source=sources, includes=['.', 'audio_io'])

View File

@@ -1,3 +1,5 @@
#include "devicedefines.h"
#if (XUA_DFU == 1)
#include <xs1.h>
#include <platform.h>
#include "devicedefines.h"
@@ -579,3 +581,5 @@ int DFUDeviceRequests(XUD_ep ep0_out, XUD_ep &?ep0_in, USB_SetupPacket_t &sp, ch
return returnVal;
}
#endif /* NO_USB */
#endif

View File

@@ -1,3 +1,5 @@
#include "devicedefines.h"
#if (XUA_DFU == 1)
#include <xs1.h>
#include <flash.h>
#include <flashlib.h>
@@ -245,4 +247,5 @@ int flash_cmd_erase_all(void)
}
return 0;
}
#endif

View File

@@ -1 +0,0 @@
module README.

View File

@@ -1,9 +0,0 @@
MIDI Module for USB Audio Framework
===================================
:scope: General Use
:description: MIDI
:keywords: MIDI
:boards:

View File

@@ -1,12 +0,0 @@
# You can set flags specifically for your module by using the MODULE_XCC_FLAGS
# variable. So the following
#
# MODULE_XCC_FLAGS = $(XCC_FLAGS) -O3
#
# specifies that everything in the modules should have the application
# build flags with -O3 appended (so the files will build at
# optimization level -O3).
#
# You can also set MODULE_XCC_C_FLAGS, MODULE_XCC_XC_FLAGS etc..
DEPENDENT_MODULES = module_queue

View File

@@ -1 +0,0 @@
One line module description.

View File

@@ -1,3 +0,0 @@
def use_module(bld):
source = bld.path.ant_glob('src/*.xc')
bld.module(source=source, depends_on='module_queue')