forked from PAWPAW-Mirror/lib_xua
Simplification of calls to StandardRequest() based on if DFU is enabled or not.
This commit is contained in:
@@ -580,34 +580,10 @@ void Endpoint0( chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
|
|||||||
|
|
||||||
if(retVal > 0)
|
if(retVal > 0)
|
||||||
{
|
{
|
||||||
#ifndef DFU
|
#ifdef DFU
|
||||||
|
|
||||||
#ifdef AUDIO_CLASS_FALLBACK
|
|
||||||
/* Return Audio 2.0 Descriptors with Audio 1.0 as fallback */
|
|
||||||
retVal = USB_StandardRequests(ep0_out, ep0_in,
|
|
||||||
devDesc_Audio2, sizeof(devDesc_Audio2),
|
|
||||||
cfgDesc_Audio2, sizeof(cfgDesc_Audio2),
|
|
||||||
devDesc_Audio1, sizeof(devDesc_Audio1),
|
|
||||||
cfgDesc_Audio1, sizeof(cfgDesc_Audio1),
|
|
||||||
strDescs, sizeof(strDescs)/sizeof(strDescs[0]),
|
|
||||||
sp, c_usb_test, g_curUsbSpeed);
|
|
||||||
#else
|
|
||||||
/* Return Audio 2.0 Descriptors */
|
|
||||||
cfgDesc_Audio2[1] = CONFIGURATION;
|
|
||||||
cfgDesc_Null[1] = OTHER_SPEED_CONFIGURATION;
|
|
||||||
|
|
||||||
retVal = USB_StandardRequests(ep0_out, ep0_in,
|
|
||||||
devDesc_Audio2, sizeof(devDesc_Audio2),
|
|
||||||
cfgDesc_Audio2, sizeof(cfgDesc_Audio2),
|
|
||||||
devDesc_Null, sizeof(devDesc_Null),
|
|
||||||
cfgDesc_Null, sizeof(cfgDesc_Null),
|
|
||||||
strDescs, sizeof(strDescs)/sizeof(strDescs[0]),
|
|
||||||
sp, c_usb_test, g_curUsbSpeed);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#else /* ifndef DFU */
|
|
||||||
if (!DFU_mode_active)
|
if (!DFU_mode_active)
|
||||||
{
|
{
|
||||||
|
#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,
|
retVal = USB_StandardRequests(ep0_out, ep0_in,
|
||||||
@@ -655,6 +631,7 @@ void Endpoint0( chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
|
|||||||
cfgDesc_Null, sizeof(cfgDesc_Null),
|
cfgDesc_Null, sizeof(cfgDesc_Null),
|
||||||
strDescs, sizeof(strDescs)/sizeof(strDescs[0]), sp, c_usb_test, g_curUsbSpeed);
|
strDescs, sizeof(strDescs)/sizeof(strDescs[0]), sp, c_usb_test, g_curUsbSpeed);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef DFU
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -666,8 +643,7 @@ void Endpoint0( chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
|
|||||||
null, 0,
|
null, 0,
|
||||||
strDescs, sizeof(strDescs), sp, c_usb_test, g_curUsbSpeed);
|
strDescs, sizeof(strDescs), sp, c_usb_test, g_curUsbSpeed);
|
||||||
}
|
}
|
||||||
#endif /* ifndef DFU else */
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (retVal < 0)
|
if (retVal < 0)
|
||||||
@@ -684,8 +660,6 @@ void Endpoint0( chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
|
|||||||
timer tmr;
|
timer tmr;
|
||||||
unsigned s;
|
unsigned s;
|
||||||
DFU_mode_active = 1;
|
DFU_mode_active = 1;
|
||||||
//tmr :> s;
|
|
||||||
//tmr when timerafter(s + 500000) :> s;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -694,11 +668,9 @@ void Endpoint0( chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
|
|||||||
{
|
{
|
||||||
timer tmr;
|
timer tmr;
|
||||||
unsigned s;
|
unsigned s;
|
||||||
// Restart audio
|
|
||||||
//outuint(c_audioControl, AUDIO_START_FROM_DFU);
|
|
||||||
DFU_mode_active = 0;
|
DFU_mode_active = 0;
|
||||||
|
|
||||||
// Send reboot command
|
/* Send reboot command */
|
||||||
tmr :> s;
|
tmr :> s;
|
||||||
tmr when timerafter(s + 5000000) :> s;
|
tmr when timerafter(s + 5000000) :> s;
|
||||||
device_reboot(c_audioControl);
|
device_reboot(c_audioControl);
|
||||||
|
|||||||
Reference in New Issue
Block a user