EP0 changed to use switch statement when handling USB_SET_INTERFACE requests

This commit is contained in:
Sam Chesney
2014-07-29 15:22:51 +01:00
parent cbe78f355c
commit 201c899f23

View File

@@ -268,9 +268,10 @@ void Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
/* Over-riding USB_StandardRequests implementation */ /* Over-riding USB_StandardRequests implementation */
if(sp.bRequest == USB_SET_INTERFACE) if(sp.bRequest == USB_SET_INTERFACE)
{ {
/* Check for audio stream from host start/stop */ switch (sp.wIndex)
if(sp.wIndex == 1) /* Output interface */
{ {
/* Check for audio stream from host start/stop */
case INTERFACE_NUMBER_AUDIO_OUTPUT:
/* Check the alt is in range */ /* Check the alt is in range */
if(sp.wValue <= OUTPUT_FORMAT_COUNT) if(sp.wValue <= OUTPUT_FORMAT_COUNT)
{ {
@@ -301,9 +302,8 @@ void Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
chkct(c_audioControl, XS1_CT_END); chkct(c_audioControl, XS1_CT_END);
} }
} }
} break;
else if(sp.wIndex == 2) /* Input interface */ case INTERFACE_NUMBER_AUDIO_INPUT:
{
/* Check the alt is in range */ /* Check the alt is in range */
if(sp.wValue <= INPUT_FORMAT_COUNT) if(sp.wValue <= INPUT_FORMAT_COUNT)
{ {
@@ -334,7 +334,16 @@ void Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
chkct(c_audioControl, XS1_CT_END); chkct(c_audioControl, XS1_CT_END);
} }
} }
break;
{
default:
/* Unhandled interface */
break;
} }
if ((sp.wIndex == INTERFACE_NUMBER_AUDIO_OUTPUT) || (sp.wIndex == INTERFACE_NUMBER_AUDIO_INPUT))
{
#if (NUM_USB_CHAN_OUT > 0) && (NUM_USB_CHAN_IN > 0) #if (NUM_USB_CHAN_OUT > 0) && (NUM_USB_CHAN_IN > 0)
/* Check for stream start stop on output and input audio interfaces */ /* Check for stream start stop on output and input audio interfaces */
if(sp.wValue && !g_interfaceAlt[1] && !g_interfaceAlt[2]) if(sp.wValue && !g_interfaceAlt[1] && !g_interfaceAlt[2])
@@ -364,6 +373,7 @@ void Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
UserAudioStreamStop(); UserAudioStreamStop();
} }
#endif #endif
}
} /* if(sp.bRequest == SET_INTERFACE) */ } /* if(sp.bRequest == SET_INTERFACE) */
break; /* BMREQ_H2D_STANDARD_INT */ break; /* BMREQ_H2D_STANDARD_INT */