diff --git a/module_usb_audio/devicedefines.h b/module_usb_audio/devicedefines.h index 66e0dd63..16ff6835 100644 --- a/module_usb_audio/devicedefines.h +++ b/module_usb_audio/devicedefines.h @@ -112,6 +112,10 @@ #undef IAP #endif +#if defined(IAP_INT_EP) && (IAP_INT_EP == 0) +#undef IAP_INT_EP +#endif + #if defined(SU1_ADC_ENABLE) && (SU1_ADC_ENABLE == 0) #undef SU1_ADC_ENABLE #endif @@ -380,7 +384,11 @@ #endif #define EP_CNT_OUT_IAP (IAP_INTERFACES) +#ifdef IAP_INT_EP #define EP_CNT_IN_IAP (IAP_INTERFACES * 2) +#else +#define EP_CNT_IN_IAP (IAP_INTERFACES) +#endif #define EP_CNT_OUT_HID (0) #define EP_CNT_IN_HID (HID_INTERFACES) @@ -405,7 +413,9 @@ #define EP_NUM_IN_MIDI (EP_NUM_IN_AUD_INT + 1) #define EP_NUM_IN_HID (EP_NUM_IN_AUD_INT + EP_CNT_IN_MIDI + 1) #define EP_NUM_IN_IAP (EP_NUM_IN_AUD_INT + EP_CNT_IN_MIDI + EP_CNT_IN_HID + 1) /* iAP Bulk */ +#ifdef IAP_INT_EP #define EP_NUM_IN_IAP_INT (EP_NUM_IN_AUD_INT + EP_CNT_IN_MIDI + EP_CNT_IN_HID + 2) /* iAP interrupt */ +#endif #define EP_NUM_OUT_AUD (1) /* Always 1 */ #define EP_NUM_OUT_MIDI (2) /* Always 2 */ @@ -418,7 +428,9 @@ #define EP_ADR_IN_MIDI (EP_NUM_IN_MIDI | 0x80) #define EP_ADR_IN_HID (EP_NUM_IN_HID | 0x80) #define EP_ADR_IN_IAP (EP_NUM_IN_IAP | 0x80) +#ifdef IAP_INT_EP #define EP_ADR_IN_IAP_INT (EP_NUM_IN_IAP_INT | 0x80) +#endif #define EP_ADR_OUT_AUD EP_NUM_OUT_AUD #define EP_ADR_OUT_MIDI EP_NUM_OUT_MIDI diff --git a/module_usb_audio/endpoint0/descriptors.h b/module_usb_audio/endpoint0/descriptors.h index 76518a44..a296cc1a 100644 --- a/module_usb_audio/endpoint0/descriptors.h +++ b/module_usb_audio/endpoint0/descriptors.h @@ -172,8 +172,12 @@ unsigned char devQualDesc_Null[] = #endif #ifdef IAP +#ifdef IAP_INT_EP #define IAP_LENGTH (30) #else +#define IAP_LENGTH (23) +#endif +#else #define IAP_LENGTH (0) #endif @@ -1350,6 +1354,7 @@ unsigned char cfgDesc_Audio2[] = 0x02, /* 5 wMaxPacketSize */ 0x00, /* 6 bInterval : Ignored for Bulk. Set to zero. (field size 1 bytes) */ +#ifdef IAP_INT_EP /* iAP Interrupt IN Endpoint Descriptor */ 0x07, /* 0 bLength : Size of this descriptor, in bytes. (field size 1 bytes) */ 0x05, /* 1 bDescriptorType : ENDPOINT descriptor. (field size 1 bytes) */ @@ -1358,6 +1363,7 @@ unsigned char cfgDesc_Audio2[] = 0x40, /* 4 wMaxPacketSize : 64 bytes per packet. (field size 2 bytes) - has to be 0x40 for compliance*/ 0x00, /* 5 wMaxPacketSize */ 0x08, /* 6 bInterval : (2^(bInterval-1))/8 ms. Must be between 4 and 32ms (field size 1 bytes) */ +#endif #endif diff --git a/module_usb_audio/main.xc b/module_usb_audio/main.xc index 6cbebc08..2f7eb135 100755 --- a/module_usb_audio/main.xc +++ b/module_usb_audio/main.xc @@ -294,7 +294,12 @@ void usb_audio_core(chanend c_mix_out c_midi, #endif #ifdef IAP - c_xud_out[EP_NUM_OUT_IAP], c_xud_in[EP_NUM_IN_IAP], c_xud_in[EP_NUM_IN_IAP_INT], c_iap, + c_xud_out[EP_NUM_OUT_IAP], /* iAP Out */ + c_xud_in[EP_NUM_IN_IAP], /* iAP In */ +#ifdef IAP_INT_EP + c_xud_in[EP_NUM_IN_IAP_INT], /* iAP Interrupt In */ +#endif + c_iap, #endif #if defined(SPDIF_RX) || defined(ADAT_RX) /* Audio Interrupt - only used for interrupts on external clock change */ diff --git a/module_usb_audio/usb_buffer/usb_buffer.h b/module_usb_audio/usb_buffer/usb_buffer.h index daed7365..f68600d6 100644 --- a/module_usb_audio/usb_buffer/usb_buffer.h +++ b/module_usb_audio/usb_buffer/usb_buffer.h @@ -27,7 +27,9 @@ void buffer(chanend c_aud_out, #ifdef IAP chanend c_iap_from_host, chanend c_iap_to_host, +#ifdef IAP_INT_EP chanend c_iap_to_host_int, +#endif chanend c_iap, #endif #if defined(SPDIF_RX) || defined(ADAT_RX) diff --git a/module_usb_audio/usb_buffer/usb_buffer.xc b/module_usb_audio/usb_buffer/usb_buffer.xc index dfeadc95..79ded1e1 100644 --- a/module_usb_audio/usb_buffer/usb_buffer.xc +++ b/module_usb_audio/usb_buffer/usb_buffer.xc @@ -86,7 +86,9 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud #ifdef IAP chanend c_iap_from_host, chanend c_iap_to_host, +#ifdef IAP_INT_EP chanend c_iap_to_host_int, +#endif chanend c_iap, #endif #if defined(SPDIF_RX) || defined(ADAT_RX) @@ -113,8 +115,10 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud #ifdef IAP XUD_ep ep_iap_from_host = XUD_InitEp(c_iap_from_host); XUD_ep ep_iap_to_host = XUD_InitEp(c_iap_to_host); +#ifdef IAP_INT_EP XUD_ep ep_iap_to_host_int = XUD_InitEp(c_iap_to_host_int); #endif +#endif #if defined(SPDIF_RX) || defined(ADAT_RX) XUD_ep ep_int = XUD_InitEp(c_int); #endif @@ -548,8 +552,10 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud if(tmp == -1) { - XUD_ResetEndpoint(ep_iap_to_host, null); - XUD_ResetEndpoint(ep_iap_to_host_int, null); + XUD_ResetEndpoint(ep_iap_to_host, null); +#ifdef IAP_INT_EP + XUD_ResetEndpoint(ep_iap_to_host_int, null); +#endif iap_send_reset(c_iap); iap_draining_chan = 1; // Drain c_iap until a reset is sent back iap_data_collected_from_device = 0; @@ -564,6 +570,7 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud } break; /* IAP IN to host */ +#ifdef IAP_INT_EP case XUD_SetData_Select(c_iap_to_host_int, ep_iap_to_host_int, tmp): asm("#iap int d->h"); @@ -571,6 +578,7 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud /* Note, could get a reset notification here, but deal with it in the case above */ break; #endif +#endif #ifdef HID_CONTROLS /* HID Report Data */ @@ -698,14 +706,18 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud /* Note we don't ack the last byte yet... */ if (iap_data_collected_from_device == iap_expected_data_length) { - int reset1, reset2; + int reset1 = 0, reset2; +#ifdef IAP_INT_EP reset1 = XUD_SetReady_In(ep_iap_to_host_int, gc_zero_buffer, 0); +#endif reset2 = XUD_SetReady_In(ep_iap_to_host, iap_to_host_buffer, iap_data_collected_from_device); if((reset1 == -1) || (reset2 == -1)) { printstr("rst 2"); +#ifdef IAP_INT_EP XUD_ResetEndpoint(ep_iap_to_host_int, null); +#endif XUD_ResetEndpoint(ep_iap_to_host, null); iap_send_reset(c_iap); iap_draining_chan = 1; // Drain c_iap until a reset is sent back