forked from PAWPAW-Mirror/lib_xua
Delay for feedback stability after SF change now based on bus-speed. Allows faster SF changes at high-speed.
This commit is contained in:
@@ -209,10 +209,14 @@
|
|||||||
#error Bad DEFAULT_MCLK_FREQ
|
#error Bad DEFAULT_MCLK_FREQ
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* The number of clock ticks to wait for the audio feeback to stabalise */
|
/* The number of clock ticks to wait for the audio feeback to stabalise
|
||||||
#ifndef FEEDBACK_STABILITY_DELAY
|
* Note, feedback always counts 128 SOFs (16ms @ HS, 128ms @ FS) */
|
||||||
/* Note, feedback always counts 128 SOFs (16ms @ HS, 128ms @ FS) */
|
#ifndef FEEDBACK_STABILITY_DELAY_HS
|
||||||
#define FEEDBACK_STABILITY_DELAY (20000000)
|
#define FEEDBACK_STABILITY_DELAY_HS (2000000)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef FEEDBACK_STABILITY_DELAY_FS
|
||||||
|
#define FEEDBACK_STABILITY_DELAY_FS (20000000)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Vendor String */
|
/* Vendor String */
|
||||||
|
|||||||
@@ -80,6 +80,31 @@ static void storeFreq(unsigned char buffer[], int &i, int freq)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Delay based on USB speed. Feedback takes longer to stabilise at FS */
|
||||||
|
void FeedbackStabilityDelay()
|
||||||
|
{
|
||||||
|
|
||||||
|
unsigned usbSpeed;
|
||||||
|
timer t;
|
||||||
|
unsigned time;
|
||||||
|
unsigned delay;
|
||||||
|
|
||||||
|
asm("ldw %0, dp[g_curUsbSpeed]" : "=r" (usbSpeed) :);
|
||||||
|
|
||||||
|
if (usbSpeed == XUD_SPEED_HS)
|
||||||
|
{
|
||||||
|
delay = FEEDBACK_STABILITY_DELAY_HS;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delay = FEEDBACK_STABILITY_DELAY_FS;
|
||||||
|
}
|
||||||
|
|
||||||
|
t :> time;
|
||||||
|
t when timerafter(time + delay):> void;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static unsigned longMul(unsigned a, unsigned b, int prec)
|
static unsigned longMul(unsigned a, unsigned b, int prec)
|
||||||
{
|
{
|
||||||
@@ -314,12 +339,7 @@ int AudioClassRequests_2(XUD_ep ep0_out, XUD_ep ep0_in, USB_SetupPacket_t &sp, c
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Allow time for our feedback to stabilise*/
|
/* Allow time for our feedback to stabilise*/
|
||||||
{
|
FeedbackStabilityDelay();
|
||||||
timer t;
|
|
||||||
unsigned time;
|
|
||||||
t :> time;
|
|
||||||
t when timerafter(time+FEEDBACK_STABILITY_DELAY):> void;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send 0 Length as status stage */
|
/* Send 0 Length as status stage */
|
||||||
@@ -1044,14 +1064,9 @@ int AudioEndpointRequests_1(XUD_ep ep0_out, XUD_ep ep0_in, USB_SetupPacket_t &sp
|
|||||||
/* Wait for handshake back - i.e. pll locked and clocks okay */
|
/* Wait for handshake back - i.e. pll locked and clocks okay */
|
||||||
chkct(c_audioControl, XS1_CT_END);
|
chkct(c_audioControl, XS1_CT_END);
|
||||||
|
|
||||||
/* Allow time for the change - feedback to stabalise */
|
/* Allow time for the change - feedback to stabilise */
|
||||||
{
|
FeedbackStabilityDelay();
|
||||||
timer t;
|
}
|
||||||
unsigned time;
|
|
||||||
t :> time;
|
|
||||||
t when timerafter(time+FEEDBACK_STABILTY_DELAY):> void;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return XUD_SetBuffer(ep0_in, buffer, 0);
|
return XUD_SetBuffer(ep0_in, buffer, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user