retVal -> result and XUD_Result_t enum properly used.

This commit is contained in:
Ross Owen
2014-02-18 11:59:36 +00:00
parent 80920296d7
commit b9b9ee5e36

View File

@@ -130,8 +130,9 @@ void Endpoint0( chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
#ifdef MIXER #ifdef MIXER
/* Set up mixer default state */ /* Set up mixer default state */
for (int i = 0; i < 18*8; i++) { for (int i = 0; i < 18*8; i++)
mixer1Weights[i] = 0x8001; //-inf {
mixer1Weights[i] = 0x8001; //-inf
} }
/* Configure default connections */ /* Configure default connections */
@@ -232,11 +233,11 @@ void Endpoint0( chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
while(1) while(1)
{ {
/* Returns 0 for success, -1 for bus reset */ /* Returns 0 for success, -1 for bus reset */
XUD_Result_t retVal = USB_GetSetupPacket(ep0_out, ep0_in, sp); XUD_Result_t result = USB_GetSetupPacket(ep0_out, ep0_in, sp);
if (!retVal) if (result == XUD_RES_OKAY)
{ {
retVal = 1; result = XUD_RES_ERR;
/* Inspect Request type and Receipient and direction */ /* Inspect Request type and Receipient and direction */
switch( (sp.bmRequestType.Direction << 7) | (sp.bmRequestType.Recipient ) | (sp.bmRequestType.Type << 5) ) switch( (sp.bmRequestType.Direction << 7) | (sp.bmRequestType.Recipient ) | (sp.bmRequestType.Type << 5) )
@@ -389,7 +390,7 @@ void Endpoint0( chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
g_interfaceAlt[sp.wIndex] = sp.wValue; g_interfaceAlt[sp.wIndex] = sp.wValue;
/* No data stage for this request, just do data stage */ /* No data stage for this request, just do data stage */
retVal = XUD_DoSetRequestStatus(ep0_in); result = XUD_DoSetRequestStatus(ep0_in);
} /* if(sp.bRequest == SET_INTERFACE) */ } /* if(sp.bRequest == SET_INTERFACE) */
@@ -412,9 +413,8 @@ void Endpoint0( chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
{ {
case HID_REPORT: case HID_REPORT:
/* Return HID report descriptor */ /* Return HID report descriptor */
retVal = XUD_DoGetRequest(ep0_out, ep0_in, hidReportDescriptor, result = XUD_DoGetRequest(ep0_out, ep0_in, hidReportDescriptor,
sizeof(hidReportDescriptor), sp.wLength); sizeof(hidReportDescriptor), sp.wLength);
break; break;
} }
} }
@@ -448,11 +448,11 @@ void Endpoint0( chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
} }
#endif #endif
///* No data stage for this request, just do status stage */ ///* No data stage for this request, just do status stage */
//retVal = XUD_DoSetRequestStatus(ep0_in); //result = XUD_DoSetRequestStatus(ep0_in);
// /* We want to run USB_StandardsRequests() implementation also */ // /* We want to run USB_StandardsRequests() implementation also */
//if(retVal == 0) //if(result == 0)
// retVal = 1; // result = 1;
break; break;
default: default:
@@ -472,10 +472,10 @@ void Endpoint0( chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
#if (AUDIO_CLASS == 2) && defined(AUDIO_CLASS_FALLBACK) #if (AUDIO_CLASS == 2) && defined(AUDIO_CLASS_FALLBACK)
if(g_curUsbSpeed == XUD_SPEED_FS) if(g_curUsbSpeed == XUD_SPEED_FS)
{ {
retVal = AudioEndpointRequests_1(ep0_out, ep0_in, sp, c_audioControl, c_mix_ctl, c_clk_ctl); result = AudioEndpointRequests_1(ep0_out, ep0_in, sp, c_audioControl, c_mix_ctl, c_clk_ctl);
} }
#elif (AUDIO_CLASS==1) #elif (AUDIO_CLASS==1)
retVal = AudioEndpointRequests_1(ep0_out, ep0_in, sp, c_audioControl, c_mix_ctl, c_clk_ctl); result = AudioEndpointRequests_1(ep0_out, ep0_in, sp, c_audioControl, c_mix_ctl, c_clk_ctl);
#endif #endif
} }
@@ -523,7 +523,7 @@ void Endpoint0( chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
} }
/* TODO we should not make the assumption that all DFU requests are handled */ /* TODO we should not make the assumption that all DFU requests are handled */
retVal = 0; result = 0;
} }
#endif #endif
/* Check for: - Audio CONTROL interface request - always 0, note we check for DFU first /* Check for: - Audio CONTROL interface request - always 0, note we check for DFU first
@@ -535,24 +535,24 @@ void Endpoint0( chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
#if (AUDIO_CLASS == 2) && defined(AUDIO_CLASS_FALLBACK) #if (AUDIO_CLASS == 2) && defined(AUDIO_CLASS_FALLBACK)
if(g_curUsbSpeed == XUD_SPEED_HS) if(g_curUsbSpeed == XUD_SPEED_HS)
{ {
retVal = AudioClassRequests_2(ep0_out, ep0_in, sp, c_audioControl, c_mix_ctl, c_clk_ctl); result = AudioClassRequests_2(ep0_out, ep0_in, sp, c_audioControl, c_mix_ctl, c_clk_ctl);
} }
else else
{ {
retVal = AudioClassRequests_1(ep0_out, ep0_in, sp, c_audioControl, c_mix_ctl, c_clk_ctl); result = AudioClassRequests_1(ep0_out, ep0_in, sp, c_audioControl, c_mix_ctl, c_clk_ctl);
} }
#elif (AUDIO_CLASS==2) #elif (AUDIO_CLASS==2)
retVal = AudioClassRequests_2(ep0_out, ep0_in, sp, c_audioControl, c_mix_ctl, c_clk_ctl); result = AudioClassRequests_2(ep0_out, ep0_in, sp, c_audioControl, c_mix_ctl, c_clk_ctl);
#else #else
retVal = AudioClassRequests_1(ep0_out, ep0_in, sp, c_audioControl, c_mix_ctl, c_clk_ctl); result = AudioClassRequests_1(ep0_out, ep0_in, sp, c_audioControl, c_mix_ctl, c_clk_ctl);
#endif #endif
#ifdef VENDOR_AUDIO_REQS #ifdef VENDOR_AUDIO_REQS
#error #error
/* If retVal is 1 at this point, then request to audio interface not handled - handle vendor audio reqs */ /* If result is ERR at this point, then request to audio interface not handled - handle vendor audio reqs */
if(retVal == 1) if(result == XUD_RES_ERR)
{ {
retVal = VendorAudioRequests(ep0_out, ep0_in, sp.bRequest, result = VendorAudioRequests(ep0_out, ep0_in, sp.bRequest,
sp.wValue >> 8, sp.wValue & 0xff, sp.wValue >> 8, sp.wValue & 0xff,
sp.wIndex >> 8, sp.bmRequestType.Direction, sp.wIndex >> 8, sp.bmRequestType.Direction,
c_audioControl, c_mix_ctl, c_clk_ctl); c_audioControl, c_mix_ctl, c_clk_ctl);
@@ -566,9 +566,9 @@ void Endpoint0( chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
break; break;
} }
} /* if(retVal == 0) */ } /* if(result == XUD_RES_OKAY) */
if(retVal > 0) if(result == XUD_RES_ERR)
{ {
#ifdef DFU #ifdef DFU
if (!DFU_mode_active) if (!DFU_mode_active)
@@ -576,7 +576,7 @@ void Endpoint0( chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
#endif #endif
#ifdef AUDIO_CLASS_FALLBACK #ifdef AUDIO_CLASS_FALLBACK
/* Return Audio 2.0 Descriptors with Audio 1.0 as fallback */ /* Return Audio 2.0 Descriptors with Audio 1.0 as fallback */
retVal = USB_StandardRequests(ep0_out, ep0_in, result = USB_StandardRequests(ep0_out, ep0_in,
devDesc_Audio2, sizeof(devDesc_Audio2), devDesc_Audio2, sizeof(devDesc_Audio2),
cfgDesc_Audio2, sizeof(cfgDesc_Audio2), cfgDesc_Audio2, sizeof(cfgDesc_Audio2),
devDesc_Audio1, sizeof(devDesc_Audio1), devDesc_Audio1, sizeof(devDesc_Audio1),
@@ -654,7 +654,7 @@ void Endpoint0( chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
#endif #endif
} }
retVal = USB_StandardRequests(ep0_out, ep0_in, result = USB_StandardRequests(ep0_out, ep0_in,
devDesc_Audio2, sizeof(devDesc_Audio2), devDesc_Audio2, sizeof(devDesc_Audio2),
cfgDesc_Audio2, sizeof(cfgDesc_Audio2), cfgDesc_Audio2, sizeof(cfgDesc_Audio2),
null, 0, null, 0,
@@ -662,7 +662,7 @@ void Endpoint0( chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
strDescs, sizeof(strDescs)/sizeof(strDescs[0]), sp, c_usb_test, g_curUsbSpeed); strDescs, sizeof(strDescs)/sizeof(strDescs[0]), sp, c_usb_test, g_curUsbSpeed);
#elif (AUDIO_CLASS == 1) #elif (AUDIO_CLASS == 1)
/* Return Audio 1.0 Descriptors in FS, should never be in HS! */ /* Return Audio 1.0 Descriptors in FS, should never be in HS! */
retVal = USB_StandardRequests(ep0_out, ep0_in, result = USB_StandardRequests(ep0_out, ep0_in,
null, 0, null, 0,
null, 0, null, 0,
devDesc_Audio1, sizeof(devDesc_Audio1), devDesc_Audio1, sizeof(devDesc_Audio1),
@@ -670,7 +670,7 @@ void Endpoint0( chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
strDescs, sizeof(strDescs)/sizeof(strDescs[0]), sp, c_usb_test, g_curUsbSpeed); strDescs, sizeof(strDescs)/sizeof(strDescs[0]), sp, c_usb_test, g_curUsbSpeed);
#else #else
/* Return Audio 2.0 Descriptors with Null device as fallback */ /* Return Audio 2.0 Descriptors with Null device as fallback */
retVal = USB_StandardRequests(ep0_out, ep0_in, result = USB_StandardRequests(ep0_out, ep0_in,
devDesc_Audio2, sizeof(devDesc_Audio2), devDesc_Audio2, sizeof(devDesc_Audio2),
cfgDesc_Audio2, sizeof(cfgDesc_Audio2), cfgDesc_Audio2, sizeof(cfgDesc_Audio2),
devDesc_Null, sizeof(devDesc_Null), devDesc_Null, sizeof(devDesc_Null),
@@ -682,7 +682,7 @@ void Endpoint0( chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
else else
{ {
/* Running in DFU mode - always return same descs for DFU whether HS or FS */ /* Running in DFU mode - always return same descs for DFU whether HS or FS */
retVal = USB_StandardRequests(ep0_out, ep0_in, result = USB_StandardRequests(ep0_out, ep0_in,
DFUdevDesc, sizeof(DFUdevDesc), DFUdevDesc, sizeof(DFUdevDesc),
DFUcfgDesc, sizeof(DFUcfgDesc), DFUcfgDesc, sizeof(DFUcfgDesc),
null, 0, /* Used same descriptors for full and high-speed */ null, 0, /* Used same descriptors for full and high-speed */
@@ -692,7 +692,7 @@ void Endpoint0( chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
#endif #endif
} }
if (retVal < 0) if (result == XUD_RES_RST)
{ {
g_curUsbSpeed = XUD_ResetEndpoint(ep0_out, ep0_in); g_curUsbSpeed = XUD_ResetEndpoint(ep0_out, ep0_in);