|
|
@ -110,7 +110,6 @@ void USB_Disable(void)
|
|
|
|
void USB_ResetInterface(void)
|
|
|
|
void USB_ResetInterface(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
uint8_t PrescalerNeeded;
|
|
|
|
uint8_t PrescalerNeeded;
|
|
|
|
uint8_t nbit = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(USB_DEVICE_OPT_FULLSPEED)
|
|
|
|
#if defined(USB_DEVICE_OPT_FULLSPEED)
|
|
|
|
if (USB_Options & USB_DEVICE_OPT_LOWSPEED)
|
|
|
|
if (USB_Options & USB_DEVICE_OPT_LOWSPEED)
|
|
|
@ -121,12 +120,14 @@ void USB_ResetInterface(void)
|
|
|
|
PrescalerNeeded = F_USB / 6000000;
|
|
|
|
PrescalerNeeded = F_USB / 6000000;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
while (PrescalerNeeded && nbit < 7) {
|
|
|
|
uint8_t DividerIndex = 0;
|
|
|
|
|
|
|
|
while (PrescalerNeeded > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
DividerIndex++;
|
|
|
|
PrescalerNeeded >>= 1;
|
|
|
|
PrescalerNeeded >>= 1;
|
|
|
|
nbit++;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CLK.USBCTRL = (nbit - 1) << CLK_USBPSDIV_gp;
|
|
|
|
CLK.USBCTRL = (DividerIndex - 1) << CLK_USBPSDIV_gp;
|
|
|
|
|
|
|
|
|
|
|
|
if (USB_Options & USB_OPT_PLLCLKSRC)
|
|
|
|
if (USB_Options & USB_OPT_PLLCLKSRC)
|
|
|
|
CLK.USBCTRL |= (CLK_USBSRC_PLL_gc | CLK_USBSEN_bm);
|
|
|
|
CLK.USBCTRL |= (CLK_USBSRC_PLL_gc | CLK_USBSEN_bm);
|
|
|
|