Initial work to run flash code on a remote tile from USB tile. Also added some error passing for DFU (such that device stalls the host). Still needs merging with dummy_deliver.

This commit is contained in:
Ross Owen
2015-06-12 14:43:50 +01:00
parent ee7d058614
commit 4d93a9c906
8 changed files with 205 additions and 129 deletions

View File

@@ -2,6 +2,7 @@
#define __audio_h__
#include "devicedefines.h"
#include "dfu_interface.h"
/** The audio driver thread.
*
* This function drives I2S ports and handles samples to/from other digital
@@ -21,7 +22,11 @@ void audio(chanend c_in,
#if(defined(SPDIF_RX) || defined(ADAT_RX))
chanend c_dig,
#endif
chanend ?c_config, chanend ?c_adc);
chanend ?c_config, chanend ?c_adc
#if (XUD_TILE != 0)
, server interface i_dfu dfuInterface
#endif
);
void SpdifTxWrapper(chanend c_spdif_tx);

View File

@@ -14,6 +14,8 @@
#include <xs1_su.h>
#include "devicedefines.h"
#include "dfu_interface.h"
#include "audioports.h"
#include "audiohw.h"
#ifdef SPDIF_TX
@@ -866,46 +868,69 @@ void SpdifTxWrapper(chanend c_spdif_tx)
/* This function is a dummy version of the deliver thread that does not
connect to the codec ports. It is used during DFU reset. */
[[distributable]]
void DFUHandler(server interface i_dfu i, chanend ?c_user_cmd);
#pragma select handler
void testct_byref(chanend c, int &returnVal)
{
returnVal = 0;
if(testct(c))
returnVal = 1;
}
unsigned static dummy_deliver(chanend c_out)
{
int ct;
outuint(c_out, 0);
while (1)
{
outuint(c_out, 0);
/* Check for sample freq change or new samples from mixer*/
if(testct(c_out))
{
unsigned command = inct(c_out);
return command;
}
else
select
{
/* Check for sample freq change or new samples from mixer*/
case testct_byref(c_out, ct):
if(ct)
{
unsigned command = inct(c_out);
return command;
}
else
{
#ifndef MIXER // Interfaces straight to decouple()
(void) inuint(c_out);
(void) inuint(c_out);
#pragma loop unroll
for(int i = 0; i < NUM_USB_CHAN_IN; i++)
{
outuint(c_out, 0);
}
for(int i = 0; i < NUM_USB_CHAN_IN; i++)
{
outuint(c_out, 0);
}
#pragma loop unroll
for(int i = 0; i < NUM_USB_CHAN_OUT; i++)
{
(void) inuint(c_out);
}
for(int i = 0; i < NUM_USB_CHAN_OUT; i++)
{
(void) inuint(c_out);
}
#else
#pragma loop unroll
for(int i = 0; i < NUM_USB_CHAN_OUT; i++)
{
(void) inuint(c_out);
}
for(int i = 0; i < NUM_USB_CHAN_OUT; i++)
{
(void) inuint(c_out);
}
#pragma loop unroll
for(int i = 0; i < NUM_USB_CHAN_IN; i++)
{
outuint(c_out, 0);
}
for(int i = 0; i < NUM_USB_CHAN_IN; i++)
{
outuint(c_out, 0);
}
#endif
}
outuint(c_out, 0);
break;
}
}
return 0;
@@ -923,7 +948,11 @@ chanend c_spdif_out,
#if (defined(ADAT_RX) || defined(SPDIF_RX))
chanend c_dig_rx,
#endif
chanend ?c_config, chanend ?c)
chanend ?c_config, chanend ?c
#if XUD_TILE != 0
, server interface i_dfu dfuInterface
#endif
)
{
#if defined (SPDIF_TX) && (SPDIF_TX_TILE == AUDIO_IO_TILE)
chan c_spdif_out;
@@ -1213,8 +1242,12 @@ chanend ?c_config, chanend ?c)
while (1)
{
command = dummy_deliver(c_mix_out);
par{
#if XUD_TILE != 0
DFUHandler(dfuInterface, null);
#endif
command = dummy_deliver(c_mix_out);
}
curSamFreq = inuint(c_mix_out);
if (curSamFreq == AUDIO_START_FROM_DFU)

View File

@@ -558,6 +558,8 @@ void Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
if (interfaceNum == DFU_IF)
{
int reset = 0;
/* If running in application mode stop audio */
/* Don't interupt audio for save and restore cmds */
if ((DFU_IF == INTERFACE_NUMBER_DFU) && (sp.bRequest != XMOS_DFU_SAVESTATE) &&
@@ -571,14 +573,16 @@ void Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
}
/* This will return 1 if reset requested */
if (DFUDeviceRequests(ep0_out, &ep0_in, &sp, null, g_interfaceAlt[sp.wIndex], dfuInterface))
result = DFUDeviceRequests(ep0_out, &ep0_in, &sp, null, g_interfaceAlt[sp.wIndex], dfuInterface, &reset);
if(reset && result == XUD_RES_OKAY)
{
DFUDelay(50000000);
device_reboot(c_audioControl);
}
/* TODO we should not make the assumption that all DFU requests are handled */
result = 0;
//result = 0;
}
#endif
/* Check for: - Audio CONTROL interface request - always 0, note we check for DFU first

View File

@@ -278,6 +278,7 @@ void usb_audio_core(chanend c_mix_out
#endif
, chanend ?c_clk_int
, chanend ?c_clk_ctl
, client interface i_dfu dfuInterface
)
{
chan c_sof;
@@ -298,13 +299,7 @@ void usb_audio_core(chanend c_mix_out
#else
#define c_EANativeTransport_ctrl null
#endif
#ifdef DFU
interface i_dfu dfuInterface;
#else
#define dfuInterface null
#endif
par
{
/* USB Interface Core */
@@ -376,12 +371,7 @@ void usb_audio_core(chanend c_mix_out
/* Endpoint 0 Core */
{
thread_speed();
par
{
[[distribute]]
DFUHandler(dfuInterface, null);
Endpoint0( c_xud_out[0], c_xud_in[0], c_aud_ctl, c_mix_ctl, c_clk_ctl, c_EANativeTransport_ctrl, dfuInterface);
}
Endpoint0( c_xud_out[0], c_xud_in[0], c_aud_ctl, c_mix_ctl, c_clk_ctl, c_EANativeTransport_ctrl, dfuInterface);
}
/* Decoupling core */
@@ -409,6 +399,9 @@ void usb_audio_io(chanend c_aud_in, chanend ?c_adc,
chanend ?c_adat_rx,
chanend ?c_clk_ctl,
chanend ?c_clk_int
#if (XUD_TILE != 0)
, server interface i_dfu dfuInterface
#endif
)
{
#ifdef MIXER
@@ -445,7 +438,11 @@ void usb_audio_io(chanend c_aud_in, chanend ?c_adc,
#if defined(SPDIF_RX) || defined(ADAT_RX)
c_dig_rx,
#endif
c_aud_cfg, c_adc);
c_aud_cfg, c_adc
#if XUD_TILE != 0
,dfuInterface
#endif
);
}
#if defined(SPDIF_RX) || defined(ADAT_RX)
@@ -523,25 +520,41 @@ int main()
#define c_clk_ctl null
#endif
#ifdef DFU
interface i_dfu dfuInterface;
#else
#define dfuInterface null
#endif
USER_MAIN_DECLARATIONS
par
{
on tile[XUD_TILE]: usb_audio_core(c_mix_out
{
on tile[XUD_TILE]:
par
{
#if (XUD_TILE == 0)
/* Check if USB is on the flash tile (tile 0) */
[[distribute]]
DFUHandler(dfuInterface, null);
#endif
usb_audio_core(c_mix_out
#ifdef MIDI
, c_midi
, c_midi
#endif
#ifdef IAP
, c_iap
, c_iap
#ifdef IAP_EA_NATIVE_TRANS
, c_ea_data
, c_ea_data
#endif
#endif
#ifdef MIXER
, c_mix_ctl
, c_mix_ctl
#endif
, c_clk_int, c_clk_ctl
);
, c_clk_int, c_clk_ctl, dfuInterface
);
}
on tile[AUDIO_IO_TILE]: usb_audio_io(c_mix_out, c_adc
#if defined(SPDIF_TX) && (SPDIF_TX_TILE != AUDIO_IO_TILE)
@@ -551,6 +564,10 @@ int main()
, c_mix_ctl
#endif
,c_aud_cfg, c_spdif_rx, c_adat_rx, c_clk_ctl, c_clk_int
#if XUD_TILE != 0
, dfuInterface
#endif
);
#if defined(SPDIF_TX) && (SPDIF_TX_TILE != AUDIO_IO_TILE)