Upates for XUD refactor

This commit is contained in:
Ross Owen
2012-06-11 11:36:46 +01:00
parent 2f1bbb4a98
commit 050b6001ab
7 changed files with 67 additions and 41 deletions

View File

@@ -251,8 +251,8 @@
#define EP_ADR_OUT_IAP EP_NUM_OUT_IAP
/* Endpoint count totals */
#define NUM_EP_OUT (1 + NUM_EP_OUT_AUD + NUM_EP_OUT_MIDI + NUM_EP_OUT_IAP) /* +1 due to EP0 */
#define NUM_EP_IN (2 + NUM_EP_IN_AUD + NUM_EP_IN_MIDI + NUM_EP_IN_IAP + NUM_EP_IN_HID) /* +1 due to EP0 and Int EP */
#define NUM_EP_OUT 4// (1 + NUM_EP_OUT_AUD + NUM_EP_OUT_MIDI + NUM_EP_OUT_IAP) /* +1 due to EP0 */
#define NUM_EP_IN 5 //(2 + NUM_EP_IN_AUD + NUM_EP_IN_MIDI + NUM_EP_IN_IAP + NUM_EP_IN_HID) /* +1 due to EP0 and Int EP */
#define AUDIO_STOP_FOR_DFU (0x12345678)
#define AUDIO_START_FROM_DFU (0x87654321)

View File

@@ -361,7 +361,7 @@ int AudioClassRequests_2(XUD_ep ep0_out, XUD_ep ep0_in, SetupPacket &sp, chanend
/* Send 0 Length as status stage */
return XUD_SetBuffer_ResetPid(ep0_in, buffer, 0, PIDn_DATA1);
return XUD_SetBuffer(ep0_in, buffer, 0);
}
/* Direction: Device-to-host: Send Current Sample Freq */
@@ -526,13 +526,18 @@ int AudioClassRequests_2(XUD_ep ep0_out, XUD_ep ep0_in, SetupPacket &sp, chanend
if(sp.bmRequestType.Direction == BM_REQTYPE_DIRECTION_OUT) /* Direction: Host-to-device */
{
/* Expect OUT here (with v2yyolume) */
loop = XUD_GetBuffer(ep0_out, buffer);
/* Check for rst/suspend */
if(loop < 0)
return loop;
{
printintln(loop);
return loop;
}
#if 0
if(unitID == FU_USBOUT)
{
if ((sp.wValue & 0xff) <= NUM_USB_CHAN_OUT) {
@@ -547,6 +552,7 @@ int AudioClassRequests_2(XUD_ep ep0_out, XUD_ep ep0_in, SetupPacket &sp, chanend
updateVol( unitID, ( sp.wValue & 0xff ), c_mix_ctl );
}
}
#endif
/* Send 0 Length as status stage */
return XUD_DoSetRequestStatus(ep0_in, 0);
@@ -581,6 +587,16 @@ int AudioClassRequests_2(XUD_ep ep0_out, XUD_ep ep0_in, SetupPacket &sp, chanend
if(sp.bmRequestType.Direction == BM_REQTYPE_DIRECTION_OUT) // Direction: Host-to-device
{
{
unsigned time;
timer t;
t :> time;
t when timerafter(time+10000000):> void;
}
/* Expect OUT here with mute */
loop = XUD_GetBuffer(ep0_out, buffer);
@@ -1102,18 +1118,22 @@ int AudioClassRequests_1(XUD_ep c_ep0_out, XUD_ep c_ep0_in, SetupPacket &sp, cha
{
case SET_INTERFACE:
{
return XUD_SetBuffer_ResetPid(c_ep0_in, buffer, 0, PIDn_DATA1);
return XUD_SetBuffer(c_ep0_in, buffer, 0);
break;
}
case B_REQ_SET_CUR:
{
loop = XUD_GetBuffer(c_ep0_out, buffer);
/* Inspect for rst/suspend */
if(loop < 0)
return loop;
unitID = sp.wIndex >> 8;
@@ -1205,7 +1225,7 @@ int AudioClassRequests_1(XUD_ep c_ep0_out, XUD_ep c_ep0_in, SetupPacket &sp, cha
}
}
return XUD_SetBuffer_ResetPid(c_ep0_in, buffer, 0, PIDn_DATA1);
return XUD_SetBuffer(c_ep0_in, buffer, 0);
break;
}
@@ -1248,10 +1268,10 @@ int AudioClassRequests_1(XUD_ep c_ep0_out, XUD_ep c_ep0_in, SetupPacket &sp, cha
}
else if(unitID == 0)
{
printintln(unitID);
//printintln(unitID);
}
loop = XUD_SetBuffer_ResetPid(c_ep0_in, buffer, sp.wLength, PIDn_DATA1);
loop = XUD_SetBuffer(c_ep0_in, buffer, sp.wLength);
if(loop < 0)
return loop;
@@ -1265,7 +1285,7 @@ int AudioClassRequests_1(XUD_ep c_ep0_out, XUD_ep c_ep0_in, SetupPacket &sp, cha
buffer[0] = (MIN_MIXER_VOLUME & 0xff);
buffer[1] = (MIN_MIXER_VOLUME >> 8);
loop = XUD_SetBuffer_ResetPid(c_ep0_in, buffer, sp.wLength, PIDn_DATA1);
loop = XUD_SetBuffer(c_ep0_in, buffer, sp.wLength);
if(loop < 0)
return loop;
@@ -1279,7 +1299,7 @@ int AudioClassRequests_1(XUD_ep c_ep0_out, XUD_ep c_ep0_in, SetupPacket &sp, cha
buffer[0] = (MAX_MIXER_VOLUME & 0xff);
buffer[1] = (MAX_MIXER_VOLUME >> 8);
loop = XUD_SetBuffer_ResetPid(c_ep0_in, buffer, sp.wLength, PIDn_DATA1);
loop = XUD_SetBuffer(c_ep0_in, buffer, sp.wLength);
if(loop < 0)
return 0;
@@ -1292,7 +1312,7 @@ int AudioClassRequests_1(XUD_ep c_ep0_out, XUD_ep c_ep0_in, SetupPacket &sp, cha
{
buffer[0] = (VOLUME_RES_MIXER & 0xff);
buffer[1] = (VOLUME_RES_MIXER >> 8);
loop = XUD_SetBuffer_ResetPid(c_ep0_in, buffer, sp.wLength, PIDn_DATA1);
loop = XUD_SetBuffer(c_ep0_in, buffer, sp.wLength);
if(loop < 0)
return loop;

View File

@@ -95,7 +95,7 @@ unsigned g_epStatusOut[NUM_EP_OUT];
unsigned g_epStatusIn[NUM_EP_IN];
/* Global variable for current USB bus speed (i.e. FS/HS) */
unsigned g_curUsbSpeed = 0;
unsigned g_curUsbSpeed = XUD_SPEED_HS;
#ifdef HOST_ACTIVE_CALL
void VendorHostActive(int active);
@@ -566,7 +566,7 @@ void Endpoint0( chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
case SET_ADDRESS:
/* Status stage: Send a zero length packet */
retVal = XUD_SetBuffer_ResetPid(ep0_in, buffer, 0, PIDn_DATA1);
retVal = XUD_SetBuffer(ep0_in, buffer, 0);
/* TODO We should wait until ACK is received for status stage before changing address */
//XUD_Sup_Delay(50000);

View File

@@ -651,8 +651,8 @@ void check_for_interrupt(chanend ?c_clk_int) {
/* Make request to send to XUD endpoint - response handled in usb_buffer */
//XUD_SetReady(int_usb_ep, 0);
asm("ldaw %0, dp[g_intData]":"=r"(x));
XUD_SetReady_In(int_usb_ep, 0,x,6);
//asm("ldaw %0, dp[g_intData]":"=r"(x));
XUD_SetReady_In(int_usb_ep, g_intData, 6);
}
break;
@@ -781,7 +781,7 @@ void decouple(chanend c_mix_out,
SET_SHARED_GLOBAL(g_midi_from_host_flag, midi_from_host_flag);
// send the current host -> device buffer out of the fifo
XUD_SetReady(midi_from_host_usb_ep, 1);
//XUD_SetReady(midi_from_host_usb_ep, 1);
#endif
#ifdef IAP
@@ -811,7 +811,7 @@ void decouple(chanend c_mix_out,
// send the current host -> device buffer out of the fifo
SET_SHARED_GLOBAL(g_aud_from_host_buffer, g_aud_from_host_wrptr);
XUD_SetReady(aud_from_host_usb_ep, 1);
//XUD_SetReady(aud_from_host_usb_ep, 1);
#endif
#ifdef INPUT
@@ -832,7 +832,7 @@ void decouple(chanend c_mix_out,
GET_SHARED_GLOBAL(p, g_aud_to_host_buffer);
read_via_xc_ptr(len, p);
XUD_SetReady_In(aud_to_host_usb_ep, PIDn_DATA0, g_aud_to_host_buffer, len);
XUD_SetReady_InPtr(aud_to_host_usb_ep, g_aud_to_host_buffer, len);
}
#endif
@@ -910,7 +910,7 @@ void decouple(chanend c_mix_out,
if(outOverflow)
{
XUD_SetReady(aud_from_host_usb_ep, 1);
//XUD_SetReady(aud_from_host_usb_ep, 1);
outOverflow = 0;
}
@@ -994,7 +994,7 @@ void decouple(chanend c_mix_out,
if (space_left <= 0 || space_left >= MAX_USB_AUD_PACKET_SIZE)
{
SET_SHARED_GLOBAL(g_aud_from_host_buffer, aud_from_host_wrptr);
XUD_SetReady(aud_from_host_usb_ep, 1);
// XUD_SetReady(aud_from_host_usb_ep, 1);
}
else
{
@@ -1021,7 +1021,7 @@ void decouple(chanend c_mix_out,
/* Come out of OUT overflow state */
outOverflow = 0;
SET_SHARED_GLOBAL(g_aud_from_host_buffer, aud_from_host_wrptr);
XUD_SetReady(aud_from_host_usb_ep, 1);
//XUD_SetReady(aud_from_host_usb_ep, 1);
#ifdef DEBUG_LEDS
led(c_led);
#endif
@@ -1104,7 +1104,7 @@ void decouple(chanend c_mix_out,
int p, len;
GET_SHARED_GLOBAL(p, g_aud_to_host_buffer);
asm("ldw %0, %1[0]":"=r"(len):"r"(p));
XUD_SetReady_In(aud_to_host_usb_ep, PIDn_DATA0, p+4, len);
XUD_SetReady_InPtr(aud_to_host_usb_ep, p+4, len);
aud_in_ready = 1;
}
continue;
@@ -1128,7 +1128,7 @@ void decouple(chanend c_mix_out,
swap(midi_to_host_buffer_being_collected, midi_to_host_buffer_being_sent);
/* Request to send packet */
XUD_SetReady_In(midi_to_host_usb_ep, 0, midi_to_host_buffer_being_sent+4, midi_data_collected_from_device);
XUD_SetReady_InPtr(midi_to_host_usb_ep, midi_to_host_buffer_being_sent+4, midi_data_collected_from_device);
/* Mark as waiting for host to poll us */
midi_waiting_on_send_to_host = 1;
@@ -1178,7 +1178,7 @@ void decouple(chanend c_mix_out,
if (midi_data_remaining_to_device == 0)
{
/* We have read an entire packet - Mark ready to receive another */
XUD_SetReady(midi_from_host_usb_ep, 1);
//XUD_SetReady(midi_from_host_usb_ep, 1);
}
else
{
@@ -1214,7 +1214,7 @@ void decouple(chanend c_mix_out,
swap(midi_to_host_buffer_being_collected, midi_to_host_buffer_being_sent);
// Signal other side to swap
XUD_SetReady_In(midi_to_host_usb_ep, 0, midi_to_host_buffer_being_sent+4, midi_data_collected_from_device);
XUD_SetReady_InPtr(midi_to_host_usb_ep, midi_to_host_buffer_being_sent+4, midi_data_collected_from_device);
midi_data_collected_from_device = 0;
midi_waiting_on_send_to_host = 1;
}
@@ -1253,8 +1253,8 @@ void decouple(chanend c_mix_out,
swap(iap_to_host_buffer_being_collected, iap_to_host_buffer_being_sent);
/* Request to send packet */
XUD_SetReady_In(iap_to_host_int_usb_ep, 0, zero_buffer, 0); // ZLP to int ep
XUD_SetReady_In(iap_to_host_usb_ep, 0, iap_to_host_buffer_being_sent+4, iap_data_collected_from_device);
XUD_SetReady_InPtr(iap_to_host_int_usb_ep, 0, zero_buffer, 0); // ZLP to int ep
XUD_SetReady_InPtr(iap_to_host_usb_ep, 0, iap_to_host_buffer_being_sent+4, iap_data_collected_from_device);
/* Mark as waiting for host to poll us */
iap_waiting_on_send_to_host = 1;

View File

@@ -16,12 +16,15 @@
* \param c_aud_ctl Audio control channel connected to Endpoint0()
* \param p_off_mclk A port that is clocked of the MCLK input (not the MCLK input itself)
*/
void buffer(chanend c_aud_out, chanend c_aud_in, chanend c_aud_fb,
#ifdef MIDI
void buffer(chanend c_aud_out,
chanend c_aud_in,
chanend c_aud_fb,
//#ifdef MIDI
chanend c_midi_from_host,
chanend c_midi_to_host,
#endif
//#endif
#ifdef IAP
#error IAP
chanend c_iap_from_host,
chanend c_iap_to_host,
chanend c_iap_to_host_int,

View File

@@ -70,10 +70,10 @@ extern unsigned g_numUsbChanIn;
* @return void
*/
void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud_fb,
#ifdef MIDI
//#ifdef MIDI
chanend c_midi_from_host,
chanend c_midi_to_host,
#endif
//#endif
#ifdef IAP
chanend c_iap_from_host,
chanend c_iap_to_host,
@@ -224,19 +224,19 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud
int usb_speed;
int x;
asm("ldaw %0, dp[fb_clocks]":"=r"(x));
//asm("ldaw %0, dp[fb_clocks]":"=r"(x));
GET_SHARED_GLOBAL(usb_speed, g_curUsbSpeed);
if (usb_speed == XUD_SPEED_HS)
{
XUD_SetReady_In(ep_aud_fb, PIDn_DATA0, x, 4);
XUD_SetReady_In(ep_aud_fb, fb_clocks, 4);
}
else
{
XUD_SetReady_In(ep_aud_fb, PIDn_DATA0, x, 3);
XUD_SetReady_In(ep_aud_fb, fb_clocks, 3);
}
}
@@ -503,11 +503,11 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud
if (usb_speed == XUD_SPEED_HS)
{
XUD_SetReady_In(ep_aud_fb, PIDn_DATA0, x, 4);
XUD_SetReady_In(ep_aud_fb, fb_clocks, 4);
}
else
{
XUD_SetReady_In(ep_aud_fb, PIDn_DATA0, x, 3);
XUD_SetReady_In(ep_aud_fb, fb_clocks, 3);
}
}
break;

View File

@@ -2,7 +2,6 @@
* @file midioutparse.xc
* @brief Parses USB-MIDI events into set of MIDI bytes
* @author Russell Gallop, XMOS Semiconductor
* @version 0.1
*/
#include "midioutparse.h"
@@ -12,7 +11,8 @@
*
* @param[in] ev USB-MIDI event
*/
{unsigned, unsigned, unsigned, unsigned, unsigned} breakEvent(unsigned ev) {
#if 1
{unsigned, unsigned, unsigned, unsigned, unsigned} static breakEvent(unsigned ev) {
unsigned cable_number = (ev >> 28) & 0xf;
unsigned codeIndexNumber = (ev >> 24) & 0xf;
unsigned midi0 = (ev >> 16) & 0xff;
@@ -20,6 +20,8 @@
unsigned midi2 = (ev >> 0) & 0xff;
return {cable_number, codeIndexNumber, midi0, midi1, midi2};
}
#endif
/**
* @brief Parse a USB-MIDI event into the MIDI bytes and a length field
@@ -33,6 +35,7 @@
unsigned size = 0;
{cable_number, codeIndexNumber, midi[0], midi[1], midi[2]} = breakEvent(event);
// Not doing anything with cable number
switch (codeIndexNumber) {
case 0x3: // Three-byte system Common messages like SPP, etc.