diff options
| author | Dean <Dean@d5102386-fcda-11dd-9fdb-3debd5008f28> | 2011-03-15 06:39:34 +0000 |
|---|---|---|
| committer | Dean <Dean@d5102386-fcda-11dd-9fdb-3debd5008f28> | 2011-03-15 06:39:34 +0000 |
| commit | ad64a8e64e1b92356da3de0d38b9af529673af84 (patch) | |
| tree | e695226ad0d2525042d562f78701522747057265 /LUFA/Drivers/USB/Core/AVR8 | |
| parent | 2e5f3c2d322057ad0b7f74ff38b588165ec764e0 (diff) | |
Implemented on-demand PLL clock generation for the U4, U6 and U7 series USB AVRs when automatic PLL mode is specified.
git-svn-id: http://lufa-lib.googlecode.com/svn/trunk@1712 d5102386-fcda-11dd-9fdb-3debd5008f28
Diffstat (limited to 'LUFA/Drivers/USB/Core/AVR8')
| -rw-r--r-- | LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.c | 40 | ||||
| -rw-r--r-- | LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.c | 9 |
2 files changed, 35 insertions, 14 deletions
diff --git a/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.c b/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.c index 18fa48a2..8b417113 100644 --- a/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.c +++ b/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.c @@ -65,6 +65,13 @@ void USB_Init( else USB_REG_Off(); + if (!(USB_Options & USB_OPT_MANUAL_PLL)) + { + #if defined(USB_SERIES_4_AVR) + PLLFRQ = ((1 << PLLUSB) | (1 << PDIV3) | (1 << PDIV1)); + #endif + } + #if defined(USB_CAN_BE_BOTH) if (Mode == USB_MODE_UID) { @@ -118,22 +125,9 @@ void USB_ResetInterface(void) USB_Controller_Reset(); - if (!(USB_Options & USB_OPT_MANUAL_PLL)) - { - #if defined(USB_SERIES_4_AVR) - PLLFRQ = ((1 << PLLUSB) | (1 << PDIV3) | (1 << PDIV1)); - #endif - - USB_PLL_On(); - while (!(USB_PLL_IsReady())); - } - #if defined(USB_CAN_BE_BOTH) if (UIDModeSelectEnabled) - { - UHWCON |= (1 << UIDE); - USB_INT_Enable(USB_INT_IDTI); - } + USB_INT_Enable(USB_INT_IDTI); #endif USB_CLK_Unfreeze(); @@ -145,6 +139,16 @@ void USB_ResetInterface(void) UHWCON |= (1 << UIMOD); #endif + if (!(USB_Options & USB_OPT_MANUAL_PLL)) + { + #if defined(USB_SERIES_2_AVR) + USB_PLL_On(); + while (!(USB_PLL_IsReady())); + #else + USB_PLL_Off(); + #endif + } + USB_Init_Device(); #endif } @@ -153,6 +157,14 @@ void USB_ResetInterface(void) #if defined(USB_CAN_BE_HOST) UHWCON &= ~(1 << UIMOD); + if (!(USB_Options & USB_OPT_MANUAL_PLL)) + { + #if defined(USB_CAN_BE_HOST) + USB_PLL_On(); + while (!(USB_PLL_IsReady())); + #endif + } + USB_Init_Host(); #endif } diff --git a/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.c b/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.c index e983cde8..856ccd62 100644 --- a/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.c +++ b/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.c @@ -90,11 +90,20 @@ ISR(USB_GEN_vect, ISR_BLOCK) if (USB_VBUS_GetStatus()) { + if (!(USB_Options & USB_OPT_MANUAL_PLL)) + { + USB_PLL_On(); + while (!(USB_PLL_IsReady())); + } + USB_DeviceState = DEVICE_STATE_Powered; EVENT_USB_Device_Connect(); } else { + if (!(USB_Options & USB_OPT_MANUAL_PLL)) + USB_PLL_Off(); + USB_DeviceState = DEVICE_STATE_Unattached; EVENT_USB_Device_Disconnect(); } |
